/
window.h
195 lines (165 loc) · 5.54 KB
/
window.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
/******************************************************************************
// QSyncthingTray
// Copyright (c) Matthias Frick, All rights reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3.0 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library.
******************************************************************************/
#ifndef WINDOW_H
#define WINDOW_H
#include "syncconnector.h"
#include "processmonitor.hpp"
#include "startuptab.hpp"
#include "platforms.hpp"
#include <qst/settingsmigrator.hpp>
#include <qst/statswidget.h>
#include <qst/updatenotifier.h>
#include <QDoubleSpinBox>
#include <QSystemTrayIcon>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QSettings>
#include <QProcess>
#include <QFileDialog>
#include <QTabWidget>
#include <QMovie>
#include <memory>
#ifndef QT_NO_SYSTEMTRAYICON
#include <QDialog>
QT_BEGIN_NAMESPACE
class QAction;
class QCheckBox;
class QComboBox;
class QGroupBox;
class QLabel;
class QLineEdit;
class QMenu;
class QPushButton;
class QSpinBox;
class QTextEdit;
QT_END_NAMESPACE
//! [0]
class Window : public QDialog
{
Q_OBJECT
public:
Window();
void setVisible(bool visible) Q_DECL_OVERRIDE;
protected:
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
private slots:
void updateConnectionHealth(const ConnectionStateData& state);
void onNetworkActivity(bool activity);
void setIcon(int index);
void iconActivated(QSystemTrayIcon::ActivationReason reason);
void showWebView();
void messageClicked();
void testURL();
void authCheckBoxChanged(int state);
void monoChromeIconChanged(int state);
void animateIconBoxChanged(int state);
void webViewZoomFactorChanged(double value);
void showAboutPage();
void folderClicked();
void syncedFileClicked();
void onUpdateIcon();
void pauseSyncthingClicked(int state);
void quit();
void onUpdateConnState(const ConnectionState& result);
void checkForUpdate();
private:
qst::settings::SettingsMigrator mSettingsMigrator;
void createSettingsGroupBox();
void createActions();
void createTrayIcon();
void saveSettings();
void loadSettings();
void showAuthentication(bool show);
void showMessage(const std::string& title, const std::string& body,
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information);
void createFoldersMenu();
void createLastSyncedMenu();
void createDefaultSettings();
void validateSSLSupport();
void onStartAnimation(bool animate);
QTabWidget *mpSettingsTabsWidget;
QGroupBox *mpSettingsGroupBox;
QLabel *mpURLLabel;
QLineEdit *mpSyncthingUrlLineEdit;
QLabel *userNameLabel;
QLabel *userPasswordLabel;
QLabel *mpAPIKeyLabel;
QLineEdit *mpUserNameLineEdit;
QLineEdit *userPassword;
QLineEdit *mpAPIKeyEdit;
QCheckBox *mpAuthCheckBox;
QLabel *mpUrlTestResultLabel;
QPushButton *mpTestConnectionButton;
QGroupBox *mpAppearanceGroupBox;
QCheckBox *mpMonochromeIconBox;
QCheckBox *mpNotificationsIconBox;
QCheckBox *mpShouldAnimateIconBox;
QLabel *mpWebViewZoomFactorLabel;
QDoubleSpinBox *mpWebViewZoomFactor;
QLabel *mpSyncPollIntervalLabel;
QDoubleSpinBox *mpSyncPollIntervalBox;
QLabel *mpStatsLengthLabel;
QDoubleSpinBox *mpStatsLengthBox;
QAction *mpConnectedState;
QAction *mpNumberOfConnectionsAction;
QAction *mpCurrentTrafficAction;
QAction *mpTrafficInAction;
QAction *mpTrafficOutAction;
QAction *mpShowWebViewAction;
QAction *mpPreferencesAction;
QAction *mpShowGitHubAction;
QAction *mpCheckUpdateAction;
QAction *mpPauseSyncthingAction;
QAction *mpQuitAction;
QAction *mpStatsWidgetAction;
qst::stats::StatsWidget *mpStatsWidget;
QList<QAction*> mCurrentFoldersActions;
QMenu *mpFolderMenu = nullptr;
QList<QAction*> mCurrentSyncedFilesActions;
QMenu *mpLastSyncedMenu = nullptr;
std::list<FolderNameFullPath> mCurrentFoldersLocations;
LastSyncedFileList mLastSyncedFiles;
QSystemTrayIcon *mpTrayIcon = nullptr;
QMenu *mpTrayIconMenu = nullptr;
QUrl mCurrentUrl;
int mLastIconIndex = -1;
QString mCurrentUserName;
QString mCurrentUserPassword;
std::shared_ptr<qst::connector::SyncConnector> mpSyncConnector;
std::unique_ptr<qst::monitor::ProcessMonitor> mpProcessMonitor;
std::unique_ptr<qst::settings::StartupTab> mpStartupTab;
QSettings mSettings;
std::unique_ptr<QMovie> mpAnimatedIconMovie;
bool mIconMonochrome;
bool mNotificationsEnabled;
bool mShouldAnimateIcon;
bool mShouldStopAnimation;
int mLastConnectionState;
qst::update::UpdateNotifier mUpdateNotifier;
void onUpdateCheck(const bool isNewVersion);
template <typename T>
void checkAndSetValue(QString key, T value);
template <typename U, typename T>
void setElements(U &&func, T uiElement);
template <typename U, typename T, typename ... TArgs>
void setElements(U &&func, T uiElement, TArgs... Elements);
};
//! [0]
#endif // QT_NO_SYSTEMTRAYICON
#endif