📄 evamainwindow.cpp
字号:
/*************************************************************************** * Copyright (C) 2005 by yunfan * * yunfan_zg@163.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "evamainwindow.h"#include <stdlib.h>#include <qpushbutton.h>#include <qtoolbutton.h>#include <qlabel.h>#include <qheader.h>#include <qtooltip.h>#include <qimage.h>#include <qpixmap.h>#include <qlistview.h>#include <qpopupmenu.h>#include <qmessagebox.h>#include <qtextcodec.h>#include <qevent.h>#include <klocale.h>#include "evafriendlist.h"#include "../evamain.h"#include "evauhmanager.h"#include "evauser.h"#include "evaresource.h"#include "evahtmlparser.h"MainWindowTip::MainWindowTip(QWidget *parent) : QToolTip(parent) {}void MainWindowTip::maybeTip(const QPoint &pos){ if(!parentWidget()->inherits("EvaMainWindow")) return; QRect r( ((EvaMainWindow *)parentWidget())->tipRect(pos) ); if(!r.isValid()) return; tip(r, ((EvaMainWindow *)parentWidget())->myInfoTip());}EvaMainWindow::EvaMainWindow(QWidget* parent, const char* name, WFlags fl) : EvaMainUIBase(parent, name, fl), groupMenu(NULL), buddyMenu(NULL), qunMenu(NULL), qunOrgsMenu(NULL), qunDiscussMenu(NULL), sysMenu(NULL), statusMenu(NULL), pixOnline(NULL), pixOffline(NULL), pixLeave(NULL), pixInvisible(NULL){ qqNum = 0; myTip = new MainWindowTip(this); QObject::connect(listView, SIGNAL(doubleClicked(QListViewItem *, const QPoint & , int)), this, SLOT(slotBuddyDoubleClick(QListViewItem *, const QPoint & , int))); QObject::connect(listView, SIGNAL(clicked(QListViewItem *)), this, SLOT(slotListViewClicked(QListViewItem *))); QObject::connect(pbSearch, SIGNAL(clicked()), this, SLOT(slotSearch())); QObject::connect(pbMessages, SIGNAL(clicked()), this, SLOT(slotSystemMessages())); QObject::connect(tbMyFace, SIGNAL(clicked()), this, SLOT(slotTbMyFace()));}EvaMainWindow::~EvaMainWindow(){ if(groupMenu) delete groupMenu; if(buddyMenu) delete buddyMenu;}void EvaMainWindow::setMainInfo(const unsigned int id, const QString &nick, QPixmap *pix){ qqNum = id; QString name = nick; if(strlen(nick.ascii()) > 12 ) name = nick.left(9) + "..."; EvaHtmlParser parser; parser.setAbsImagePath(EvaMain::images->getSmileyPath()); parser.convertToHtml(name, false, true); tlNick->setText("<qt><nobr>"+name+"</nobr></qt>"); slotUpdateBuddyStat(); tbMyFace->setIconSet( QIconSet(*pix)); QObject::disconnect(listView, SIGNAL(contextMenuRequested(QListViewItem *, const QPoint & , int)), 0, 0 ); QObject::disconnect(listView, SIGNAL(itemRenamed(QListViewItem *, int)), 0, 0 ); QObject::disconnect(listView, SIGNAL(deleteMeFrom(int )), 0, 0 ); QObject::disconnect(listView, SIGNAL(groupChanged(int, int)), 0, 0 ); QObject::disconnect(listView, SIGNAL(requestAddBuddy(const unsigned int)), 0, 0 ); QObject::connect(listView, SIGNAL(contextMenuRequested(QListViewItem *, const QPoint & , int)), this, SLOT(slotContextMenu(QListViewItem *, const QPoint & , int))); QObject::connect(listView, SIGNAL(itemRenamed(QListViewItem *, int)), this, SLOT(slotItemRenamed(QListViewItem *, int))); QObject::connect(listView, SIGNAL(deleteMeFrom(int )), this, SIGNAL(deleteMeFrom(int))); QObject::connect(listView, SIGNAL(groupChanged(int, int)), this, SIGNAL(groupChanged(int, int))); QObject::connect(listView, SIGNAL(requestAddBuddy(const unsigned int)), this, SIGNAL(requestAddBuddy(const unsigned int)));}void EvaMainWindow::slotUpdateBuddyStat(){ int all = EvaMain::user->getFriendList().numberOfFriends(); int onlines = EvaMain::user->getFriendList().numberOfOnlines(); tlQQ->setText(" ( "+ QString::number(onlines) + "/" + QString::number(all) + ")");}void EvaMainWindow::setStatusPixmaps(QPixmap *online, QPixmap *offline, QPixmap *leave, QPixmap *invisble){ pixOnline = online; pixOffline = offline; pixLeave = leave; pixInvisible = invisble; this->offline();}void EvaMainWindow::setSystemMenu( QPopupMenu *sys){ if(sys){ sysMenu = sys; pbSystem->setPopup(sys); }}void EvaMainWindow::setStatusMenu( QPopupMenu *status){ if(status){ statusMenu = status; pbStatus->setPopup(status); }}void EvaMainWindow::setBasicPixmaps(QPixmap *sys, QPixmap *open, QPixmap *close, QPixmap *na, QPixmap *msg){ this->pbSystem->setIconSet(QIconSet(*sys)); listView->setupPixmaps(open, close, na, msg); listView->setPaletteBackgroundPixmap(*EvaMain::images->getIcon("BACK_GROUND")); listView->setStaticBackground(true);}void EvaMainWindow::setGroupMenu(QPixmap *rename, QPixmap *newGroup, QPixmap *deleleGroup, QPixmap *onlineBuddies, QPixmap *allBuddies, QPixmap *qun ){ groupMenu = new QPopupMenu(); groupMenu->insertItem(QIconSet(*rename), i18n("Rename"), this, SLOT(slotRenameGroup()), -1, 0); groupMenu->insertItem(QIconSet(*newGroup), i18n( "New Group"), this, SLOT(slotNewGroup()), -1, 1); groupMenu->insertItem(QIconSet(*deleleGroup), i18n( "Delele Group"), this, SLOT(slotDelGroup()), -1, 2); groupMenu->insertSeparator(-1); groupMenu->insertItem(QIconSet(*qun), i18n( "Create Qun"), this, SLOT(slotQunCreate()), -1); groupMenu->insertSeparator(-1); groupMenu->insertItem(QIconSet(*onlineBuddies), i18n( "Show Online"), this, SLOT(slotShowOnlineBuddies()), -1); groupMenu->insertItem(QIconSet(*allBuddies), i18n( "Show All"), this, SLOT(slotShowAllBuddies()), -1);}void EvaMainWindow::setBuddyMenu(QPixmap *chat, QPixmap *level, QPixmap * details, QPixmap *msgHistory, QPixmap *deleteBuddy){ buddyMenu = new QPopupMenu(); buddyMenu->insertItem(QIconSet(*chat), i18n( "Chat"), this, SLOT(slotIMChat()), -1); buddyMenu->insertItem(QIconSet(*EvaMain::images->getIcon("FILE_TRANSFER")), i18n( "Send File"), this, SLOT(slotSendFile()), -1); buddyMenu->insertSeparator(-1); buddyMenu->insertItem(QIconSet(*level), i18n( "Update Level"), this, SLOT(slotUpdataLevel()), -1); buddyMenu->insertItem(QIconSet(*details), i18n( "Details"), this, SLOT(slotDetails()), -1); buddyMenu->insertItem(QIconSet(*EvaMain::images->getIcon("MEMO")), i18n("Modify Memo"), this, SLOT(slotModifyMemo()),-1); buddyMenu->insertItem(QIconSet(*msgHistory), i18n( "History"), this, SLOT(slotHistory()), -1); buddyMenu->insertSeparator(-1); buddyMenu->insertItem(QIconSet(*deleteBuddy), i18n( "Delete Buddy"), this, SLOT(slotDelBuddy()), -1);}void EvaMainWindow::setQunMenu(QPixmap *chat, QPixmap * details, QPixmap *msgHistory, QPixmap *exitQun){ qunMenu = new QPopupMenu(); qunMenu->insertItem(QIconSet(*chat), i18n( "Chat"), this, SLOT(slotIMQunChat()), -1); qunMenu->insertSeparator(-1); qunMenu->insertItem(QIconSet(*details), i18n( "Details"), this, SLOT(slotQunDetails()), -1); qunMenu->insertItem(QIconSet(*msgHistory), i18n( "History"), this, SLOT(slotQunHistory()), -1); qunMenu->insertSeparator(-1); qunMenu->insertItem(QIconSet(*exitQun), i18n( "Exit Qun" ), this, SLOT(slotQunExit()), -1);}void EvaMainWindow::setOrgsMenu(){ qunOrgsMenu = new QPopupMenu(); qunOrgsMenu->insertItem(i18n( "Not implement yet"));}void EvaMainWindow::setDiscussMenu(){ qunDiscussMenu = new QPopupMenu(); qunDiscussMenu->insertItem(i18n( "Not implement yet"));}void EvaMainWindow::changeGroupTo(const unsigned int id, const int index){ listView->changeGroupTo(id, index);}void EvaMainWindow::addGroup(QString &name, const int index){ listView->addGroup(name, index);}void EvaMainWindow::addBuddy(const QString &nick, const unsigned int id, const QString signature, const int index, QPixmap *on, QPixmap *off, EvaBuddyItem::Status status){ listView->addBuddy(nick, id, signature, index, on, off, status);}void EvaMainWindow::updateNick(const unsigned int id, const QString &nick){ listView->updateNick(id, nick);}void EvaMainWindow::updateSignature(const unsigned int id, const QString &sig){ listView->updateSignature(id, sig);}void EvaMainWindow::updateFacePixmaps(const unsigned int id, QPixmap *on, QPixmap *off){ if(!on || !off) return; listView->updateFacePixmaps(id, on, off);}void EvaMainWindow::addQun(QString &name, const unsigned int id, QPixmap *pic){ listView->addQun(name, id, pic);}void EvaMainWindow::updateQun(QString &name, const unsigned int id, QPixmap *pic){ listView->updateQun(name, id, pic);}void EvaMainWindow::refreshFace(const QSize &size){ listView->refreshFace(size);}void EvaMainWindow::setFaceSize(const QSize &size){ listView->setFaceSize(size);} void EvaMainWindow::clearList(){ listView->clear();}void EvaMainWindow::updateAllGroupTitles(){ listView->updateAllGroupTitles();}void EvaMainWindow::changeToOnline(unsigned int id){ listView->changeToOnline(id); slotUpdateBuddyStat();}void EvaMainWindow::changeToOffline(unsigned int id){ listView->changeToOffline(id); slotUpdateBuddyStat();}void EvaMainWindow::changeToLeave(unsigned int id){ listView->changeToLeave(id); slotUpdateBuddyStat();}void EvaMainWindow::changeToInvisible(unsigned int id){ listView->changeToInvisible(id); slotUpdateBuddyStat();}void EvaMainWindow::newMessage(unsigned int id){ listView->startFlash(id);}void EvaMainWindow::gotMessage(unsigned int id){ listView->stopFlash(id);}void EvaMainWindow::newQunMessage(unsigned int id){ listView->startQunFlash(id);}void EvaMainWindow::gotQunMessage(unsigned int id){ listView->stopQunFlash(id);}void EvaMainWindow::deleteBuddy(unsigned int id){ listView->removeBuddy(id);}void EvaMainWindow::online(){ if(pixOnline) pbStatus->setIconSet(QIconSet(*pixOnline)); pbStatus->setText(i18n( "Online"));}void EvaMainWindow::offline(){ if(pixOffline) pbStatus->setIconSet(QIconSet(*pixOffline)); pbStatus->setText(i18n( "Offline"));}void EvaMainWindow::leave(){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -