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