1 /* 2 * This file is part of Licq, an instant messaging client for UNIX. 3 * Copyright (C) 1999-2010,2012 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 CHATDLG_H 21 #define CHATDLG_H 22 23 #include <deque> 24 #include <list> 25 26 #include <QDialog> 27 #include <QTextEdit> 28 29 class QColor; 30 class QComboBox; 31 class QGridLayout; 32 class QGroupBox; 33 class QLabel; 34 class QListWidget; 35 class QMenu; 36 class QPixmap; 37 class QSocketNotifier; 38 class QToolButton; 39 40 namespace Licq 41 { 42 class IcqChatManager; 43 class IcqChatUser; 44 class UserId; 45 } 46 47 namespace LicqQtGui 48 { 49 class ChatWindow : public QTextEdit 50 { 51 Q_OBJECT 52 public: 53 ChatWindow(QWidget* p); ~ChatWindow()54 virtual ~ChatWindow() {} 55 56 QString lastLine() const; 57 void appendNoNewLine(const QString& s); 58 void GotoEnd(); 59 60 void setBackground(const QColor&); 61 void setForeground(const QColor&); 62 63 public slots: 64 virtual void insert (const QString&); 65 virtual void paste(); cut()66 virtual void cut() {} 67 void backspace(); 68 69 private: 70 virtual void keyPressEvent(QKeyEvent*); 71 virtual void mousePressEvent(QMouseEvent*); 72 virtual void mouseMoveEvent(QMouseEvent*); 73 virtual void mouseReleaseEvent(QMouseEvent* e); 74 75 signals: 76 void keyPressed(QKeyEvent*); 77 }; 78 79 80 class ChatDlg; 81 typedef std::list<ChatDlg*> ChatDlgList; 82 typedef struct { 83 Licq::IcqChatUser* u; 84 ChatWindow* w; 85 QLabel* l; 86 } UserWindowPair; 87 typedef std::list<UserWindowPair> ChatUserWindowsList; 88 typedef std::list<QPixmap*> QPixmapList; 89 90 enum ChatMode { CHAT_PANE, CHAT_IRC }; 91 92 93 //=====ChatDlg=============================================================== 94 95 class ChatDlg : public QDialog 96 { 97 Q_OBJECT 98 public: 99 /** 100 * Constructor, creates and displayes a new chat dialog 101 * 102 * @param userId User to open chat with 103 * @param parent Parent widget 104 */ 105 ChatDlg(const Licq::UserId& userId, QWidget* parent = 0); 106 virtual ~ChatDlg(); 107 108 bool StartAsClient(unsigned short nPort); 109 bool StartAsServer(); 110 111 unsigned short LocalPort(); id()112 QString id() { return myId; } Ppid()113 unsigned long Ppid() { return myPpid; } 114 115 QString ChatClients(); 116 QString ChatName(); 117 118 static ChatDlgList chatDlgs; 119 120 private: 121 Licq::IcqChatManager* chatman; 122 123 ChatWindow* mlePaneLocal; 124 ChatWindow* mleIRCRemote; 125 ChatWindow* mleIRCLocal; 126 QGridLayout* paneLayout; 127 QGridLayout* remoteLayout; 128 QGroupBox* boxPane; 129 QGroupBox* boxIRC; 130 QLabel* lblLocal; 131 QLabel* lblRemote; 132 QMenu* mnuMode; 133 QMenu* mnuStyle; 134 QMenu* mnuMain; 135 QMenu* mnuFg; 136 QMenu* mnuBg; 137 QListWidget* lstUsers; 138 139 QAction* tbtBold; 140 QAction* tbtItalic; 141 QAction* tbtUnderline; 142 QAction* tbtStrikeOut; 143 QAction* tbtLaugh; 144 QAction* tbtBeep; 145 QAction* tbtFg; 146 QAction* tbtBg; 147 QAction* tbtIgnore; 148 QAction* tbtEncoding; 149 150 QString linebuf, chatname; 151 QComboBox* cmbFontName; 152 QComboBox* cmbFontSize; 153 154 ChatMode m_nMode; 155 ChatUserWindowsList chatUserWindows; 156 157 QString myId; 158 unsigned long myPpid; 159 QSocketNotifier* sn; 160 bool myAudio; 161 int myChatEncoding; 162 163 virtual void closeEvent(QCloseEvent*); 164 ChatWindow* GetWindow(Licq::IcqChatUser* u); 165 void UpdateRemotePane(); 166 167 friend class JoinChatDlg; 168 169 private slots: 170 void chatSend(QKeyEvent*); 171 void chatSendBeep(); 172 void chatClose(Licq::IcqChatUser*); 173 174 void slot_chat(); 175 bool slot_save(); 176 void slot_audio(bool audio); 177 178 void fontSizeChanged(const QString&); 179 void fontNameChanged(const QString&); 180 void sendFontInfo(); 181 void fontStyleChanged(); 182 void changeFrontColor(QAction* action); 183 void changeBackColor(QAction* action); 184 void updateRemoteStyle(); 185 186 void SwitchToPaneMode(); 187 void SwitchToIRCMode(); 188 void setEncoding(QAction* action); 189 }; 190 191 } // namespace LicqQtGui 192 193 #endif 194