source: qutecom-2.2/wengophone/src/presentation/qt/chat/QtChatWidget.h @ 562:1498dcb678d6

Last change on this file since 562:1498dcb678d6 was 562:1498dcb678d6, checked in by laurent@…, 3 years ago

clean google translation automator

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