qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
chatform.h
Go to the documentation of this file.
1 /*
2  Copyright © 2014-2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include <QElapsedTimer>
23 #include <QLabel>
24 #include <QSet>
25 #include <QTimer>
26 
27 #include "genericchatform.h"
28 #include "src/core/core.h"
29 #include "src/model/ichatlog.h"
31 #include "src/model/status.h"
34 #include "src/video/netcamview.h"
35 
36 class CallConfirmWidget;
37 class FileTransferInstance;
38 class Friend;
39 class History;
40 class OfflineMsgEngine;
41 class QPixmap;
42 class QHideEvent;
43 class QMoveEvent;
44 class ImagePreviewButton;
45 
46 class ChatForm : public GenericChatForm
47 {
48  Q_OBJECT
49 public:
51  ~ChatForm() override;
52  void setStatusMessage(const QString& newMessage);
53 
54  void setFriendTyping(bool isTyping);
55 
56  void show(ContentLayout* contentLayout) final;
57 
58  static const QString ACTION_PREFIX;
59 
60 signals:
61 
62  void incomingNotification(uint32_t friendId);
63  void outgoingNotification();
64  void stopNotification();
65  void endCallNotification();
66  void rejectCall(uint32_t friendId);
67  void acceptCall(uint32_t friendId);
68  void updateFriendActivity(Friend& frnd);
69 
70 public slots:
71  void onAvInvite(uint32_t friendId, bool video);
72  void onAvStart(uint32_t friendId, bool video);
73  void onAvEnd(uint32_t friendId, bool error);
74  void onAvatarChanged(const ToxPk& friendPk, const QPixmap& pic);
75  void onFileNameChanged(const ToxPk& friendPk);
76  void onExtensionSupportChanged(ExtensionSet extensions);
77  void clearChatArea();
78  void onShowMessagesClicked();
79  void onSplitterMoved(int pos, int index);
80  void reloadTheme() final;
81 
82 private slots:
84  void onAttachClicked() override;
85  void onScreenshotClicked() override;
86 
87  void onTextEditChanged();
88  void onCallTriggered();
89  void onVideoCallTriggered();
90  void onAnswerCallTriggered(bool video);
91  void onRejectCallTriggered();
92  void onMicMuteToggle();
93  void onVolMuteToggle();
94 
95  void onFriendStatusChanged(const ToxPk& friendPk, Status::Status status);
96  void onFriendTypingChanged(quint32 friendId, bool isTyping);
97  void onFriendNameChanged(const QString& name);
98  void onStatusMessage(const QString& message);
99  void onUpdateTime();
100  void previewImage(const QPixmap& pixmap);
101  void cancelImagePreview();
102  void sendImageFromPreview();
103  void doScreenshot();
104  void onCopyStatusMessage();
105 
107 
108 private:
109  void updateMuteMicButton();
110  void updateMuteVolButton();
111  void retranslateUi();
112  void showOutgoingCall(bool video);
113  void startCounter();
114  void stopCounter(bool error = false);
115  void updateCallButtons();
116  void showNetcam();
117  void hideNetcam();
118 
119 protected:
120  std::unique_ptr<NetCamView> createNetcam();
121  void dragEnterEvent(QDragEnterEvent* ev) final;
122  void dropEvent(QDropEvent* ev) final;
123  void hideEvent(QHideEvent* event) final;
124  void showEvent(QShowEvent* event) final;
125 
126 private:
131  QLabel* callDuration;
133  QTimer typingTimer;
134  QElapsedTimer timeElapsed;
138  bool isTyping;
140  std::unique_ptr<NetCamView> netcam;
141 };
ChatForm::setStatusMessage
void setStatusMessage(const QString &newMessage)
Definition: chatform.cpp:218
ChatForm::onSplitterMoved
void onSplitterMoved(int pos, int index)
Definition: chatform.cpp:778
ChatForm::showEvent
void showEvent(QShowEvent *event) final
Definition: chatform.cpp:721
CallConfirmWidget
This is a widget with dialog buttons to accept/reject a call.
Definition: callconfirmwidget.h:31
ChatForm
Definition: chatform.h:46
history.h
ChatForm::stopCounter
void stopCounter(bool error=false)
Definition: chatform.cpp:680
ImagePreviewButton
Definition: imagepreviewwidget.h:26
GenericChatForm
Parent class for all chatforms. It's provide the minimum required UI elements and methods to work wit...
Definition: genericchatform.h:67
ChatForm::updateCallButtons
void updateCallButtons()
Definition: chatform.cpp:431
ChatForm::onTextEditChanged
void onTextEditChanged()
Definition: chatform.cpp:254
ChatForm::core
Core & core
Definition: chatform.h:127
netcamview.h
ichatlog.h
ChatForm::statusMessageLabel
CroppingLabel * statusMessageLabel
Definition: chatform.h:129
ChatForm::onMicMuteToggle
void onMicMuteToggle()
Definition: chatform.cpp:442
CroppingLabel
Definition: croppinglabel.h:26
Profile
Handles all qTox internal paths.
Definition: profile.h:42
ChatForm::onVideoCallTriggered
void onVideoCallTriggered()
Definition: chatform.cpp:417
OfflineMsgEngine
Definition: offlinemsgengine.h:37
ChatForm::incomingNotification
void incomingNotification(uint32_t friendId)
HistMessageContentType::file
@ file
ChatForm::timeElapsed
QElapsedTimer timeElapsed
Definition: chatform.h:134
GenericChatForm::chatLog
IChatLog & chatLog
Definition: genericchatform.h:166
ChatForm::reloadTheme
void reloadTheme() final
Definition: chatform.cpp:716
screenshotgrabber.h
ChatForm::onExtensionSupportChanged
void onExtensionSupportChanged(ExtensionSet extensions)
Definition: chatform.cpp:249
ChatForm::createNetcam
std::unique_ptr< NetCamView > createNetcam()
Definition: chatform.cpp:505
ChatForm::statusMessageMenu
QMenu statusMessageMenu
Definition: chatform.h:130
ChatForm::onScreenshotClicked
void onScreenshotClicked() override
Definition: chatform.cpp:574
ChatForm::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *ev) final
Definition: chatform.cpp:519
ChatForm::onAvatarChanged
void onAvatarChanged(const ToxPk &friendPk, const QPixmap &pic)
Definition: chatform.cpp:496
IMessageDispatcher
Definition: imessagedispatcher.h:34
ChatForm::imagePreviewSource
QPixmap imagePreviewSource
Definition: chatform.h:136
ChatForm::onAnswerCallTriggered
void onAnswerCallTriggered(bool video)
Definition: chatform.cpp:381
ChatForm::previewImage
void previewImage(const QPixmap &pixmap)
Definition: chatform.cpp:589
IChatLog
Definition: ichatlog.h:83
ChatForm::sendImageFromPreview
void sendImageFromPreview()
Definition: chatform.cpp:602
Status
Definition: status.cpp:29
ChatForm::retranslateUi
void retranslateUi()
Definition: chatform.cpp:731
ChatForm::onAvInvite
void onAvInvite(uint32_t friendId, bool video)
Definition: chatform.cpp:306
ChatForm::clearChatArea
void clearChatArea()
Definition: chatform.cpp:569
ChatForm::netcam
std::unique_ptr< NetCamView > netcam
Definition: chatform.h:140
GenericChatForm::event
bool event(QEvent *) final
Definition: genericchatform.cpp:387
ChatForm::showNetcam
void showNetcam()
Definition: chatform.cpp:743
ChatForm::updateMuteMicButton
void updateMuteMicButton()
Definition: chatform.cpp:646
ChatForm::showOutgoingCall
void showOutgoingCall(bool video)
Definition: chatform.cpp:372
HistMessageContentType::message
@ message
ChatForm::doScreenshot
void doScreenshot()
Definition: chatform.cpp:581
ChatForm::endCallNotification
void endCallNotification()
ToxPk
This class represents a Tox Public Key, which is a part of Tox ID.
Definition: toxpk.h:26
ChatForm::updateMuteVolButton
void updateMuteVolButton()
Definition: chatform.cpp:657
Friend
Definition: friend.h:31
ChatForm::rejectCall
void rejectCall(uint32_t friendId)
ChatForm::onCopyStatusMessage
void onCopyStatusMessage()
Definition: chatform.cpp:636
ChatForm::cancelImagePreview
void cancelImagePreview()
Definition: chatform.cpp:596
ChatForm::onAvStart
void onAvStart(uint32_t friendId, bool video)
Definition: chatform.cpp:336
GenericChatForm::contentLayout
QVBoxLayout * contentLayout
Definition: genericchatform.h:146
ChatForm::onCallTriggered
void onCallTriggered()
Definition: chatform.cpp:406
ChatForm::hideEvent
void hideEvent(QHideEvent *event) final
Definition: chatform.cpp:726
ChatForm::onFileNameChanged
void onFileNameChanged(const ToxPk &friendPk)
Definition: chatform.cpp:238
ChatForm::onAvEnd
void onAvEnd(uint32_t friendId, bool error)
Definition: chatform.cpp:353
ChatForm::outgoingNotification
void outgoingNotification()
NetCamView
Definition: netcamview.h:38
ChatForm::acceptCall
void acceptCall(uint32_t friendId)
ChatForm::isTyping
bool isTyping
Definition: chatform.h:138
ChatForm::callDuration
QLabel * callDuration
Definition: chatform.h:131
ChatForm::callUpdateFriendActivity
void callUpdateFriendActivity()
Definition: chatform.cpp:225
ChatForm::~ChatForm
~ChatForm() override
Definition: chatform.cpp:213
ChatForm::copyStatusAction
QAction * copyStatusAction
Definition: chatform.h:135
ChatForm::imagePreview
ImagePreviewButton * imagePreview
Definition: chatform.h:137
ChatForm::show
void show(ContentLayout *contentLayout) final
Definition: chatform.cpp:711
ChatForm::dropEvent
void dropEvent(QDropEvent *ev) final
Definition: chatform.cpp:526
ChatForm::typingTimer
QTimer typingTimer
Definition: chatform.h:133
ChatForm::ChatForm
ChatForm(Profile &profile, Friend *chatFriend, IChatLog &chatLog, IMessageDispatcher &messageDispatcher)
Definition: chatform.cpp:108
ExtensionSet
std::bitset< ExtensionType::max > ExtensionSet
Definition: extension.h:32
History
Interacts with the profile database to save the chat history.
Definition: history.h:135
ChatForm::onAttachClicked
void onAttachClicked() override
Definition: chatform.cpp:275
ChatForm::updateFriendActivity
void updateFriendActivity(Friend &frnd)
ChatForm::setFriendTyping
void setFriendTyping(bool isTyping)
Definition: chatform.cpp:704
ChatForm::onVolMuteToggle
void onVolMuteToggle()
Definition: chatform.cpp:449
ChatForm::updateFriendActivityForFile
void updateFriendActivityForFile(const ToxFile &file)
Definition: chatform.cpp:230
ChatForm::lastCallIsVideo
bool lastCallIsVideo
Definition: chatform.h:139
ChatForm::stopNotification
void stopNotification()
ChatForm::f
Friend * f
Definition: chatform.h:128
core.h
ContentLayout
Definition: contentlayout.h:25
ChatForm::onFriendTypingChanged
void onFriendTypingChanged(quint32 friendId, bool isTyping)
Definition: chatform.cpp:475
ChatForm::onFriendStatusChanged
void onFriendStatusChanged(const ToxPk &friendPk, Status::Status status)
Definition: chatform.cpp:456
ChatForm::ACTION_PREFIX
static const QString ACTION_PREFIX
Definition: chatform.h:58
ChatForm::onUpdateTime
void onUpdateTime()
Definition: chatform.cpp:699
imessagedispatcher.h
ChatForm::callDurationTimer
QTimer * callDurationTimer
Definition: chatform.h:132
genericchatform.h
ToxFile
Definition: toxfile.h:32
ChatForm::onRejectCallTriggered
void onRejectCallTriggered()
Definition: chatform.cpp:400
ChatForm::onStatusMessage
void onStatusMessage(const QString &message)
Definition: chatform.cpp:489
GenericChatForm::messageDispatcher
IMessageDispatcher & messageDispatcher
Definition: genericchatform.h:167
ChatForm::startCounter
void startCounter()
Definition: chatform.cpp:668
ChatForm::onFriendNameChanged
void onFriendNameChanged(const QString &name)
Definition: chatform.cpp:482
ChatForm::hideNetcam
void hideNetcam()
Definition: chatform.cpp:762
status.h
Core
Definition: core.h:59
ChatForm::onShowMessagesClicked
void onShowMessagesClicked()
Definition: chatform.cpp:785