1 /* 2 * This file is part of Licq, an instant messaging client for UNIX. 3 * Copyright (C) 2007-2013 Licq developers <licq-dev@googlegroups.com> 4 * 5 * Licq is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * Licq is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with Licq; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 #ifndef USEREVENTCOMMON_H 21 #define USEREVENTCOMMON_H 22 23 #include <QWidget> 24 25 #include <list> 26 #include <string> 27 28 #include <licq/userid.h> 29 30 class QActionGroup; 31 class QHBoxLayout; 32 class QMenu; 33 class QToolBar; 34 class QVBoxLayout; 35 36 namespace Licq 37 { 38 class User; 39 } 40 41 namespace LicqQtGui 42 { 43 class InfoField; 44 45 class UserEventCommon : public QWidget 46 { 47 Q_OBJECT 48 49 public: 50 /** 51 * Constructor 52 * 53 * @param userId User to open event dialog for 54 * @param parent Parent widget 55 * @param name Object name to set for widget 56 */ 57 UserEventCommon(const Licq::UserId& userId, QWidget* parent = 0, const char* name = 0); 58 virtual ~UserEventCommon(); 59 60 /** 61 * Get user for this dialog 62 * 63 * @return (First) user associated with with dialog 64 */ userId()65 const Licq::UserId& userId() const { return myUsers.front(); } ppid()66 unsigned long ppid() const { return myPpid; } convoId()67 unsigned long convoId() { return myConvoId; } convoUsers()68 const std::list<Licq::UserId>& convoUsers() const { return myUsers; } setConvoId(unsigned long n)69 void setConvoId(unsigned long n) { myConvoId = n; } 70 71 /** 72 * Check if a user is part of this conversation 73 * 74 * @param userId Id of user to check 75 * @return True if user is in conversation 76 */ 77 bool isUserInConvo(const Licq::UserId& userId) const; 78 void setTyping(bool isTyping); 79 80 public slots: 81 /** 82 * This window got or lost focus 83 * Called from tab dialog when tab is switched 84 * 85 * @param gotFocus True if this window/tab got focus 86 */ 87 void focusChanged(bool gotFocus); 88 89 protected: 90 bool myIsOwner; 91 bool myDeleteUser; 92 unsigned long myPpid; 93 unsigned long myConvoId; 94 time_t myRemoteTimeOffset; 95 std::list<Licq::UserId> myUsers; 96 unsigned long mySendFuncs; 97 98 // ID of the higest event we've processed. Helps determine 99 // which events we already processed in the ctor. 100 int myHighestEventId; 101 102 QString myBaseTitle; 103 QString myProgressMsg; 104 105 QHBoxLayout* myTophLayout; 106 QVBoxLayout* myTopLayout; 107 QVBoxLayout* myMainWidget; 108 QToolBar* myToolBar; 109 QMenu* myEncodingsMenu; 110 QActionGroup* myEncodingsGroup; 111 QAction* myMenu; 112 QAction* myHistory; 113 QAction* myInfo; 114 QAction* myEncoding; 115 QAction* mySecure; 116 QAction* myEmoticon; 117 QAction* myForeColor; 118 QAction* myBackColor; 119 QAction* myPopupNextMessage; 120 InfoField* myTimezone; 121 QTimer* myTimeTimer; 122 123 void flashTaskbar(); 124 void updateWidgetInfo(const Licq::User* u); 125 void pushToolTip(QAction* action, const QString& tooltip); 126 127 /** 128 * A user has been update, this virtual function allows subclasses to add additional handling 129 * This function will only be called if user is in this conversation 130 * 131 * @param userId Updated user 132 * @param subSignal Type of update 133 * @param argument Signal specific argument 134 * @param cid Conversation id 135 */ 136 virtual void userUpdated(const Licq::UserId& userId, unsigned long subSignal, int argument, unsigned long cid) = 0; 137 138 /** 139 * Overloaded to get events when this window/tab looses and gains focus 140 */ 141 virtual bool event(QEvent* event); 142 143 protected slots: 144 /** 145 * Update iconset in menus and on buttons 146 */ 147 virtual void updateIcons(); 148 149 /** 150 * Update keyboard shortcuts 151 */ 152 virtual void updateShortcuts(); 153 154 void connectSignal(); 155 void setEncoding(QAction* action); 156 void setMsgWinSticky(bool sticky = true); 157 void showHistory(); 158 void showUserInfo(); 159 void switchSecurity(); 160 void updateTime(); 161 void showUserMenu(); 162 void showEncodingsMenu(); 163 void updatedUser(const Licq::UserId& userId, unsigned long subSignal, int argument, unsigned long cid); 164 165 signals: 166 /** 167 * Dialog has finished 168 * 169 * @param userId User for this dialog 170 */ 171 void finished(const Licq::UserId& userId); 172 void encodingChanged(); 173 }; 174 175 } // namespace LicqQtGui 176 177 #endif 178