?? fxmainwindow.cpp
字號:
switch (reason) { case QSystemTrayIcon::Trigger: if (showNewMsgDlg()) return; //here codes should be ajust after later.. if (fx_status == SYS_RELOGIN) //relogin state will not handle this message.. return; trayMessageClicked();#if MAC_OS this->setVisible( !this->isVisible()); if(this->isVisible()) { this->activateWindow(); setWindowState (Qt::WindowNoState ) ; }#endif break; case QSystemTrayIcon::DoubleClick: //here codes should be ajust after later.. if (fx_status == SYS_RELOGIN) //relogin state will not handle this message.. return; trayMessageClicked(); if ( this->isVisible() && windowState() != Qt::WindowNoState ) { this->activateWindow(); setWindowState ( Qt::WindowNoState ) ; return; } this->setVisible( !this->isVisible()); if(this->isVisible()) { this->activateWindow(); setWindowState ( Qt::WindowNoState ) ; } break; case QSystemTrayIcon::MiddleClick: break; default: ; }}void FxMainWindow::init_UI(){ Settings::instance().setMainWindow(this);#if 1 Settings::instance().setUser((qlonglong)strtol(fx_get_usr_uid(), NULL, 10));#else Settings::instance().setUser(1000);#endif if (Settings::instance().isMainWindowTopHint()) this->setWindowFlags(Qt::WindowStaysOnTopHint); //remove the maximizeButtonHint this->setWindowFlags( windowFlags() ^ Qt::WindowMaximizeButtonHint);#if WIN32 setWindowTitle(QString::fromUtf8(fx_get_usr_show_name()) + "--Win Fetion");#else#if MAC_OS setWindowTitle(QString::fromUtf8(fx_get_usr_show_name()) + "--Mac Fetion");#else setWindowTitle(QString::fromUtf8(fx_get_usr_show_name()) + "--Linux Fetion");#endif#endif this->setWindowIcon(getSysTrayIcon(1)); move(Settings::instance().MainWinPos()); //UI set all images of main windows //****************************************************/ LibFetion_image->setPixmap(getLibFetionImage()); UI_Portrait->setPixmap (getPortraitImage()); UI_ImpresaBK->setPixmap (getImpresaBKImage()); UI_SearchBK->setPixmap (getSearchBKImage()); UI_AddFriend->setPixmap (getAddImage()); UI_Search->setText(tr("search friends...")); UI_Edit_NiceName->setText(QString::fromUtf8(fx_get_usr_show_name())); UI_Edit_NiceName->hide(); setUINiceName(); version->setText(VERSION_NO); ///****************************************************/ ///************* init some contorl ***************************************/ view->header()->setHidden(1); view->setRootIsDecorated(true); //add all account to main view buddyopt = new BuddyOpt(view); //init search control search->header()->setHidden(1); search->setRootIsDecorated(true); search->hide(); msgwin = new FxMsgWindow(0); msgwin->setMainWind(this); //fx_updata_account_info_all(); //****************************************************//}void FxMainWindow::initAllActions(){ OnlineAct = new QAction(tr("online"), this); OnlineAct->setIcon(getOnlineStatusIcon(FX_STATUS_ONLINE)); connect(OnlineAct, SIGNAL(triggered()), this, SLOT(setOnlineStatus())); OfflineAct = new QAction(tr("offline"), this); OfflineAct->setIcon(getOnlineStatusIcon(FX_STATUS_OFFLINE)); connect(OfflineAct, SIGNAL(triggered()), this, SLOT(setOfflineStatus())); BusyAct = new QAction(tr("busy"), this); BusyAct->setIcon(getOnlineStatusIcon(FX_STATUS_BUSY)); connect(BusyAct, SIGNAL(triggered()), this, SLOT(setBusyStatus())); AwayAct = new QAction(tr("away"), this); AwayAct->setIcon(getOnlineStatusIcon(FX_STATUS_AWAY)); connect(AwayAct, SIGNAL(triggered()), this, SLOT(setAwayStatus())); acceptSMSAct = new QAction(tr("accept SMS"), this); connect(acceptSMSAct, SIGNAL(triggered()), this, SLOT(setacceptSMS())); refuseSMSAct = new QAction(tr("refuse SMS"), this); connect(refuseSMSAct, SIGNAL(triggered()), this, SLOT(setrefuseSMS())); if (fx_get_user_refuse_sms_day()) //is get from libfetion.. { refuseSMSAct->setIcon(getMenuIcon(ApplyIcon)); acceptSMSAct->setIcon(QPixmap()); } else { acceptSMSAct->setIcon(getMenuIcon(ApplyIcon)); refuseSMSAct->setIcon(QPixmap()); } addBuddyAct = new QAction(tr("add friend"), this); addBuddyAct->setStatusTip(tr("add friend")); addBuddyAct->setIcon(getMenuIcon(AddBuddyIcon)); connect(addBuddyAct, SIGNAL(triggered()), this, SLOT(addBuddy())); sendselfAct = new QAction(tr("send sms to self"), this); sendselfAct->setStatusTip(tr("send sms to self")); sendselfAct->setIcon(getMenuIcon(SMSBuddyIcon)); connect(sendselfAct, SIGNAL(triggered()), this, SLOT(sendself())); sendgroupsmsAct = new QAction(tr("send group sms"), this); sendgroupsmsAct->setStatusTip(tr("send group sms")); sendgroupsmsAct->setIcon(getMenuIcon(SMSBuddyIcon)); connect(sendgroupsmsAct, SIGNAL(triggered()), this, SLOT(sendgroupsms())); exitAct = new QAction(tr("Exit"), this); exitAct->setShortcut(tr("Ctrl+Q")); exitAct->setStatusTip(tr("Exit the application")); exitAct->setIcon(getMenuIcon(ExitIcon)); connect(exitAct, SIGNAL(triggered()), this, SLOT(tmp_exit())); personlInfoAct = new QAction(tr("personlInfo"), this); personlInfoAct->setStatusTip(tr("personlInfo")); personlInfoAct->setIcon(getMenuIcon(GetInfoBuddyIcon)); connect(personlInfoAct, SIGNAL(triggered()), this, SLOT(personlInfo())); CheckNewVersionAct = new QAction(tr("checkNewVersion"), this); CheckNewVersionAct->setStatusTip(tr("checkNewVersion")); CheckNewVersionAct->setIcon(getMenuIcon(AboutIcon)); connect(CheckNewVersionAct, SIGNAL(triggered()), this, SLOT(checkNewVersion())); ReportBugAct = new QAction(tr("reportBugAct"), this); ReportBugAct->setStatusTip(tr("reportBugAct")); ReportBugAct->setIcon(getMenuIcon(AboutIcon)); connect(ReportBugAct, SIGNAL(triggered()), this, SLOT(reportBugAct())); AboutLibFetionAct = new QAction(tr("aboutLibFetion"), this); AboutLibFetionAct->setStatusTip(tr("aboutLibFetion")); AboutLibFetionAct->setIcon(getMenuIcon(AboutIcon)); connect(AboutLibFetionAct, SIGNAL(triggered()), this, SLOT(aboutLibFetion())); AboutCMAct = new QAction(tr("aboutChinaMobile"), this); AboutCMAct->setStatusTip(tr("aboutChinaMobile")); AboutCMAct->setIcon(getMenuIcon(AboutIcon)); connect(AboutCMAct, SIGNAL(triggered()), this, SLOT(aboutCM())); AutoLoginAct = new QAction(tr("autologin"), this); if (isAutoLogin(NULL, NULL, NULL)) AutoLoginAct->setIcon(getMenuIcon(ApplyIcon)); else AutoLoginAct->setIcon(getMenuIcon(CancelIcon)); AutoLoginAct->setStatusTip(tr("autologin")); connect(AutoLoginAct, SIGNAL(triggered()), this, SLOT(menu_setAutoLogin())); MuteAct = new QAction(tr("mute"), this); if (Settings::instance().isMute()) MuteAct->setIcon(getMenuIcon(ApplyIcon)); else MuteAct->setIcon(getMenuIcon(CancelIcon)); MuteAct->setStatusTip(tr("autoshowmsg")); connect(MuteAct, SIGNAL(triggered()), this, SLOT(menu_setmute())); IsAutoShowMsgAct = new QAction(tr("autoshowmsg"), this);#if MAC_OS IsAutoShowMsgAct->setVisible(false); #endif if (Settings::instance().isAutoShowMsg()) IsAutoShowMsgAct->setIcon(getMenuIcon(ApplyIcon)); else IsAutoShowMsgAct->setIcon(getMenuIcon(CancelIcon)); IsAutoShowMsgAct->setStatusTip(tr("autoshowmsg")); connect(IsAutoShowMsgAct, SIGNAL(triggered()), this, SLOT(menu_setautoshowmsg()));#if 0 SetUndgeMsgAct = new QAction(tr("undgemsg"), this); if (1) //if (!isAutoShowMsg(fx_get_usr_uid())) SetUndgeMsgAct->setIcon(getMenuIcon(CancelIcon)); else SetUndgeMsgAct->setIcon(getMenuIcon(ApplyIcon)); SetUndgeMsgAct->setStatusTip(tr("undgemsg")); connect(SetUndgeMsgAct, SIGNAL(triggered()), this, SLOT(menu_setundgemsg()));#endif SetLongSMSAct = new QAction(tr("catsms"), this); if (Settings::instance().isEnableLongSMS()) SetLongSMSAct->setIcon(getMenuIcon(ApplyIcon)); else SetLongSMSAct->setIcon(getMenuIcon(CancelIcon)); SetLongSMSAct->setStatusTip(tr("catsms")); connect(SetLongSMSAct, SIGNAL(triggered()), this, SLOT(menu_setlongsms())); SaveMsgHistroyAct = new QAction(tr("savemsghistroy"), this); SaveMsgHistroyAct->setStatusTip(tr("savemsghistroy")); SaveMsgHistroyAct->setIcon(getMenuIcon(HistoryIcon)); connect(SaveMsgHistroyAct, SIGNAL(triggered()), this, SLOT(saveMsgHistroy())); CleanMsgHistroyAct = new QAction(tr("cleanmsghistroy"), this); CleanMsgHistroyAct->setStatusTip(tr("cleanmsghistroy")); CleanMsgHistroyAct->setIcon(getMenuIcon(HistoryIcon)); connect(CleanMsgHistroyAct, SIGNAL(triggered()), this, SLOT(cleanMsgHistroy())); ConfigAppAct = new QAction(tr("moresetting"), this); ConfigAppAct->setStatusTip(tr("moresetting")); ConfigAppAct->setIcon(getMenuIcon(OptionsIcon)); connect(ConfigAppAct, SIGNAL(triggered()), this, SLOT(showConfigDlg())); AddGroupAct = new QAction(tr("add group"), this); AddGroupAct->setIcon(getMenuIcon(AddGroupIcon)); connect(AddGroupAct, SIGNAL(triggered()), this, SLOT(addGroup())); DeleteGroupAct = new QAction(tr("delete group"), this); DeleteGroupAct->setIcon(getMenuIcon(DeleteGroupIcon)); connect(DeleteGroupAct, SIGNAL(triggered()), this, SLOT(deleteGroup())); ReNameGroupAct = new QAction(tr("rename group"), this); ReNameGroupAct->setIcon(getMenuIcon(ReNameGroupIcon)); connect(ReNameGroupAct, SIGNAL(triggered()), this, SLOT(renameGroup())); ReNameBuddyAct = new QAction(tr("rename buddy"), this); ReNameBuddyAct->setIcon(getMenuIcon(ReNameBuddyIcon)); connect(ReNameBuddyAct, SIGNAL(triggered()), this, SLOT(renameBuddy())); IMBuddyAct = new QAction(tr("im buddy"), this); IMBuddyAct->setIcon(getMenuIcon(IMBuddyIcon)); connect(IMBuddyAct, SIGNAL(triggered()), this, SLOT(imBuddy())); SMSBuddyAct = new QAction(tr("sms buddy"), this); SMSBuddyAct->setIcon(getMenuIcon(SMSBuddyIcon)); connect(SMSBuddyAct, SIGNAL(triggered()), this, SLOT(smsBuddy())); GetInfoBuddyAct = new QAction(tr("get info buddy"), this); GetInfoBuddyAct->setIcon(getMenuIcon(GetInfoBuddyIcon)); connect(GetInfoBuddyAct, SIGNAL(triggered()), this, SLOT(getInfoBuddy())); RefreshInfoBuddyAct = new QAction(tr("updata info buddy"), this); RefreshInfoBuddyAct->setIcon(getMenuIcon(RefreshBuddyIcon)); connect(RefreshInfoBuddyAct, SIGNAL(triggered()), this, SLOT(updataInfoBuddy())); DeleteBuddyAct = new QAction(tr("delete buddy"), this); DeleteBuddyAct->setIcon(getMenuIcon(DeleteBuddyIcon)); connect(DeleteBuddyAct, SIGNAL(triggered()), this, SLOT(deleteBuddy())); AddBlackBuddyAct = new QAction(tr("add to black list"), this); AddBlackBuddyAct->setIcon(getMenuIcon(BackInBuddyIcon)); connect(AddBlackBuddyAct, SIGNAL(triggered()), this, SLOT(addBlackBuddy())); RemoveBlackBuddyAct = new QAction(tr("remove frome black list"), this); RemoveBlackBuddyAct->setIcon(getMenuIcon(RemoveBlackIcon)); connect(RemoveBlackBuddyAct, SIGNAL(triggered()), this, SLOT(removeBlackBuddy())); IMQunAct = new QAction(tr("im qun"), this); IMQunAct->setIcon(getMenuIcon(IMBuddyIcon)); connect(IMQunAct, SIGNAL(triggered()), this, SLOT(imQun())); SMSQunAct = new QAction(tr("sms qun"), this); SMSQunAct->setIcon(getMenuIcon(SMSBuddyIcon)); connect(SMSQunAct, SIGNAL(triggered()), this, SLOT(smsQun())); GetInfoQunAct = new QAction(tr("getinfo qun"), this); GetInfoQunAct->setIcon(getMenuIcon(GetInfoBuddyIcon)); connect(GetInfoQunAct, SIGNAL(triggered()), this, SLOT(getInfoQun()));}void FxMainWindow::createMenu(){ QMenu *sendSmsMenu; //tmp menu of send sms reloginTrayMenu = new QMenu(this); reloginTrayMenu->addAction(exitAct); trayIconMenu = new QMenu(this); traySetStatusMenu = trayIconMenu->addMenu(tr("change online status")); traySetStatusMenu->setIcon( getOnlineStatusIcon(fx_get_user_state())); traySetStatusMenu->addAction(OnlineAct); traySetStatusMenu->addAction(OfflineAct); traySetStatusMenu->addAction(BusyAct); traySetStatusMenu->addAction(AwayAct); sendSmsMenu = trayIconMenu->addMenu(tr("sendsms")); sendSmsMenu->setIcon(getMenuIcon(SMSBuddyIcon)); sendSmsMenu->addAction(sendselfAct); sendSmsMenu->addAction(sendgroupsmsAct); trayIconMenu->addAction(addBuddyAct); trayIconMenu->addAction(personlInfoAct); trayIconMenu->addSeparator(); trayIconMenu->addAction(exitAct); buddySetStatusMenu = buddyMenu->addMenu(tr("change online status")); buddySetStatusMenu->setIcon( getOnlineStatusIcon(fx_get_user_state())); buddySetStatusMenu->addAction(OnlineAct); buddySetStatusMenu->addAction(OfflineAct); buddySetStatusMenu->addAction(BusyAct); buddySetStatusMenu->addAction(AwayAct); buddySetStatusMenu->addSeparator(); buddySetStatusMenu->addAction(acceptSMSAct); buddySetStatusMenu->addAction(refuseSMSAct); buddyMenu->addMenu(buddySetStatusMenu ); sendSmsMenu = buddyMenu->addMenu(tr("sendsms")); sendSmsMenu->setIcon(getMenuIcon(SMSBuddyIcon)); sendSmsMenu->addAction(sendselfAct); sendSmsMenu->addAction(sendgroupsmsAct); buddyMenu->addAction(addBuddyAct); buddyMenu->addAction(personlInfoAct); buddyMenu->addSeparator(); buddyMenu->addAction(exitAct); //menuSetting->addAction (SetImpresaAct); menuSetting->addAction (AutoLoginAct); menuSetting->addAction (MuteAct); menuSetting->addAction (IsAutoShowMsgAct); //menuSetting->addAction (SetUndgeMsgAct); //menuSetting->addAction (SetLongSMSAct); msgHistroyMenu = menuSetting->addMenu(tr("msghistroy")); msgHistroyMenu->setIcon(getMenuIcon(HistoryIcon)); msgHistroyMenu->addAction (SaveMsgHistroyAct); msgHistroyMenu->addAction (CleanMsgHistroyAct); menuSetting->addAction (ConfigAppAct); menuAbout->addAction (CheckNewVersionAct); menuAbout->addAction (ReportBugAct); menuAbout->addAction (AboutLibFetionAct); menuAbout->addAction (AboutCMAct);}void FxMainWindow::init_slot_signal(){#if 0 connect(UI_ImpresaBK, SIGNAL(clicked ()), this, SLOT(UI_enable_impresa())); connect(UI_SearchBK, SIGNAL(clicked ()), this, SLOT(UI_enable_search()));#endif connect(UI_Impresa, SIGNAL(clicked ()), this, SLOT(UI_enable_impresa())); connect(UI_Search, SIGNAL(clicked ()), this, SLOT(UI_enable_search())); connect(UI_AddFriend, SIGNAL(clicked ()), this, SLOT(addBuddy())); connect(UI_Portrait, SIGNAL(clicked ()), this, SLOT(showPortrait())); connect(UI_NiceName, SIGNAL(clicked ()), this, SLOT(showNiceNameEdit())); connect(UI_Edit_NiceName, SIGNAL(editingFinished ()), this, SLOT(changeNiceName ())); connect(UI_Edit_NiceName, SIGNAL(outfocus ()), UI_Edit_NiceName, SLOT(hide ())); connect(UI_Impresa, SIGNAL(editingFinished ()), this, SLOT(changeImpresa ())); connect(UI_Search, SIGNAL(editingFinished ()), this, SLOT(SearcheditingFinished ())); connect(UI_Impresa, SIGNAL(infocus ()), this, SLOT(ImpresaFocusIn ())); connect(UI_Search, SIGNAL(infocus ()), this, SLOT(SearchFocusIn ())); connect(UI_Search, SIGNAL(textChanged (const QString &) ), this, SLOT(SearchtextChanged (const QString &))); if(isHaveTray) { connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(trayMessageClicked())); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); } connect(&minimizedTimer, SIGNAL(timeout()), this, SLOT(minimizedWind())); connect(&trayFlickTimer, SIGNAL(timeout()), this, SLOT(flickerTray())); connect(&reloginTimer, SIGNAL(timeout()), this, SLOT(relogin_timer())); connect(search, SIGNAL(itemDoubleClicked (QTreeWidgetItem* , int) ), this, SLOT(searchaccountDoubleClicked ( QTreeWidgetItem *, int))); connect(view, SIGNAL(itemDoubleClicked (QTreeWidgetItem* , int) ), this, SLOT(accountDoubleClicked ( QTreeWidgetItem *, int))); connect(view, SIGNAL(itemPressed (QTreeWidgetItem* , int) ), this, SLOT(accountPressed ( QTreeWidgetItem *, int))); connect(this, SIGNAL(signal_Current_Version(int)), this, SLOT( haveCurrentVersionMessage(int) ) ); connect(this, SIGNAL(signal_AddAccountApp(char*, char*)), this, SLOT( haveAddAccountAppMessage(char*, char*) ) ); connect(this, SIGNAL(signal_MoveGroup(qlonglong, int)), this, SLOT( haveMoveGroupMessage(qlonglong, int) ) ); connect(this, SIGNAL(signal_NewSysMsg(qlonglong) ), this, SLOT( haveNewSysMessage(qlonglong) ) ); connect(this, SIGNAL(signal_NewMsg(qlonglong) ), this, SLOT( haveNewMessage(qlonglong) ) ); connect(this, SIGNAL(signal_NewQunMsg(qlonglong) ), this, SLOT( haveNewQunMessage(qlonglong) ) ); connect(this, SIGNAL(signal_UpdateAcInfo(qlonglong) ), this, SLOT( updateAccountInfo(qlonglong) ) ); connect(this, SIGNAL(signal_SysDialogMsg(int, int, qlonglong)), this, SLOT( slot_SysDialogMsg(int, int, qlonglong)) ); connect(this, SIGNAL(signal_SystemNetErr(int)), this, SLOT( slot_SystemNetErr(int)) ); connect(this, SIGNAL(signal_DeRegistered()), this, SLOT( slot_DeRegistered()) ); connect(this, SIGNAL(signal_del_buddy(int, int, qlonglong)), this, SLOT( slot_del_buddy(int, int, qlonglong)) ); connect(this, SIGNAL(signal_set_nickname_ok()), this, SLOT(setUINiceName())); connect(this, SIGNAL(signal_set_state(int)), this, SLOT( slot_set_state(int)) ); connect(this, SIGNAL(signal_add_group(int, int, qlonglong)), this, SLOT( slot_add_group(int, int, qlonglong)) ); connect(this, SIGNAL(signal_del_group(int, int, qlonglong)), this, SLOT( slot_del_group(int, int, qlonglong)) ); connect(this, SIGNAL(signal_reName_group(int, int, qlonglong)), this, SLOT( slot_reName_group(int, int, qlonglong)) ); connect(this, SIGNAL(signal_reName_buddy(int, int, qlonglong)), this, SLOT( slot_reName_buddy(int, int, qlonglong)) ); connect(this, SIGNAL(signal_add_buddy(int, int, qlonglong)), this, SLOT( slot_add_buddy(int, int, qlonglong)) ); connect(this, SIGNAL(signal_UpdateSmsDay(int) ), this, SLOT( slot_updateSmsDay(int) ) );}void FxMainWindow::showPortrait(){ buddySetStatusMenu->exec(QCursor::pos());}void FxMainWindow::showNiceNameEdit(){ UI_Edit_NiceName->setText(QString::fromUtf8(fx_get_usr_show_name())); UI_Edit_NiceName->show(); UI_Edit_NiceName->setFocus();}void FxMainWindow::addBuddy(){ this->show(); tmp_addBuddy = new FxAddBuddy(this); tmp_addBuddy->exec(); //fix a bug when addbuddy show, and mainwindow is hide, quit the addbuddy, //mainwindows will quit too. this->show(); delete tmp_addBuddy; tmp_addBuddy = NULL;}void FxMainWindow::sendgroupsms(){ FxSendGroupSMS * groupSms = new FxSendGroupSMS(this, this); groupSms->show();}void FxMainWindow::sendself(){ msgwin->addAccount((qlonglong)strtol(fx_get_usr_uid(), NULL, 10), true); /* FxSmsWindow *smswin = new FxSmsWindow(this); smswin->show(); */}void FxMainWindow::about(){ QMessageBox::about(this, tr("About Menu"), tr("The <b>Menu</b> example shows how to create " "menu-bar menus and context menus."));}Account_Info* FxMainWindow::getAc_InfoOfCurrentItem(){ QTreeWidgetItem *item = view->currentItem (); if(!item) return NULL; if(!item->parent()) //it is a account return NULL;#if MS_VC6 Account_Info *ac_info =(Account_Info*)(item->data(0, Qt::UserRole).toUInt());#else Account_Info *ac_info =item->data(0, Qt::UserRole).value<Account_Info*>();#endif return ac_info;}Group_Info* FxMainWindow::getGp_InfoOfCurrentItem(){ QTreeWidgetItem *item = view->currentItem (); if(!item) return NULL; if(item->parent()) //it is a account return NULL;#if MS_VC6 Group_Info *group_info =(Group_Info *)(item->data(0, Qt::UserRole).toUInt() );#else Group_Info *group_info = item->data(0, Qt::UserRole).value<Group_Info*>();#endif return group_info;}Qun_Info* FxMainWindow::getQun_InfoOfCurrentItem(){ QTreeWidgetItem *item = view->currentItem ();
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -