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"
|
|
|
|
#include "lang.h"
|
|
|
|
|
2015-03-02 12:34:16 +00:00
|
|
|
#include "localstorage.h"
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
#include "connectionbox.h"
|
|
|
|
#include "mainwidget.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
#include "mainwindow.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-12-23 21:19:57 +00:00
|
|
|
ConnectionBox::ConnectionBox() : AbstractBox(st::boxWidth)
|
2016-08-27 04:49:18 +00:00
|
|
|
, _hostInput(this, st::connectionHostInputField, lang(lng_connection_host_ph), Global::ConnectionProxy().host)
|
|
|
|
, _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)
|
|
|
|
, _autoRadio(this, qsl("conn_type"), dbictAuto, lang(lng_connection_auto_rb), (Global::ConnectionType() == dbictAuto))
|
|
|
|
, _httpProxyRadio(this, qsl("conn_type"), dbictHttpProxy, lang(lng_connection_http_proxy_rb), (Global::ConnectionType() == dbictHttpProxy))
|
|
|
|
, _tcpProxyRadio(this, qsl("conn_type"), dbictTcpProxy, lang(lng_connection_tcp_proxy_rb), (Global::ConnectionType() == dbictTcpProxy))
|
|
|
|
, _tryIPv6(this, lang(lng_connection_try_ipv6), Global::TryIPv6(), st::defaultBoxCheckbox)
|
2015-12-23 21:19:57 +00:00
|
|
|
, _save(this, lang(lng_connection_save), st::defaultBoxButton)
|
|
|
|
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
connect(&_save, SIGNAL(clicked()), this, SLOT(onSave()));
|
|
|
|
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
connect(&_autoRadio, SIGNAL(changed()), this, SLOT(onChange()));
|
|
|
|
connect(&_httpProxyRadio, SIGNAL(changed()), this, SLOT(onChange()));
|
|
|
|
connect(&_tcpProxyRadio, SIGNAL(changed()), this, SLOT(onChange()));
|
|
|
|
|
2015-10-06 19:49:23 +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-04-02 10:33:19 +00:00
|
|
|
prepare();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectionBox::showAll() {
|
|
|
|
_autoRadio.show();
|
|
|
|
_httpProxyRadio.show();
|
|
|
|
_tcpProxyRadio.show();
|
2015-06-25 18:04:40 +00:00
|
|
|
_tryIPv6.show();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
int32 h = st::boxTitleHeight + st::boxOptionListPadding.top() + _autoRadio.height() + st::boxOptionListPadding.top() + _httpProxyRadio.height() + st::boxOptionListPadding.top() + _tcpProxyRadio.height() + st::boxOptionListPadding.top() + st::connectionIPv6Skip + _tryIPv6.height() + st::boxOptionListPadding.bottom() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom();
|
2015-04-02 10:33:19 +00:00
|
|
|
if (_httpProxyRadio.checked() || _tcpProxyRadio.checked()) {
|
2015-10-06 19:49:23 +00:00
|
|
|
h += 2 * st::boxOptionListPadding.top() + 2 * _hostInput.height();
|
2014-05-30 08:53:19 +00:00
|
|
|
_hostInput.show();
|
|
|
|
_portInput.show();
|
|
|
|
_userInput.show();
|
|
|
|
_passwordInput.show();
|
|
|
|
} else {
|
|
|
|
_hostInput.hide();
|
|
|
|
_portInput.hide();
|
|
|
|
_userInput.hide();
|
|
|
|
_passwordInput.hide();
|
|
|
|
}
|
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
_save.show();
|
|
|
|
_cancel.show();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
setMaxHeight(h);
|
2015-04-02 10:33:19 +00:00
|
|
|
resizeEvent(0);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
void ConnectionBox::doSetInnerFocus() {
|
2015-04-02 10:33:19 +00:00
|
|
|
if (!_hostInput.isHidden()) {
|
|
|
|
_hostInput.setFocus();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectionBox::paintEvent(QPaintEvent *e) {
|
2015-04-04 20:01:34 +00:00
|
|
|
Painter p(this);
|
2015-04-02 10:33:19 +00:00
|
|
|
if (paint(p)) return;
|
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
paintTitle(p, lang(lng_connection_header));
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
void ConnectionBox::resizeEvent(QResizeEvent *e) {
|
2015-10-06 19:49:23 +00:00
|
|
|
_autoRadio.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), st::boxTitleHeight + st::boxOptionListPadding.top());
|
|
|
|
_httpProxyRadio.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _autoRadio.y() + _autoRadio.height() + st::boxOptionListPadding.top());
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
int32 inputy = 0;
|
|
|
|
if (_httpProxyRadio.checked()) {
|
2015-10-06 19:49:23 +00:00
|
|
|
inputy = _httpProxyRadio.y() + _httpProxyRadio.height() + st::boxOptionListPadding.top();
|
|
|
|
_tcpProxyRadio.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), inputy + st::boxOptionListPadding.top() + 2 * _hostInput.height() + st::boxOptionListPadding.top());
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2015-10-06 19:49:23 +00:00
|
|
|
_tcpProxyRadio.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _httpProxyRadio.y() + _httpProxyRadio.height() + st::boxOptionListPadding.top());
|
2015-04-02 10:33:19 +00:00
|
|
|
if (_tcpProxyRadio.checked()) {
|
2015-10-06 19:49:23 +00:00
|
|
|
inputy = _tcpProxyRadio.y() + _tcpProxyRadio.height() + st::boxOptionListPadding.top();
|
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) {
|
2015-10-06 19:49:23 +00:00
|
|
|
_hostInput.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultRadiobutton.textPosition.x() - st::defaultInputField.textMargins.left(), inputy);
|
2015-10-11 08:37:24 +00:00
|
|
|
_portInput.moveToRight(st::boxPadding.right(), inputy);
|
2015-10-06 19:49:23 +00:00
|
|
|
_userInput.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultRadiobutton.textPosition.x() - st::defaultInputField.textMargins.left(), _hostInput.y() + _hostInput.height() + st::boxOptionListPadding.top());
|
2015-10-11 08:37:24 +00:00
|
|
|
_passwordInput.moveToRight(st::boxPadding.right(), _userInput.y());
|
2015-04-02 10:33:19 +00:00
|
|
|
}
|
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
int32 tryipv6y = (_tcpProxyRadio.checked() ? (_userInput.y() + _userInput.height()) : (_tcpProxyRadio.y() + _tcpProxyRadio.height())) + st::boxOptionListPadding.top() + st::connectionIPv6Skip;
|
|
|
|
_tryIPv6.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), tryipv6y);
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
|
|
|
|
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
|
2016-08-17 15:14:08 +00:00
|
|
|
|
|
|
|
AbstractBox::resizeEvent(e);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectionBox::onChange() {
|
|
|
|
showAll();
|
|
|
|
if (_httpProxyRadio.checked() || _tcpProxyRadio.checked()) {
|
|
|
|
_hostInput.setFocus();
|
2015-10-06 19:49:23 +00:00
|
|
|
if (_httpProxyRadio.checked() && !_portInput.getLastText().toInt()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
_portInput.setText(qsl("80"));
|
|
|
|
_portInput.updatePlaceholder();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
void ConnectionBox::onSubmit() {
|
|
|
|
if (_hostInput.hasFocus()) {
|
|
|
|
if (!_hostInput.getLastText().trimmed().isEmpty()) {
|
|
|
|
_portInput.setFocus();
|
|
|
|
} else {
|
|
|
|
_hostInput.showError();
|
|
|
|
}
|
|
|
|
} else if (_portInput.hasFocus()) {
|
|
|
|
if (_portInput.getLastText().trimmed().toInt() > 0) {
|
|
|
|
_userInput.setFocus();
|
|
|
|
} else {
|
|
|
|
_portInput.showError();
|
|
|
|
}
|
|
|
|
} 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();
|
|
|
|
} else {
|
|
|
|
onSave();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void ConnectionBox::onSave() {
|
|
|
|
if (_httpProxyRadio.checked() || _tcpProxyRadio.checked()) {
|
2016-08-27 04:49:18 +00:00
|
|
|
ProxyData p;
|
2015-10-06 19:49:23 +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()) {
|
|
|
|
_hostInput.setFocus();
|
|
|
|
return;
|
|
|
|
} else if (!p.port) {
|
|
|
|
_portInput.setFocus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (_httpProxyRadio.checked()) {
|
2016-08-27 04:49:18 +00:00
|
|
|
Global::SetConnectionType(dbictHttpProxy);
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2016-08-27 04:49:18 +00:00
|
|
|
Global::SetConnectionType(dbictTcpProxy);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2016-08-27 04:49:18 +00:00
|
|
|
Global::SetConnectionProxy(p);
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2016-08-27 04:49:18 +00:00
|
|
|
Global::SetConnectionType(dbictAuto);
|
|
|
|
Global::SetConnectionProxy(ProxyData());
|
2016-03-20 08:16:35 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
2014-05-30 08:53:19 +00:00
|
|
|
QNetworkProxyFactory::setUseSystemConfiguration(false);
|
|
|
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
2016-03-20 08:16:35 +00:00
|
|
|
#endif
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2016-08-27 04:49:18 +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();
|
|
|
|
|
2015-06-25 18:04:40 +00:00
|
|
|
cSetRestarting(true);
|
|
|
|
cSetRestartingToSettings(true);
|
|
|
|
App::quit();
|
|
|
|
} else {
|
2016-08-27 04:49:18 +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();
|
|
|
|
reinitImageLinkManager();
|
2015-12-30 19:09:20 +00:00
|
|
|
reinitWebLoadManager();
|
2016-08-16 16:53:10 +00:00
|
|
|
onClose();
|
2015-06-25 18:04:40 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-12-23 21:19:57 +00:00
|
|
|
|
|
|
|
AutoDownloadBox::AutoDownloadBox() : AbstractBox(st::boxWidth)
|
2016-06-10 11:18:55 +00:00
|
|
|
, _photoPrivate(this, lang(lng_media_auto_private_chats), !(cAutoDownloadPhoto() & dbiadNoPrivate), st::defaultBoxCheckbox)
|
|
|
|
, _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)
|
|
|
|
, _sectionHeight(st::boxTitleHeight + 2 * (st::defaultBoxCheckbox.height + st::setLittleSkip))
|
2015-12-23 21:19:57 +00:00
|
|
|
, _save(this, lang(lng_connection_save), st::defaultBoxButton)
|
|
|
|
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
|
|
|
|
|
2015-12-27 21:37:48 +00:00
|
|
|
setMaxHeight(3 * _sectionHeight + st::setLittleSkip + _gifPlay.height() + st::setLittleSkip + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom());
|
2015-12-23 21:19:57 +00:00
|
|
|
|
|
|
|
connect(&_save, SIGNAL(clicked()), this, SLOT(onSave()));
|
|
|
|
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
|
|
|
|
|
|
|
|
prepare();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AutoDownloadBox::showAll() {
|
|
|
|
_photoPrivate.show();
|
|
|
|
_photoGroups.show();
|
|
|
|
_audioPrivate.show();
|
|
|
|
_audioGroups.show();
|
|
|
|
_gifPrivate.show();
|
|
|
|
_gifGroups.show();
|
2015-12-27 21:37:48 +00:00
|
|
|
_gifPlay.show();
|
2015-12-23 21:19:57 +00:00
|
|
|
|
|
|
|
_save.show();
|
|
|
|
_cancel.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AutoDownloadBox::paintEvent(QPaintEvent *e) {
|
|
|
|
Painter p(this);
|
|
|
|
if (paint(p)) return;
|
|
|
|
|
|
|
|
p.setPen(st::black);
|
|
|
|
p.setFont(st::semiboldFont);
|
|
|
|
p.drawTextLeft(st::boxTitlePosition.x(), st::boxTitlePosition.y(), width(), lang(lng_media_auto_photo));
|
|
|
|
p.drawTextLeft(st::boxTitlePosition.x(), _sectionHeight + st::boxTitlePosition.y(), width(), lang(lng_media_auto_audio));
|
|
|
|
p.drawTextLeft(st::boxTitlePosition.x(), 2 * _sectionHeight + st::boxTitlePosition.y(), width(), lang(lng_media_auto_gif));
|
|
|
|
}
|
|
|
|
|
|
|
|
void AutoDownloadBox::resizeEvent(QResizeEvent *e) {
|
|
|
|
_photoPrivate.moveToLeft(st::boxTitlePosition.x(), st::boxTitleHeight + st::setLittleSkip);
|
|
|
|
_photoGroups.moveToLeft(st::boxTitlePosition.x(), _photoPrivate.y() + _photoPrivate.height() + st::setLittleSkip);
|
|
|
|
|
|
|
|
_audioPrivate.moveToLeft(st::boxTitlePosition.x(), _sectionHeight + st::boxTitleHeight + st::setLittleSkip);
|
|
|
|
_audioGroups.moveToLeft(st::boxTitlePosition.x(), _audioPrivate.y() + _audioPrivate.height() + st::setLittleSkip);
|
|
|
|
|
|
|
|
_gifPrivate.moveToLeft(st::boxTitlePosition.x(), 2 * _sectionHeight + st::boxTitleHeight + st::setLittleSkip);
|
|
|
|
_gifGroups.moveToLeft(st::boxTitlePosition.x(), _gifPrivate.y() + _gifPrivate.height() + st::setLittleSkip);
|
2015-12-27 21:37:48 +00:00
|
|
|
_gifPlay.moveToLeft(st::boxTitlePosition.x(), _gifGroups.y() + _gifGroups.height() + st::setLittleSkip);
|
2015-12-23 21:19:57 +00:00
|
|
|
|
|
|
|
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
|
|
|
|
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
|
2016-08-17 15:14:08 +00:00
|
|
|
|
|
|
|
AbstractBox::resizeEvent(e);
|
2015-12-23 21:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AutoDownloadBox::onSave() {
|
2015-12-27 21:37:48 +00:00
|
|
|
bool changed = false;
|
|
|
|
int32 autoDownloadPhoto = (_photoPrivate.checked() ? 0 : dbiadNoPrivate) | (_photoGroups.checked() ? 0 : dbiadNoGroups);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
int32 autoDownloadAudio = (_audioPrivate.checked() ? 0 : dbiadNoPrivate) | (_audioGroups.checked() ? 0 : dbiadNoGroups);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
int32 autoDownloadGif = (_gifPrivate.checked() ? 0 : dbiadNoPrivate) | (_gifGroups.checked() ? 0 : dbiadNoGroups);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
if (cAutoPlayGif() != _gifPlay.checked()) {
|
|
|
|
cSetAutoPlayGif(_gifPlay.checked());
|
|
|
|
if (!cAutoPlayGif()) {
|
|
|
|
App::stopGifItems();
|
|
|
|
}
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (changed) Local::writeUserSettings();
|
2015-12-23 21:19:57 +00:00
|
|
|
onClose();
|
|
|
|
}
|