2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2014-12-01 10:47:38 +00:00
|
|
|
Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#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:
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
SettingsInner(SettingsWidget *parent);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
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 gotFullSelf(const MTPUserFull &self);
|
|
|
|
|
|
|
|
void showAll();
|
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
void updateChatBackground();
|
|
|
|
void needBackgroundUpdate(bool tile);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
public slots:
|
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
void usernameChanged();
|
2014-05-30 08:53:19 +00:00
|
|
|
void updateConnectionType();
|
|
|
|
|
2015-03-02 12:34:16 +00:00
|
|
|
void passcodeChanged();
|
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
void updateBackgroundRect();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void peerUpdated(PeerData *data);
|
|
|
|
|
|
|
|
void onUpdatePhoto();
|
|
|
|
void onUpdatePhotoCancel();
|
|
|
|
|
|
|
|
void onAutoUpdate();
|
|
|
|
void onCheckNow();
|
|
|
|
void onRestartNow();
|
|
|
|
|
2015-03-02 12:34:16 +00:00
|
|
|
void onPasscode();
|
|
|
|
void onPasscodeOff();
|
|
|
|
void onAutoLock();
|
2015-04-02 10:33:19 +00:00
|
|
|
void onPassword();
|
|
|
|
void onPasswordOff();
|
|
|
|
void onReloadPassword(Qt::ApplicationState state = Qt::ApplicationActive);
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void onConnectionType();
|
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
void onUsername();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void onWorkmodeTray();
|
|
|
|
void onWorkmodeWindow();
|
|
|
|
|
|
|
|
void onAutoStart();
|
|
|
|
void onStartMinimized();
|
2014-07-18 10:37:34 +00:00
|
|
|
void onSendToMenu();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void onScaleAuto();
|
|
|
|
void onScaleChange();
|
|
|
|
|
|
|
|
void onSoundNotify();
|
|
|
|
void onDesktopNotify();
|
2014-07-18 10:37:34 +00:00
|
|
|
void onSenderName();
|
|
|
|
void onMessagePreview();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-08-11 19:50:48 +00:00
|
|
|
void onWindowsNotifications();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void onReplaceEmojis();
|
|
|
|
void onViewEmojis();
|
|
|
|
|
|
|
|
void onEnterSend();
|
|
|
|
void onCtrlEnterSend();
|
|
|
|
|
|
|
|
void onDontAskDownloadPath();
|
|
|
|
void onDownloadPathEdit();
|
|
|
|
void onDownloadPathEdited();
|
|
|
|
void onDownloadPathClear();
|
|
|
|
void onDownloadPathClearSure();
|
2014-11-22 09:45:04 +00:00
|
|
|
void onTempDirCleared(int task);
|
|
|
|
void onTempDirClearFailed(int task);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
void onBackFromGallery();
|
|
|
|
void onBackFromFile();
|
|
|
|
void onTileBackground();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-01-02 14:55:24 +00:00
|
|
|
void onLocalStorageClear();
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void onUpdateChecking();
|
|
|
|
void onUpdateLatest();
|
|
|
|
void onUpdateDownloading(qint64 ready, qint64 total);
|
|
|
|
void onUpdateReady();
|
|
|
|
void onUpdateFailed();
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
void onShowSessions();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void onPhotoUpdateDone(PeerId peer);
|
|
|
|
void onPhotoUpdateFail(PeerId peer);
|
|
|
|
void onPhotoUpdateStart();
|
|
|
|
|
2014-12-19 21:20:30 +00:00
|
|
|
void onChangeLanguage();
|
2014-12-20 21:33:08 +00:00
|
|
|
void onSaveTestLang();
|
2014-12-19 21:20:30 +00:00
|
|
|
|
2015-01-02 14:55:24 +00:00
|
|
|
void onUpdateLocalStorage();
|
|
|
|
|
2015-08-12 18:01:32 +00:00
|
|
|
void onAskQuestion();
|
|
|
|
void onAskQuestionSure();
|
|
|
|
void onTelegramFAQ();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
void saveError(const QString &str = QString());
|
|
|
|
|
2015-08-12 18:01:32 +00:00
|
|
|
void supportGot(const MTPhelp_Support &support);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void setScale(DBIScale newScale);
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
QString _testlang, _secretText;
|
2014-12-20 21:33:08 +00:00
|
|
|
|
2014-10-22 19:44:30 +00:00
|
|
|
UserData *_self;
|
2014-10-22 18:39:03 +00:00
|
|
|
UserData *self() const {
|
2014-10-22 19:44:30 +00:00
|
|
|
return App::self() ? _self : static_cast<UserData*>(0);
|
2014-10-22 18:39:03 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
int32 _left;
|
|
|
|
|
|
|
|
// profile
|
|
|
|
Text _nameText;
|
|
|
|
QString _nameCache;
|
|
|
|
TextLinkPtr _photoLink;
|
|
|
|
FlatButton _uploadPhoto;
|
|
|
|
LinkButton _cancelPhoto;
|
|
|
|
bool _nameOver, _photoOver;
|
|
|
|
anim::fvalue a_photo;
|
|
|
|
|
|
|
|
QString _errorText;
|
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
// contact info
|
2015-02-09 13:26:59 +00:00
|
|
|
QString _phoneText;
|
|
|
|
LinkButton _chooseUsername;
|
2014-10-22 18:39:03 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// notifications
|
2015-08-11 19:50:48 +00:00
|
|
|
FlatCheckbox _desktopNotify, _senderName, _messagePreview, _windowsNotifications, _soundNotify;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
// general
|
2014-12-19 21:20:30 +00:00
|
|
|
LinkButton _changeLanguage;
|
2014-05-30 08:53:19 +00:00
|
|
|
FlatCheckbox _autoUpdate;
|
|
|
|
LinkButton _checkNow, _restartNow;
|
2015-01-15 14:22:15 +00:00
|
|
|
bool _supportTray; // cSupportTray() value on settings create
|
2014-05-30 08:53:19 +00:00
|
|
|
FlatCheckbox _workmodeTray, _workmodeWindow;
|
2014-07-18 10:37:34 +00:00
|
|
|
FlatCheckbox _autoStart, _startMinimized, _sendToMenu;
|
2014-05-30 08:53:19 +00:00
|
|
|
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;
|
|
|
|
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;
|
2015-02-03 15:02:46 +00:00
|
|
|
|
|
|
|
// chat background
|
|
|
|
QPixmap _background;
|
|
|
|
LinkButton _backFromGallery, _backFromFile;
|
|
|
|
FlatCheckbox _tileBackground;
|
|
|
|
bool _needBackgroundUpdate;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
// local storage
|
2015-01-02 14:55:24 +00:00
|
|
|
LinkButton _localStorageClear;
|
|
|
|
int32 _localStorageHeight;
|
|
|
|
int32 _storageClearingWidth, _storageClearedWidth, _storageClearFailedWidth;
|
|
|
|
TempDirClearState _storageClearState;
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// advanced
|
2015-03-02 12:34:16 +00:00
|
|
|
LinkButton _passcodeEdit, _passcodeTurnOff, _autoLock;
|
|
|
|
QString _autoLockText;
|
|
|
|
int32 _autoLockWidth;
|
2015-04-02 10:33:19 +00:00
|
|
|
LinkButton _passwordEdit, _passwordTurnOff;
|
|
|
|
QString _waitingConfirm;
|
|
|
|
QByteArray _curPasswordSalt;
|
|
|
|
bool _hasPasswordRecovery;
|
|
|
|
QString _curPasswordHint;
|
|
|
|
QByteArray _newPasswordSalt;
|
2015-03-02 12:34:16 +00:00
|
|
|
LinkButton _connectionType;
|
2014-05-30 08:53:19 +00:00
|
|
|
QString _connectionTypeText;
|
|
|
|
int32 _connectionTypeWidth;
|
2015-08-12 18:01:32 +00:00
|
|
|
LinkButton _showSessions, _askQuestion, _telegramFAQ;
|
2015-03-02 12:34:16 +00:00
|
|
|
FlatButton _logOut;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-08-12 18:01:32 +00:00
|
|
|
mtpRequestId _supportGetRequest;
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
void gotPassword(const MTPaccount_Password &result);
|
|
|
|
void offPasswordDone(const MTPBool &result);
|
|
|
|
bool offPasswordFail(const RPCError &error);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void setUpdatingState(UpdatingState state, bool force = false);
|
|
|
|
void setDownloadProgress(qint64 ready, qint64 total);
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
class SettingsWidget : public QWidget, public Animated {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
SettingsWidget(Window *parent);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e);
|
|
|
|
void dropEvent(QDropEvent *e);
|
|
|
|
|
2014-12-12 16:27:03 +00:00
|
|
|
void updateWideMode();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void animShow(const QPixmap &bgAnimCache, bool back = false);
|
|
|
|
bool animStep(float64 ms);
|
|
|
|
|
|
|
|
void updateOnlineDisplay();
|
|
|
|
void updateConnectionType();
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
void rpcInvalidate();
|
2014-10-22 18:39:03 +00:00
|
|
|
void usernameChanged();
|
2014-08-01 11:09:46 +00:00
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
void setInnerFocus();
|
|
|
|
void needBackgroundUpdate(bool tile);
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
~SettingsWidget();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void onParentResize(const QSize &newSize);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void showAll();
|
|
|
|
void hideAll();
|
|
|
|
|
|
|
|
QPixmap _animCache, _bgAnimCache;
|
|
|
|
anim::ivalue a_coord, a_bgCoord;
|
|
|
|
anim::fvalue a_alpha, a_bgAlpha;
|
|
|
|
|
|
|
|
ScrollArea _scroll;
|
|
|
|
SettingsInner _inner;
|
|
|
|
IconedButton _close;
|
|
|
|
};
|