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
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
2016-11-08 14:43:10 +00:00
|
|
|
#include "boxes/connectionbox.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-11-08 14:43:10 +00:00
|
|
|
#include "lang.h"
|
2017-03-04 10:23:56 +00:00
|
|
|
#include "storage/localstorage.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
#include "mainwidget.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
#include "mainwindow.h"
|
2016-11-11 13:46:04 +00:00
|
|
|
#include "ui/widgets/checkbox.h"
|
|
|
|
#include "ui/widgets/buttons.h"
|
2016-11-15 11:56:49 +00:00
|
|
|
#include "ui/widgets/input_fields.h"
|
2016-09-27 13:37:18 +00:00
|
|
|
#include "history/history_location_manager.h"
|
2016-11-15 11:56:49 +00:00
|
|
|
#include "styles/style_boxes.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
ConnectionBox::ConnectionBox(QWidget *parent)
|
|
|
|
: _hostInput(this, st::connectionHostInputField, lang(lng_connection_host_ph), Global::ConnectionProxy().host)
|
2016-08-27 04:49:18 +00:00
|
|
|
, _portInput(this, st::connectionPortInputField, lang(lng_connection_port_ph), QString::number(Global::ConnectionProxy().port))
|
|
|
|
, _userInput(this, st::connectionUserInputField, lang(lng_connection_user_ph), Global::ConnectionProxy().user)
|
|
|
|
, _passwordInput(this, st::connectionPasswordInputField, lang(lng_connection_password_ph), Global::ConnectionProxy().password)
|
2017-03-18 21:06:10 +00:00
|
|
|
, _typeGroup(std::make_shared<Ui::RadioenumGroup<DBIConnectionType>>(Global::ConnectionType()))
|
|
|
|
, _autoRadio(this, _typeGroup, dbictAuto, lang(lng_connection_auto_rb), st::defaultBoxCheckbox)
|
|
|
|
, _httpProxyRadio(this, _typeGroup, dbictHttpProxy, lang(lng_connection_http_proxy_rb), st::defaultBoxCheckbox)
|
|
|
|
, _tcpProxyRadio(this, _typeGroup, dbictTcpProxy, lang(lng_connection_tcp_proxy_rb), st::defaultBoxCheckbox)
|
2016-12-13 17:07:56 +00:00
|
|
|
, _tryIPv6(this, lang(lng_connection_try_ipv6), Global::TryIPv6(), st::defaultBoxCheckbox) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectionBox::prepare() {
|
|
|
|
setTitle(lang(lng_connection_header));
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
addButton(lang(lng_connection_save), [this] { onSave(); });
|
|
|
|
addButton(lang(lng_cancel), [this] { closeBox(); });
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-03-18 21:06:10 +00:00
|
|
|
_typeGroup->setChangedCallback([this](DBIConnectionType value) { typeChanged(value); });
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-10-28 09:20:24 +00:00
|
|
|
connect(_hostInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
|
|
|
|
connect(_portInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
|
|
|
|
connect(_userInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
|
|
|
|
connect(_passwordInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-11-18 13:34:58 +00:00
|
|
|
updateControlsVisibility();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-11-18 13:34:58 +00:00
|
|
|
void ConnectionBox::updateControlsVisibility() {
|
2016-12-13 17:07:56 +00:00
|
|
|
auto newHeight = st::boxOptionListPadding.top() + _autoRadio->heightNoMargins() + st::boxOptionListSkip + _httpProxyRadio->heightNoMargins() + st::boxOptionListSkip + _tcpProxyRadio->heightNoMargins() + st::boxOptionListSkip + st::connectionIPv6Skip + _tryIPv6->heightNoMargins() + st::boxOptionListPadding.bottom() + st::boxPadding.bottom();
|
2017-03-18 21:06:10 +00:00
|
|
|
if (_typeGroup->value() == dbictAuto) {
|
|
|
|
_hostInput->hide();
|
|
|
|
_portInput->hide();
|
|
|
|
_userInput->hide();
|
|
|
|
_passwordInput->hide();
|
|
|
|
} else {
|
2016-12-13 17:07:56 +00:00
|
|
|
newHeight += 2 * st::boxOptionInputSkip + 2 * _hostInput->height();
|
2016-10-28 09:20:24 +00:00
|
|
|
_hostInput->show();
|
|
|
|
_portInput->show();
|
|
|
|
_userInput->show();
|
|
|
|
_passwordInput->show();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
setDimensions(st::boxWidth, newHeight);
|
|
|
|
updateControlsPosition();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
void ConnectionBox::setInnerFocus() {
|
2016-12-20 13:03:51 +00:00
|
|
|
if (_hostInput->isHidden()) {
|
|
|
|
setFocus();
|
|
|
|
} else {
|
|
|
|
_hostInput->setFocusFast();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
void ConnectionBox::resizeEvent(QResizeEvent *e) {
|
2016-12-13 17:07:56 +00:00
|
|
|
BoxContent::resizeEvent(e);
|
|
|
|
|
|
|
|
updateControlsPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectionBox::updateControlsPosition() {
|
2017-03-18 21:06:10 +00:00
|
|
|
auto type = _typeGroup->value();
|
2016-12-13 17:07:56 +00:00
|
|
|
_autoRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), st::boxOptionListPadding.top());
|
|
|
|
_httpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _autoRadio->bottomNoMargins() + st::boxOptionListSkip);
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2017-03-18 21:06:10 +00:00
|
|
|
auto inputy = 0;
|
|
|
|
if (type == dbictHttpProxy) {
|
2016-12-09 18:56:01 +00:00
|
|
|
inputy = _httpProxyRadio->bottomNoMargins() + st::boxOptionInputSkip;
|
2016-12-13 17:07:56 +00:00
|
|
|
_tcpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), inputy + st::boxOptionInputSkip + 2 * _hostInput->height() + st::boxOptionListSkip);
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2016-12-13 17:07:56 +00:00
|
|
|
_tcpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _httpProxyRadio->bottomNoMargins() + st::boxOptionListSkip);
|
2017-03-18 21:06:10 +00:00
|
|
|
if (type == dbictTcpProxy) {
|
2016-12-09 18:56:01 +00:00
|
|
|
inputy = _tcpProxyRadio->bottomNoMargins() + st::boxOptionInputSkip;
|
2015-04-02 10:33:19 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
if (inputy) {
|
2016-12-02 19:16:35 +00:00
|
|
|
_hostInput->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultBoxCheckbox.textPosition.x() - st::defaultInputField.textMargins.left(), inputy);
|
2016-10-28 09:20:24 +00:00
|
|
|
_portInput->moveToRight(st::boxPadding.right(), inputy);
|
2016-12-09 18:56:01 +00:00
|
|
|
_userInput->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultBoxCheckbox.textPosition.x() - st::defaultInputField.textMargins.left(), _hostInput->y() + _hostInput->height() + st::boxOptionInputSkip);
|
2016-10-28 09:20:24 +00:00
|
|
|
_passwordInput->moveToRight(st::boxPadding.right(), _userInput->y());
|
2015-04-02 10:33:19 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 21:06:10 +00:00
|
|
|
auto tryipv6y = ((type == dbictTcpProxy) ? _userInput->bottomNoMargins() : _tcpProxyRadio->bottomNoMargins()) + st::boxOptionListSkip + st::connectionIPv6Skip;
|
2016-10-28 09:20:24 +00:00
|
|
|
_tryIPv6->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), tryipv6y);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 21:06:10 +00:00
|
|
|
void ConnectionBox::typeChanged(DBIConnectionType type) {
|
2016-11-18 13:34:58 +00:00
|
|
|
updateControlsVisibility();
|
2017-03-18 21:06:10 +00:00
|
|
|
if (type != dbictAuto) {
|
2016-12-20 13:03:51 +00:00
|
|
|
if (!_hostInput->hasFocus() && !_portInput->hasFocus() && !_userInput->hasFocus() && !_passwordInput->hasFocus()) {
|
|
|
|
_hostInput->setFocusFast();
|
|
|
|
}
|
2017-03-18 21:06:10 +00:00
|
|
|
if ((type == dbictHttpProxy) && !_portInput->getLastText().toInt()) {
|
2016-10-28 09:20:24 +00:00
|
|
|
_portInput->setText(qsl("80"));
|
2016-12-20 13:03:51 +00:00
|
|
|
_portInput->finishAnimations();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
void ConnectionBox::onSubmit() {
|
2016-10-28 09:20:24 +00:00
|
|
|
if (_hostInput->hasFocus()) {
|
|
|
|
if (!_hostInput->getLastText().trimmed().isEmpty()) {
|
|
|
|
_portInput->setFocus();
|
2015-10-06 19:49:23 +00:00
|
|
|
} else {
|
2016-10-28 09:20:24 +00:00
|
|
|
_hostInput->showError();
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
2016-10-28 09:20:24 +00:00
|
|
|
} else if (_portInput->hasFocus()) {
|
|
|
|
if (_portInput->getLastText().trimmed().toInt() > 0) {
|
|
|
|
_userInput->setFocus();
|
2015-10-06 19:49:23 +00:00
|
|
|
} else {
|
2016-10-28 09:20:24 +00:00
|
|
|
_portInput->showError();
|
2015-10-06 19:49:23 +00:00
|
|
|
}
|
2016-10-28 09:20:24 +00:00
|
|
|
} else if (_userInput->hasFocus()) {
|
|
|
|
_passwordInput->setFocus();
|
|
|
|
} else if (_passwordInput->hasFocus()) {
|
|
|
|
if (_hostInput->getLastText().trimmed().isEmpty()) {
|
|
|
|
_hostInput->setFocus();
|
|
|
|
_hostInput->showError();
|
|
|
|
} else if (_portInput->getLastText().trimmed().toInt() <= 0) {
|
|
|
|
_portInput->setFocus();
|
|
|
|
_portInput->showError();
|
2015-10-06 19:49:23 +00:00
|
|
|
} else {
|
|
|
|
onSave();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void ConnectionBox::onSave() {
|
2017-03-18 21:06:10 +00:00
|
|
|
auto type = _typeGroup->value();
|
|
|
|
if (type == dbictAuto) {
|
|
|
|
Global::SetConnectionType(type);
|
|
|
|
Global::SetConnectionProxy(ProxyData());
|
|
|
|
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
|
|
|
QNetworkProxyFactory::setUseSystemConfiguration(false);
|
|
|
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
|
|
|
#endif // !TDESKTOP_DISABLE_NETWORK_PROXY
|
|
|
|
} else {
|
2016-08-27 04:49:18 +00:00
|
|
|
ProxyData p;
|
2016-10-28 09:20:24 +00:00
|
|
|
p.host = _hostInput->getLastText().trimmed();
|
|
|
|
p.user = _userInput->getLastText().trimmed();
|
|
|
|
p.password = _passwordInput->getLastText().trimmed();
|
|
|
|
p.port = _portInput->getLastText().toInt();
|
2014-05-30 08:53:19 +00:00
|
|
|
if (p.host.isEmpty()) {
|
2016-10-28 09:20:24 +00:00
|
|
|
_hostInput->setFocus();
|
2014-05-30 08:53:19 +00:00
|
|
|
return;
|
|
|
|
} else if (!p.port) {
|
2016-10-28 09:20:24 +00:00
|
|
|
_portInput->setFocus();
|
2014-05-30 08:53:19 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-03-18 21:06:10 +00:00
|
|
|
Global::SetConnectionType(type);
|
2016-08-27 04:49:18 +00:00
|
|
|
Global::SetConnectionProxy(p);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2016-10-28 09:20:24 +00:00
|
|
|
if (cPlatform() == dbipWindows && Global::TryIPv6() != _tryIPv6->checked()) {
|
|
|
|
Global::SetTryIPv6(_tryIPv6->checked());
|
2015-06-25 18:04:40 +00:00
|
|
|
Local::writeSettings();
|
2016-08-27 04:49:18 +00:00
|
|
|
Global::RefConnectionTypeChanged().notify();
|
|
|
|
|
2016-10-28 12:44:28 +00:00
|
|
|
App::restart();
|
2015-06-25 18:04:40 +00:00
|
|
|
} else {
|
2016-10-28 09:20:24 +00:00
|
|
|
Global::SetTryIPv6(_tryIPv6->checked());
|
2015-06-25 18:04:40 +00:00
|
|
|
Local::writeSettings();
|
2016-08-27 04:49:18 +00:00
|
|
|
Global::RefConnectionTypeChanged().notify();
|
|
|
|
|
2015-06-25 18:04:40 +00:00
|
|
|
MTP::restart();
|
2016-09-27 13:37:18 +00:00
|
|
|
reinitLocationManager();
|
2015-12-30 19:09:20 +00:00
|
|
|
reinitWebLoadManager();
|
2016-12-13 17:07:56 +00:00
|
|
|
closeBox();
|
2015-06-25 18:04:40 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-12-23 21:19:57 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
AutoDownloadBox::AutoDownloadBox(QWidget *parent)
|
|
|
|
: _photoPrivate(this, lang(lng_media_auto_private_chats), !(cAutoDownloadPhoto() & dbiadNoPrivate), st::defaultBoxCheckbox)
|
2016-06-10 11:18:55 +00:00
|
|
|
, _photoGroups(this, lang(lng_media_auto_groups), !(cAutoDownloadPhoto() & dbiadNoGroups), st::defaultBoxCheckbox)
|
|
|
|
, _audioPrivate(this, lang(lng_media_auto_private_chats), !(cAutoDownloadAudio() & dbiadNoPrivate), st::defaultBoxCheckbox)
|
|
|
|
, _audioGroups(this, lang(lng_media_auto_groups), !(cAutoDownloadAudio() & dbiadNoGroups), st::defaultBoxCheckbox)
|
|
|
|
, _gifPrivate(this, lang(lng_media_auto_private_chats), !(cAutoDownloadGif() & dbiadNoPrivate), st::defaultBoxCheckbox)
|
|
|
|
, _gifGroups(this, lang(lng_media_auto_groups), !(cAutoDownloadGif() & dbiadNoGroups), st::defaultBoxCheckbox)
|
|
|
|
, _gifPlay(this, lang(lng_media_auto_play), cAutoPlayGif(), st::defaultBoxCheckbox)
|
2016-12-13 17:07:56 +00:00
|
|
|
, _sectionHeight(st::boxTitleHeight + 2 * (st::defaultBoxCheckbox.height + st::setLittleSkip)) {
|
|
|
|
}
|
2015-12-23 21:19:57 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
void AutoDownloadBox::prepare() {
|
|
|
|
addButton(lang(lng_connection_save), [this] { onSave(); });
|
|
|
|
addButton(lang(lng_cancel), [this] { closeBox(); });
|
2015-12-23 21:19:57 +00:00
|
|
|
|
2016-12-20 13:03:51 +00:00
|
|
|
setDimensions(st::boxWidth, 3 * _sectionHeight - st::autoDownloadTopDelta + st::setLittleSkip + _gifPlay->heightNoMargins() + st::setLittleSkip);
|
2015-12-23 21:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AutoDownloadBox::paintEvent(QPaintEvent *e) {
|
2016-12-13 17:07:56 +00:00
|
|
|
BoxContent::paintEvent(e);
|
2016-11-19 14:47:28 +00:00
|
|
|
|
2015-12-23 21:19:57 +00:00
|
|
|
Painter p(this);
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
p.setPen(st::boxTitleFg);
|
|
|
|
p.setFont(st::autoDownloadTitleFont);
|
|
|
|
p.drawTextLeft(st::autoDownloadTitlePosition.x(), st::autoDownloadTitlePosition.y(), width(), lang(lng_media_auto_photo));
|
|
|
|
p.drawTextLeft(st::autoDownloadTitlePosition.x(), _sectionHeight + st::autoDownloadTitlePosition.y(), width(), lang(lng_media_auto_audio));
|
|
|
|
p.drawTextLeft(st::autoDownloadTitlePosition.x(), 2 * _sectionHeight + st::autoDownloadTitlePosition.y(), width(), lang(lng_media_auto_gif));
|
2015-12-23 21:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AutoDownloadBox::resizeEvent(QResizeEvent *e) {
|
2016-12-13 17:07:56 +00:00
|
|
|
BoxContent::resizeEvent(e);
|
|
|
|
|
2016-12-20 13:03:51 +00:00
|
|
|
auto top = st::boxTitleHeight - st::autoDownloadTopDelta;
|
|
|
|
_photoPrivate->moveToLeft(st::boxTitlePosition.x(), top + st::setLittleSkip);
|
2016-12-02 19:16:35 +00:00
|
|
|
_photoGroups->moveToLeft(st::boxTitlePosition.x(), _photoPrivate->bottomNoMargins() + st::setLittleSkip);
|
2015-12-23 21:19:57 +00:00
|
|
|
|
2016-12-20 13:03:51 +00:00
|
|
|
_audioPrivate->moveToLeft(st::boxTitlePosition.x(), _sectionHeight + top + st::setLittleSkip);
|
2016-12-02 19:16:35 +00:00
|
|
|
_audioGroups->moveToLeft(st::boxTitlePosition.x(), _audioPrivate->bottomNoMargins() + st::setLittleSkip);
|
2015-12-23 21:19:57 +00:00
|
|
|
|
2016-12-20 13:03:51 +00:00
|
|
|
_gifPrivate->moveToLeft(st::boxTitlePosition.x(), 2 * _sectionHeight + top + st::setLittleSkip);
|
2016-12-02 19:16:35 +00:00
|
|
|
_gifGroups->moveToLeft(st::boxTitlePosition.x(), _gifPrivate->bottomNoMargins() + st::setLittleSkip);
|
|
|
|
_gifPlay->moveToLeft(st::boxTitlePosition.x(), _gifGroups->bottomNoMargins() + st::setLittleSkip);
|
2015-12-23 21:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AutoDownloadBox::onSave() {
|
2015-12-27 21:37:48 +00:00
|
|
|
bool changed = false;
|
2016-10-28 09:20:24 +00:00
|
|
|
int32 autoDownloadPhoto = (_photoPrivate->checked() ? 0 : dbiadNoPrivate) | (_photoGroups->checked() ? 0 : dbiadNoGroups);
|
2015-12-27 21:37:48 +00:00
|
|
|
if (cAutoDownloadPhoto() != autoDownloadPhoto) {
|
|
|
|
bool enabledPrivate = ((cAutoDownloadPhoto() & dbiadNoPrivate) && !(autoDownloadPhoto & dbiadNoPrivate));
|
|
|
|
bool enabledGroups = ((cAutoDownloadPhoto() & dbiadNoGroups) && !(autoDownloadPhoto & dbiadNoGroups));
|
|
|
|
cSetAutoDownloadPhoto(autoDownloadPhoto);
|
|
|
|
if (enabledPrivate || enabledGroups) {
|
|
|
|
const PhotosData &data(App::photosData());
|
|
|
|
for (PhotosData::const_iterator i = data.cbegin(), e = data.cend(); i != e; ++i) {
|
|
|
|
i.value()->automaticLoadSettingsChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
changed = true;
|
|
|
|
}
|
2016-10-28 09:20:24 +00:00
|
|
|
int32 autoDownloadAudio = (_audioPrivate->checked() ? 0 : dbiadNoPrivate) | (_audioGroups->checked() ? 0 : dbiadNoGroups);
|
2015-12-27 21:37:48 +00:00
|
|
|
if (cAutoDownloadAudio() != autoDownloadAudio) {
|
|
|
|
bool enabledPrivate = ((cAutoDownloadAudio() & dbiadNoPrivate) && !(autoDownloadAudio & dbiadNoPrivate));
|
|
|
|
bool enabledGroups = ((cAutoDownloadAudio() & dbiadNoGroups) && !(autoDownloadAudio & dbiadNoGroups));
|
|
|
|
cSetAutoDownloadAudio(autoDownloadAudio);
|
|
|
|
if (enabledPrivate || enabledGroups) {
|
2016-02-12 16:35:06 +00:00
|
|
|
const DocumentsData &data(App::documentsData());
|
|
|
|
for (DocumentsData::const_iterator i = data.cbegin(), e = data.cend(); i != e; ++i) {
|
|
|
|
if (i.value()->voice()) {
|
|
|
|
i.value()->automaticLoadSettingsChanged();
|
|
|
|
}
|
2015-12-27 21:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
changed = true;
|
|
|
|
}
|
2016-10-28 09:20:24 +00:00
|
|
|
int32 autoDownloadGif = (_gifPrivate->checked() ? 0 : dbiadNoPrivate) | (_gifGroups->checked() ? 0 : dbiadNoGroups);
|
2015-12-27 21:37:48 +00:00
|
|
|
if (cAutoDownloadGif() != autoDownloadGif) {
|
|
|
|
bool enabledPrivate = ((cAutoDownloadGif() & dbiadNoPrivate) && !(autoDownloadGif & dbiadNoPrivate));
|
|
|
|
bool enabledGroups = ((cAutoDownloadGif() & dbiadNoGroups) && !(autoDownloadGif & dbiadNoGroups));
|
|
|
|
cSetAutoDownloadGif(autoDownloadGif);
|
|
|
|
if (enabledPrivate || enabledGroups) {
|
|
|
|
const DocumentsData &data(App::documentsData());
|
|
|
|
for (DocumentsData::const_iterator i = data.cbegin(), e = data.cend(); i != e; ++i) {
|
2016-02-12 16:35:06 +00:00
|
|
|
if (i.value()->isAnimation()) {
|
|
|
|
i.value()->automaticLoadSettingsChanged();
|
|
|
|
}
|
2015-12-27 21:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
changed = true;
|
|
|
|
}
|
2016-10-28 09:20:24 +00:00
|
|
|
if (cAutoPlayGif() != _gifPlay->checked()) {
|
|
|
|
cSetAutoPlayGif(_gifPlay->checked());
|
2015-12-27 21:37:48 +00:00
|
|
|
if (!cAutoPlayGif()) {
|
|
|
|
App::stopGifItems();
|
|
|
|
}
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (changed) Local::writeUserSettings();
|
2016-12-13 17:07:56 +00:00
|
|
|
closeBox();
|
2015-12-23 21:19:57 +00:00
|
|
|
}
|