forked from arthurzam/dukto-qt5
/
guibehind.h
204 lines (186 loc) · 7.62 KB
/
guibehind.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/* DUKTO - A simple, fast and multi-platform file transfer tool for LAN users
* Copyright (C) 2011 Emanuele Colombo
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef GUIBEHIND_H
#define GUIBEHIND_H
#include <QObject>
#include "buddylistitemmodel.h"
#include "recentlistitemmodel.h"
#include "ipaddressitemmodel.h"
#include "destinationbuddy.h"
#include "duktoprotocol.h"
#include "theme.h"
#ifdef UPDATER
class UpdatesChecker;
#endif
class Settings;
class DuktoWindow;
class SystemTray;
class GuiBehind : public QObject
{
Q_OBJECT
Q_PROPERTY(QString currentTransferBuddy READ currentTransferBuddy NOTIFY currentTransferBuddyChanged)
Q_PROPERTY(int currentTransferProgress READ currentTransferProgress NOTIFY currentTransferProgressChanged)
Q_PROPERTY(QString currentTransferStats READ currentTransferStats NOTIFY currentTransferStatsChanged)
Q_PROPERTY(bool currentTransferSending READ currentTransferSending NOTIFY currentTransferSendingChanged)
Q_PROPERTY(QString textSnippetBuddy READ textSnippetBuddy NOTIFY textSnippetBuddyChanged)
Q_PROPERTY(QString textSnippet READ textSnippet WRITE setTextSnippet NOTIFY textSnippetChanged)
Q_PROPERTY(bool textSnippetSending READ textSnippetSending NOTIFY textSnippetSendingChanged)
Q_PROPERTY(QString currentPath READ currentPath NOTIFY currentPathChanged)
Q_PROPERTY(bool clipboardTextAvailable READ clipboardTextAvailable NOTIFY clipboardTextAvailableChanged)
Q_PROPERTY(QString remoteDestinationAddress READ remoteDestinationAddress WRITE setRemoteDestinationAddress NOTIFY remoteDestinationAddressChanged)
Q_PROPERTY(QString overlayState READ overlayState WRITE setOverlayState NOTIFY overlayStateChanged)
Q_PROPERTY(QString messagePageText READ messagePageText WRITE setMessagePageText NOTIFY messagePageTextChanged)
Q_PROPERTY(QString messagePageTitle READ messagePageTitle WRITE setMessagePageTitle NOTIFY messagePageTitleChanged)
Q_PROPERTY(QString messagePageBackState READ messagePageBackState WRITE setMessagePageBackState NOTIFY messagePageBackStateChanged)
Q_PROPERTY(bool showTermsOnStart READ showTermsOnStart WRITE setShowTermsOnStart NOTIFY showTermsOnStartChanged)
Q_PROPERTY(bool showUpdateBanner READ showUpdateBanner WRITE setShowUpdateBanner NOTIFY showUpdateBannerChanged)
Q_PROPERTY(QString buddyName READ buddyName WRITE setBuddyName NOTIFY buddyNameChanged)
public:
explicit GuiBehind(Settings* settings);
virtual ~GuiBehind();
void setViewer(DuktoWindow *view, SystemTray *tray);
bool canAcceptDrop();
void sendDroppedFiles(QStringList *files);
void close();
QString currentTransferBuddy();
void setCurrentTransferBuddy(const QString &buddy);
int currentTransferProgress();
void setCurrentTransferProgress(int value);
QString currentTransferStats();
void setCurrentTransferStats(const QString &stats);
QString textSnippetBuddy();
void setTextSnippetBuddy(const QString &buddy);
QString textSnippet();
void setTextSnippet(const QString &txt);
bool textSnippetSending();
void setTextSnippetSending(bool sending);
QString currentPath();
void setCurrentPath(const QString &path);
bool currentTransferSending();
void setCurrentTransferSending(bool sending);
bool clipboardTextAvailable();
QString remoteDestinationAddress();
void setRemoteDestinationAddress(const QString &address);
QString overlayState();
void setOverlayState(const QString &state);
QString messagePageText();
void setMessagePageText(const QString &message);
QString messagePageTitle();
void setMessagePageTitle(const QString &title);
QString messagePageBackState();
void setMessagePageBackState(const QString &state);
bool showTermsOnStart();
void setShowTermsOnStart(bool show);
bool showUpdateBanner();
void setShowUpdateBanner(bool show);
void setBuddyName(const QString &name);
QString buddyName();
protected:
bool eventFilter(QObject *, QEvent *event);
signals:
void currentTransferBuddyChanged();
void currentTransferProgressChanged();
void currentTransferStatsChanged();
void currentTransferSendingChanged();
void textSnippetBuddyChanged();
void textSnippetChanged();
void textSnippetSendingChanged();
void currentPathChanged();
void clipboardTextAvailableChanged();
void remoteDestinationAddressChanged();
void overlayStateChanged();
void messagePageTextChanged();
void messagePageTitleChanged();
void messagePageBackStateChanged();
void showTermsOnStartChanged();
void showUpdateBannerChanged();
void buddyNameChanged();
// Received by QML
void transferStart();
void receiveCompleted();
void gotoTextSnippet();
void gotoSendPage();
void gotoMessagePage();
void hideAllOverlays();
public slots:
void showRandomBack();
void clipboardChanged();
void remoteDestinationAddressHandler();
void periodicHello();
void showUpdatesMessage();
void sendScreenStage2();
// Called by Dukto protocol
void peerListAdded(const Peer &peer);
void peerListRemoved(const Peer &peer);
void receiveFileStart(const QString &senderIp);
void transferStatusUpdate(qint64 total, qint64 partial);
void receiveFileComplete(QStringList *files, qint64 totalSize);
void receiveTextComplete(QString *text, qint64 totalSize);
void sendFileComplete();
void sendFileError(int code);
void receiveFileCancelled();
void sendFileAborted();
// Called by QML
void openDestinationFolder();
void refreshIpList();
void showTextSnippet(const QString &text, const QString &sender);
void openFile(const QString &path);
void changeDestinationFolder();
void showSendPage(const QString &ip);
void sendSomeFiles();
void sendFolder();
void sendClipboardText();
void sendText();
void sendScreen();
void changeThemeColor(const QString &color);
void resetProgressStatus();
void abortTransfer();
private:
DuktoWindow *mView = nullptr;
QTimer *mShowBackTimer = nullptr;
QTimer *mPeriodicHelloTimer = nullptr;
Settings *mSettings;
DestinationBuddy *mDestBuddy = nullptr;
BuddyListItemModel mBuddiesList;
RecentListItemModel mRecentList;
IpAddressItemModel mIpAddresses;
DuktoProtocol mDuktoProtocol;
Theme mTheme;
#ifdef UPDATER
UpdatesChecker *mUpdatesChecker;
#endif
int mCurrentTransferProgress;
QString mCurrentTransferBuddy;
QString mCurrentTransferStats;
bool mCurrentTransferSending;
QString mTextSnippetBuddy;
QString mTextSnippet;
bool mTextSnippetSending;
bool mClipboardTextAvailable;
QString mRemoteDestinationAddress;
QString mOverlayState;
QString mMessagePageText;
QString mMessagePageTitle;
QString mMessagePageBackState;
bool mShowUpdateBanner;
QString mScreenTempPath;
bool prepareStartTransfer(QString *ip, qint16 *port);
void startTransfer(const QStringList &files);
void startTransfer(const QString &text);
};
#endif // GUIBEHIND_H