fxmainwindow.cpp

来自「linux-下的fetion-0.8.1。包括所有源代码」· C++ 代码 · 共 2,191 行 · 第 1/4 页

CPP
2,191
字号
	if(!item)		return NULL;	if(!item->parent()) 		return NULL;#if MS_VC6	Qun_Info *qun_info =(Qun_Info*)(item->data(0, Qt::UserRole).toUInt());#else	Qun_Info *qun_info =item->data(0, Qt::UserRole).value<Qun_Info*>();#endif	return qun_info;}void FxMainWindow::setImpresa(){	bool ok;	QString text = QInputDialog::getText(this, tr("setImpresa"),			tr("please input newImpresa"), QLineEdit::Normal,			"", &ok);	if (ok)	{		if (text.isEmpty())			fx_set_user_impresa(NULL, NULL, NULL);		else			fx_set_user_impresa(text.toUtf8().data(), NULL, NULL); 	}	setUINiceName();}void FxMainWindow::addGroup(){	bool ok;	QString text = QInputDialog::getText(this, tr("addGroup"),			tr("please input group name"), QLineEdit::Normal,			"", &ok);	if (ok && !text.isEmpty())		fx_add_buddylist(text.toUtf8().data(), NULL, NULL); }void FxMainWindow::deleteGroup(){	QTreeWidgetItem *item = view->currentItem ();	if(!item)		return;	if(item->childCount() > 0)	{		QMessageBox::warning(this, tr("can not delete group"), tr("group is not null"),QMessageBox::Yes);		return;		}	Group_Info* group_info = getGp_InfoOfCurrentItem();	if(!group_info)		return;	QString msg = tr("are you sure to delete group") + group_info->groupName;	int ret = QMessageBox::warning(this, tr("delete group"), msg,			QMessageBox::Yes, QMessageBox::Cancel);	if (ret == QMessageBox::Yes)		fx_delete_buddylist(group_info->groupID, NULL, NULL);}void FxMainWindow::renameGroup(){	Group_Info* group_info = getGp_InfoOfCurrentItem();	if(!group_info)		return;	bool ok;	QString text = QInputDialog::getText(this, tr("renameGroup"),			tr("please input new group name"), QLineEdit::Normal,			"", &ok);	if (ok && !text.isEmpty())		fx_rename_buddylist(group_info->groupID, text.toUtf8().data(), NULL, NULL); }void FxMainWindow::renameBuddy(){	Account_Info *ac_info =getAc_InfoOfCurrentItem();	if(!ac_info)		return;	bool ok;	QString text = QInputDialog::getText(this, tr("renamebudd"),			tr("please input new buddy name"), QLineEdit::Normal,			"", &ok);	if (ok && !text.isEmpty())		fx_set_buddyinfo(ac_info->accountID, text.toUtf8().data(), NULL, NULL); }void FxMainWindow::imQun(){	Qun_Info* qun_info = getQun_InfoOfCurrentItem();	if(!qun_info)		return;	msgwin->addQunWin(qun_info->qunID);}void FxMainWindow::smsQun(){	Qun_Info* qun_info = getQun_InfoOfCurrentItem();	if(!qun_info)		return;	msgwin->addQunWin(qun_info->qunID, true);}void FxMainWindow::getInfoQun(){	Qun_Info* qun_info = getQun_InfoOfCurrentItem();	if(!qun_info)		return;	this->setVisible( true);	this->activateWindow();	QDialog *window = new QDialog(this);	window->setWindowTitle(tr("see qun info"));	QTextEdit *AcInfo = new QTextEdit(window);	QDialogButtonBox *buttonBox = new QDialogButtonBox(window);	buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);	QVBoxLayout *layout = new QVBoxLayout;	layout->addWidget(AcInfo);	layout->addWidget(buttonBox);	window->setLayout(layout);	setQunInfo(AcInfo, qun_info->qunID);	connect(buttonBox, SIGNAL(accepted()), window, SLOT(accept()));	connect(buttonBox, SIGNAL(rejected()), window, SLOT(reject()));	window->exec();	delete window;}void FxMainWindow::imBuddy(){	Account_Info *ac_info =getAc_InfoOfCurrentItem();	if(!ac_info)		return;	showMsgWindow(ac_info->accountID);	//msgwin->addAccount(ac_info->accountID);}void FxMainWindow::smsBuddy(){	Account_Info *ac_info =getAc_InfoOfCurrentItem();	if(!ac_info)		return;	msgwin->addAccount(ac_info->accountID, true);}void FxMainWindow::getInfoBuddy(){	Account_Info *ac_info =getAc_InfoOfCurrentItem();	if(!ac_info) return;	const Fetion_Account *account =fx_get_account_by_id(ac_info->accountID);	if(!account) return;	FxShowAccountInfo * showInfo = new FxShowAccountInfo(account, this); 	showInfo->exec();	delete showInfo;}void FxMainWindow::updataInfoBuddy(){	Account_Info *ac_info =getAc_InfoOfCurrentItem();	if(!ac_info)		return;	fx_updata_account_info_by_id (ac_info->accountID);}void FxMainWindow::deleteBuddy(){	Account_Info *ac_info =getAc_InfoOfCurrentItem();	if(!ac_info)		return;	QString msg = tr("are you sure to delete buddy")+ ac_info->accountName;	int ret = QMessageBox::warning(this, tr("delete buddy"),msg,			QMessageBox::Yes,QMessageBox::Cancel);	if (ret == QMessageBox::Yes)	{		msg = tr("delete buddy can not stop it send message to you,") + "\r\n" +			tr("shoud you want to add it to blacklist") ;		ret = QMessageBox::warning(this, tr("add to black"),msg,				QMessageBox::Yes,QMessageBox::Cancel);		if(ret == QMessageBox::Yes)			fx_addto_blacklist_by_id(ac_info->accountID, NULL, NULL);		fx_delete_buddy_by_id(ac_info->accountID, NULL, NULL);	}}void FxMainWindow::addBlackBuddy(){	Account_Info *ac_info =getAc_InfoOfCurrentItem();	if(!ac_info)		return;	fx_addto_blacklist_by_id(ac_info->accountID, NULL, NULL);}void FxMainWindow::removeBlackBuddy(){	Account_Info *ac_info =getAc_InfoOfCurrentItem();	if(!ac_info)		return;	fx_removefrom_blacklist_by_id(ac_info->accountID, NULL, NULL);}void FxMainWindow::tmp_exit(){	isQuit = true;	close();}void FxMainWindow::setOnlineStatus(){	fx_set_user_state(FX_STATUS_ONLINE, NULL, NULL, NULL);}void FxMainWindow::setOfflineStatus(){	fx_set_user_state(FX_STATUS_OFFLINE, NULL, NULL, NULL);}void FxMainWindow::setBusyStatus(){	fx_set_user_state(FX_STATUS_BUSY, NULL, NULL, NULL);}void FxMainWindow::setAwayStatus(){	fx_set_user_state(FX_STATUS_AWAY, NULL, NULL, NULL);}void FxMainWindow::setacceptSMS(){	fx_set_user_refuse_sms_day(0, NULL, NULL);}void FxMainWindow::setrefuseSMS(){	this->show();	FxRefuseSMS * xx = new FxRefuseSMS(this);	xx->exec();	delete xx;}void FxMainWindow::setQunInfo(QTextEdit *AcInfo, qlonglong qun_id){	QString info;	Fetion_QunInfo *quninfo = NULL;	const Fetion_Qun *fx_qun = fx_get_qun_by_id(qun_id);	if(fx_qun)		quninfo = fx_qun->quninfo;	if (!quninfo)	{		AcInfo->append(tr("qun name:"));		AcInfo->append(tr("qun introduce:"));		AcInfo->append(tr("qun bulletin:"));		return;	}	info = tr("qun name:");	info += "<b style=\"color:red; \">" + 		QString::fromUtf8(quninfo->name) 		+"</b>";	AcInfo->append(info);	info = tr("qun introduce:");	info += "<b style=\"color:red; \">" + 		QString::fromUtf8(quninfo->introduce) 		+"</b>";	AcInfo->append(info);	info = tr("qun bulletin:");	info += "<b style=\"color:red; \">" + 		QString::fromUtf8(quninfo->bulletin) 		+"</b>";	AcInfo->append(info);}void FxMainWindow::setPersonalInfo(QTextEdit *AcInfo, const Fetion_Personal *personal){	bool hP = false;	if(personal)		hP = true;	QString info;	info += tr("mobile_no:");	if(hP)		info += "<b style=\"color:red; \">" + 			QString::fromUtf8(fx_get_usr_mobilenum()) 			+"</b>";	else 		info += "<b style=\"color:red; \"> </b>"; 	AcInfo->append(info);	info = tr("fetion_no:");	info += "<b style=\"color:red; \">"+QString::fromUtf8(fx_get_usr_uid()) +"</b>";	AcInfo->append(info);	//AcInfo->append(<b style=\"color:red; \">" + tr("personal infomation")+"</b>");	info = tr("nickname:");	if(hP)		info += "<b style=\"color:red; \">" + 			QString::fromUtf8(personal->nickname) 			+"</b>";	else 		info += "<b style=\"color:red; \"> </b>"; 	AcInfo->append(info);	info = tr("name:");	if(hP)		info += "<b style=\"color:red; \">" + 			QString::fromUtf8(personal->name) 			+"</b>";	else 		info += "<b style=\"color:red; \"> </b>"; 	AcInfo->append(info);	info = tr("gender:");	if(hP)		switch(personal->gender)		{			case 2:				info += "<b style=\"color:red; \">" + tr("girl") +"</b>";				break;			case 1:				info += "<b style=\"color:red; \">" + tr("boy") +"</b>";				break;			case 0:				info += "<b style=\"color:red; \">" + tr("unknow") +"</b>";				break;		}	else		info += "<b style=\"color:red; \">" + tr("unknow") +"</b>";	AcInfo->append(info);	info = tr("score:");	info += "<b style=\"color:red; \">" + QString("%1").arg(fx_get_usr_score()) +"</b>";	AcInfo->append(info);	info = tr("impresa:");	if(hP)		info += "<b style=\"color:red; \">" + 			QString::fromUtf8(personal->impresa) 			+"</b>";	else 		info += "<b style=\"color:red; \"> </b>"; 	AcInfo->append(info);}void FxMainWindow::personlInfo(){	this->setVisible( true);	this->activateWindow();	QDialog *window = new QDialog(this);	window->setWindowTitle(tr("see personal info"));	QTextEdit *AcInfo = new QTextEdit(window);	QDialogButtonBox *buttonBox = new QDialogButtonBox(window);	buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);	QVBoxLayout *layout = new QVBoxLayout;	layout->addWidget(AcInfo);	layout->addWidget(buttonBox);	window->setLayout(layout);	setPersonalInfo(AcInfo, fx_data_get_PersonalInfo());	connect(buttonBox, SIGNAL(accepted()), window, SLOT(accept()));	connect(buttonBox, SIGNAL(rejected()), window, SLOT(reject()));	window->exec();	delete window;}void FxMainWindow::checkNewVersion(){	this->show();	QString info;	if (newVersion > CURRENT_VERSION)		info = 	tr("LibFetion Have New Version,"		"access http://www.libfetion.cn for more infomation");	else		info = 	tr("the current Version is the new Version");	QMessageBox::about(this,tr("LibFetion"), info);}void FxMainWindow::reportBugAct(){	QDesktopServices::openUrl(QUrl("http://www.libfetion.cn/bbs"));}void FxMainWindow::aboutLibFetion(){	this->show();	QMessageBox::about(this, tr("About LibFetion"),			tr(	"Application Current Version"  ) + VERSION_NO +			tr(	"<br>This application is based on LibFetion library to writing, for more infomation access<a href=\"http://www.libfetion.cn\"> www.libfetion.cn </a> <br>"				"Copyright @ 2008 <b> <a href=\"mailto:dedodong@163.com\">DDD</a> (dedodong@163.com)</b>. All Rights reserved."));}void FxMainWindow::aboutCM(){	this->show();	QMessageBox::about(this, tr("About CHINA Mobile"),			tr("<a href=\"http://www.fetion.com.cn\"> China Mobile Fetion</a>"				"China Mobile Fetion introduce"));}void FxMainWindow::menu_setmute(){	bool currentIsMute = Settings::instance().isMute();	Settings::instance().setMute (!currentIsMute);	if (currentIsMute)		MuteAct->setIcon(getMenuIcon(CancelIcon));	else 		MuteAct->setIcon(getMenuIcon(ApplyIcon));}void FxMainWindow::saveMsgHistroy(){	this->show();	bool ok;	QString text = QInputDialog::getText(this, tr("saveMsgHistroy"),			tr("please input password"), QLineEdit::Password,			"", &ok);	if (ok && !text.isEmpty())	{		if (text == QString(fx_get_usr_passwd()))		{			QString fileName = QFileDialog::getSaveFileName(this,					tr("saveMsgHistroy"),					QDir::homePath(),					tr("Text Files (*.htm)"));			if (!fileName.isEmpty())			{				int ret = export_history ((qlonglong)strtol(fx_get_usr_uid(), NULL, 10), 						fileName.toUtf8().data());				if (ret == 2 )					QMessageBox::critical(this, tr("save file error"), tr("the path of file can't write") ); 			}		} else 			QMessageBox::critical(this, tr("error"), tr("the password error") ); 	}}void FxMainWindow::cleanMsgHistroy(){	this->show();	bool ok;	QString text = QInputDialog::getText(this, tr("cleanMsgHistroy"),			tr("please input password"), QLineEdit::Password,			"", &ok);	if (ok && !text.isEmpty())	{		if (text == QString(fx_get_usr_passwd()))			clean_history ((qlonglong)strtol(fx_get_usr_uid(), NULL, 10));		else 			QMessageBox::critical(this, tr("error"), tr("the password error") ); 	}}void FxMainWindow::showConfigDlg(){	show();	FxConfigDia * configdia= new FxConfigDia(this, this);	configdia->show();}void FxMainWindow::menu_setautoshowmsg(){	bool currentIsAutoShowMsg = Settings::instance().isAutoShowMsg();	Settings::instance().setAutoShowMsg (!currentIsAutoShowMsg);	if (currentIsAutoShowMsg)		IsAutoShowMsgAct->setIcon(getMenuIcon(ApplyIcon));	else 		IsAutoShowMsgAct->setIcon(getMenuIcon(CancelIcon));}void FxMainWindow::menu_setundgemsg(){	QMessageBox::critical(this, ("setundgemsg"), ("setundgemsg") ); 	fx_send_nudge(630352708L);}void FxMainWindow::menu_setlongsms(){	bool currentIsEnableLongSMS = Settings::instance().isEnableLongSMS();	Settings::instance().setEnableLongSMS (!currentIsEnableLongSMS);	if (currentIsEnableLongSMS)		SetLongSMSAct->setIcon(getMenuIcon(CancelIcon));	else 		SetLongSMSAct->setIcon(getMenuIcon(ApplyIcon));}void FxMainWindow::menu_setAutoLogin(){	bool currentIsAutoLogin = Settings::instance().isAutoLogin();	Settings::instance().setAutoLogin(!currentIsAutoLogin);	if (currentIsAutoLogin)		AutoLoginAct->setIcon(getMenuIcon(CancelIcon));	else 		AutoLoginAct->setIcon(getMenuIcon(ApplyIcon));}void FxMainWindow::initTrayIcon(){	isHaveTray = QSystemTrayIcon::isSystemTrayAvailable();	if(isHaveTray)	{		trayIcon = new QSystemTrayIcon(this);		trayIcon->setContextMenu(trayIconMenu);		trayIcon->setIcon(getSysTrayIcon (fx_get_user_state()));		trayIcon->show();#if WIN32		trayIcon->setToolTip (QString::fromUtf8(fx_get_usr_show_name()) + " Win Fetion");#else#if MAC_OS		trayIcon->setToolTip (QString::fromUtf8(fx_get_usr_show_name()) + " Mac Fetion");#else		trayIcon->setToolTip (QString::fromUtf8(fx_get_usr_show_name()) + " Linux Fetion");#endif#endif	}}

⌨️ 快捷键说明

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