forked from telegramdesktop/tdesktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettingswidget.h
351 lines (257 loc) · 7.78 KB
/
settingswidget.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop 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 3 of the License, or
(at your option) any later version.
It 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.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
*/
#pragma once
#include "gui/flatbutton.h"
#include "gui/flatcheckbox.h"
#include "sysbuttons.h"
#include <QtWidgets/QWidget>
class Window;
class Settings;
class Slider : public QWidget {
Q_OBJECT
public:
Slider(QWidget *parent, const style::slider &st, int32 count, int32 sel = 0);
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
int32 selected() const;
void setSelected(int32 sel);
void paintEvent(QPaintEvent *e);
signals:
void changed(int32 oldSelected);
private:
int32 _count, _sel, _wasSel;
style::slider _st;
bool _pressed;
};
class SettingsInner : public QWidget, public RPCSender, public Animated {
Q_OBJECT
public:
SettingsInner(SettingsWidget *parent);
void paintEvent(QPaintEvent *e);
void resizeEvent(QResizeEvent *e);
void keyPressEvent(QKeyEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *e);
void contextMenuEvent(QContextMenuEvent *e);
bool animStep(float64 ms);
void updateSize(int32 newWidth);
void updateOnlineDisplay();
void showAll();
void chooseCustomLang();
void updateChatBackground();
void needBackgroundUpdate(bool tile);
void enableDisplayNotify(bool enable);
public slots:
void usernameChanged();
void updateConnectionType();
void passcodeChanged();
void updateBackgroundRect();
void peerUpdated(PeerData *data);
void onUpdatePhoto();
void onUpdatePhotoCancel();
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
void onAutoUpdate();
void onCheckNow();
#endif
void onRestartNow();
void onFullPeerUpdated(PeerData *peer);
void onPasscode();
void onPasscodeOff();
void onAutoLock();
void onPassword();
void onPasswordOff();
void onReloadPassword(Qt::ApplicationState state = Qt::ApplicationActive);
void onConnectionType();
void onUsername();
void onWorkmodeTray();
void onWorkmodeWindow();
void onAutoStart();
void onStartMinimized();
void onSendToMenu();
void onScaleAuto();
void onScaleChange();
void onSoundNotify();
void onIncludeMuted();
void onDesktopNotify();
void onSenderName();
void onMessagePreview();
void onWindowsNotifications();
void onReplaceEmojis();
void onViewEmojis();
void onStickers();
void onEnterSend();
void onCtrlEnterSend();
void onDontAskDownloadPath();
void onDownloadPathEdit();
void onDownloadPathEdited();
void onDownloadPathClear();
void onDownloadPathClearSure();
void onTempDirCleared(int task);
void onTempDirClearFailed(int task);
void onBackFromGallery();
void onBackFromFile();
void onTileBackground();
void onLocalStorageClear();
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
void onUpdateChecking();
void onUpdateLatest();
void onUpdateDownloading(qint64 ready, qint64 total);
void onUpdateReady();
void onUpdateFailed();
#endif
void onShowSessions();
void onPhotoUpdateDone(PeerId peer);
void onPhotoUpdateFail(PeerId peer);
void onPhotoUpdateStart();
void onChangeLanguage();
void onSaveTestLang();
void onUpdateLocalStorage();
void onAskQuestion();
void onAskQuestionSure();
void onTelegramFAQ();
private:
void saveError(const QString &str = QString());
void supportGot(const MTPhelp_Support &support);
void setScale(DBIScale newScale);
QString _testlang, _secretText;
UserData *_self;
UserData *self() const {
return App::self() ? _self : static_cast<UserData*>(0);
}
int32 _left;
// profile
Text _nameText;
QString _nameCache;
TextLinkPtr _photoLink;
FlatButton _uploadPhoto;
LinkButton _cancelPhoto;
bool _nameOver, _photoOver;
anim::fvalue a_photo;
QString _errorText;
// contact info
QString _phoneText;
LinkButton _chooseUsername;
// notifications
FlatCheckbox _desktopNotify, _senderName, _messagePreview, _windowsNotifications, _soundNotify, _includeMuted;
// general
LinkButton _changeLanguage;
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
FlatCheckbox _autoUpdate;
LinkButton _checkNow, _restartNow;
#endif
bool _supportTray; // cSupportTray() value on settings create
FlatCheckbox _workmodeTray, _workmodeWindow;
FlatCheckbox _autoStart, _startMinimized, _sendToMenu;
FlatCheckbox _dpiAutoScale;
Slider _dpiSlider;
int32 _dpiWidth1, _dpiWidth2, _dpiWidth3, _dpiWidth4;
QString _curVersionText, _newVersionText;
int32 _curVersionWidth, _newVersionWidth;
enum UpdatingState {
UpdatingNone,
UpdatingCheck,
UpdatingLatest,
UpdatingDownload,
UpdatingFail,
UpdatingReady
};
UpdatingState _updatingState;
QString _newVersionDownload;
// chat options
FlatCheckbox _replaceEmojis;
LinkButton _viewEmojis, _stickers;
FlatRadiobutton _enterSend, _ctrlEnterSend;
FlatCheckbox _dontAskDownloadPath;
int32 _downloadPathWidth;
LinkButton _downloadPathEdit, _downloadPathClear;
int32 _tempDirClearingWidth, _tempDirClearedWidth, _tempDirClearFailedWidth;
enum TempDirClearState {
TempDirClearFailed = 0,
TempDirEmpty = 1,
TempDirExists = 2,
TempDirClearing = 3,
TempDirCleared = 4,
};
TempDirClearState _tempDirClearState;
// chat background
QPixmap _background;
LinkButton _backFromGallery, _backFromFile;
FlatCheckbox _tileBackground;
bool _needBackgroundUpdate;
// local storage
LinkButton _localStorageClear;
int32 _localStorageHeight;
int32 _storageClearingWidth, _storageClearedWidth, _storageClearFailedWidth;
TempDirClearState _storageClearState;
// advanced
LinkButton _passcodeEdit, _passcodeTurnOff, _autoLock;
QString _autoLockText;
int32 _autoLockWidth;
LinkButton _passwordEdit, _passwordTurnOff;
QString _waitingConfirm;
QByteArray _curPasswordSalt;
bool _hasPasswordRecovery;
QString _curPasswordHint;
QByteArray _newPasswordSalt;
LinkButton _connectionType;
QString _connectionTypeText;
int32 _connectionTypeWidth;
LinkButton _showSessions, _askQuestion, _telegramFAQ;
FlatButton _logOut;
mtpRequestId _supportGetRequest;
void gotPassword(const MTPaccount_Password &result);
void offPasswordDone(const MTPBool &result);
bool offPasswordFail(const RPCError &error);
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
void setUpdatingState(UpdatingState state, bool force = false);
void setDownloadProgress(qint64 ready, qint64 total);
#endif
};
class SettingsWidget : public TWidget {
Q_OBJECT
public:
SettingsWidget(Window *parent);
void paintEvent(QPaintEvent *e);
void resizeEvent(QResizeEvent *e);
void dragEnterEvent(QDragEnterEvent *e);
void dropEvent(QDropEvent *e);
void updateWideMode();
void animShow(const QPixmap &bgAnimCache, bool back = false);
bool animStep_show(float64 ms);
void animStop_show();
void updateOnlineDisplay();
void updateConnectionType();
void updateDisplayNotify();
void rpcInvalidate();
void usernameChanged();
void setInnerFocus();
void needBackgroundUpdate(bool tile);
~SettingsWidget();
public slots:
void onParentResize(const QSize &newSize);
private:
void showAll();
void hideAll();
Animation _a_show;
QPixmap _cacheUnder, _cacheOver;
anim::ivalue a_coordUnder, a_coordOver;
anim::fvalue a_shadow;
ScrollArea _scroll;
SettingsInner _inner;
IconedButton _close;
};