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.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2016-02-08 10:56:18 +00:00
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
2016-04-21 17:57:29 +00:00
|
|
|
#include "settingswidget.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-05-25 12:09:05 +00:00
|
|
|
#include "observer_peer.h"
|
2016-04-21 17:57:29 +00:00
|
|
|
#include "lang.h"
|
2015-10-12 21:02:10 +00:00
|
|
|
#include "boxes/aboutbox.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
#include "mainwidget.h"
|
|
|
|
#include "application.h"
|
|
|
|
#include "boxes/photocropbox.h"
|
|
|
|
#include "boxes/connectionbox.h"
|
2015-02-03 15:02:46 +00:00
|
|
|
#include "boxes/backgroundbox.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
#include "boxes/addcontactbox.h"
|
|
|
|
#include "boxes/emojibox.h"
|
|
|
|
#include "boxes/confirmbox.h"
|
|
|
|
#include "boxes/downloadpathbox.h"
|
2014-10-22 18:39:03 +00:00
|
|
|
#include "boxes/usernamebox.h"
|
2014-12-19 21:20:30 +00:00
|
|
|
#include "boxes/languagebox.h"
|
2015-03-02 12:34:16 +00:00
|
|
|
#include "boxes/passcodebox.h"
|
|
|
|
#include "boxes/autolockbox.h"
|
2015-04-02 10:33:19 +00:00
|
|
|
#include "boxes/sessionsbox.h"
|
2015-12-02 17:17:53 +00:00
|
|
|
#include "boxes/stickersetbox.h"
|
2014-12-20 21:33:08 +00:00
|
|
|
#include "langloaderplain.h"
|
2016-04-07 18:05:28 +00:00
|
|
|
#include "ui/filedialog.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
#include "apiwrap.h"
|
2015-06-03 18:13:01 +00:00
|
|
|
#include "autoupdater.h"
|
2014-11-22 09:45:04 +00:00
|
|
|
#include "localstorage.h"
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Slider::Slider(QWidget *parent, const style::slider &st, int32 count, int32 sel) : QWidget(parent),
|
|
|
|
_count(count), _sel(snap(sel, 0, _count)), _wasSel(_sel), _st(st), _pressed(false) {
|
2014-06-15 12:31:03 +00:00
|
|
|
resize(_st.width, _st.bar.pxHeight());
|
2014-05-30 08:53:19 +00:00
|
|
|
setCursor(style::cur_pointer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Slider::mousePressEvent(QMouseEvent *e) {
|
|
|
|
_pressed = true;
|
|
|
|
mouseMoveEvent(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Slider::mouseMoveEvent(QMouseEvent *e) {
|
|
|
|
if (_pressed) {
|
2014-06-15 12:31:03 +00:00
|
|
|
int32 newSel = snap(qRound((_count - 1) * float64(e->pos().x() - _st.bar.pxWidth() / 2) / (width() - _st.bar.pxWidth())), 0, _count - 1);
|
2014-05-30 08:53:19 +00:00
|
|
|
if (newSel != _sel) {
|
|
|
|
_sel = newSel;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Slider::mouseReleaseEvent(QMouseEvent *e) {
|
|
|
|
_pressed = false;
|
|
|
|
if (_sel != _wasSel) {
|
|
|
|
emit changed(_wasSel);
|
|
|
|
_wasSel = _sel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int32 Slider::selected() const {
|
|
|
|
return _sel;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Slider::setSelected(int32 sel) {
|
|
|
|
if (_sel != sel) {
|
|
|
|
_sel = sel;
|
|
|
|
emit changed(_wasSel);
|
|
|
|
_wasSel = _sel;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Slider::paintEvent(QPaintEvent *e) {
|
2016-04-21 17:57:29 +00:00
|
|
|
Painter p(this);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-06-10 06:54:56 +00:00
|
|
|
p.fillRect(0, (height() - _st.thickness) / 2, width(), _st.thickness, _st.color->b);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-06-15 12:31:03 +00:00
|
|
|
int32 x = qFloor(_sel * float64(width() - _st.bar.pxWidth()) / (_count - 1)), y = (height() - _st.bar.pxHeight()) / 2;
|
2016-04-21 17:57:29 +00:00
|
|
|
p.drawSprite(QPoint(x, y), _st.bar);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString scaleLabel(DBIScale scale) {
|
|
|
|
switch (scale) {
|
|
|
|
case dbisOne: return qsl("100%");
|
|
|
|
case dbisOneAndQuarter: return qsl("125%");
|
|
|
|
case dbisOneAndHalf: return qsl("150%");
|
|
|
|
case dbisTwo: return qsl("200%");
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool scaleIs(DBIScale scale) {
|
2014-06-14 19:32:11 +00:00
|
|
|
return cRealScale() == scale || (cRealScale() == dbisAuto && cScreenScale() == scale);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent)
|
|
|
|
, _self(App::self())
|
|
|
|
|
|
|
|
// profile
|
|
|
|
, _nameCache(self() ? self()->name : QString())
|
|
|
|
, _uploadPhoto(this, lang(lng_settings_upload), st::btnSetUpload)
|
|
|
|
, _cancelPhoto(this, lang(lng_cancel))
|
|
|
|
, _nameOver(false)
|
|
|
|
, _photoOver(false)
|
|
|
|
, a_photoOver(0)
|
|
|
|
, _a_photo(animation(this, &SettingsInner::step_photo))
|
|
|
|
|
|
|
|
// contact info
|
2016-05-31 19:27:11 +00:00
|
|
|
, _phoneText(self() ? App::formatPhone(self()->phone()) : QString())
|
2015-12-08 12:33:37 +00:00
|
|
|
, _chooseUsername(this, (self() && !self()->username.isEmpty()) ? ('@' + self()->username) : lang(lng_settings_choose_username))
|
|
|
|
|
|
|
|
// notifications
|
|
|
|
, _desktopNotify(this, lang(lng_settings_desktop_notify), cDesktopNotify())
|
|
|
|
, _senderName(this, lang(lng_settings_show_name), cNotifyView() <= dbinvShowName)
|
|
|
|
, _messagePreview(this, lang(lng_settings_show_preview), cNotifyView() <= dbinvShowPreview)
|
|
|
|
, _windowsNotifications(this, lang(lng_settings_use_windows), cWindowsNotifications())
|
|
|
|
, _soundNotify(this, lang(lng_settings_sound_notify), cSoundNotify())
|
|
|
|
, _includeMuted(this, lang(lng_settings_include_muted), cIncludeMuted())
|
|
|
|
|
|
|
|
// general
|
|
|
|
, _changeLanguage(this, lang(lng_settings_change_lang))
|
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
|
|
|
, _autoUpdate(this, lang(lng_settings_auto_update), cAutoUpdate())
|
|
|
|
, _checkNow(this, lang(lng_settings_check_now))
|
|
|
|
, _restartNow(this, lang(lng_settings_update_now))
|
|
|
|
#endif
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
, _supportTray(cSupportTray())
|
|
|
|
, _workmodeTray(this, lang(lng_settings_workmode_tray), (cWorkMode() == dbiwmTrayOnly || cWorkMode() == dbiwmWindowAndTray))
|
|
|
|
, _workmodeWindow(this, lang(lng_settings_workmode_window), (cWorkMode() == dbiwmWindowOnly || cWorkMode() == dbiwmWindowAndTray))
|
|
|
|
|
|
|
|
, _autoStart(this, lang(lng_settings_auto_start), cAutoStart())
|
|
|
|
, _startMinimized(this, lang(lng_settings_start_min), cStartMinimized())
|
|
|
|
, _sendToMenu(this, lang(lng_settings_add_sendto), cSendToMenu())
|
|
|
|
|
|
|
|
, _dpiAutoScale(this, lng_settings_scale_auto(lt_cur, scaleLabel(cScreenScale())), (cConfigScale() == dbisAuto))
|
|
|
|
, _dpiSlider(this, st::dpiSlider, dbisScaleCount - 1, cEvalScale(cConfigScale()) - 1)
|
|
|
|
, _dpiWidth1(st::dpiFont1->width(scaleLabel(dbisOne)))
|
|
|
|
, _dpiWidth2(st::dpiFont2->width(scaleLabel(dbisOneAndQuarter)))
|
|
|
|
, _dpiWidth3(st::dpiFont3->width(scaleLabel(dbisOneAndHalf)))
|
|
|
|
, _dpiWidth4(st::dpiFont4->width(scaleLabel(dbisTwo)))
|
|
|
|
|
|
|
|
// chat options
|
|
|
|
, _replaceEmojis(this, lang(lng_settings_replace_emojis), cReplaceEmojis())
|
|
|
|
, _viewEmojis(this, lang(lng_settings_view_emojis))
|
|
|
|
, _stickers(this, lang(lng_stickers_you_have))
|
|
|
|
|
|
|
|
, _enterSend(this, qsl("send_key"), 0, lang(lng_settings_send_enter), !cCtrlEnter())
|
|
|
|
, _ctrlEnterSend(this, qsl("send_key"), 1, lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_settings_send_cmdenter : lng_settings_send_ctrlenter), cCtrlEnter())
|
|
|
|
|
|
|
|
, _dontAskDownloadPath(this, lang(lng_download_path_dont_ask), !cAskDownloadPath())
|
|
|
|
, _downloadPathWidth(st::linkFont->width(lang(lng_download_path_label)) + st::linkFont->spacew)
|
2015-12-23 21:19:57 +00:00
|
|
|
, _downloadPathEdit(this, cDownloadPath().isEmpty() ? lang(lng_download_path_default) : ((cDownloadPath() == qsl("tmp")) ? lang(lng_download_path_temp) : st::linkFont->elided(QDir::toNativeSeparators(cDownloadPath()), st::setWidth - st::cbDefFlat.textLeft - _downloadPathWidth)))
|
2015-12-08 12:33:37 +00:00
|
|
|
, _downloadPathClear(this, lang(lng_download_path_clear))
|
|
|
|
, _tempDirClearingWidth(st::linkFont->width(lang(lng_download_path_clearing)))
|
|
|
|
, _tempDirClearedWidth(st::linkFont->width(lang(lng_download_path_cleared)))
|
|
|
|
, _tempDirClearFailedWidth(st::linkFont->width(lang(lng_download_path_clear_failed)))
|
|
|
|
|
2015-12-23 21:19:57 +00:00
|
|
|
, _autoDownload(this, lang(lng_media_auto_settings))
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
// local storage
|
|
|
|
, _localStorageClear(this, lang(lng_local_storage_clear))
|
|
|
|
, _localStorageHeight(1)
|
|
|
|
, _storageClearingWidth(st::linkFont->width(lang(lng_local_storage_clearing)))
|
|
|
|
, _storageClearedWidth(st::linkFont->width(lang(lng_local_storage_cleared)))
|
|
|
|
, _storageClearFailedWidth(st::linkFont->width(lang(lng_local_storage_clear_failed)))
|
|
|
|
|
2015-12-24 19:26:28 +00:00
|
|
|
// chat background
|
|
|
|
, _backFromGallery(this, lang(lng_settings_bg_from_gallery))
|
|
|
|
, _backFromFile(this, lang(lng_settings_bg_from_file))
|
|
|
|
, _tileBackground(this, lang(lng_settings_bg_tile), cTileBackground())
|
2016-02-21 14:27:54 +00:00
|
|
|
, _adaptiveForWide(this, lang(lng_settings_adaptive_wide), Global::AdaptiveForWide())
|
2015-12-24 19:26:28 +00:00
|
|
|
, _needBackgroundUpdate(false)
|
2016-06-22 13:39:54 +00:00
|
|
|
, _radial(animation(this, &SettingsInner::step_radial))
|
2015-12-24 19:26:28 +00:00
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
// advanced
|
|
|
|
, _passcodeEdit(this, lang(cHasPasscode() ? lng_passcode_change : lng_passcode_turn_on))
|
|
|
|
, _passcodeTurnOff(this, lang(lng_passcode_turn_off))
|
|
|
|
, _autoLock(this, (cAutoLock() % 3600) ? lng_passcode_autolock_minutes(lt_count, cAutoLock() / 60) : lng_passcode_autolock_hours(lt_count, cAutoLock() / 3600))
|
|
|
|
, _autoLockText(lang(psIdleSupported() ? lng_passcode_autolock_away : lng_passcode_autolock_inactive) + ' ')
|
|
|
|
, _autoLockWidth(st::linkFont->width(_autoLockText))
|
|
|
|
, _passwordEdit(this, lang(lng_cloud_password_set))
|
|
|
|
, _passwordTurnOff(this, lang(lng_passcode_turn_off))
|
|
|
|
, _hasPasswordRecovery(false)
|
|
|
|
, _connectionType(this, lang(lng_connection_auto_connecting))
|
|
|
|
, _connectionTypeText(lang(lng_connection_type) + ' ')
|
|
|
|
, _connectionTypeWidth(st::linkFont->width(_connectionTypeText))
|
|
|
|
, _showSessions(this, lang(lng_settings_show_sessions))
|
|
|
|
, _askQuestion(this, lang(lng_settings_ask_question))
|
|
|
|
, _telegramFAQ(this, lang(lng_settings_faq))
|
2016-04-01 15:32:26 +00:00
|
|
|
, _logOut(this, lang(lng_settings_logout), st::btnRedLink)
|
2015-12-08 12:33:37 +00:00
|
|
|
, _supportGetRequest(0) {
|
2016-06-01 20:05:37 +00:00
|
|
|
Notify::registerPeerObserver(Notify::PeerUpdate::Flag::UsernameChanged, this, &SettingsInner::notifyPeerUpdated);
|
2016-05-25 12:09:05 +00:00
|
|
|
|
2016-06-14 16:26:41 +00:00
|
|
|
App::clearMousedItems();
|
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
if (self()) {
|
2016-03-18 10:18:30 +00:00
|
|
|
self()->loadUserpic();
|
2015-12-24 19:26:28 +00:00
|
|
|
|
2015-10-11 08:37:24 +00:00
|
|
|
connect(App::wnd(), SIGNAL(imageLoaded()), this, SLOT(update()));
|
2015-12-07 10:06:59 +00:00
|
|
|
connect(App::api(), SIGNAL(fullPeerUpdated(PeerData*)), this, SLOT(onFullPeerUpdated(PeerData*)));
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
_nameText.setText(st::setNameFont, _nameCache, _textNameOptions);
|
2015-06-29 22:09:23 +00:00
|
|
|
PhotoData *selfPhoto = (self()->photoId && self()->photoId != UnknownPeerPhotoId) ? App::photo(self()->photoId) : 0;
|
2016-03-29 17:17:00 +00:00
|
|
|
if (selfPhoto && selfPhoto->date) {
|
|
|
|
_photoLink.reset(new PhotoOpenClickHandler(selfPhoto, self()));
|
|
|
|
}
|
2015-12-07 10:06:59 +00:00
|
|
|
App::api()->requestFullPeer(self());
|
2015-04-02 10:33:19 +00:00
|
|
|
onReloadPassword();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
connect(App::main(), SIGNAL(peerPhotoChanged(PeerData *)), this, SLOT(peerUpdated(PeerData *)));
|
|
|
|
connect(App::main(), SIGNAL(peerNameChanged(PeerData *, const PeerData::Names &, const PeerData::NameFirstChars &)), this, SLOT(peerUpdated(PeerData *)));
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
Sandbox::connect(SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(onReloadPassword(Qt::ApplicationState)));
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// profile
|
|
|
|
connect(&_uploadPhoto, SIGNAL(clicked()), this, SLOT(onUpdatePhoto()));
|
|
|
|
connect(&_cancelPhoto, SIGNAL(clicked()), this, SLOT(onUpdatePhotoCancel()));
|
|
|
|
|
|
|
|
connect(App::app(), SIGNAL(peerPhotoDone(PeerId)), this, SLOT(onPhotoUpdateDone(PeerId)));
|
|
|
|
connect(App::app(), SIGNAL(peerPhotoFail(PeerId)), this, SLOT(onPhotoUpdateFail(PeerId)));
|
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
// contact info
|
|
|
|
connect(&_chooseUsername, SIGNAL(clicked()), this, SLOT(onUsername()));
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// notifications
|
2014-07-18 10:37:34 +00:00
|
|
|
_senderName.setDisabled(!_desktopNotify.checked());
|
|
|
|
_messagePreview.setDisabled(_senderName.disabled() || !_senderName.checked());
|
2014-05-30 08:53:19 +00:00
|
|
|
connect(&_desktopNotify, SIGNAL(changed()), this, SLOT(onDesktopNotify()));
|
2014-07-18 10:37:34 +00:00
|
|
|
connect(&_senderName, SIGNAL(changed()), this, SLOT(onSenderName()));
|
|
|
|
connect(&_messagePreview, SIGNAL(changed()), this, SLOT(onMessagePreview()));
|
2015-08-11 19:50:48 +00:00
|
|
|
connect(&_windowsNotifications, SIGNAL(changed()), this, SLOT(onWindowsNotifications()));
|
2014-05-30 08:53:19 +00:00
|
|
|
connect(&_soundNotify, SIGNAL(changed()), this, SLOT(onSoundNotify()));
|
2015-08-28 15:15:56 +00:00
|
|
|
connect(&_includeMuted, SIGNAL(changed()), this, SLOT(onIncludeMuted()));
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
// general
|
2014-12-19 21:20:30 +00:00
|
|
|
connect(&_changeLanguage, SIGNAL(clicked()), this, SLOT(onChangeLanguage()));
|
2015-08-19 22:00:37 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
2014-05-30 08:53:19 +00:00
|
|
|
connect(&_autoUpdate, SIGNAL(changed()), this, SLOT(onAutoUpdate()));
|
|
|
|
connect(&_checkNow, SIGNAL(clicked()), this, SLOT(onCheckNow()));
|
|
|
|
connect(&_restartNow, SIGNAL(clicked()), this, SLOT(onRestartNow()));
|
2015-08-19 22:00:37 +00:00
|
|
|
#endif
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
connect(&_workmodeTray, SIGNAL(changed()), this, SLOT(onWorkmodeTray()));
|
|
|
|
connect(&_workmodeWindow, SIGNAL(changed()), this, SLOT(onWorkmodeWindow()));
|
|
|
|
|
|
|
|
_startMinimized.setDisabled(!_autoStart.checked());
|
|
|
|
connect(&_autoStart, SIGNAL(changed()), this, SLOT(onAutoStart()));
|
|
|
|
connect(&_startMinimized, SIGNAL(changed()), this, SLOT(onStartMinimized()));
|
2014-07-18 10:37:34 +00:00
|
|
|
connect(&_sendToMenu, SIGNAL(changed()), this, SLOT(onSendToMenu()));
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
connect(&_dpiAutoScale, SIGNAL(changed()), this, SLOT(onScaleAuto()));
|
|
|
|
connect(&_dpiSlider, SIGNAL(changed(int32)), this, SLOT(onScaleChange()));
|
|
|
|
|
2016-04-27 12:02:17 +00:00
|
|
|
_curVersionText = lng_settings_current_version(lt_version, QString::fromLatin1(AppVersionStr.c_str()) + (cAlphaVersion() ? " alpha" : "") + (cBetaVersion() ? qsl(" beta %1").arg(cBetaVersion()) : QString())) + ' ';
|
2015-10-03 10:09:09 +00:00
|
|
|
_curVersionWidth = st::linkFont->width(_curVersionText);
|
2014-05-30 08:53:19 +00:00
|
|
|
_newVersionText = lang(lng_settings_update_ready) + ' ';
|
2015-10-03 10:09:09 +00:00
|
|
|
_newVersionWidth = st::linkFont->width(_newVersionText);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-05-25 12:09:05 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
2016-02-08 14:54:55 +00:00
|
|
|
Sandbox::connect(SIGNAL(updateChecking()), this, SLOT(onUpdateChecking()));
|
|
|
|
Sandbox::connect(SIGNAL(updateLatest()), this, SLOT(onUpdateLatest()));
|
|
|
|
Sandbox::connect(SIGNAL(updateProgress(qint64,qint64)), this, SLOT(onUpdateDownloading(qint64,qint64)));
|
|
|
|
Sandbox::connect(SIGNAL(updateFailed()), this, SLOT(onUpdateFailed()));
|
|
|
|
Sandbox::connect(SIGNAL(updateReady()), this, SLOT(onUpdateReady()));
|
2016-05-25 12:09:05 +00:00
|
|
|
#endif
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
// chat options
|
|
|
|
connect(&_replaceEmojis, SIGNAL(changed()), this, SLOT(onReplaceEmojis()));
|
|
|
|
connect(&_viewEmojis, SIGNAL(clicked()), this, SLOT(onViewEmojis()));
|
2015-12-02 17:17:53 +00:00
|
|
|
connect(&_stickers, SIGNAL(clicked()), this, SLOT(onStickers()));
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
connect(&_enterSend, SIGNAL(changed()), this, SLOT(onEnterSend()));
|
|
|
|
connect(&_ctrlEnterSend, SIGNAL(changed()), this, SLOT(onCtrlEnterSend()));
|
|
|
|
|
|
|
|
connect(&_dontAskDownloadPath, SIGNAL(changed()), this, SLOT(onDontAskDownloadPath()));
|
|
|
|
connect(&_downloadPathEdit, SIGNAL(clicked()), this, SLOT(onDownloadPathEdit()));
|
|
|
|
connect(&_downloadPathClear, SIGNAL(clicked()), this, SLOT(onDownloadPathClear()));
|
|
|
|
switch (App::wnd()->tempDirState()) {
|
2016-04-12 21:31:28 +00:00
|
|
|
case MainWindow::TempDirEmpty: _tempDirClearState = TempDirEmpty; break;
|
|
|
|
case MainWindow::TempDirExists: _tempDirClearState = TempDirExists; break;
|
|
|
|
case MainWindow::TempDirRemoving: _tempDirClearState = TempDirClearing; break;
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2014-11-22 09:45:04 +00:00
|
|
|
connect(App::wnd(), SIGNAL(tempDirCleared(int)), this, SLOT(onTempDirCleared(int)));
|
|
|
|
connect(App::wnd(), SIGNAL(tempDirClearFailed(int)), this, SLOT(onTempDirClearFailed(int)));
|
2015-12-23 21:19:57 +00:00
|
|
|
connect(&_autoDownload, SIGNAL(clicked()), this, SLOT(onAutoDownload()));
|
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
|
|
|
connect(&_localStorageClear, SIGNAL(clicked()), this, SLOT(onLocalStorageClear()));
|
|
|
|
switch (App::wnd()->localStorageState()) {
|
2016-04-12 21:31:28 +00:00
|
|
|
case MainWindow::TempDirEmpty: _storageClearState = TempDirEmpty; break;
|
|
|
|
case MainWindow::TempDirExists: _storageClearState = TempDirExists; break;
|
|
|
|
case MainWindow::TempDirRemoving: _storageClearState = TempDirClearing; break;
|
2014-11-22 09:45:04 +00:00
|
|
|
}
|
|
|
|
|
2015-12-24 19:26:28 +00:00
|
|
|
// chat background
|
|
|
|
if (!cChatBackground()) App::initBackground();
|
|
|
|
updateChatBackground();
|
|
|
|
connect(&_backFromGallery, SIGNAL(clicked()), this, SLOT(onBackFromGallery()));
|
|
|
|
connect(&_backFromFile, SIGNAL(clicked()), this, SLOT(onBackFromFile()));
|
|
|
|
connect(&_tileBackground, SIGNAL(changed()), this, SLOT(onTileBackground()));
|
2016-02-21 14:27:54 +00:00
|
|
|
connect(&_adaptiveForWide, SIGNAL(changed()), this, SLOT(onAdaptiveForWide()));
|
2015-12-24 19:26:28 +00:00
|
|
|
|
2016-06-22 13:39:54 +00:00
|
|
|
if (radialLoading()) {
|
|
|
|
radialStart();
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// advanced
|
2015-03-02 12:34:16 +00:00
|
|
|
connect(&_passcodeEdit, SIGNAL(clicked()), this, SLOT(onPasscode()));
|
|
|
|
connect(&_passcodeTurnOff, SIGNAL(clicked()), this, SLOT(onPasscodeOff()));
|
|
|
|
connect(&_autoLock, SIGNAL(clicked()), this, SLOT(onAutoLock()));
|
2015-04-02 10:33:19 +00:00
|
|
|
connect(&_passwordEdit, SIGNAL(clicked()), this, SLOT(onPassword()));
|
|
|
|
connect(&_passwordTurnOff, SIGNAL(clicked()), this, SLOT(onPasswordOff()));
|
2016-03-20 08:16:35 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
2014-05-30 08:53:19 +00:00
|
|
|
connect(&_connectionType, SIGNAL(clicked()), this, SLOT(onConnectionType()));
|
2016-03-20 08:16:35 +00:00
|
|
|
#endif
|
2015-04-02 10:33:19 +00:00
|
|
|
connect(&_showSessions, SIGNAL(clicked()), this, SLOT(onShowSessions()));
|
2015-08-12 18:01:32 +00:00
|
|
|
connect(&_askQuestion, SIGNAL(clicked()), this, SLOT(onAskQuestion()));
|
|
|
|
connect(&_telegramFAQ, SIGNAL(clicked()), this, SLOT(onTelegramFAQ()));
|
2014-11-18 12:40:43 +00:00
|
|
|
connect(&_logOut, SIGNAL(clicked()), App::wnd(), SLOT(onLogout()));
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
if (App::main()) {
|
|
|
|
connect(App::main(), SIGNAL(peerUpdated(PeerData*)), this, SLOT(peerUpdated(PeerData*)));
|
|
|
|
}
|
|
|
|
|
|
|
|
updateOnlineDisplay();
|
|
|
|
|
2016-01-30 16:31:10 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
2016-02-08 14:54:55 +00:00
|
|
|
switch (Sandbox::updatingState()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
case Application::UpdatingDownload:
|
|
|
|
setUpdatingState(UpdatingDownload, true);
|
2016-02-08 14:54:55 +00:00
|
|
|
setDownloadProgress(Sandbox::updatingReady(), Sandbox::updatingSize());
|
2014-05-30 08:53:19 +00:00
|
|
|
break;
|
|
|
|
case Application::UpdatingReady: setUpdatingState(UpdatingReady, true); break;
|
|
|
|
default: setUpdatingState(UpdatingNone, true); break;
|
|
|
|
}
|
2016-01-30 16:31:10 +00:00
|
|
|
#endif
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
updateConnectionType();
|
|
|
|
|
|
|
|
setMouseTracking(true);
|
|
|
|
}
|
|
|
|
|
2016-05-25 12:09:05 +00:00
|
|
|
void SettingsInner::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
|
|
|
if (update.peer == App::self()) {
|
2016-06-01 20:05:37 +00:00
|
|
|
if (update.flags & Notify::PeerUpdate::Flag::UsernameChanged) {
|
2016-05-25 12:09:05 +00:00
|
|
|
usernameChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void SettingsInner::peerUpdated(PeerData *data) {
|
2014-10-22 18:39:03 +00:00
|
|
|
if (self() && data == self()) {
|
2015-06-29 22:09:23 +00:00
|
|
|
if (self()->photoId && self()->photoId != UnknownPeerPhotoId) {
|
2014-10-22 18:39:03 +00:00
|
|
|
PhotoData *selfPhoto = App::photo(self()->photoId);
|
2014-05-30 08:53:19 +00:00
|
|
|
if (selfPhoto->date) {
|
2016-03-29 17:17:00 +00:00
|
|
|
_photoLink.reset(new PhotoOpenClickHandler(selfPhoto, self()));
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2016-03-29 17:17:00 +00:00
|
|
|
_photoLink.clear();
|
2015-12-07 10:06:59 +00:00
|
|
|
App::api()->requestFullPeer(self());
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
} else {
|
2016-03-29 17:17:00 +00:00
|
|
|
_photoLink.clear();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
if (_nameCache != self()->name) {
|
|
|
|
_nameCache = self()->name;
|
2014-05-30 08:53:19 +00:00
|
|
|
_nameText.setText(st::setNameFont, _nameCache, _textNameOptions);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::paintEvent(QPaintEvent *e) {
|
2016-03-18 10:18:30 +00:00
|
|
|
Painter p(this);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
p.setClipRect(e->rect());
|
|
|
|
|
|
|
|
int32 top = 0;
|
2014-10-22 18:39:03 +00:00
|
|
|
if (self()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
// profile
|
|
|
|
top += st::setTop;
|
|
|
|
|
|
|
|
_nameText.drawElided(p, _uploadPhoto.x() + st::setNameLeft, top + st::setNameTop, _uploadPhoto.width() - st::setNameLeft);
|
|
|
|
if (!_cancelPhoto.isHidden()) {
|
|
|
|
p.setFont(st::linkFont->f);
|
|
|
|
p.setPen(st::black->p);
|
2014-10-22 18:39:03 +00:00
|
|
|
p.drawText(_uploadPhoto.x() + st::setStatusLeft, _cancelPhoto.y() + st::linkFont->ascent, lang(lng_settings_uploading_photo));
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_photoLink) {
|
2016-03-18 10:18:30 +00:00
|
|
|
self()->paintUserpicLeft(p, st::setPhotoSize, _left, top, st::setWidth);
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2015-12-08 12:33:37 +00:00
|
|
|
if (a_photoOver.current() < 1) {
|
2016-04-21 17:57:29 +00:00
|
|
|
p.drawSprite(QPoint(_left, top), st::setPhotoImg);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-12-08 12:33:37 +00:00
|
|
|
if (a_photoOver.current() > 0) {
|
|
|
|
p.setOpacity(a_photoOver.current());
|
2016-04-21 17:57:29 +00:00
|
|
|
p.drawSprite(QPoint(_left, top), st::setOverPhotoImg);
|
2014-05-30 08:53:19 +00:00
|
|
|
p.setOpacity(1);
|
|
|
|
}
|
|
|
|
}
|
2014-10-22 18:39:03 +00:00
|
|
|
|
|
|
|
p.setFont(st::setStatusFont->f);
|
|
|
|
bool connecting = App::wnd()->connectingVisible();
|
2016-06-10 11:18:55 +00:00
|
|
|
p.setPen((connecting ? st::profileOfflineFg : st::profileOnlineFg)->p);
|
2014-10-22 18:39:03 +00:00
|
|
|
p.drawText(_uploadPhoto.x() + st::setStatusLeft, top + st::setStatusTop + st::setStatusFont->ascent, lang(connecting ? lng_status_connecting : lng_status_online));
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
top += st::setPhotoSize;
|
|
|
|
|
|
|
|
if (!_errorText.isEmpty()) {
|
|
|
|
p.setFont(st::setErrFont->f);
|
|
|
|
p.setPen(st::setErrColor->p);
|
|
|
|
p.drawText(QRect(_uploadPhoto.x(), _uploadPhoto.y() + _uploadPhoto.height() + st::setLittleSkip, _uploadPhoto.width(), st::setErrFont->height), _errorText, style::al_center);
|
|
|
|
}
|
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
// contact info
|
|
|
|
p.setFont(st::setHeaderFont->f);
|
|
|
|
p.setPen(st::setHeaderColor->p);
|
|
|
|
p.drawText(_left + st::setHeaderLeft, top + st::setHeaderTop + st::setHeaderFont->ascent, lang(lng_settings_section_contact_info));
|
|
|
|
top += st::setHeaderSkip;
|
|
|
|
|
|
|
|
p.setFont(st::linkFont->f);
|
|
|
|
p.setPen(st::black->p);
|
|
|
|
p.drawText(_left, top + st::linkFont->ascent, lang(lng_settings_phone_number));
|
2015-02-09 13:26:59 +00:00
|
|
|
p.drawText(_left + st::setContactInfoLeft, top + st::linkFont->ascent, _phoneText);
|
2014-10-22 18:39:03 +00:00
|
|
|
top += st::linkFont->height + st::setLittleSkip;
|
|
|
|
|
|
|
|
p.drawText(_left, top + st::linkFont->ascent, lang(lng_settings_username));
|
|
|
|
top += st::linkFont->height;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// notifications
|
|
|
|
p.setFont(st::setHeaderFont->f);
|
|
|
|
p.setPen(st::setHeaderColor->p);
|
|
|
|
p.drawText(_left + st::setHeaderLeft, top + st::setHeaderTop + st::setHeaderFont->ascent, lang(lng_settings_section_notify));
|
|
|
|
top += st::setHeaderSkip;
|
|
|
|
|
|
|
|
top += _desktopNotify.height() + st::setLittleSkip;
|
2014-07-18 10:37:34 +00:00
|
|
|
top += _senderName.height() + st::setLittleSkip;
|
|
|
|
top += _messagePreview.height() + st::setSectionSkip;
|
2015-08-11 19:50:48 +00:00
|
|
|
if (App::wnd()->psHasNativeNotifications() && cPlatform() == dbipWindows) {
|
|
|
|
top += _windowsNotifications.height() + st::setSectionSkip;
|
|
|
|
}
|
2015-08-28 15:15:56 +00:00
|
|
|
top += _soundNotify.height() + st::setSectionSkip;
|
|
|
|
top += _includeMuted.height();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// general
|
|
|
|
p.setFont(st::setHeaderFont->f);
|
|
|
|
p.setPen(st::setHeaderColor->p);
|
|
|
|
p.drawText(_left + st::setHeaderLeft, top + st::setHeaderTop + st::setHeaderFont->ascent, lang(lng_settings_section_general));
|
|
|
|
top += st::setHeaderSkip;
|
|
|
|
|
2015-08-19 22:00:37 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
2016-01-01 07:42:06 +00:00
|
|
|
top += _autoUpdate.height();
|
2014-05-30 08:53:19 +00:00
|
|
|
QString textToDraw;
|
|
|
|
if (cAutoUpdate()) {
|
|
|
|
switch (_updatingState) {
|
|
|
|
case UpdatingNone: textToDraw = _curVersionText; break;
|
|
|
|
case UpdatingCheck: textToDraw = lang(lng_settings_update_checking); break;
|
|
|
|
case UpdatingLatest: textToDraw = lang(lng_settings_latest_installed); break;
|
|
|
|
case UpdatingDownload: textToDraw = _newVersionDownload; break;
|
|
|
|
case UpdatingReady: textToDraw = _newVersionText; break;
|
|
|
|
case UpdatingFail: textToDraw = lang(lng_settings_update_fail); break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
textToDraw = _curVersionText;
|
|
|
|
}
|
2015-12-23 21:19:57 +00:00
|
|
|
p.setFont(st::linkFont);
|
|
|
|
p.setPen(st::setVersionColor);
|
2014-05-30 08:53:19 +00:00
|
|
|
p.drawText(_left + st::setVersionLeft, top + st::setVersionTop + st::linkFont->ascent, textToDraw);
|
|
|
|
top += st::setVersionHeight;
|
2015-08-19 22:00:37 +00:00
|
|
|
#endif
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-06-15 12:31:03 +00:00
|
|
|
if (cPlatform() == dbipWindows) {
|
|
|
|
top += _workmodeTray.height() + st::setLittleSkip;
|
|
|
|
top += _workmodeWindow.height() + st::setSectionSkip;
|
2016-01-01 07:42:06 +00:00
|
|
|
|
2014-06-15 12:31:03 +00:00
|
|
|
top += _autoStart.height() + st::setLittleSkip;
|
2014-07-18 10:37:34 +00:00
|
|
|
top += _startMinimized.height() + st::setSectionSkip;
|
|
|
|
|
|
|
|
top += _sendToMenu.height();
|
2015-01-15 14:22:15 +00:00
|
|
|
} else if (_supportTray) {
|
2014-09-20 21:31:03 +00:00
|
|
|
top += _workmodeTray.height();
|
|
|
|
}
|
|
|
|
|
2014-06-15 12:31:03 +00:00
|
|
|
if (!cRetina()) {
|
|
|
|
p.setFont(st::setHeaderFont->f);
|
|
|
|
p.setPen(st::setHeaderColor->p);
|
|
|
|
p.drawText(_left + st::setHeaderLeft, top + st::setHeaderTop + st::setHeaderFont->ascent, lang(lng_settings_scale_label));
|
|
|
|
top += st::setHeaderSkip;
|
|
|
|
top += _dpiAutoScale.height() + st::setLittleSkip;
|
2016-01-01 07:42:06 +00:00
|
|
|
|
2014-06-15 12:31:03 +00:00
|
|
|
top += _dpiSlider.height() + st::dpiFont4->height;
|
|
|
|
int32 sLeft = _dpiSlider.x() + _dpiWidth1 / 2, sWidth = _dpiSlider.width();
|
|
|
|
float64 sStep = (sWidth - _dpiWidth1 / 2 - _dpiWidth4 / 2) / float64(dbisScaleCount - 2);
|
|
|
|
p.setFont(st::dpiFont1->f);
|
2016-01-01 07:42:06 +00:00
|
|
|
|
2014-06-15 12:31:03 +00:00
|
|
|
p.setPen((scaleIs(dbisOne) ? st::dpiActive : st::dpiInactive)->p);
|
|
|
|
p.drawText(sLeft + qRound(0 * sStep) - _dpiWidth1 / 2, top - (st::dpiFont4->height - st::dpiFont1->height) / 2 - st::dpiFont1->descent, scaleLabel(dbisOne));
|
|
|
|
p.setFont(st::dpiFont2->f);
|
|
|
|
p.setPen((scaleIs(dbisOneAndQuarter) ? st::dpiActive : st::dpiInactive)->p);
|
|
|
|
p.drawText(sLeft + qRound(1 * sStep) - _dpiWidth2 / 2, top - (st::dpiFont4->height - st::dpiFont2->height) / 2 - st::dpiFont2->descent, scaleLabel(dbisOneAndQuarter));
|
|
|
|
p.setFont(st::dpiFont3->f);
|
|
|
|
p.setPen((scaleIs(dbisOneAndHalf) ? st::dpiActive : st::dpiInactive)->p);
|
|
|
|
p.drawText(sLeft + qRound(2 * sStep) - _dpiWidth3 / 2, top - (st::dpiFont4->height - st::dpiFont3->height) / 2 - st::dpiFont3->descent, scaleLabel(dbisOneAndHalf));
|
|
|
|
p.setFont(st::dpiFont4->f);
|
|
|
|
p.setPen((scaleIs(dbisTwo) ? st::dpiActive : st::dpiInactive)->p);
|
|
|
|
p.drawText(sLeft + qRound(3 * sStep) - _dpiWidth4 / 2, top - (st::dpiFont4->height - st::dpiFont4->height) / 2 - st::dpiFont4->descent, scaleLabel(dbisTwo));
|
|
|
|
p.setFont(st::linkFont->f);
|
|
|
|
}
|
2016-01-01 07:42:06 +00:00
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
if (self()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
// chat options
|
|
|
|
p.setFont(st::setHeaderFont->f);
|
|
|
|
p.setPen(st::setHeaderColor->p);
|
|
|
|
p.drawText(_left + st::setHeaderLeft, top + st::setHeaderTop + st::setHeaderFont->ascent, lang(lng_settings_section_chat));
|
|
|
|
top += st::setHeaderSkip;
|
|
|
|
|
2015-12-02 17:17:53 +00:00
|
|
|
top += _replaceEmojis.height() + st::setLittleSkip;
|
|
|
|
top += _stickers.height() + st::setSectionSkip;
|
2014-05-30 08:53:19 +00:00
|
|
|
top += _enterSend.height() + st::setLittleSkip;
|
|
|
|
top += _ctrlEnterSend.height() + st::setSectionSkip;
|
|
|
|
|
|
|
|
top += _dontAskDownloadPath.height();
|
|
|
|
if (!cAskDownloadPath()) {
|
|
|
|
top += st::setLittleSkip;
|
|
|
|
p.setFont(st::linkFont->f);
|
|
|
|
p.setPen(st::black->p);
|
2015-12-23 21:19:57 +00:00
|
|
|
p.drawText(_left + st::cbDefFlat.textLeft, top + st::linkFont->ascent, lang(lng_download_path_label));
|
2014-09-30 14:11:09 +00:00
|
|
|
if (cDownloadPath() == qsl("tmp")) {
|
2014-05-30 08:53:19 +00:00
|
|
|
QString clearText;
|
|
|
|
int32 clearWidth = 0;
|
|
|
|
switch (_tempDirClearState) {
|
|
|
|
case TempDirClearing: clearText = lang(lng_download_path_clearing); clearWidth = _tempDirClearingWidth; break;
|
|
|
|
case TempDirCleared: clearText = lang(lng_download_path_cleared); clearWidth = _tempDirClearedWidth; break;
|
|
|
|
case TempDirClearFailed: clearText = lang(lng_download_path_clear_failed); clearWidth = _tempDirClearFailedWidth; break;
|
|
|
|
}
|
|
|
|
if (clearWidth) {
|
|
|
|
p.drawText(_left + st::setWidth - clearWidth, top + st::linkFont->ascent, clearText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
top += _downloadPathEdit.height();
|
|
|
|
}
|
2015-12-23 21:19:57 +00:00
|
|
|
top += st::setLittleSkip;
|
|
|
|
top += _autoDownload.height();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
// local storage
|
|
|
|
p.setFont(st::setHeaderFont->f);
|
|
|
|
p.setPen(st::setHeaderColor->p);
|
|
|
|
p.drawText(_left + st::setHeaderLeft, top + st::setHeaderTop + st::setHeaderFont->ascent, lang(lng_settings_section_cache));
|
|
|
|
|
|
|
|
p.setFont(st::linkFont->f);
|
|
|
|
p.setPen(st::black->p);
|
|
|
|
QString clearText;
|
|
|
|
int32 clearWidth = 0;
|
2015-01-02 14:55:24 +00:00
|
|
|
switch (_storageClearState) {
|
|
|
|
case TempDirClearing: clearText = lang(lng_local_storage_clearing); clearWidth = _storageClearingWidth; break;
|
|
|
|
case TempDirCleared: clearText = lang(lng_local_storage_cleared); clearWidth = _storageClearedWidth; break;
|
|
|
|
case TempDirClearFailed: clearText = lang(lng_local_storage_clear_failed); clearWidth = _storageClearFailedWidth; break;
|
2014-11-22 09:45:04 +00:00
|
|
|
}
|
|
|
|
if (clearWidth) {
|
2015-01-02 14:55:24 +00:00
|
|
|
p.drawText(_left + st::setWidth - clearWidth, top + st::setHeaderTop + st::setHeaderFont->ascent, clearText);
|
|
|
|
}
|
|
|
|
|
|
|
|
top += st::setHeaderSkip;
|
|
|
|
|
2016-01-01 07:42:06 +00:00
|
|
|
int32 cntImages = Local::hasImages() + Local::hasStickers() + Local::hasWebFiles(), cntAudios = Local::hasAudios();
|
2015-01-02 14:55:24 +00:00
|
|
|
if (cntImages > 0 && cntAudios > 0) {
|
|
|
|
if (_localStorageHeight != 2) {
|
|
|
|
cntAudios = 0;
|
|
|
|
QTimer::singleShot(0, this, SLOT(onUpdateLocalStorage()));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (_localStorageHeight != 1) {
|
|
|
|
QTimer::singleShot(0, this, SLOT(onUpdateLocalStorage()));
|
|
|
|
}
|
2014-11-22 09:45:04 +00:00
|
|
|
}
|
2015-01-02 14:55:24 +00:00
|
|
|
if (cntImages > 0) {
|
2016-01-01 07:42:06 +00:00
|
|
|
QString cnt = lng_settings_images_cached(lt_count, cntImages, lt_size, formatSizeText(Local::storageImagesSize() + Local::storageStickersSize() + Local::storageWebFilesSize()));
|
2015-01-02 14:55:24 +00:00
|
|
|
p.drawText(_left + st::setHeaderLeft, top + st::linkFont->ascent, cnt);
|
|
|
|
}
|
|
|
|
if (_localStorageHeight == 2) top += _localStorageClear.height() + st::setLittleSkip;
|
|
|
|
if (cntAudios > 0) {
|
|
|
|
QString cnt = lng_settings_audios_cached(lt_count, cntAudios, lt_size, formatSizeText(Local::storageAudiosSize()));
|
|
|
|
p.drawText(_left + st::setHeaderLeft, top + st::linkFont->ascent, cnt);
|
|
|
|
} else if (cntImages <= 0) {
|
|
|
|
p.drawText(_left + st::setHeaderLeft, top + st::linkFont->ascent, lang(lng_settings_no_data_cached));
|
|
|
|
}
|
|
|
|
top += _localStorageClear.height();
|
2015-12-24 19:26:28 +00:00
|
|
|
|
|
|
|
// chat background
|
|
|
|
p.setFont(st::setHeaderFont->f);
|
|
|
|
p.setPen(st::setHeaderColor->p);
|
|
|
|
p.drawText(_left + st::setHeaderLeft, top + st::setHeaderTop + st::setHeaderFont->ascent, lang(lng_settings_section_background));
|
|
|
|
top += st::setHeaderSkip;
|
|
|
|
|
2016-06-22 13:39:54 +00:00
|
|
|
bool radial = false;
|
|
|
|
float64 radialOpacity = 0;
|
|
|
|
if (_radial.animating()) {
|
|
|
|
_radial.step(getms());
|
|
|
|
radial = _radial.animating();
|
|
|
|
radialOpacity = _radial.opacity();
|
|
|
|
}
|
|
|
|
if (radial) {
|
|
|
|
auto backThumb = App::main() ? App::main()->newBackgroundThumb() : ImagePtr();
|
|
|
|
if (backThumb->isNull()) {
|
|
|
|
p.drawPixmap(_left, top, _background);
|
|
|
|
} else {
|
|
|
|
const QPixmap &pix = App::main()->newBackgroundThumb()->pixBlurred(st::setBackgroundSize);
|
|
|
|
p.drawPixmap(_left, top, st::setBackgroundSize, st::setBackgroundSize, pix, 0, (pix.height() - st::setBackgroundSize) / 2, st::setBackgroundSize, st::setBackgroundSize);
|
|
|
|
}
|
2015-12-24 19:26:28 +00:00
|
|
|
|
2016-06-22 13:39:54 +00:00
|
|
|
auto outer = radialRect();
|
|
|
|
QRect inner(QPoint(outer.x() + (outer.width() - st::radialSize.width()) / 2, outer.y() + (outer.height() - st::radialSize.height()) / 2), st::radialSize);
|
|
|
|
p.setPen(Qt::NoPen);
|
|
|
|
p.setBrush(st::black);
|
|
|
|
p.setOpacity(radialOpacity * st::radialBgOpacity);
|
2015-12-24 19:26:28 +00:00
|
|
|
|
2016-06-22 13:39:54 +00:00
|
|
|
p.setRenderHint(QPainter::HighQualityAntialiasing);
|
|
|
|
p.drawEllipse(inner);
|
|
|
|
p.setRenderHint(QPainter::HighQualityAntialiasing, false);
|
2015-12-24 19:26:28 +00:00
|
|
|
|
2016-06-22 13:39:54 +00:00
|
|
|
p.setOpacity(1);
|
|
|
|
QRect arc(inner.marginsRemoved(QMargins(st::radialLine, st::radialLine, st::radialLine, st::radialLine)));
|
|
|
|
_radial.draw(p, arc, st::radialLine, st::white);
|
2015-12-24 19:26:28 +00:00
|
|
|
} else {
|
|
|
|
p.drawPixmap(_left, top, _background);
|
|
|
|
}
|
|
|
|
top += st::setBackgroundSize;
|
|
|
|
top += st::setLittleSkip;
|
|
|
|
top += _tileBackground.height();
|
2016-02-21 14:27:54 +00:00
|
|
|
if (Global::AdaptiveLayout() == Adaptive::WideLayout) {
|
|
|
|
top += st::setLittleSkip;
|
|
|
|
top += _adaptiveForWide.height();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// advanced
|
|
|
|
p.setFont(st::setHeaderFont->f);
|
|
|
|
p.setPen(st::setHeaderColor->p);
|
|
|
|
p.drawText(_left + st::setHeaderLeft, top + st::setHeaderTop + st::setHeaderFont->ascent, lang(lng_settings_section_advanced));
|
|
|
|
top += st::setHeaderSkip;
|
2016-01-01 07:42:06 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
p.setFont(st::linkFont->f);
|
|
|
|
p.setPen(st::black->p);
|
2015-03-02 12:34:16 +00:00
|
|
|
if (self()) {
|
|
|
|
top += _passcodeEdit.height() + st::setLittleSkip;
|
|
|
|
if (cHasPasscode()) {
|
|
|
|
p.drawText(_left, top + st::linkFont->ascent, _autoLockText);
|
|
|
|
top += _autoLock.height() + st::setLittleSkip;
|
|
|
|
}
|
2015-04-02 10:33:19 +00:00
|
|
|
if (!_waitingConfirm.isEmpty()) p.drawText(_left, top + st::linkFont->ascent, _waitingConfirm);
|
|
|
|
top += _passwordEdit.height() + st::setLittleSkip;
|
2015-03-02 12:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
p.drawText(_left, _connectionType.y() + st::linkFont->ascent, _connectionTypeText);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::resizeEvent(QResizeEvent *e) {
|
|
|
|
_left = (width() - st::setWidth) / 2;
|
|
|
|
|
|
|
|
int32 top = 0;
|
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
if (self()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
// profile
|
|
|
|
top += st::setTop;
|
|
|
|
top += st::setPhotoSize;
|
|
|
|
_uploadPhoto.move(_left + st::setWidth - _uploadPhoto.width(), top - _uploadPhoto.height());
|
|
|
|
_cancelPhoto.move(_left + st::setWidth - _cancelPhoto.width(), top - _uploadPhoto.height() + st::btnSetUpload.textTop + st::btnSetUpload.font->ascent - st::linkFont->ascent);
|
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
// contact info
|
|
|
|
top += st::setHeaderSkip;
|
|
|
|
top += st::linkFont->height + st::setLittleSkip;
|
2015-02-09 13:26:59 +00:00
|
|
|
_chooseUsername.move(_left + st::setContactInfoLeft, top); top += st::linkFont->height;
|
2014-10-22 18:39:03 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// notifications
|
|
|
|
top += st::setHeaderSkip;
|
|
|
|
_desktopNotify.move(_left, top); top += _desktopNotify.height() + st::setLittleSkip;
|
2014-07-18 10:37:34 +00:00
|
|
|
_senderName.move(_left, top); top += _senderName.height() + st::setLittleSkip;
|
|
|
|
_messagePreview.move(_left, top); top += _messagePreview.height() + st::setSectionSkip;
|
2015-08-11 19:50:48 +00:00
|
|
|
if (App::wnd()->psHasNativeNotifications() && cPlatform() == dbipWindows) {
|
|
|
|
_windowsNotifications.move(_left, top); top += _windowsNotifications.height() + st::setSectionSkip;
|
|
|
|
}
|
2015-08-28 15:15:56 +00:00
|
|
|
_soundNotify.move(_left, top); top += _soundNotify.height() + st::setSectionSkip;
|
|
|
|
_includeMuted.move(_left, top); top += _includeMuted.height();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// general
|
|
|
|
top += st::setHeaderSkip;
|
2014-12-19 21:20:30 +00:00
|
|
|
_changeLanguage.move(_left + st::setWidth - _changeLanguage.width(), top - st::setHeaderSkip + st::setHeaderTop + st::setHeaderFont->ascent - st::linkFont->ascent);
|
2015-08-19 22:00:37 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
2014-05-30 08:53:19 +00:00
|
|
|
_autoUpdate.move(_left, top);
|
2014-06-17 05:37:53 +00:00
|
|
|
_checkNow.move(_left + st::setWidth - _checkNow.width(), top + st::cbDefFlat.textTop); top += _autoUpdate.height();
|
2014-05-30 08:53:19 +00:00
|
|
|
_restartNow.move(_left + st::setWidth - _restartNow.width(), top + st::setVersionTop);
|
|
|
|
top += st::setVersionHeight;
|
2015-08-19 22:00:37 +00:00
|
|
|
#endif
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-06-15 12:31:03 +00:00
|
|
|
if (cPlatform() == dbipWindows) {
|
|
|
|
_workmodeTray.move(_left, top); top += _workmodeTray.height() + st::setLittleSkip;
|
|
|
|
_workmodeWindow.move(_left, top); top += _workmodeWindow.height() + st::setSectionSkip;
|
2016-01-01 07:42:06 +00:00
|
|
|
|
2014-06-15 12:31:03 +00:00
|
|
|
_autoStart.move(_left, top); top += _autoStart.height() + st::setLittleSkip;
|
2014-07-18 10:37:34 +00:00
|
|
|
_startMinimized.move(_left, top); top += _startMinimized.height() + st::setSectionSkip;
|
|
|
|
|
|
|
|
_sendToMenu.move(_left, top); top += _sendToMenu.height();
|
2015-01-15 14:22:15 +00:00
|
|
|
} else if (_supportTray) {
|
2014-09-20 21:31:03 +00:00
|
|
|
_workmodeTray.move(_left, top); top += _workmodeTray.height();
|
|
|
|
}
|
2014-06-15 12:31:03 +00:00
|
|
|
if (!cRetina()) {
|
|
|
|
top += st::setHeaderSkip;
|
|
|
|
_dpiAutoScale.move(_left, top); top += _dpiAutoScale.height() + st::setLittleSkip;
|
|
|
|
_dpiSlider.move(_left, top); top += _dpiSlider.height() + st::dpiFont4->height;
|
|
|
|
}
|
2016-01-01 07:42:06 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// chat options
|
2014-10-22 18:39:03 +00:00
|
|
|
if (self()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
top += st::setHeaderSkip;
|
|
|
|
_viewEmojis.move(_left + st::setWidth - _viewEmojis.width(), top + st::cbDefFlat.textTop);
|
2015-12-02 17:17:53 +00:00
|
|
|
_replaceEmojis.move(_left, top); top += _replaceEmojis.height() + st::setLittleSkip;
|
|
|
|
_stickers.move(_left + st::cbDefFlat.textLeft, top); top += _stickers.height() + st::setSectionSkip;
|
2014-05-30 08:53:19 +00:00
|
|
|
_enterSend.move(_left, top); top += _enterSend.height() + st::setLittleSkip;
|
|
|
|
_ctrlEnterSend.move(_left, top); top += _ctrlEnterSend.height() + st::setSectionSkip;
|
|
|
|
_dontAskDownloadPath.move(_left, top); top += _dontAskDownloadPath.height();
|
|
|
|
if (!cAskDownloadPath()) {
|
|
|
|
top += st::setLittleSkip;
|
2015-12-23 21:19:57 +00:00
|
|
|
_downloadPathEdit.move(_left + st::cbDefFlat.textLeft + _downloadPathWidth, top);
|
2014-09-30 14:11:09 +00:00
|
|
|
if (cDownloadPath() == qsl("tmp")) {
|
2014-05-30 08:53:19 +00:00
|
|
|
_downloadPathClear.move(_left + st::setWidth - _downloadPathClear.width(), top);
|
|
|
|
}
|
|
|
|
top += _downloadPathEdit.height();
|
|
|
|
}
|
2015-12-23 21:19:57 +00:00
|
|
|
top += st::setLittleSkip;
|
|
|
|
_autoDownload.move(_left + st::cbDefFlat.textLeft, top); top += _autoDownload.height();
|
2015-02-03 15:02:46 +00:00
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
// local storage
|
2015-01-02 14:55:24 +00:00
|
|
|
_localStorageClear.move(_left + st::setWidth - _localStorageClear.width(), top + st::setHeaderTop + st::setHeaderFont->ascent - st::linkFont->ascent);
|
2014-11-22 09:45:04 +00:00
|
|
|
top += st::setHeaderSkip;
|
2016-01-01 07:42:06 +00:00
|
|
|
if ((Local::hasImages() || Local::hasStickers() || Local::hasWebFiles()) && Local::hasAudios()) {
|
2015-01-02 14:55:24 +00:00
|
|
|
_localStorageHeight = 2;
|
|
|
|
top += _localStorageClear.height() + st::setLittleSkip;
|
|
|
|
} else {
|
|
|
|
_localStorageHeight = 1;
|
|
|
|
}
|
|
|
|
top += _localStorageClear.height();
|
2015-12-24 19:26:28 +00:00
|
|
|
|
|
|
|
// chat background
|
|
|
|
top += st::setHeaderSkip;
|
|
|
|
_backFromGallery.move(_left + st::setBackgroundSize + st::setLittleSkip, top);
|
|
|
|
_backFromFile.move(_left + st::setBackgroundSize + st::setLittleSkip, top + _backFromGallery.height() + st::setLittleSkip);
|
|
|
|
top += st::setBackgroundSize;
|
|
|
|
|
|
|
|
top += st::setLittleSkip;
|
|
|
|
_tileBackground.move(_left, top); top += _tileBackground.height();
|
2016-02-21 14:27:54 +00:00
|
|
|
if (Global::AdaptiveLayout() == Adaptive::WideLayout) {
|
|
|
|
top += st::setLittleSkip;
|
|
|
|
_adaptiveForWide.move(_left, top); top += _adaptiveForWide.height();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// advanced
|
|
|
|
top += st::setHeaderSkip;
|
2015-03-02 12:34:16 +00:00
|
|
|
if (self()) {
|
|
|
|
_passcodeEdit.move(_left, top);
|
|
|
|
_passcodeTurnOff.move(_left + st::setWidth - _passcodeTurnOff.width(), top); top += _passcodeTurnOff.height() + st::setLittleSkip;
|
|
|
|
if (cHasPasscode()) {
|
|
|
|
_autoLock.move(_left + _autoLockWidth, top); top += _autoLock.height() + st::setLittleSkip;
|
|
|
|
}
|
2015-04-02 10:33:19 +00:00
|
|
|
_passwordEdit.move(_left, top);
|
|
|
|
_passwordTurnOff.move(_left + st::setWidth - _passwordTurnOff.width(), top); top += _passwordTurnOff.height() + st::setLittleSkip;
|
2015-03-02 12:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_connectionType.move(_left + _connectionTypeWidth, top); top += _connectionType.height() + st::setLittleSkip;
|
2014-10-22 18:39:03 +00:00
|
|
|
if (self()) {
|
2015-04-02 10:33:19 +00:00
|
|
|
_showSessions.move(_left, top); top += _showSessions.height() + st::setSectionSkip;
|
2015-08-12 18:01:32 +00:00
|
|
|
_askQuestion.move(_left, top); top += _askQuestion.height() + st::setLittleSkip;
|
|
|
|
_telegramFAQ.move(_left, top); top += _telegramFAQ.height() + st::setSectionSkip;
|
2014-05-30 08:53:19 +00:00
|
|
|
_logOut.move(_left, top);
|
2015-08-12 18:01:32 +00:00
|
|
|
} else {
|
|
|
|
top += st::setSectionSkip - st::setLittleSkip;
|
|
|
|
_telegramFAQ.move(_left, top);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::keyPressEvent(QKeyEvent *e) {
|
2014-12-18 18:40:49 +00:00
|
|
|
if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Back) {
|
2014-05-30 08:53:19 +00:00
|
|
|
App::wnd()->showSettings();
|
|
|
|
}
|
2015-04-02 10:33:19 +00:00
|
|
|
_secretText += e->text().toLower();
|
|
|
|
int32 size = _secretText.size(), from = 0;
|
|
|
|
while (size > from) {
|
|
|
|
QStringRef str(_secretText.midRef(from));
|
2015-06-27 13:02:00 +00:00
|
|
|
if (str == qstr("debugmode")) {
|
2015-04-02 10:33:19 +00:00
|
|
|
QString text = cDebug() ? qsl("Do you want to disable DEBUG logs?") : qsl("Do you want to enable DEBUG logs?\n\nAll network events will be logged.");
|
|
|
|
ConfirmBox *box = new ConfirmBox(text);
|
|
|
|
connect(box, SIGNAL(confirmed()), App::app(), SLOT(onSwitchDebugMode()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2015-04-02 10:33:19 +00:00
|
|
|
from = size;
|
|
|
|
break;
|
2015-06-27 13:02:00 +00:00
|
|
|
} else if (str == qstr("testmode")) {
|
2015-04-02 10:33:19 +00:00
|
|
|
QString text = cTestMode() ? qsl("Do you want to disable TEST mode?") : qsl("Do you want to enable TEST mode?\n\nYou will be switched to test cloud.");
|
|
|
|
ConfirmBox *box = new ConfirmBox(text);
|
|
|
|
connect(box, SIGNAL(confirmed()), App::app(), SLOT(onSwitchTestMode()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2015-04-02 10:33:19 +00:00
|
|
|
from = size;
|
|
|
|
break;
|
2016-03-17 18:03:08 +00:00
|
|
|
} else if (str == qstr("loadlang")) {
|
|
|
|
chooseCustomLang();
|
2016-06-22 18:41:13 +00:00
|
|
|
break;
|
2016-03-17 18:03:08 +00:00
|
|
|
} else if (str == qstr("debugfiles") && cDebug()) {
|
|
|
|
if (DebugLogging::FileLoader()) {
|
|
|
|
Global::RefDebugLoggingFlags() &= ~DebugLogging::FileLoaderFlag;
|
|
|
|
} else {
|
|
|
|
Global::RefDebugLoggingFlags() |= DebugLogging::FileLoaderFlag;
|
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
Ui::showLayer(new InformBox(DebugLogging::FileLoader() ? qsl("Enabled file download logging") : qsl("Disabled file download logging")));
|
2016-06-22 18:41:13 +00:00
|
|
|
break;
|
2016-02-02 16:21:07 +00:00
|
|
|
} else if (str == qstr("crashplease")) {
|
|
|
|
t_assert(!"Crashed in Settings!");
|
2016-06-22 18:41:13 +00:00
|
|
|
break;
|
2016-04-11 10:59:01 +00:00
|
|
|
} else if (str == qstr("workmode")) {
|
2016-06-22 18:41:13 +00:00
|
|
|
auto text = Global::DialogsModeEnabled() ? qsl("Disable work mode?") : qsl("Enable work mode?");
|
2016-04-11 10:59:01 +00:00
|
|
|
auto box = std_::make_unique<ConfirmBox>(text);
|
|
|
|
connect(box.get(), SIGNAL(confirmed()), App::app(), SLOT(onSwitchWorkMode()));
|
|
|
|
Ui::showLayer(box.release());
|
|
|
|
from = size;
|
|
|
|
break;
|
2016-06-22 18:41:13 +00:00
|
|
|
} else if (str == qstr("moderate")) {
|
|
|
|
auto text = Global::ModerateModeEnabled() ? qsl("Disable moderate mode?") : qsl("Enable moderate mode?");
|
|
|
|
auto box = std_::make_unique<ConfirmBox>(text);
|
|
|
|
connect(box.get(), SIGNAL(confirmed()), this, SLOT(onSwitchModerateMode()));
|
|
|
|
Ui::showLayer(box.release());
|
|
|
|
break;
|
|
|
|
} else if (str == qstr("clearstickers")) {
|
|
|
|
auto box = std_::make_unique<ConfirmBox>(qsl("Clear frequently used stickers list?"));
|
|
|
|
connect(box.get(), SIGNAL(confirmed()), this, SLOT(onClearStickers()));
|
|
|
|
Ui::showLayer(box.release());
|
|
|
|
break;
|
2016-03-17 18:03:08 +00:00
|
|
|
} else if (
|
|
|
|
qsl("debugmode").startsWith(str) ||
|
|
|
|
qsl("testmode").startsWith(str) ||
|
|
|
|
qsl("loadlang").startsWith(str) ||
|
2016-06-22 18:41:13 +00:00
|
|
|
qsl("clearstickers").startsWith(str) ||
|
|
|
|
qsl("moderate").startsWith(str) ||
|
2016-03-17 18:03:08 +00:00
|
|
|
qsl("debugfiles").startsWith(str) ||
|
2016-04-11 10:59:01 +00:00
|
|
|
qsl("workmode").startsWith(str) ||
|
2016-03-17 18:03:08 +00:00
|
|
|
qsl("crashplease").startsWith(str)) {
|
2015-04-02 10:33:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
++from;
|
|
|
|
}
|
|
|
|
_secretText = (size > from) ? _secretText.mid(from) : QString();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::mouseMoveEvent(QMouseEvent *e) {
|
2014-10-22 18:39:03 +00:00
|
|
|
if (!self()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
setCursor(style::cur_default);
|
|
|
|
} else {
|
|
|
|
bool nameOver = QRect(_uploadPhoto.x() + st::setNameLeft, st::setTop + st::setNameTop, qMin(_uploadPhoto.width() - int(st::setNameLeft), _nameText.maxWidth()), st::setNameFont->height).contains(e->pos());
|
|
|
|
if (nameOver != _nameOver) {
|
|
|
|
_nameOver = nameOver;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool photoOver = QRect(_left, st::setTop, st::setPhotoSize, st::setPhotoSize).contains(e->pos());
|
|
|
|
if (photoOver != _photoOver) {
|
|
|
|
_photoOver = photoOver;
|
|
|
|
if (!_photoLink) {
|
2015-12-08 12:33:37 +00:00
|
|
|
a_photoOver.start(_photoOver ? 1 : 0);
|
|
|
|
_a_photo.start();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setCursor((_nameOver || _photoOver) ? style::cur_pointer : style::cur_default);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::mousePressEvent(QMouseEvent *e) {
|
|
|
|
mouseMoveEvent(e);
|
2014-10-22 18:39:03 +00:00
|
|
|
if (!self()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (QRect(_uploadPhoto.x() + st::setNameLeft, st::setTop + st::setNameTop, qMin(_uploadPhoto.width() - int(st::setNameLeft), _nameText.maxWidth()), st::setNameFont->height).contains(e->pos())) {
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(new EditNameTitleBox(self()));
|
2014-05-30 08:53:19 +00:00
|
|
|
} else if (QRect(_left, st::setTop, st::setPhotoSize, st::setPhotoSize).contains(e->pos())) {
|
|
|
|
if (_photoLink) {
|
2015-12-25 13:09:14 +00:00
|
|
|
App::photo(self()->photoId)->download();
|
2014-05-30 08:53:19 +00:00
|
|
|
_photoLink->onClick(e->button());
|
|
|
|
} else {
|
|
|
|
onUpdatePhoto();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::contextMenuEvent(QContextMenuEvent *e) {
|
|
|
|
}
|
|
|
|
|
2016-02-21 14:27:54 +00:00
|
|
|
void SettingsInner::updateAdaptiveLayout() {
|
|
|
|
showAll();
|
|
|
|
resizeEvent(0);
|
|
|
|
}
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void SettingsInner::step_photo(float64 ms, bool timer) {
|
2014-05-30 08:53:19 +00:00
|
|
|
float64 dt = ms / st::setPhotoDuration;
|
|
|
|
if (dt >= 1) {
|
2015-12-08 12:33:37 +00:00
|
|
|
_a_photo.stop();
|
|
|
|
a_photoOver.finish();
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2015-12-08 12:33:37 +00:00
|
|
|
a_photoOver.update(dt, anim::linear);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-12-08 12:33:37 +00:00
|
|
|
if (timer) update(_left, st::setTop, st::setPhotoSize, st::setPhotoSize);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::updateSize(int32 newWidth) {
|
|
|
|
if (_logOut.isHidden()) {
|
2015-08-12 18:01:32 +00:00
|
|
|
resize(newWidth, _telegramFAQ.geometry().bottom() + st::setBottom);
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
|
|
|
resize(newWidth, _logOut.geometry().bottom() + st::setBottom);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-04 06:14:20 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void SettingsInner::updateOnlineDisplay() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::updateConnectionType() {
|
2015-06-25 18:04:40 +00:00
|
|
|
QString connection;
|
2014-05-30 08:53:19 +00:00
|
|
|
switch (cConnectionType()) {
|
|
|
|
case dbictAuto: {
|
|
|
|
QString transport = MTP::dctransport();
|
2015-06-25 18:04:40 +00:00
|
|
|
connection = transport.isEmpty() ? lang(lng_connection_auto_connecting) : lng_connection_auto(lt_transport, transport);
|
|
|
|
} break;
|
|
|
|
case dbictHttpProxy:
|
|
|
|
case dbictTcpProxy: {
|
|
|
|
QString transport = MTP::dctransport();
|
|
|
|
connection = transport.isEmpty() ? lang(lng_connection_proxy_connecting) : lng_connection_proxy(lt_transport, transport);
|
2014-05-30 08:53:19 +00:00
|
|
|
} break;
|
|
|
|
}
|
2015-06-25 18:04:40 +00:00
|
|
|
_connectionType.setText(connection);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2015-03-02 12:34:16 +00:00
|
|
|
void SettingsInner::passcodeChanged() {
|
|
|
|
resizeEvent(0);
|
|
|
|
_passcodeEdit.setText(lang(cHasPasscode() ? lng_passcode_change : lng_passcode_turn_on));
|
|
|
|
_autoLock.setText((cAutoLock() % 3600) ? lng_passcode_autolock_minutes(lt_count, cAutoLock() / 60) : lng_passcode_autolock_hours(lt_count, cAutoLock() / 3600));
|
2015-04-02 10:33:19 +00:00
|
|
|
// _passwordEdit.setText()
|
2015-03-02 12:34:16 +00:00
|
|
|
showAll();
|
|
|
|
}
|
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
void SettingsInner::updateBackgroundRect() {
|
2016-06-22 13:39:54 +00:00
|
|
|
update(radialRect());
|
2015-02-03 15:02:46 +00:00
|
|
|
}
|
|
|
|
|
2015-12-07 10:06:59 +00:00
|
|
|
void SettingsInner::onFullPeerUpdated(PeerData *peer) {
|
|
|
|
if (!self() || self() != peer) return;
|
|
|
|
|
2015-06-29 22:09:23 +00:00
|
|
|
PhotoData *selfPhoto = (self()->photoId && self()->photoId != UnknownPeerPhotoId) ? App::photo(self()->photoId) : 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
if (selfPhoto && selfPhoto->date) {
|
2016-03-29 17:17:00 +00:00
|
|
|
_photoLink.reset(new PhotoOpenClickHandler(selfPhoto, self()));
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2016-03-29 17:17:00 +00:00
|
|
|
_photoLink.clear();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
void SettingsInner::gotPassword(const MTPaccount_Password &result) {
|
|
|
|
_waitingConfirm = QString();
|
|
|
|
|
|
|
|
switch (result.type()) {
|
|
|
|
case mtpc_account_noPassword: {
|
2016-04-08 10:44:35 +00:00
|
|
|
const auto &d(result.c_account_noPassword());
|
2015-04-02 10:33:19 +00:00
|
|
|
_curPasswordSalt = QByteArray();
|
|
|
|
_hasPasswordRecovery = false;
|
|
|
|
_curPasswordHint = QString();
|
|
|
|
_newPasswordSalt = qba(d.vnew_salt);
|
|
|
|
QString pattern = qs(d.vemail_unconfirmed_pattern);
|
|
|
|
if (!pattern.isEmpty()) _waitingConfirm = lng_cloud_password_waiting(lt_email, pattern);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case mtpc_account_password: {
|
2016-04-08 10:44:35 +00:00
|
|
|
const auto &d(result.c_account_password());
|
2015-04-02 10:33:19 +00:00
|
|
|
_curPasswordSalt = qba(d.vcurrent_salt);
|
2015-10-29 00:16:52 +00:00
|
|
|
_hasPasswordRecovery = mtpIsTrue(d.vhas_recovery);
|
2015-04-02 10:33:19 +00:00
|
|
|
_curPasswordHint = qs(d.vhint);
|
|
|
|
_newPasswordSalt = qba(d.vnew_salt);
|
|
|
|
QString pattern = qs(d.vemail_unconfirmed_pattern);
|
|
|
|
if (!pattern.isEmpty()) _waitingConfirm = lng_cloud_password_waiting(lt_email, pattern);
|
|
|
|
} break;
|
|
|
|
}
|
2015-10-03 10:09:09 +00:00
|
|
|
_waitingConfirm = st::linkFont->elided(_waitingConfirm, st::setWidth - _passwordTurnOff.width());
|
2015-04-02 10:33:19 +00:00
|
|
|
_passwordEdit.setText(lang(_curPasswordSalt.isEmpty() ? lng_cloud_password_set : lng_cloud_password_edit));
|
|
|
|
showAll();
|
|
|
|
update();
|
|
|
|
|
|
|
|
_newPasswordSalt.resize(_newPasswordSalt.size() + 8);
|
|
|
|
memset_rand(_newPasswordSalt.data() + _newPasswordSalt.size() - 8, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::offPasswordDone(const MTPBool &result) {
|
|
|
|
onReloadPassword();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SettingsInner::offPasswordFail(const RPCError &error) {
|
2016-04-08 10:44:35 +00:00
|
|
|
if (MTP::isDefaultHandledError(error)) return false;
|
2015-04-04 20:01:34 +00:00
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
onReloadPassword();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
void SettingsInner::usernameChanged() {
|
2015-02-09 13:26:59 +00:00
|
|
|
_chooseUsername.setText((self() && !self()->username.isEmpty()) ? ('@' + self()->username) : lang(lng_settings_choose_username));
|
2014-10-22 18:39:03 +00:00
|
|
|
showAll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void SettingsInner::showAll() {
|
|
|
|
// profile
|
2014-10-22 18:39:03 +00:00
|
|
|
if (self()) {
|
|
|
|
if (App::app()->isPhotoUpdating(self()->id)) {
|
2014-05-30 08:53:19 +00:00
|
|
|
_cancelPhoto.show();
|
|
|
|
_uploadPhoto.hide();
|
|
|
|
} else {
|
|
|
|
_cancelPhoto.hide();
|
|
|
|
_uploadPhoto.show();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_uploadPhoto.hide();
|
|
|
|
_cancelPhoto.hide();
|
|
|
|
}
|
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
// contact info
|
|
|
|
if (self()) {
|
2015-02-09 13:26:59 +00:00
|
|
|
_chooseUsername.show();
|
2014-10-22 18:39:03 +00:00
|
|
|
} else {
|
|
|
|
_chooseUsername.hide();
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// notifications
|
2014-10-22 18:39:03 +00:00
|
|
|
if (self()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
_desktopNotify.show();
|
2014-07-18 10:37:34 +00:00
|
|
|
_senderName.show();
|
|
|
|
_messagePreview.show();
|
2015-08-11 19:50:48 +00:00
|
|
|
if (App::wnd()->psHasNativeNotifications() && cPlatform() == dbipWindows) {
|
|
|
|
_windowsNotifications.show();
|
|
|
|
} else {
|
|
|
|
_windowsNotifications.hide();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
_soundNotify.show();
|
2015-08-28 15:15:56 +00:00
|
|
|
_includeMuted.show();
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
|
|
|
_desktopNotify.hide();
|
2014-07-18 10:37:34 +00:00
|
|
|
_senderName.hide();
|
|
|
|
_messagePreview.hide();
|
2015-08-11 19:50:48 +00:00
|
|
|
_windowsNotifications.hide();
|
2014-05-30 08:53:19 +00:00
|
|
|
_soundNotify.hide();
|
2015-08-28 15:15:56 +00:00
|
|
|
_includeMuted.hide();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// general
|
2014-12-19 21:20:30 +00:00
|
|
|
_changeLanguage.show();
|
2015-08-19 22:00:37 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
2014-05-30 08:53:19 +00:00
|
|
|
_autoUpdate.show();
|
|
|
|
setUpdatingState(_updatingState, true);
|
2015-08-19 22:00:37 +00:00
|
|
|
#endif
|
2014-06-15 12:31:03 +00:00
|
|
|
if (cPlatform() == dbipWindows) {
|
|
|
|
_workmodeTray.show();
|
|
|
|
_workmodeWindow.show();
|
|
|
|
|
|
|
|
_autoStart.show();
|
|
|
|
_startMinimized.show();
|
2014-07-18 10:37:34 +00:00
|
|
|
|
|
|
|
_sendToMenu.show();
|
2014-06-15 12:31:03 +00:00
|
|
|
} else {
|
2015-01-15 14:22:15 +00:00
|
|
|
if (_supportTray) {
|
2014-09-20 21:31:03 +00:00
|
|
|
_workmodeTray.show();
|
|
|
|
} else {
|
|
|
|
_workmodeTray.hide();
|
|
|
|
}
|
2014-06-15 12:31:03 +00:00
|
|
|
_workmodeWindow.hide();
|
2016-01-01 07:42:06 +00:00
|
|
|
|
2014-06-15 12:31:03 +00:00
|
|
|
_autoStart.hide();
|
|
|
|
_startMinimized.hide();
|
2014-07-18 10:37:34 +00:00
|
|
|
|
2014-07-18 11:12:18 +00:00
|
|
|
_sendToMenu.hide();
|
2014-07-18 10:37:34 +00:00
|
|
|
}
|
2014-06-15 12:31:03 +00:00
|
|
|
if (cRetina()) {
|
|
|
|
_dpiSlider.hide();
|
|
|
|
_dpiAutoScale.hide();
|
|
|
|
} else {
|
|
|
|
_dpiSlider.show();
|
|
|
|
_dpiAutoScale.show();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
// chat options
|
2014-10-22 18:39:03 +00:00
|
|
|
if (self()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
_replaceEmojis.show();
|
|
|
|
if (cReplaceEmojis()) {
|
|
|
|
_viewEmojis.show();
|
|
|
|
} else {
|
|
|
|
_viewEmojis.hide();
|
|
|
|
}
|
2015-12-02 17:17:53 +00:00
|
|
|
_stickers.show();
|
2014-05-30 08:53:19 +00:00
|
|
|
_enterSend.show();
|
|
|
|
_ctrlEnterSend.show();
|
|
|
|
_dontAskDownloadPath.show();
|
|
|
|
if (cAskDownloadPath()) {
|
|
|
|
_downloadPathEdit.hide();
|
|
|
|
_downloadPathClear.hide();
|
|
|
|
} else {
|
|
|
|
_downloadPathEdit.show();
|
2014-09-30 14:11:09 +00:00
|
|
|
if (cDownloadPath() == qsl("tmp") && _tempDirClearState == TempDirExists) { // dir exists, not clearing right now
|
2014-05-30 08:53:19 +00:00
|
|
|
_downloadPathClear.show();
|
|
|
|
} else {
|
|
|
|
_downloadPathClear.hide();
|
|
|
|
}
|
|
|
|
}
|
2015-12-23 21:19:57 +00:00
|
|
|
_autoDownload.show();
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
|
|
|
_replaceEmojis.hide();
|
|
|
|
_viewEmojis.hide();
|
2015-12-02 17:17:53 +00:00
|
|
|
_stickers.hide();
|
2014-05-30 08:53:19 +00:00
|
|
|
_enterSend.hide();
|
|
|
|
_ctrlEnterSend.hide();
|
|
|
|
_dontAskDownloadPath.hide();
|
|
|
|
_downloadPathEdit.hide();
|
|
|
|
_downloadPathClear.hide();
|
2015-12-23 21:19:57 +00:00
|
|
|
_autoDownload.hide();
|
2014-11-22 09:45:04 +00:00
|
|
|
}
|
|
|
|
|
2015-12-24 19:26:28 +00:00
|
|
|
// local storage
|
|
|
|
if (self() && _storageClearState == TempDirExists) {
|
|
|
|
_localStorageClear.show();
|
|
|
|
} else {
|
|
|
|
_localStorageClear.hide();
|
|
|
|
}
|
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
// chat background
|
|
|
|
if (self()) {
|
|
|
|
_backFromGallery.show();
|
|
|
|
_backFromFile.show();
|
|
|
|
_tileBackground.show();
|
2016-02-21 14:27:54 +00:00
|
|
|
if (Global::AdaptiveLayout() == Adaptive::WideLayout) {
|
|
|
|
_adaptiveForWide.show();
|
|
|
|
} else {
|
|
|
|
_adaptiveForWide.hide();
|
|
|
|
}
|
2015-02-03 15:02:46 +00:00
|
|
|
} else {
|
|
|
|
_backFromGallery.hide();
|
|
|
|
_backFromFile.hide();
|
|
|
|
_tileBackground.hide();
|
2016-02-21 14:27:54 +00:00
|
|
|
_adaptiveForWide.hide();
|
2015-02-03 15:02:46 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
// advanced
|
2014-10-22 18:39:03 +00:00
|
|
|
if (self()) {
|
2015-03-02 12:34:16 +00:00
|
|
|
_passcodeEdit.show();
|
|
|
|
if (cHasPasscode()) {
|
|
|
|
_autoLock.show();
|
|
|
|
_passcodeTurnOff.show();
|
|
|
|
} else {
|
|
|
|
_autoLock.hide();
|
|
|
|
_passcodeTurnOff.hide();
|
|
|
|
}
|
2015-04-02 10:33:19 +00:00
|
|
|
if (_waitingConfirm.isEmpty()) {
|
|
|
|
_passwordEdit.show();
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2015-04-02 10:33:19 +00:00
|
|
|
_passwordEdit.hide();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-04-02 10:33:19 +00:00
|
|
|
if (_curPasswordSalt.isEmpty() && _waitingConfirm.isEmpty()) {
|
|
|
|
_passwordTurnOff.hide();
|
|
|
|
} else {
|
|
|
|
_passwordTurnOff.show();
|
|
|
|
}
|
|
|
|
_showSessions.show();
|
2015-08-12 18:01:32 +00:00
|
|
|
_askQuestion.show();
|
2014-05-30 08:53:19 +00:00
|
|
|
_logOut.show();
|
|
|
|
} else {
|
2015-03-02 12:34:16 +00:00
|
|
|
_passcodeEdit.hide();
|
|
|
|
_autoLock.hide();
|
|
|
|
_passcodeTurnOff.hide();
|
2015-04-02 10:33:19 +00:00
|
|
|
_passwordEdit.hide();
|
|
|
|
_passwordTurnOff.hide();
|
|
|
|
_showSessions.hide();
|
2015-08-12 18:01:32 +00:00
|
|
|
_askQuestion.hide();
|
2014-05-30 08:53:19 +00:00
|
|
|
_logOut.hide();
|
|
|
|
}
|
2015-08-12 18:01:32 +00:00
|
|
|
_telegramFAQ.show();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::saveError(const QString &str) {
|
|
|
|
_errorText = str;
|
|
|
|
resizeEvent(0);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2015-08-12 18:01:32 +00:00
|
|
|
void SettingsInner::supportGot(const MTPhelp_Support &support) {
|
|
|
|
if (!App::main()) return;
|
|
|
|
|
|
|
|
if (support.type() == mtpc_help_support) {
|
2016-04-08 10:44:35 +00:00
|
|
|
const auto &d(support.c_help_support());
|
2015-08-12 18:01:32 +00:00
|
|
|
UserData *u = App::feedUsers(MTP_vector<MTPUser>(1, d.vuser));
|
2015-12-13 11:36:08 +00:00
|
|
|
Ui::showPeerHistory(u, ShowAtUnreadMsgId);
|
2015-08-12 18:01:32 +00:00
|
|
|
App::wnd()->hideSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void SettingsInner::onUpdatePhotoCancel() {
|
2014-10-22 18:39:03 +00:00
|
|
|
if (self()) {
|
|
|
|
App::app()->cancelPhotoUpdate(self()->id);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
showAll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onUpdatePhoto() {
|
2016-04-04 08:55:47 +00:00
|
|
|
if (!self()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
saveError();
|
|
|
|
|
2016-01-01 07:42:06 +00:00
|
|
|
QStringList imgExtensions(cImgExtensions());
|
2014-05-30 08:53:19 +00:00
|
|
|
QString filter(qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;All files (*.*)"));
|
|
|
|
|
|
|
|
QImage img;
|
|
|
|
QString file;
|
|
|
|
QByteArray remoteContent;
|
|
|
|
if (filedialogGetOpenFile(file, remoteContent, lang(lng_choose_images), filter)) {
|
|
|
|
if (!remoteContent.isEmpty()) {
|
|
|
|
img = App::readImage(remoteContent);
|
|
|
|
} else {
|
|
|
|
if (!file.isEmpty()) {
|
|
|
|
img = App::readImage(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (img.isNull() || img.width() > 10 * img.height() || img.height() > 10 * img.width()) {
|
|
|
|
saveError(lang(lng_bad_photo));
|
|
|
|
return;
|
|
|
|
}
|
2015-11-09 09:51:22 +00:00
|
|
|
PhotoCropBox *box = new PhotoCropBox(img, self());
|
2014-05-30 08:53:19 +00:00
|
|
|
connect(box, SIGNAL(closed()), this, SLOT(onPhotoUpdateStart()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
void SettingsInner::onShowSessions() {
|
|
|
|
SessionsBox *box = new SessionsBox();
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2014-12-19 21:20:30 +00:00
|
|
|
}
|
|
|
|
|
2016-06-22 18:41:13 +00:00
|
|
|
void SettingsInner::onClearStickers() {
|
|
|
|
auto &recent(cGetRecentStickers());
|
|
|
|
if (!recent.isEmpty()) {
|
|
|
|
recent.clear();
|
|
|
|
Local::writeUserSettings();
|
|
|
|
}
|
|
|
|
auto &sets(Global::RefStickerSets());
|
|
|
|
auto it = sets.find(Stickers::CustomSetId);
|
|
|
|
if (it != sets.cend()) {
|
|
|
|
sets.erase(it);
|
|
|
|
Local::writeStickers();
|
|
|
|
}
|
|
|
|
if (auto m = App::main()) {
|
|
|
|
emit m->stickersUpdated();
|
|
|
|
}
|
|
|
|
Ui::hideLayer();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onSwitchModerateMode() {
|
|
|
|
Global::SetModerateModeEnabled(!Global::ModerateModeEnabled());
|
|
|
|
Local::writeUserSettings();
|
|
|
|
Ui::hideLayer();
|
|
|
|
}
|
|
|
|
|
2015-08-12 18:01:32 +00:00
|
|
|
void SettingsInner::onAskQuestion() {
|
|
|
|
if (!App::self()) return;
|
|
|
|
|
2015-10-03 10:09:09 +00:00
|
|
|
ConfirmBox *box = new ConfirmBox(lang(lng_settings_ask_sure), lang(lng_settings_ask_ok), st::defaultBoxButton, lang(lng_settings_faq_button));
|
2015-08-12 18:01:32 +00:00
|
|
|
connect(box, SIGNAL(confirmed()), this, SLOT(onAskQuestionSure()));
|
|
|
|
connect(box, SIGNAL(cancelPressed()), this, SLOT(onTelegramFAQ()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2015-08-12 18:01:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onAskQuestionSure() {
|
|
|
|
if (_supportGetRequest) return;
|
|
|
|
_supportGetRequest = MTP::send(MTPhelp_GetSupport(), rpcDone(&SettingsInner::supportGot));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onTelegramFAQ() {
|
2015-10-12 21:02:10 +00:00
|
|
|
QDesktopServices::openUrl(telegramFaqLink());
|
2015-08-12 18:01:32 +00:00
|
|
|
}
|
|
|
|
|
2015-08-13 15:09:04 +00:00
|
|
|
void SettingsInner::chooseCustomLang() {
|
|
|
|
QString file;
|
|
|
|
QByteArray arr;
|
|
|
|
if (filedialogGetOpenFile(file, arr, qsl("Choose language .strings file"), qsl("Language files (*.strings)"))) {
|
|
|
|
_testlang = QFileInfo(file).absoluteFilePath();
|
2015-10-11 08:37:24 +00:00
|
|
|
LangLoaderPlain loader(_testlang, LangLoaderRequest(lng_sure_save_language, lng_cancel, lng_box_ok));
|
2015-08-13 15:09:04 +00:00
|
|
|
if (loader.errors().isEmpty()) {
|
|
|
|
LangLoaderResult result = loader.found();
|
|
|
|
QString text = result.value(lng_sure_save_language, langOriginal(lng_sure_save_language)),
|
2015-10-03 10:09:09 +00:00
|
|
|
save = result.value(lng_box_ok, langOriginal(lng_box_ok)),
|
2015-10-11 08:37:24 +00:00
|
|
|
cancel = result.value(lng_cancel, langOriginal(lng_cancel));
|
2015-10-03 10:09:09 +00:00
|
|
|
ConfirmBox *box = new ConfirmBox(text, save, st::defaultBoxButton, cancel);
|
2015-08-13 15:09:04 +00:00
|
|
|
connect(box, SIGNAL(confirmed()), this, SLOT(onSaveTestLang()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2015-08-13 15:09:04 +00:00
|
|
|
} else {
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(new InformBox("Custom lang failed :(\n\nError: " + loader.errors()));
|
2015-08-13 15:09:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-19 21:20:30 +00:00
|
|
|
void SettingsInner::onChangeLanguage() {
|
2014-12-20 21:33:08 +00:00
|
|
|
if ((_changeLanguage.clickModifiers() & Qt::ShiftModifier) && (_changeLanguage.clickModifiers() & Qt::AltModifier)) {
|
2015-08-13 15:09:04 +00:00
|
|
|
chooseCustomLang();
|
2014-12-20 21:33:08 +00:00
|
|
|
} else {
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(new LanguageBox());
|
2014-12-20 21:33:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onSaveTestLang() {
|
|
|
|
cSetLangFile(_testlang);
|
|
|
|
cSetLang(languageTest);
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeSettings();
|
2014-12-20 21:33:08 +00:00
|
|
|
cSetRestarting(true);
|
|
|
|
App::quit();
|
2014-12-19 21:20:30 +00:00
|
|
|
}
|
|
|
|
|
2015-01-02 14:55:24 +00:00
|
|
|
void SettingsInner::onUpdateLocalStorage() {
|
|
|
|
resizeEvent(0);
|
|
|
|
updateSize(width());
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2015-08-19 22:00:37 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
2014-05-30 08:53:19 +00:00
|
|
|
void SettingsInner::onAutoUpdate() {
|
|
|
|
cSetAutoUpdate(!cAutoUpdate());
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeSettings();
|
2014-05-30 08:53:19 +00:00
|
|
|
resizeEvent(0);
|
|
|
|
if (cAutoUpdate()) {
|
2016-02-08 14:54:55 +00:00
|
|
|
Sandbox::startUpdateCheck();
|
2014-05-30 08:53:19 +00:00
|
|
|
if (_updatingState == UpdatingNone) {
|
|
|
|
_checkNow.show();
|
|
|
|
} else if (_updatingState == UpdatingReady) {
|
|
|
|
_restartNow.show();
|
|
|
|
}
|
|
|
|
} else {
|
2016-02-08 14:54:55 +00:00
|
|
|
Sandbox::stopUpdate();
|
2014-05-30 08:53:19 +00:00
|
|
|
_restartNow.hide();
|
|
|
|
_checkNow.hide();
|
|
|
|
}
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onCheckNow() {
|
|
|
|
if (!cAutoUpdate()) return;
|
|
|
|
|
|
|
|
cSetLastUpdateCheck(0);
|
2016-02-08 14:54:55 +00:00
|
|
|
Sandbox::startUpdateCheck();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-08-19 22:00:37 +00:00
|
|
|
#endif
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void SettingsInner::onRestartNow() {
|
2016-01-30 16:31:10 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
2015-06-03 18:13:01 +00:00
|
|
|
checkReadyUpdate();
|
2014-05-30 08:53:19 +00:00
|
|
|
if (_updatingState == UpdatingReady) {
|
|
|
|
cSetRestartingUpdate(true);
|
|
|
|
} else {
|
|
|
|
cSetRestarting(true);
|
2014-12-19 21:20:30 +00:00
|
|
|
cSetRestartingToSettings(true);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2016-01-30 16:31:10 +00:00
|
|
|
#else
|
2015-08-19 22:00:37 +00:00
|
|
|
cSetRestarting(true);
|
|
|
|
cSetRestartingToSettings(true);
|
2016-01-30 16:31:10 +00:00
|
|
|
#endif
|
2014-05-30 08:53:19 +00:00
|
|
|
App::quit();
|
|
|
|
}
|
|
|
|
|
2015-03-02 12:34:16 +00:00
|
|
|
void SettingsInner::onPasscode() {
|
|
|
|
PasscodeBox *box = new PasscodeBox();
|
|
|
|
connect(box, SIGNAL(closed()), this, SLOT(passcodeChanged()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2015-03-02 12:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onPasscodeOff() {
|
|
|
|
PasscodeBox *box = new PasscodeBox(true);
|
|
|
|
connect(box, SIGNAL(closed()), this, SLOT(passcodeChanged()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2015-03-02 12:34:16 +00:00
|
|
|
}
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
void SettingsInner::onPassword() {
|
|
|
|
PasscodeBox *box = new PasscodeBox(_newPasswordSalt, _curPasswordSalt, _hasPasswordRecovery, _curPasswordHint);
|
|
|
|
connect(box, SIGNAL(reloadPassword()), this, SLOT(onReloadPassword()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2015-04-02 10:33:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onPasswordOff() {
|
|
|
|
if (_curPasswordSalt.isEmpty()) {
|
|
|
|
_passwordTurnOff.hide();
|
|
|
|
|
|
|
|
// int32 flags = MTPDaccount_passwordInputSettings::flag_new_salt | MTPDaccount_passwordInputSettings::flag_new_password_hash | MTPDaccount_passwordInputSettings::flag_hint | MTPDaccount_passwordInputSettings::flag_email;
|
2016-03-19 16:55:15 +00:00
|
|
|
MTPDaccount_passwordInputSettings::Flags flags = MTPDaccount_passwordInputSettings::Flag::f_email;
|
2016-04-01 10:23:40 +00:00
|
|
|
MTPaccount_PasswordInputSettings settings(MTP_account_passwordInputSettings(MTP_flags(flags), MTP_bytes(QByteArray()), MTP_bytes(QByteArray()), MTP_string(QString()), MTP_string(QString())));
|
|
|
|
MTP::send(MTPaccount_UpdatePasswordSettings(MTP_bytes(QByteArray()), settings), rpcDone(&SettingsInner::offPasswordDone), rpcFail(&SettingsInner::offPasswordFail));
|
2015-04-02 10:33:19 +00:00
|
|
|
} else {
|
|
|
|
PasscodeBox *box = new PasscodeBox(_newPasswordSalt, _curPasswordSalt, _hasPasswordRecovery, _curPasswordHint, true);
|
|
|
|
connect(box, SIGNAL(reloadPassword()), this, SLOT(onReloadPassword()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2015-04-02 10:33:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onReloadPassword(Qt::ApplicationState state) {
|
|
|
|
if (state == Qt::ApplicationActive) {
|
|
|
|
MTP::send(MTPaccount_GetPassword(), rpcDone(&SettingsInner::gotPassword));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-02 12:34:16 +00:00
|
|
|
void SettingsInner::onAutoLock() {
|
|
|
|
AutoLockBox *box = new AutoLockBox();
|
|
|
|
connect(box, SIGNAL(closed()), this, SLOT(passcodeChanged()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2015-03-02 12:34:16 +00:00
|
|
|
}
|
|
|
|
|
2016-03-20 08:16:35 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
2014-05-30 08:53:19 +00:00
|
|
|
void SettingsInner::onConnectionType() {
|
|
|
|
ConnectionBox *box = new ConnectionBox();
|
|
|
|
connect(box, SIGNAL(closed()), this, SLOT(updateConnectionType()), Qt::QueuedConnection);
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2016-03-20 08:16:35 +00:00
|
|
|
#endif
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-10-22 18:39:03 +00:00
|
|
|
void SettingsInner::onUsername() {
|
|
|
|
UsernameBox *box = new UsernameBox();
|
|
|
|
connect(box, SIGNAL(closed()), this, SLOT(usernameChanged()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2014-10-22 18:39:03 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void SettingsInner::onWorkmodeTray() {
|
2014-09-20 21:31:03 +00:00
|
|
|
if ((!_workmodeTray.checked() || cPlatform() != dbipWindows) && !_workmodeWindow.checked()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
_workmodeWindow.setChecked(true);
|
|
|
|
}
|
|
|
|
DBIWorkMode newMode = (_workmodeTray.checked() && _workmodeWindow.checked()) ? dbiwmWindowAndTray : (_workmodeTray.checked() ? dbiwmTrayOnly : dbiwmWindowOnly);
|
|
|
|
if (cWorkMode() != newMode && (newMode == dbiwmWindowAndTray || newMode == dbiwmTrayOnly)) {
|
|
|
|
cSetSeenTrayTooltip(false);
|
|
|
|
}
|
|
|
|
cSetWorkMode(newMode);
|
|
|
|
App::wnd()->psUpdateWorkmode();
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeSettings();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onWorkmodeWindow() {
|
|
|
|
if (!_workmodeTray.checked() && !_workmodeWindow.checked()) {
|
|
|
|
_workmodeTray.setChecked(true);
|
|
|
|
}
|
|
|
|
DBIWorkMode newMode = (_workmodeTray.checked() && _workmodeWindow.checked()) ? dbiwmWindowAndTray : (_workmodeTray.checked() ? dbiwmTrayOnly : dbiwmWindowOnly);
|
|
|
|
if (cWorkMode() != newMode && (newMode == dbiwmWindowAndTray || newMode == dbiwmTrayOnly)) {
|
|
|
|
cSetSeenTrayTooltip(false);
|
|
|
|
}
|
|
|
|
cSetWorkMode(newMode);
|
|
|
|
App::wnd()->psUpdateWorkmode();
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeSettings();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onAutoStart() {
|
|
|
|
_startMinimized.setDisabled(!_autoStart.checked());
|
|
|
|
cSetAutoStart(_autoStart.checked());
|
|
|
|
if (!_autoStart.checked() && _startMinimized.checked()) {
|
|
|
|
psAutoStart(false);
|
|
|
|
_startMinimized.setChecked(false);
|
|
|
|
} else {
|
|
|
|
psAutoStart(_autoStart.checked());
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeSettings();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onStartMinimized() {
|
|
|
|
cSetStartMinimized(_startMinimized.checked());
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeSettings();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2014-07-18 10:37:34 +00:00
|
|
|
void SettingsInner::onSendToMenu() {
|
|
|
|
cSetSendToMenu(_sendToMenu.checked());
|
|
|
|
psSendToMenu(_sendToMenu.checked());
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeSettings();
|
2014-07-18 10:37:34 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void SettingsInner::onScaleAuto() {
|
|
|
|
DBIScale newScale = _dpiAutoScale.checked() ? dbisAuto : cEvalScale(cConfigScale());
|
|
|
|
if (newScale == cScreenScale()) {
|
|
|
|
if (newScale != cScale()) {
|
|
|
|
newScale = cScale();
|
|
|
|
} else {
|
|
|
|
switch (newScale) {
|
|
|
|
case dbisOne: newScale = dbisOneAndQuarter; break;
|
|
|
|
case dbisOneAndQuarter: newScale = dbisOne; break;
|
|
|
|
case dbisOneAndHalf: newScale = dbisOneAndQuarter; break;
|
|
|
|
case dbisTwo: newScale = dbisOneAndHalf; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setScale(newScale);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onScaleChange() {
|
|
|
|
DBIScale newScale = dbisAuto;
|
|
|
|
switch (_dpiSlider.selected()) {
|
|
|
|
case 0: newScale = dbisOne; break;
|
|
|
|
case 1: newScale = dbisOneAndQuarter; break;
|
|
|
|
case 2: newScale = dbisOneAndHalf; break;
|
|
|
|
case 3: newScale = dbisTwo; break;
|
|
|
|
}
|
|
|
|
if (newScale == cScreenScale()) {
|
|
|
|
newScale = dbisAuto;
|
|
|
|
}
|
|
|
|
setScale(newScale);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::setScale(DBIScale newScale) {
|
|
|
|
if (cConfigScale() == newScale) return;
|
|
|
|
|
|
|
|
cSetConfigScale(newScale);
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeSettings();
|
2014-05-30 08:53:19 +00:00
|
|
|
App::wnd()->getTitle()->showUpdateBtn();
|
|
|
|
if (newScale == dbisAuto && !_dpiAutoScale.checked()) {
|
|
|
|
_dpiAutoScale.setChecked(true);
|
|
|
|
} else if (newScale != dbisAuto && _dpiAutoScale.checked()) {
|
|
|
|
_dpiAutoScale.setChecked(false);
|
|
|
|
}
|
|
|
|
if (newScale == dbisAuto) newScale = cScreenScale();
|
|
|
|
if (_dpiSlider.selected() != newScale - 1) {
|
|
|
|
_dpiSlider.setSelected(newScale - 1);
|
|
|
|
}
|
|
|
|
if (cEvalScale(cConfigScale()) != cEvalScale(cRealScale())) {
|
2015-10-03 10:09:09 +00:00
|
|
|
ConfirmBox *box = new ConfirmBox(lang(lng_settings_need_restart), lang(lng_settings_restart_now), st::defaultBoxButton, lang(lng_settings_restart_later));
|
2014-05-30 08:53:19 +00:00
|
|
|
connect(box, SIGNAL(confirmed()), this, SLOT(onRestartNow()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onSoundNotify() {
|
|
|
|
cSetSoundNotify(_soundNotify.checked());
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeUserSettings();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2015-08-28 15:15:56 +00:00
|
|
|
void SettingsInner::onIncludeMuted() {
|
|
|
|
cSetIncludeMuted(_includeMuted.checked());
|
2016-04-14 19:24:42 +00:00
|
|
|
Notify::unreadCounterUpdated();
|
2015-08-28 15:15:56 +00:00
|
|
|
Local::writeUserSettings();
|
|
|
|
}
|
|
|
|
|
2015-08-11 19:50:48 +00:00
|
|
|
void SettingsInner::onWindowsNotifications() {
|
2015-10-06 19:49:23 +00:00
|
|
|
if (cPlatform() != dbipWindows) return;
|
2015-08-11 19:50:48 +00:00
|
|
|
cSetWindowsNotifications(!cWindowsNotifications());
|
|
|
|
App::wnd()->notifyClearFast();
|
|
|
|
cSetCustomNotifies(!cWindowsNotifications());
|
|
|
|
Local::writeUserSettings();
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void SettingsInner::onDesktopNotify() {
|
|
|
|
cSetDesktopNotify(_desktopNotify.checked());
|
|
|
|
if (!_desktopNotify.checked()) {
|
2014-07-06 03:32:21 +00:00
|
|
|
App::wnd()->notifyClear();
|
2014-07-18 10:37:34 +00:00
|
|
|
_senderName.setDisabled(true);
|
|
|
|
_messagePreview.setDisabled(true);
|
|
|
|
} else {
|
|
|
|
_senderName.setDisabled(false);
|
|
|
|
_messagePreview.setDisabled(!_senderName.checked());
|
|
|
|
}
|
2015-10-12 21:48:14 +00:00
|
|
|
Local::writeUserSettings();
|
|
|
|
if (App::wnd()) App::wnd()->updateTrayMenu();
|
2014-07-18 10:37:34 +00:00
|
|
|
}
|
|
|
|
|
2015-02-04 06:14:20 +00:00
|
|
|
void SettingsInner::enableDisplayNotify(bool enable)
|
|
|
|
{
|
|
|
|
_desktopNotify.setChecked(enable);
|
|
|
|
}
|
|
|
|
|
2014-07-18 10:37:34 +00:00
|
|
|
void SettingsInner::onSenderName() {
|
|
|
|
_messagePreview.setDisabled(!_senderName.checked());
|
|
|
|
if (!_senderName.checked() && _messagePreview.checked()) {
|
|
|
|
_messagePreview.setChecked(false);
|
|
|
|
} else {
|
|
|
|
if (_messagePreview.checked()) {
|
|
|
|
cSetNotifyView(dbinvShowPreview);
|
|
|
|
} else if (_senderName.checked()) {
|
|
|
|
cSetNotifyView(dbinvShowName);
|
|
|
|
} else {
|
|
|
|
cSetNotifyView(dbinvShowNothing);
|
|
|
|
}
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeUserSettings();
|
2014-07-18 10:37:34 +00:00
|
|
|
App::wnd()->notifyUpdateAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onMessagePreview() {
|
|
|
|
if (_messagePreview.checked()) {
|
|
|
|
cSetNotifyView(dbinvShowPreview);
|
|
|
|
} else if (_senderName.checked()) {
|
|
|
|
cSetNotifyView(dbinvShowName);
|
|
|
|
} else {
|
|
|
|
cSetNotifyView(dbinvShowNothing);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeUserSettings();
|
2014-07-18 10:37:34 +00:00
|
|
|
App::wnd()->notifyUpdateAll();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onReplaceEmojis() {
|
|
|
|
cSetReplaceEmojis(_replaceEmojis.checked());
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeUserSettings();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
if (_replaceEmojis.checked()) {
|
|
|
|
_viewEmojis.show();
|
|
|
|
} else {
|
|
|
|
_viewEmojis.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onViewEmojis() {
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(new EmojiBox());
|
2015-12-02 17:17:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onStickers() {
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(new StickersBox());
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onEnterSend() {
|
|
|
|
if (_enterSend.checked()) {
|
|
|
|
cSetCtrlEnter(false);
|
2015-09-16 13:04:08 +00:00
|
|
|
if (App::main()) App::main()->ctrlEnterSubmitUpdated();
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeUserSettings();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onCtrlEnterSend() {
|
|
|
|
if (_ctrlEnterSend.checked()) {
|
|
|
|
cSetCtrlEnter(true);
|
2015-09-16 13:04:08 +00:00
|
|
|
if (App::main()) App::main()->ctrlEnterSubmitUpdated();
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeUserSettings();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
void SettingsInner::onBackFromGallery() {
|
|
|
|
BackgroundBox *box = new BackgroundBox();
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2015-02-03 15:02:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onBackFromFile() {
|
|
|
|
QStringList imgExtensions(cImgExtensions());
|
|
|
|
QString filter(qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;All files (*.*)"));
|
|
|
|
|
|
|
|
QImage img;
|
|
|
|
QString file;
|
|
|
|
QByteArray remoteContent;
|
|
|
|
if (filedialogGetOpenFile(file, remoteContent, lang(lng_choose_images), filter)) {
|
|
|
|
if (!remoteContent.isEmpty()) {
|
|
|
|
img = App::readImage(remoteContent);
|
|
|
|
} else {
|
|
|
|
if (!file.isEmpty()) {
|
|
|
|
img = App::readImage(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (img.isNull() || img.width() <= 0 || img.height() <= 0) return;
|
|
|
|
|
|
|
|
if (img.width() > 4096 * img.height()) {
|
|
|
|
img = img.copy((img.width() - 4096 * img.height()) / 2, 0, 4096 * img.height(), img.height());
|
|
|
|
} else if (img.height() > 4096 * img.width()) {
|
|
|
|
img = img.copy(0, (img.height() - 4096 * img.width()) / 2, img.width(), 4096 * img.width());
|
|
|
|
}
|
|
|
|
|
|
|
|
App::initBackground(-1, img);
|
|
|
|
_tileBackground.setChecked(false);
|
|
|
|
updateChatBackground();
|
|
|
|
}
|
|
|
|
|
2016-06-22 13:39:54 +00:00
|
|
|
float64 SettingsInner::radialProgress() const {
|
|
|
|
if (auto m = App::main()) {
|
|
|
|
return m->chatBackgroundProgress();
|
|
|
|
}
|
|
|
|
return 1.;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SettingsInner::radialLoading() const {
|
|
|
|
if (auto m = App::main()) {
|
|
|
|
if (m->chatBackgroundLoading()) {
|
|
|
|
m->checkChatBackground();
|
|
|
|
if (m->chatBackgroundLoading()) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
const_cast<SettingsInner*>(this)->updateChatBackground();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect SettingsInner::radialRect() const {
|
|
|
|
auto left = _left;
|
|
|
|
auto top = _tileBackground.y() - st::setLittleSkip - st::setBackgroundSize;
|
|
|
|
return QRect(left, top, st::setBackgroundSize, st::setBackgroundSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::radialStart() {
|
|
|
|
if (radialLoading() && !_radial.animating()) {
|
|
|
|
_radial.start(radialProgress());
|
|
|
|
if (auto shift = radialTimeShift()) {
|
|
|
|
_radial.update(radialProgress(), !radialLoading(), getms() + shift);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64 SettingsInner::radialTimeShift() const {
|
|
|
|
return st::radialDuration;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::step_radial(uint64 ms, bool timer) {
|
|
|
|
_radial.update(radialProgress(), !radialLoading(), ms + radialTimeShift());
|
|
|
|
if (timer && _radial.animating()) {
|
|
|
|
updateBackgroundRect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
void SettingsInner::updateChatBackground() {
|
2015-02-03 16:44:54 +00:00
|
|
|
int32 size = st::setBackgroundSize * cIntRetinaFactor();
|
|
|
|
QImage back(size, size, QImage::Format_ARGB32_Premultiplied);
|
|
|
|
back.setDevicePixelRatio(cRetinaFactor());
|
2015-02-03 15:02:46 +00:00
|
|
|
{
|
|
|
|
QPainter p(&back);
|
|
|
|
const QPixmap &pix(*cChatBackground());
|
|
|
|
int sx = (pix.width() > pix.height()) ? ((pix.width() - pix.height()) / 2) : 0;
|
|
|
|
int sy = (pix.height() > pix.width()) ? ((pix.height() - pix.width()) / 2) : 0;
|
|
|
|
int s = (pix.width() > pix.height()) ? pix.height() : pix.width();
|
|
|
|
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
|
|
|
p.drawPixmap(0, 0, st::setBackgroundSize, st::setBackgroundSize, pix, sx, sy, s, s);
|
|
|
|
}
|
2016-07-13 17:34:57 +00:00
|
|
|
_background = App::pixmapFromImageInPlace(std_::move(back));
|
2015-02-03 16:44:54 +00:00
|
|
|
_background.setDevicePixelRatio(cRetinaFactor());
|
2015-02-03 15:02:46 +00:00
|
|
|
_needBackgroundUpdate = false;
|
2016-06-22 13:39:54 +00:00
|
|
|
|
2015-02-03 16:44:54 +00:00
|
|
|
updateBackgroundRect();
|
2015-02-03 15:02:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::needBackgroundUpdate(bool tile) {
|
|
|
|
_needBackgroundUpdate = true;
|
|
|
|
_tileBackground.setChecked(tile);
|
|
|
|
updateChatBackground();
|
2016-06-22 13:39:54 +00:00
|
|
|
if (radialLoading()) {
|
|
|
|
radialStart();
|
|
|
|
}
|
2015-02-03 15:02:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onTileBackground() {
|
|
|
|
if (cTileBackground() != _tileBackground.checked()) {
|
|
|
|
cSetTileBackground(_tileBackground.checked());
|
2015-02-03 16:44:54 +00:00
|
|
|
if (App::main()) App::main()->clearCachedBackground();
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeUserSettings();
|
2015-02-03 15:02:46 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-02-21 14:27:54 +00:00
|
|
|
void SettingsInner::onAdaptiveForWide() {
|
|
|
|
if (Global::AdaptiveForWide() != _adaptiveForWide.checked()) {
|
|
|
|
Global::SetAdaptiveForWide(_adaptiveForWide.checked());
|
|
|
|
if (App::wnd()) {
|
|
|
|
App::wnd()->updateAdaptiveLayout();
|
|
|
|
}
|
|
|
|
Local::writeUserSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void SettingsInner::onDontAskDownloadPath() {
|
|
|
|
cSetAskDownloadPath(!_dontAskDownloadPath.checked());
|
2015-03-02 12:34:16 +00:00
|
|
|
Local::writeUserSettings();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
showAll();
|
|
|
|
resizeEvent(0);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onDownloadPathEdit() {
|
|
|
|
DownloadPathBox *box = new DownloadPathBox();
|
|
|
|
connect(box, SIGNAL(closed()), this, SLOT(onDownloadPathEdited()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onDownloadPathEdited() {
|
2014-09-30 14:11:09 +00:00
|
|
|
QString path;
|
|
|
|
if (cDownloadPath().isEmpty()) {
|
|
|
|
path = lang(lng_download_path_default);
|
|
|
|
} else if (cDownloadPath() == qsl("tmp")) {
|
|
|
|
path = lang(lng_download_path_temp);
|
|
|
|
} else {
|
2015-10-03 10:09:09 +00:00
|
|
|
path = st::linkFont->elided(QDir::toNativeSeparators(cDownloadPath()), st::setWidth - st::setVersionLeft - _downloadPathWidth);
|
2014-09-30 14:11:09 +00:00
|
|
|
}
|
|
|
|
_downloadPathEdit.setText(path);
|
2014-05-30 08:53:19 +00:00
|
|
|
showAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onDownloadPathClear() {
|
|
|
|
ConfirmBox *box = new ConfirmBox(lang(lng_sure_clear_downloads));
|
|
|
|
connect(box, SIGNAL(confirmed()), this, SLOT(onDownloadPathClearSure()));
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(box);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onDownloadPathClearSure() {
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::hideLayer();
|
2014-11-22 09:45:04 +00:00
|
|
|
App::wnd()->tempDirDelete(Local::ClearManagerDownloads);
|
2014-05-30 08:53:19 +00:00
|
|
|
_tempDirClearState = TempDirClearing;
|
|
|
|
showAll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2015-01-02 14:55:24 +00:00
|
|
|
void SettingsInner::onLocalStorageClear() {
|
|
|
|
App::wnd()->tempDirDelete(Local::ClearManagerStorage);
|
|
|
|
_storageClearState = TempDirClearing;
|
2014-05-30 08:53:19 +00:00
|
|
|
showAll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
void SettingsInner::onTempDirCleared(int task) {
|
|
|
|
if (task & Local::ClearManagerDownloads) {
|
|
|
|
_tempDirClearState = TempDirCleared;
|
2015-01-02 14:55:24 +00:00
|
|
|
} else if (task & Local::ClearManagerStorage) {
|
|
|
|
_storageClearState = TempDirCleared;
|
2014-11-22 09:45:04 +00:00
|
|
|
}
|
|
|
|
showAll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onTempDirClearFailed(int task) {
|
|
|
|
if (task & Local::ClearManagerDownloads) {
|
|
|
|
_tempDirClearState = TempDirClearFailed;
|
2015-01-02 14:55:24 +00:00
|
|
|
} else if (task & Local::ClearManagerStorage) {
|
|
|
|
_storageClearState = TempDirClearFailed;
|
2014-11-22 09:45:04 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
showAll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2015-12-23 21:19:57 +00:00
|
|
|
void SettingsInner::onAutoDownload() {
|
|
|
|
Ui::showLayer(new AutoDownloadBox());
|
|
|
|
}
|
|
|
|
|
2015-08-19 22:00:37 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
2014-05-30 08:53:19 +00:00
|
|
|
void SettingsInner::setUpdatingState(UpdatingState state, bool force) {
|
|
|
|
if (_updatingState != state || force) {
|
|
|
|
_updatingState = state;
|
|
|
|
if (cAutoUpdate()) {
|
|
|
|
switch (state) {
|
|
|
|
case UpdatingNone:
|
|
|
|
case UpdatingLatest: _checkNow.show(); _restartNow.hide(); break;
|
|
|
|
case UpdatingReady: _checkNow.hide(); _restartNow.show(); break;
|
|
|
|
case UpdatingCheck:
|
|
|
|
case UpdatingDownload:
|
|
|
|
case UpdatingFail: _checkNow.hide(); _restartNow.hide(); break;
|
|
|
|
}
|
|
|
|
update(0, _restartNow.y() - 10, width(), _restartNow.height() + 20);
|
|
|
|
} else {
|
|
|
|
_checkNow.hide();
|
|
|
|
_restartNow.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::setDownloadProgress(qint64 ready, qint64 total) {
|
|
|
|
qint64 readyTenthMb = (ready * 10 / (1024 * 1024)), totalTenthMb = (total * 10 / (1024 * 1024));
|
|
|
|
QString readyStr = QString::number(readyTenthMb / 10) + '.' + QString::number(readyTenthMb % 10);
|
|
|
|
QString totalStr = QString::number(totalTenthMb / 10) + '.' + QString::number(totalTenthMb % 10);
|
2014-12-18 18:40:49 +00:00
|
|
|
QString res = lng_settings_downloading(lt_ready, readyStr, lt_total, totalStr);
|
2014-05-30 08:53:19 +00:00
|
|
|
if (_newVersionDownload != res) {
|
|
|
|
_newVersionDownload = res;
|
|
|
|
if (cAutoUpdate()) {
|
|
|
|
update(0, _restartNow.y() - 10, width(), _restartNow.height() + 20);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onUpdateChecking() {
|
|
|
|
setUpdatingState(UpdatingCheck);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onUpdateLatest() {
|
|
|
|
setUpdatingState(UpdatingLatest);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onUpdateDownloading(qint64 ready, qint64 total) {
|
|
|
|
setUpdatingState(UpdatingDownload);
|
|
|
|
setDownloadProgress(ready, total);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onUpdateReady() {
|
|
|
|
setUpdatingState(UpdatingReady);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onUpdateFailed() {
|
|
|
|
setUpdatingState(UpdatingFail);
|
|
|
|
}
|
2015-08-19 22:00:37 +00:00
|
|
|
#endif
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void SettingsInner::onPhotoUpdateStart() {
|
|
|
|
showAll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onPhotoUpdateFail(PeerId peer) {
|
2014-10-22 18:39:03 +00:00
|
|
|
if (!self() || self()->id != peer) return;
|
2014-05-30 08:53:19 +00:00
|
|
|
saveError(lang(lng_bad_photo));
|
|
|
|
showAll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsInner::onPhotoUpdateDone(PeerId peer) {
|
2014-10-22 18:39:03 +00:00
|
|
|
if (!self() || self()->id != peer) return;
|
2014-05-30 08:53:19 +00:00
|
|
|
showAll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
SettingsWidget::SettingsWidget(MainWindow *parent) : TWidget(parent)
|
2015-12-08 12:33:37 +00:00
|
|
|
, _a_show(animation(this, &SettingsWidget::step_show))
|
2015-10-17 14:52:26 +00:00
|
|
|
, _scroll(this, st::setScroll)
|
|
|
|
, _inner(this)
|
|
|
|
, _close(this, st::setClose) {
|
2014-05-30 08:53:19 +00:00
|
|
|
_scroll.setWidget(&_inner);
|
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
connect(App::wnd(), SIGNAL(resized(const QSize&)), this, SLOT(onParentResize(const QSize&)));
|
2014-05-30 08:53:19 +00:00
|
|
|
connect(&_close, SIGNAL(clicked()), App::wnd(), SLOT(showSettings()));
|
|
|
|
|
2016-01-11 15:43:29 +00:00
|
|
|
setGeometry(QRect(0, st::titleHeight, App::wnd()->width(), App::wnd()->height() - st::titleHeight));
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
showAll();
|
|
|
|
}
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
void SettingsWidget::onParentResize(const QSize &newSize) {
|
2014-05-30 08:53:19 +00:00
|
|
|
resize(newSize);
|
|
|
|
}
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
void SettingsWidget::animShow(const QPixmap &bgAnimCache, bool back) {
|
2015-10-15 11:51:10 +00:00
|
|
|
if (App::app()) App::app()->mtpPause();
|
2015-10-15 10:18:24 +00:00
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
(back ? _cacheOver : _cacheUnder) = bgAnimCache;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
_a_show.stop();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
showAll();
|
|
|
|
(back ? _cacheUnder : _cacheOver) = myGrab(this);
|
2014-05-30 08:53:19 +00:00
|
|
|
hideAll();
|
2015-10-17 14:52:26 +00:00
|
|
|
|
2016-05-14 16:57:06 +00:00
|
|
|
a_coordUnder = back ? anim::ivalue(-st::slideShift, 0) : anim::ivalue(0, -st::slideShift);
|
2015-10-17 14:52:26 +00:00
|
|
|
a_coordOver = back ? anim::ivalue(0, width()) : anim::ivalue(width(), 0);
|
|
|
|
a_shadow = back ? anim::fvalue(1, 0) : anim::fvalue(0, 1);
|
|
|
|
_a_show.start();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void SettingsWidget::step_show(float64 ms, bool timer) {
|
2015-10-17 14:52:26 +00:00
|
|
|
float64 dt = ms / st::slideDuration;
|
|
|
|
if (dt >= 1) {
|
|
|
|
_a_show.stop();
|
|
|
|
|
|
|
|
a_coordUnder.finish();
|
|
|
|
a_coordOver.finish();
|
|
|
|
a_shadow.finish();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
_cacheUnder = _cacheOver = QPixmap();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
showAll();
|
|
|
|
_inner.setFocus();
|
2015-10-15 10:18:24 +00:00
|
|
|
|
|
|
|
if (App::app()) App::app()->mtpUnpause();
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2015-10-17 14:52:26 +00:00
|
|
|
a_coordUnder.update(dt, st::slideFunction);
|
|
|
|
a_coordOver.update(dt, st::slideFunction);
|
|
|
|
a_shadow.update(dt, st::slideFunction);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-12-08 12:33:37 +00:00
|
|
|
if (timer) update();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void SettingsWidget::stop_show() {
|
2015-10-17 14:52:26 +00:00
|
|
|
_a_show.stop();
|
|
|
|
}
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
void SettingsWidget::paintEvent(QPaintEvent *e) {
|
2014-05-30 08:53:19 +00:00
|
|
|
QRect r(e->rect());
|
|
|
|
bool trivial = (rect() == r);
|
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
Painter p(this);
|
2014-05-30 08:53:19 +00:00
|
|
|
if (!trivial) {
|
|
|
|
p.setClipRect(r);
|
|
|
|
}
|
2015-10-17 14:52:26 +00:00
|
|
|
if (_a_show.animating()) {
|
|
|
|
if (a_coordOver.current() > 0) {
|
2015-10-18 23:01:18 +00:00
|
|
|
p.drawPixmap(QRect(0, 0, a_coordOver.current(), height()), _cacheUnder, QRect(-a_coordUnder.current() * cRetinaFactor(), 0, a_coordOver.current() * cRetinaFactor(), height() * cRetinaFactor()));
|
2015-10-17 14:52:26 +00:00
|
|
|
p.setOpacity(a_shadow.current() * st::slideFadeOut);
|
|
|
|
p.fillRect(0, 0, a_coordOver.current(), height(), st::black->b);
|
|
|
|
p.setOpacity(1);
|
|
|
|
}
|
|
|
|
p.drawPixmap(a_coordOver.current(), 0, _cacheOver);
|
|
|
|
p.setOpacity(a_shadow.current());
|
2016-04-21 17:57:29 +00:00
|
|
|
p.drawPixmap(QRect(a_coordOver.current() - st::slideShadow.pxWidth(), 0, st::slideShadow.pxWidth(), height()), App::sprite(), st::slideShadow.rect());
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
|
|
|
p.fillRect(rect(), st::setBG->b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
void SettingsWidget::showAll() {
|
2014-05-30 08:53:19 +00:00
|
|
|
_scroll.show();
|
|
|
|
_inner.show();
|
|
|
|
_inner.showAll();
|
2016-02-08 14:54:55 +00:00
|
|
|
if (Adaptive::OneColumn()) {
|
2014-12-12 16:27:03 +00:00
|
|
|
_close.hide();
|
2016-02-08 14:54:55 +00:00
|
|
|
} else {
|
|
|
|
_close.show();
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
void SettingsWidget::hideAll() {
|
2014-05-30 08:53:19 +00:00
|
|
|
_scroll.hide();
|
|
|
|
_close.hide();
|
|
|
|
}
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
void SettingsWidget::resizeEvent(QResizeEvent *e) {
|
2014-05-30 08:53:19 +00:00
|
|
|
_scroll.resize(size());
|
|
|
|
_inner.updateSize(width());
|
|
|
|
_close.move(st::setClosePos.x(), st::setClosePos.y());
|
|
|
|
}
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
void SettingsWidget::dragEnterEvent(QDragEnterEvent *e) {
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
void SettingsWidget::dropEvent(QDropEvent *e) {
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
void SettingsWidget::updateAdaptiveLayout() {
|
|
|
|
if (Adaptive::OneColumn()) {
|
2014-12-12 16:27:03 +00:00
|
|
|
_close.hide();
|
2016-02-08 14:54:55 +00:00
|
|
|
} else {
|
|
|
|
_close.show();
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
2016-02-21 14:27:54 +00:00
|
|
|
_inner.updateAdaptiveLayout();
|
|
|
|
resizeEvent(0);
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
|
|
|
|
2016-02-21 14:27:54 +00:00
|
|
|
void SettingsWidget::updateDisplayNotify() {
|
2015-02-04 06:14:20 +00:00
|
|
|
_inner.enableDisplayNotify(cDesktopNotify());
|
|
|
|
}
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
void SettingsWidget::updateOnlineDisplay() {
|
2014-05-30 08:53:19 +00:00
|
|
|
_inner.updateOnlineDisplay();
|
|
|
|
}
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
void SettingsWidget::updateConnectionType() {
|
2014-05-30 08:53:19 +00:00
|
|
|
_inner.updateConnectionType();
|
|
|
|
}
|
|
|
|
|
2016-02-28 12:36:23 +00:00
|
|
|
void SettingsWidget::rpcClear() {
|
|
|
|
_inner.rpcClear();
|
2014-08-01 11:09:46 +00:00
|
|
|
}
|
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
void SettingsWidget::setInnerFocus() {
|
|
|
|
_inner.setFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWidget::needBackgroundUpdate(bool tile) {
|
|
|
|
_inner.needBackgroundUpdate(tile);
|
|
|
|
}
|
|
|
|
|
2014-08-01 11:09:46 +00:00
|
|
|
SettingsWidget::~SettingsWidget() {
|
2014-05-30 08:53:19 +00:00
|
|
|
if (App::wnd()) App::wnd()->noSettings(this);
|
|
|
|
}
|