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();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
void usernameChanged();
|
2014-05-30 08:53:19 +00:00
|
|
|
void updateConnectionType();
|
|
|
|
|
|
|
|
void peerUpdated(PeerData *data);
|
|
|
|
|
|
|
|
void onUpdatePhoto();
|
|
|
|
void onUpdatePhotoCancel();
|
|
|
|
|
|
|
|
void onAutoUpdate();
|
|
|
|
void onCheckNow();
|
|
|
|
void onRestartNow();
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
void onCatsAndDogs();
|
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
void onLocalImagesClear();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void onUpdateChecking();
|
|
|
|
void onUpdateLatest();
|
|
|
|
void onUpdateDownloading(qint64 ready, qint64 total);
|
|
|
|
void onUpdateReady();
|
|
|
|
void onUpdateFailed();
|
|
|
|
|
|
|
|
void onResetSessions();
|
|
|
|
|
|
|
|
void onPhotoUpdateDone(PeerId peer);
|
|
|
|
void onPhotoUpdateFail(PeerId peer);
|
|
|
|
void onPhotoUpdateStart();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void doneResetSessions(const MTPBool &res);
|
|
|
|
void saveError(const QString &str = QString());
|
|
|
|
|
|
|
|
void setScale(DBIScale newScale);
|
|
|
|
|
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
|
|
|
|
QString _phoneText, _usernameText;
|
|
|
|
int32 _phoneLeft, _usernameLeft;
|
|
|
|
LinkButton _chooseUsername, _changeUsername;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// notifications
|
2014-07-18 10:37:34 +00:00
|
|
|
FlatCheckbox _desktopNotify, _senderName, _messagePreview, _soundNotify;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
// general
|
|
|
|
FlatCheckbox _autoUpdate;
|
|
|
|
LinkButton _checkNow, _restartNow;
|
|
|
|
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;
|
|
|
|
FlatCheckbox _catsAndDogs;
|
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
// local storage
|
|
|
|
LinkButton _localImagesClear;
|
|
|
|
int32 _imagesClearingWidth, _imagesClearedWidth, _imagesClearFailedWidth;
|
|
|
|
TempDirClearState _imagesClearState;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// advanced
|
|
|
|
LinkButton _connectionType, _resetSessions;
|
|
|
|
FlatButton _logOut;
|
|
|
|
|
|
|
|
QString _connectionTypeText;
|
|
|
|
int32 _connectionTypeWidth;
|
|
|
|
|
|
|
|
bool _resetDone;
|
|
|
|
|
|
|
|
void setUpdatingState(UpdatingState state, bool force = false);
|
|
|
|
void setDownloadProgress(qint64 ready, qint64 total);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
|
|
~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;
|
|
|
|
};
|