⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evaqunchatwindow.cpp

📁 linux下的eva源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	}}void EvaQunChatWindow::slotFontClick( ){	if(!fontSelecter) return;	if(fontSelecter->isVisible()) 		fontSelecter->hide();	else{		QPoint p = teInput->mapToGlobal(QPoint(0,0));		fontSelecter->setSize( mQun->getChatFontSize());		fontSelecter->setColor(QColor(mQun->getChatFontColor()) );		fontSelecter->setGeometry(p.x() + tbFont->x() , p.y(), fontSelecter->width(), fontSelecter->height());			fontSelecter->show();	}}void EvaQunChatWindow::slotQuickReplyClick( ){}void EvaQunChatWindow::slotQuickReplyActivated( int id ){	if(!teInput->isEnabled()) return;	std::list<QString>::iterator iter;	int index = 0;	for(iter=quickList.begin(); iter!=quickList.end(); ++iter){		if(index == id) break;			index++;	}	QString message = *iter;	EvaHtmlParser parser;	parser.convertToHtml(message, false);		teInput->append(message);	slotSend();}void EvaQunChatWindow::slotHistoryClick( ){	emit requestHistory(mQun->getQunID());}void EvaQunChatWindow::slotSendKeyClick( ){}void EvaQunChatWindow::slotSend( ){	EvaHtmlParser parser;	QString msg = teInput->text();	sendtime = QDateTime::currentDateTime(Qt::LocalTime);	int fontSize = mQun->getChatFontSize();	QColor fontColor(mQun->getChatFontColor());	std::list<QString> outPicList = parser.getCustomImages(msg);	if(outPicList.size()){		sendingImageMsg = msg;		QString toShow = msg;		parser.setAbsImagePath(images->getSmileyPath());		parser.parseToAbsPath(toShow, EvaMain::user->getSetting()->getPictureCacheDir());		QString name = getSenderName( myQQ);		chatDisplay->append( name, sendtime, Qt::darkCyan, true, fontColor, (char)fontSize, 					tbU->isOn(), tbI->isOn(), tbB->isOn(), toShow);		showMessages();		//teInput->setText("");				EvaSendCustomizedPicEvent *event = new EvaSendCustomizedPicEvent();		event->setPicList(getSendFiles(outPicList));		event->setQunID(mQun->getQunID());		QApplication::postEvent((QObject *)EvaMain::picManager, event);		pbSend->setEnabled(false);		teInput->setEnabled(false);	}else{		QString tmp;		parser.convertToPlainTxt(msg, tmp);		if(msg == ""){			QMessageBox::information(0, i18n("Message"), i18n("Cannot send empty message."));			return;		}		if(strlen(msg.ascii()) > QQ_MSG_IM_MAX){			QMessageBox::information(0, i18n("Message"), i18n("Message is too long, cannot send."));			return;		}		pbSend->setEnabled(false);		teInput->setEnabled(false);		displaySendingMessage();		emit sendQunMessage(mQun->getQunID(), msg, (char)fontSize, tbU->isOn(), tbI->isOn(), tbB->isOn(),				(char)(fontColor.blue()) , (char)(fontColor.green()), (char)(fontColor.red()));		}}void EvaQunChatWindow::slotInputKeyPress( QKeyEvent * e ){	if(isSentByEnter && ((e->key() == Qt::Key_Enter) || (e->key() == Qt::Key_Return) ) && 			(e->state() != Qt::KeyButtonMask) ){		e->accept();		slotSend();	}else{		if( !(isSentByEnter) &&			( (e->key() == Qt::Key_Enter) || (e->key() == Qt::Key_Return) ) && 			( (e->state() & Qt::ControlButton)==Qt::ControlButton)    ){		e->accept();		slotSend();		}	}}void EvaQunChatWindow::slotFontChanged( QColor color, int size){	mQun->setChatFontSize(size);	mQun->setChatFontColor( color.rgb());	EvaMain::user->saveQunList();}void EvaQunChatWindow::setEnterSend( ){	isSentByEnter = true;	sendKey->setItemChecked(1,true);	sendKey->setItemChecked(2,false);	teInput->setEnterSendEnabled(isSentByEnter);}void EvaQunChatWindow::setCtrlEnterSend( ){	isSentByEnter = false;	sendKey->setItemChecked(1,false);	sendKey->setItemChecked(2,true);	teInput->setEnterSendEnabled(isSentByEnter);}void EvaQunChatWindow::slotPbCloseClick( ){	close();}QString EvaQunChatWindow::getSenderName(const unsigned int qqNum){	const FriendItem *item = mQun->getMemberDetails(qqNum);	QString name;	if(item){		name = codec->toUnicode(item->getQunRealName().c_str());		if(name.isEmpty()){			if( qqNum != myQQ)				name = codec->toUnicode(item->getNick().c_str());			else				name =myName;		}	} else{		if(qqNum != myQQ)			name = QString::number(qqNum);		else			name = myName;	}	return name;}void EvaQunChatWindow::slotTimeout(){	emit requestQunOnlineList(mQun->getQunID());}void EvaQunChatWindow::showEvent( QShowEvent * e ){	slotTimeout();	if(!timer->isActive())		timer->start(60000, false);	QWidget::showEvent(e);}void EvaQunChatWindow::closeEvent( QCloseEvent * e ){	if(timer->isActive())		timer->stop();	QWidget::closeEvent(e);}void EvaQunChatWindow::hideEvent( QHideEvent * e ){	if(timer->isActive())		timer->stop();	QWidget::hideEvent(e);}void EvaQunChatWindow::slotRequestQunMembers( ){	emit requestQunMembers(mQun->getQunID());}void EvaQunChatWindow::slotPictureReady( const QString filename , const QString tmpFileName){	if(filename.isEmpty() || tmpFileName.isEmpty()) return;	chatDisplay->updatePicture(filename, tmpFileName);}void EvaQunChatWindow::slotImageFileClick( ){	if(!teInput->isEnabled()) return;	QString destDir = EvaMain::user->getSetting()->getPictureCacheDir();	QString fileName = KFileDialog::getOpenFileName(destDir,			"*.png *.bmp *.jpg *.jpeg *.gif |" + i18n(" all images (*.png *.bmp *.jpg *.jpeg *.gif)"), this, 			i18n("select an image file"));	if(!fileName.isEmpty()){		QString destFile = EvaHelper::generateCustomSmiley(fileName, destDir);		if(destFile.isEmpty()) return;		slotAddImageToInputEdit(destFile);	}}const std::list<OutCustomizedPic> EvaQunChatWindow::getSendFiles(const std::list<QString> &fileList){	std::list<QString> outPicList = fileList;	std::list<OutCustomizedPic> picList;		std::list<QString>::iterator iter;	for(iter=outPicList.begin(); iter!=outPicList.end(); ++iter){		QString file = EvaMain::user->getSetting()->getPictureCacheDir() + "/" + QString(*iter);		QFileInfo info(file);		if(!info.exists()) continue;		int len = info.size();		OutCustomizedPic pic;		pic.fileName = file; 		pic.imageLength = len;		EvaHelper::getFileMD5(pic.fileName, (char*)pic.md5);		picList.push_back(pic);	}	return picList;}void EvaQunChatWindow::sendImageError( const QString message ){	//FIXME we might make it elegent as Tencent dose, displaying message in the display window	QMessageBox::information(0, i18n("Send Image Error"), message);	pbSend->setEnabled(true);	teInput->setEnabled(true);	teInput->setFocus();}void EvaQunChatWindow::slotSendImageDone( const unsigned int agentSessionID, const unsigned int agentIP, const unsigned short agentPort ){	sessionID = agentSessionID;	ip = agentIP;	port = agentPort;	EvaHtmlParser parser;	//QString msg = teInput->text();	//parser.convertToPlainTxt(msg, sessionID, ip, port);	parser.convertToPlainTxt(sendingImageMsg, sessionID, ip, port);	if(sendingImageMsg == ""){		QMessageBox::information(0, i18n("Message"), i18n("Cannot send empty message."));		return;	}	if(strlen(sendingImageMsg.ascii()) > QQ_MSG_IM_MAX){		QMessageBox::information(0, i18n("Message"), i18n("Message is too long, cannot send."));		return;	}	sendtime = QDateTime::currentDateTime(Qt::LocalTime);	//displaySendingMessage();	int fontSize = mQun->getChatFontSize();	QColor fontColor(mQun->getChatFontColor());		emit sendQunMessage(mQun->getQunID(), sendingImageMsg, (char)fontSize, tbU->isOn(), tbI->isOn(), tbB->isOn(),			(char)(fontColor.blue()) , (char)(fontColor.green()), (char)(fontColor.red()));}void EvaQunChatWindow::slotScreenShotClick( ){	if(!teInput->isEnabled()) return;	if(grabber) delete grabber;	grabber = new RegionGrabber();	connect( grabber, SIGNAL( regionGrabbed( const QPixmap & ) ),		SLOT( slotRegionGrabbed( const QPixmap & ) ) );}void EvaQunChatWindow::slotRegionGrabbed( const QPixmap & pix){	if ( !pix.isNull() ){		QString dir = EvaMain::user->getSetting()->getPictureCacheDir();				//QImage img = pix.convertToImage();		QString file = QUuid::createUuid().toString().upper() + ".JPG";		pix.save(dir+"/"+file, "JPEG");				QFileInfo info(dir+"/"+file);		if(info.size() > 50000){			printf("image too big, sorry\n");		}else{			char *md5 = new char[16];			EvaHelper::getFileMD5(dir+"/"+file, md5);			QString dest = EvaHelper::md5ToString(md5) + ".JPG";			EvaHelper::rename(dir+"/"+file, dir+"/"+dest);			delete md5;			slotAddImageToInputEdit(dest);		}	}		if(grabber) delete grabber;	grabber = NULL;	QApplication::restoreOverrideCursor();}void EvaQunChatWindow::slotAddImageToInputEdit( const QString & destFile){	if(!teInput->isEnabled()) return;	if(destFile.isEmpty()) return;		QString smiley = "<img src=\"" + destFile + "\">";	int para;	int index;	QFont saveFont = teInput->font();	QColor saveColor = teInput->color();	// determine the current position of the cursor	teInput->insert("\255", false, true, true);	teInput->getCursorPosition(&para,&index);	QString txt = teInput->text();	txt.replace(QRegExp("\255"),smiley);	teInput->setText(txt);	teInput->setCursorPosition(para, index);	teInput->setCurrentFont(saveFont);	teInput->setColor(saveColor);}void EvaQunChatWindow::slotRequestQunCard( const unsigned int id ){	emit requestQunCard(mQun->getQunID(), id);}void EvaQunChatWindow::slotNoticeClick( ){	//QRect rect = chatDisplay->view()->geometry();	if(lblNotice->isVisible())		lblNotice->hide();	else		lblNotice->show();	//adjustSize();	//chatDisplay->view()->setGeometry(rect);	//resize( QSize(470, 422).expandedTo(minimumSizeHint()) );}void EvaQunChatWindow::slotRequestQunRealNames( ){	if(mQun){		emit requestQunRealNames(mQun->getQunID());	}}void EvaQunChatWindow::slotManageCustomSmileys(){//	CreateSmileyWindow *win = new CreateSmileyWindow();//	win->show();	CustomSmileyManager *win = new CustomSmileyManager;	connect(win, SIGNAL(customSmileyChanged()), this, SLOT(slotCustomSmileyChanged()) );	win->show();}void EvaQunChatWindow::slotSaveAsCustomSmiley( QString url){	CreateSmileyWindow *win = new CreateSmileyWindow(url);	connect(win, SIGNAL(addCustomSmileyReady( bool )), this, SLOT(slotAddCustomSmileyReady( bool )));	win->show();}void EvaQunChatWindow::slotAddCustomSmileyReady( bool ready){	if(ready){		slotCustomSmileyChanged();	}}void EvaQunChatWindow::slotCustomSmileyChanged( ){	printf("EvaQunChatWindow :: slotCustomSmileyChanged\n");	if(smileyPopup) {		disconnect(smileyPopup, 0, 0, 0);		delete smileyPopup;	}	smileyPopup = new CustomFaceSelector(false);	connect(smileyPopup, SIGNAL(selectSysFace(int)), this, SLOT(slotSmileySelected(int)));	connect(smileyPopup, SIGNAL(selectCustomFace(const QString &)), this, SLOT(slotAddImageToInputEdit(const QString &)));	connect(smileyPopup, SIGNAL(addSmileyClicked()), this, SLOT(slotManageCustomSmileys()));}	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -