source: qutecom-2.2/wengophone/src/presentation/qt/chat/QtChatWidget.h @ 0:e18c44432190

Last change on this file since 0:e18c44432190 was 0:e18c44432190, checked in by vadim@…, 5 years ago

initial commit

File size: 5.2 KB
Line 
1/*
2 * WengoPhone, a voice over Internet phone
3 * Copyright (C) 2004-2007  Wengo
4 *
5 * This program 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 * This program 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 this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20#ifndef OWQTCHATWIDGET_H
21#define OWQTCHATWIDGET_H
22
23#include "ui_ChatWidget.h"
24
25#include "emoticons/QtEmoticon.h"
26
27#include <control/chat/CChatHandler.h>
28
29#include <imwrapper/IMContact.h>
30#include <imwrapper/IMChatSession.h>
31#include <imwrapper/IMChat.h>
32
33#include <util/Trackable.h>
34
35#include <QtCore/QTime>
36
37class Profile;
38class QtWengoPhone;
39class QtWengoStyleLabel;
40class EmoticonsWidget;
41class QFont;
42class QUrl;
43class QTimer;
44
45/**
46 *
47 * @ingroup presentation
48 * @author Mr K.
49 * @author Mathieu Stute
50 */
51class QtChatWidget : public QWidget, public Trackable {
52        Q_OBJECT
53public:
54
55        QtChatWidget(CChatHandler & cChatHandler, QtWengoPhone * qtWengoPhone,
56                int sessionId, QWidget * parent);
57
58        virtual ~QtChatWidget();
59
60        void setNickName(const QString & nickname) {_nickName = nickname;}
61
62        const QString & nickName() const {return _nickName;}
63
64        bool canDoMultiChat() {return _imChatSession->canDoMultiChat();}
65
66        void setContactId(QString contactId) {_contactId = contactId;}
67
68        int getSessionId() const {return _sessionId;}
69
70        IMChatSession * getIMChatSession() {return _imChatSession;}
71
72        QString getContactId() const {return _contactId;}
73
74        // called from the model's thread
75        void contactAddedEventHandler(IMChatSession & sender, const IMContact & imContact);
76
77        // called from the model's thread
78        void contactRemovedEventHandler(IMChatSession & sender, const IMContact & imContact);
79
80        void setIMChatSession(IMChatSession * imChatSession);
81
82        /**
83         * Adds a message to the history and display it.
84         *
85     * @param contactId id of the contact who sends the message, or "self" if the sender is the local user
86         * @param senderName name of the contact who sends the message
87         * @param str the message
88         * @param time the time of the message, will use the current time if empty
89         */
90        void addToHistory(const QString & contactId, const QString & senderName, const QString & str, const QTime & time = QTime());
91
92        /**
93         * Displays a satus message.
94         *
95         * Behaves same as addToHistory but set the text color to the status message
96         * color and does not display a contact name.
97         */
98        void addStatusMessage(const QString & statusMessage);
99
100        void saveHistoryAsHtml();
101
102        /**
103         * Sets the Contact state.
104         *
105         * If not connected and the last status was connected,
106         * the ChatEditWidget will be disabled and a status message
107         * will be displayed saying the contact went offline.
108         *
109         * If connect and the last status was disconnected,
110         * the ChatEditWidget will be enabled and a status message
111         * will be displayed saying the contact when online.
112         **/
113        void setContactConnected(bool connected);
114
115        bool canDoFileTransfer();
116
117public Q_SLOTS:
118
119        /**
120         * QtChatEditWidget text has changed
121         */
122        void chatEditTextChanged();
123
124        void changeFont();
125
126        void chooseEmoticon();
127
128        void emoticonSelected(QtEmoticon emoticon);
129
130        void showInviteDialog();
131
132        void contactAddedEventSlot(const IMContact & imContact);
133
134        void contactRemovedEventSlot(const IMContact & imContact);
135
136        virtual void setVisible(bool visible);
137
138        void sendFileToSession(const QString & filename);
139
140Q_SIGNALS:
141
142        void newMessage(IMChatSession* session,const QString & msg);
143
144        void contactAddedEventSignal(const IMContact & imContact);
145
146        void contactRemovedEventSignal(const IMContact & imContact);
147
148        void ctrlTabPressed();
149
150        void profileChangedEventHandlerSignal();
151
152protected:
153        virtual bool eventFilter(QObject* object, QEvent* event);
154
155private Q_SLOTS:
156
157        void avatarFrameButtonClicked();
158
159        void changeFontColor();
160
161        void boldClickedSlot();
162
163        void italicClickedSlot();
164
165        void underlineClickedSlot();
166
167        void contactChangedSlot(QString contactId);
168
169        void sendMessage();
170       
171        void stoppedTypingSlot();
172
173        void updateUserAvatar();
174
175private:
176        void profileChangedEventHandler();
177       
178        void updateAvatarFrame();
179
180        void showAvatarFrame();
181
182        void hideAvatarFrame();
183
184        bool historyKeyPressEventFilter(QKeyEvent* event);
185
186        bool editKeyPressEventFilter(QKeyEvent* event);
187
188        CChatHandler & _cChatHandler;
189
190        QtWengoPhone * _qtWengoPhone;
191
192        IMChatSession * _imChatSession;
193
194        QWidget * _widget;
195
196        QString _contactId;
197
198        int _sessionId;
199
200        QString _nickName;
201
202        mutable QMutex _mutex;
203
204        EmoticonsWidget * _emoticonsWidget;
205
206        Ui::ChatWidget _ui;
207
208        /** True if the Contact in this Widget is connected. */
209        bool _isContactConnected;
210
211        // font style settings
212        QFont _currentFont;
213        QColor _currentColor;
214        bool _bold;
215        bool _italic;
216        bool _underline;
217        ////
218       
219        /** stopped typing timer */
220        QTimer * _stoppedTypingTimer;
221       
222        bool _isTyping;
223};
224
225#endif //OWQTCHATWIDGET_H
Note: See TracBrowser for help on using the repository browser.