mirror of https://github.com/procxx/kepka.git
Most of the new Settings are done.
Left: auto update, privacy and security, local storage box + some minor things, like design fixes, codes like loadlang and clearing of the local storage (box) and temp download folder.
This commit is contained in:
parent
993b91ac15
commit
fdab386178
|
@ -39,6 +39,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "apiwrap.h"
|
||||
#include "numbers.h"
|
||||
#include "observer_peer.h"
|
||||
#include "window/chat_background.h"
|
||||
|
||||
namespace {
|
||||
App::LaunchState _launchState = App::Launched;
|
||||
|
@ -501,7 +502,7 @@ namespace {
|
|||
}
|
||||
if (d.is_self() && ::self != data) {
|
||||
::self = data;
|
||||
if (App::wnd()) App::wnd()->updateGlobalMenu();
|
||||
Global::RefSelfChanged().notify();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2034,8 +2035,8 @@ namespace {
|
|||
::gifItems.clear();
|
||||
lastPhotos.clear();
|
||||
lastPhotosMap.clear();
|
||||
::self = 0;
|
||||
if (App::wnd()) App::wnd()->updateGlobalMenu();
|
||||
::self = nullptr;
|
||||
Global::RefSelfChanged().notify(true);
|
||||
}
|
||||
|
||||
void historyRegDependency(HistoryItem *dependent, HistoryItem *dependency) {
|
||||
|
@ -2323,7 +2324,7 @@ namespace {
|
|||
}
|
||||
|
||||
void playSound() {
|
||||
if (cSoundNotify() && !psSkipAudioNotify()) audioPlayNotify();
|
||||
if (Global::SoundNotify() && !psSkipAudioNotify()) audioPlayNotify();
|
||||
}
|
||||
|
||||
void checkImageCacheSize() {
|
||||
|
@ -2584,11 +2585,11 @@ namespace {
|
|||
|
||||
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
QNetworkProxy getHttpProxySettings() {
|
||||
const ConnectionProxy *proxy = 0;
|
||||
const ProxyData *proxy = nullptr;
|
||||
if (Global::started()) {
|
||||
proxy = (cConnectionType() == dbictHttpProxy) ? (&cConnectionProxy()) : 0;
|
||||
proxy = (Global::ConnectionType() == dbictHttpProxy) ? (&Global::ConnectionProxy()) : nullptr;
|
||||
} else {
|
||||
proxy = Sandbox::PreLaunchProxy().host.isEmpty() ? 0 : (&Sandbox::PreLaunchProxy());
|
||||
proxy = Sandbox::PreLaunchProxy().host.isEmpty() ? nullptr : (&Sandbox::PreLaunchProxy());
|
||||
}
|
||||
if (proxy) {
|
||||
return QNetworkProxy(QNetworkProxy::HttpProxy, proxy->host, proxy->port, proxy->user, proxy->password);
|
||||
|
@ -2599,8 +2600,8 @@ namespace {
|
|||
|
||||
void setProxySettings(QTcpSocket &socket) {
|
||||
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
if (cConnectionType() == dbictTcpProxy) {
|
||||
const ConnectionProxy &p(cConnectionProxy());
|
||||
if (Global::ConnectionType() == dbictTcpProxy) {
|
||||
auto &p = Global::ConnectionProxy();
|
||||
socket.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, p.host, p.port, p.user, p.password));
|
||||
} else {
|
||||
socket.setProxy(QNetworkProxy(QNetworkProxy::NoProxy));
|
||||
|
@ -2673,50 +2674,43 @@ namespace {
|
|||
|
||||
uint64 components[3] = { 0 }, componentsScroll[3] = { 0 }, componentsPoint[3] = { 0 };
|
||||
int size = 0;
|
||||
{
|
||||
QImage img(p);
|
||||
bool remove = false;
|
||||
if (p.isNull()) {
|
||||
if (id == DefaultChatBackground) {
|
||||
img.load(st::msgBG);
|
||||
} else {
|
||||
img.load(st::msgBG0);
|
||||
if (cRetina()) {
|
||||
img = img.scaledToWidth(img.width() * 2, Qt::SmoothTransformation);
|
||||
} else if (cScale() != dbisOne) {
|
||||
img = img.scaledToWidth(convertScale(img.width()), Qt::SmoothTransformation);
|
||||
}
|
||||
id = 0;
|
||||
|
||||
QImage img(p);
|
||||
bool remove = false;
|
||||
if (p.isNull()) {
|
||||
if (id == DefaultChatBackground) {
|
||||
img.load(st::msgBG);
|
||||
} else {
|
||||
img.load(st::msgBG0);
|
||||
if (cRetina()) {
|
||||
img = img.scaledToWidth(img.width() * 2, Qt::SmoothTransformation);
|
||||
} else if (cScale() != dbisOne) {
|
||||
img = img.scaledToWidth(convertScale(img.width()), Qt::SmoothTransformation);
|
||||
}
|
||||
remove = true;
|
||||
id = 0;
|
||||
}
|
||||
if (img.format() != QImage::Format_ARGB32 && img.format() != QImage::Format_ARGB32_Premultiplied && img.format() != QImage::Format_RGB32) {
|
||||
img = img.convertToFormat(QImage::Format_RGB32);
|
||||
}
|
||||
img.setDevicePixelRatio(cRetinaFactor());
|
||||
|
||||
if (!nowrite) {
|
||||
Local::writeBackground(id, remove ? QImage() : img);
|
||||
}
|
||||
|
||||
int w = img.width(), h = img.height();
|
||||
size = w * h;
|
||||
const uchar *pix = img.constBits();
|
||||
if (pix) {
|
||||
for (int32 i = 0, l = size * 4; i < l; i += 4) {
|
||||
components[2] += pix[i + 0];
|
||||
components[1] += pix[i + 1];
|
||||
components[0] += pix[i + 2];
|
||||
}
|
||||
}
|
||||
|
||||
delete cChatBackground();
|
||||
cSetChatBackground(new QPixmap(pixmapFromImageInPlace(std_::move(img))));
|
||||
cSetChatBackgroundId(id);
|
||||
|
||||
if (App::main()) App::main()->clearCachedBackground();
|
||||
|
||||
remove = true;
|
||||
}
|
||||
if (img.format() != QImage::Format_ARGB32 && img.format() != QImage::Format_ARGB32_Premultiplied && img.format() != QImage::Format_RGB32) {
|
||||
img = img.convertToFormat(QImage::Format_RGB32);
|
||||
}
|
||||
img.setDevicePixelRatio(cRetinaFactor());
|
||||
|
||||
if (!nowrite) {
|
||||
Local::writeBackground(id, remove ? QImage() : img);
|
||||
}
|
||||
|
||||
int w = img.width(), h = img.height();
|
||||
size = w * h;
|
||||
const uchar *pix = img.constBits();
|
||||
if (pix) {
|
||||
for (int32 i = 0, l = size * 4; i < l; i += 4) {
|
||||
components[2] += pix[i + 0];
|
||||
components[1] += pix[i + 1];
|
||||
components[0] += pix[i + 2];
|
||||
}
|
||||
}
|
||||
|
||||
if (size) {
|
||||
for (int32 i = 0; i < 3; ++i) components[i] /= size;
|
||||
}
|
||||
|
@ -2733,44 +2727,42 @@ namespace {
|
|||
|
||||
uint64 max = qMax(1ULL, components[maxtomin[0]]), mid = qMax(1ULL, components[maxtomin[1]]), min = qMax(1ULL, components[maxtomin[2]]);
|
||||
|
||||
{
|
||||
QImage dog = App::sprite().toImage().copy(st::msgDogImg.rect());
|
||||
QImage::Format f = dog.format();
|
||||
if (f != QImage::Format_ARGB32 && f != QImage::Format_ARGB32_Premultiplied) {
|
||||
dog = dog.convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
||||
}
|
||||
uchar *dogBits = dog.bits();
|
||||
if (max != min) {
|
||||
float64 coef = float64(mid - min) / float64(max - min);
|
||||
for (int i = 0, s = dog.width() * dog.height() * 4; i < s; i += 4) {
|
||||
int dogmaxtomin[3] = { i, i + 1, i + 2 };
|
||||
QImage dog = App::sprite().toImage().copy(st::msgDogImg.rect());
|
||||
QImage::Format f = dog.format();
|
||||
if (f != QImage::Format_ARGB32 && f != QImage::Format_ARGB32_Premultiplied) {
|
||||
dog = dog.convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
||||
}
|
||||
uchar *dogBits = dog.bits();
|
||||
if (max != min) {
|
||||
float64 coef = float64(mid - min) / float64(max - min);
|
||||
for (int i = 0, s = dog.width() * dog.height() * 4; i < s; i += 4) {
|
||||
int dogmaxtomin[3] = { i, i + 1, i + 2 };
|
||||
if (dogBits[dogmaxtomin[0]] < dogBits[dogmaxtomin[1]]) {
|
||||
qSwap(dogmaxtomin[0], dogmaxtomin[1]);
|
||||
}
|
||||
if (dogBits[dogmaxtomin[1]] < dogBits[dogmaxtomin[2]]) {
|
||||
qSwap(dogmaxtomin[1], dogmaxtomin[2]);
|
||||
if (dogBits[dogmaxtomin[0]] < dogBits[dogmaxtomin[1]]) {
|
||||
qSwap(dogmaxtomin[0], dogmaxtomin[1]);
|
||||
}
|
||||
if (dogBits[dogmaxtomin[1]] < dogBits[dogmaxtomin[2]]) {
|
||||
qSwap(dogmaxtomin[1], dogmaxtomin[2]);
|
||||
if (dogBits[dogmaxtomin[0]] < dogBits[dogmaxtomin[1]]) {
|
||||
qSwap(dogmaxtomin[0], dogmaxtomin[1]);
|
||||
}
|
||||
}
|
||||
uchar result[3];
|
||||
result[maxtomin[0]] = dogBits[dogmaxtomin[0]];
|
||||
result[maxtomin[2]] = dogBits[dogmaxtomin[2]];
|
||||
result[maxtomin[1]] = uchar(qRound(result[maxtomin[2]] + (result[maxtomin[0]] - result[maxtomin[2]]) * coef));
|
||||
dogBits[i] = result[2];
|
||||
dogBits[i + 1] = result[1];
|
||||
dogBits[i + 2] = result[0];
|
||||
}
|
||||
} else {
|
||||
for (int i = 0, s = dog.width() * dog.height() * 4; i < s; i += 4) {
|
||||
uchar b = dogBits[i], g = dogBits[i + 1], r = dogBits[i + 2];
|
||||
dogBits[i] = dogBits[i + 1] = dogBits[i + 2] = (r + r + b + g + g + g) / 6;
|
||||
}
|
||||
uchar result[3];
|
||||
result[maxtomin[0]] = dogBits[dogmaxtomin[0]];
|
||||
result[maxtomin[2]] = dogBits[dogmaxtomin[2]];
|
||||
result[maxtomin[1]] = uchar(qRound(result[maxtomin[2]] + (result[maxtomin[0]] - result[maxtomin[2]]) * coef));
|
||||
dogBits[i] = result[2];
|
||||
dogBits[i + 1] = result[1];
|
||||
dogBits[i + 2] = result[0];
|
||||
}
|
||||
} else {
|
||||
for (int i = 0, s = dog.width() * dog.height() * 4; i < s; i += 4) {
|
||||
uchar b = dogBits[i], g = dogBits[i + 1], r = dogBits[i + 2];
|
||||
dogBits[i] = dogBits[i + 1] = dogBits[i + 2] = (r + r + b + g + g + g) / 6;
|
||||
}
|
||||
delete cChatDogImage();
|
||||
cSetChatDogImage(new QPixmap(pixmapFromImageInPlace(std_::move(dog))));
|
||||
}
|
||||
|
||||
Window::chatBackground()->init(id, pixmapFromImageInPlace(std_::move(img)), pixmapFromImageInPlace(std_::move(dog)));
|
||||
|
||||
memcpy(componentsScroll, components, sizeof(components));
|
||||
memcpy(componentsPoint, components, sizeof(components));
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "core/observer.h"
|
||||
#include "observer_peer.h"
|
||||
#include "core/observer.h"
|
||||
#include "window/chat_background.h"
|
||||
|
||||
namespace {
|
||||
void mtpStateChanged(int32 dc, int32 state) {
|
||||
|
@ -1090,11 +1091,7 @@ AppClass::~AppClass() {
|
|||
deleteAndMark(_uploader);
|
||||
deleteAndMark(_translator);
|
||||
|
||||
delete cChatBackground();
|
||||
cSetChatBackground(0);
|
||||
|
||||
delete cChatDogImage();
|
||||
cSetChatDogImage(0);
|
||||
Window::chatBackground()->reset();
|
||||
|
||||
style::stopManager();
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "settingswidget.h"
|
||||
#include "window/chat_background.h"
|
||||
#include "styles/style_overview.h"
|
||||
|
||||
BackgroundInner::BackgroundInner() :
|
||||
|
@ -130,7 +131,7 @@ void BackgroundInner::paintEvent(QPaintEvent *e) {
|
|||
const QPixmap &pix(paper.thumb->pix(st::backgroundSize.width(), st::backgroundSize.height()));
|
||||
p.drawPixmap(x, y, pix);
|
||||
|
||||
if (paper.id == cChatBackgroundId()) {
|
||||
if (paper.id == Window::chatBackground()->id()) {
|
||||
int checkPosX = x + st::backgroundSize.width() - st::overviewPhotoChecked.width();
|
||||
int checkPosY = y + st::backgroundSize.height() - st::overviewPhotoChecked.height();
|
||||
st::overviewPhotoChecked.paint(p, QPoint(checkPosX, checkPosY), width());
|
||||
|
@ -196,9 +197,9 @@ void BackgroundBox::onBackgroundChosen(int index) {
|
|||
if (index >= 0 && index < App::cServerBackgrounds().size()) {
|
||||
const App::WallPaper &paper(App::cServerBackgrounds().at(index));
|
||||
if (App::main()) App::main()->setChatBackground(paper);
|
||||
if (_updateCallback) {
|
||||
_updateCallback(!paper.id);
|
||||
}
|
||||
|
||||
using Update = Window::ChatBackgroundUpdate;
|
||||
Window::chatBackground()->notify(Update(Update::Type::Start, !paper.id));
|
||||
}
|
||||
onClose();
|
||||
}
|
||||
|
|
|
@ -54,11 +54,6 @@ class BackgroundBox : public ItemListBox {
|
|||
public:
|
||||
BackgroundBox();
|
||||
|
||||
// When background is chosen this callback is called with "bool isTiled" arg.
|
||||
void setUpdateCallback(base::lambda_unique<void(bool)> &&updateCallback) {
|
||||
_updateCallback = std::move(updateCallback);
|
||||
}
|
||||
|
||||
public slots:
|
||||
void onBackgroundChosen(int index);
|
||||
|
||||
|
@ -67,6 +62,5 @@ protected:
|
|||
|
||||
private:
|
||||
BackgroundInner _inner;
|
||||
base::lambda_unique<void(bool)> _updateCallback;
|
||||
|
||||
};
|
||||
|
|
|
@ -28,14 +28,14 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "mainwindow.h"
|
||||
|
||||
ConnectionBox::ConnectionBox() : AbstractBox(st::boxWidth)
|
||||
, _hostInput(this, st::connectionHostInputField, lang(lng_connection_host_ph), cConnectionProxy().host)
|
||||
, _portInput(this, st::connectionPortInputField, lang(lng_connection_port_ph), QString::number(cConnectionProxy().port))
|
||||
, _userInput(this, st::connectionUserInputField, lang(lng_connection_user_ph), cConnectionProxy().user)
|
||||
, _passwordInput(this, st::connectionPasswordInputField, lang(lng_connection_password_ph), cConnectionProxy().password)
|
||||
, _autoRadio(this, qsl("conn_type"), dbictAuto, lang(lng_connection_auto_rb), (cConnectionType() == dbictAuto))
|
||||
, _httpProxyRadio(this, qsl("conn_type"), dbictHttpProxy, lang(lng_connection_http_proxy_rb), (cConnectionType() == dbictHttpProxy))
|
||||
, _tcpProxyRadio(this, qsl("conn_type"), dbictTcpProxy, lang(lng_connection_tcp_proxy_rb), (cConnectionType() == dbictTcpProxy))
|
||||
, _tryIPv6(this, lang(lng_connection_try_ipv6), cTryIPv6(), st::defaultBoxCheckbox)
|
||||
, _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)
|
||||
, _save(this, lang(lng_connection_save), st::defaultBoxButton)
|
||||
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
|
||||
|
||||
|
@ -167,7 +167,7 @@ void ConnectionBox::onSubmit() {
|
|||
|
||||
void ConnectionBox::onSave() {
|
||||
if (_httpProxyRadio.checked() || _tcpProxyRadio.checked()) {
|
||||
ConnectionProxy p;
|
||||
ProxyData p;
|
||||
p.host = _hostInput.getLastText().trimmed();
|
||||
p.user = _userInput.getLastText().trimmed();
|
||||
p.password = _passwordInput.getLastText().trimmed();
|
||||
|
@ -180,28 +180,32 @@ void ConnectionBox::onSave() {
|
|||
return;
|
||||
}
|
||||
if (_httpProxyRadio.checked()) {
|
||||
cSetConnectionType(dbictHttpProxy);
|
||||
Global::SetConnectionType(dbictHttpProxy);
|
||||
} else {
|
||||
cSetConnectionType(dbictTcpProxy);
|
||||
Global::SetConnectionType(dbictTcpProxy);
|
||||
}
|
||||
cSetConnectionProxy(p);
|
||||
Global::SetConnectionProxy(p);
|
||||
} else {
|
||||
cSetConnectionType(dbictAuto);
|
||||
cSetConnectionProxy(ConnectionProxy());
|
||||
Global::SetConnectionType(dbictAuto);
|
||||
Global::SetConnectionProxy(ProxyData());
|
||||
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(false);
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||
#endif
|
||||
}
|
||||
if (cPlatform() == dbipWindows && cTryIPv6() != _tryIPv6.checked()) {
|
||||
cSetTryIPv6(_tryIPv6.checked());
|
||||
if (cPlatform() == dbipWindows && Global::TryIPv6() != _tryIPv6.checked()) {
|
||||
Global::SetTryIPv6(_tryIPv6.checked());
|
||||
Local::writeSettings();
|
||||
Global::RefConnectionTypeChanged().notify();
|
||||
|
||||
cSetRestarting(true);
|
||||
cSetRestartingToSettings(true);
|
||||
App::quit();
|
||||
} else {
|
||||
cSetTryIPv6(_tryIPv6.checked());
|
||||
Global::SetTryIPv6(_tryIPv6.checked());
|
||||
Local::writeSettings();
|
||||
Global::RefConnectionTypeChanged().notify();
|
||||
|
||||
MTP::restart();
|
||||
reinitImageLinkManager();
|
||||
reinitWebLoadManager();
|
||||
|
|
|
@ -27,28 +27,9 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "ui/filedialog.h"
|
||||
#include "pspecific.h"
|
||||
|
||||
namespace internal {
|
||||
namespace {
|
||||
|
||||
void StartCallback() {
|
||||
}
|
||||
|
||||
void FinishCallback() {
|
||||
}
|
||||
|
||||
Notify::SimpleObservedEventRegistrator<DownloadPathUpdateHandler> creator(StartCallback, FinishCallback);
|
||||
|
||||
} // namespace
|
||||
|
||||
Notify::ConnectionId plainRegisterObserver(DownloadPathUpdateHandler &&handler) {
|
||||
return creator.registerObserver(std_::forward<DownloadPathUpdateHandler>(handler));
|
||||
}
|
||||
|
||||
} // namespace interanl
|
||||
|
||||
DownloadPathBox::DownloadPathBox() : AbstractBox()
|
||||
, _path(cDownloadPath())
|
||||
, _pathBookmark(cDownloadPathBookmark())
|
||||
, _path(Global::DownloadPath())
|
||||
, _pathBookmark(Global::DownloadPathBookmark())
|
||||
, _default(this, qsl("dir_type"), 0, lang(lng_download_path_default_radio), _path.isEmpty())
|
||||
, _temp(this, qsl("dir_type"), 1, lang(lng_download_path_temp_radio), _path == qsl("tmp"))
|
||||
, _dir(this, qsl("dir_type"), 2, lang(lng_download_path_dir_radio), !_path.isEmpty() && _path != qsl("tmp"))
|
||||
|
@ -135,8 +116,8 @@ void DownloadPathBox::onChange() {
|
|||
void DownloadPathBox::onEditPath() {
|
||||
filedialogInit();
|
||||
QString path, lastPath = cDialogLastPath();
|
||||
if (!cDownloadPath().isEmpty() && cDownloadPath() != qstr("tmp")) {
|
||||
cSetDialogLastPath(cDownloadPath().left(cDownloadPath().size() - (cDownloadPath().endsWith('/') ? 1 : 0)));
|
||||
if (!Global::DownloadPath().isEmpty() && Global::DownloadPath() != qstr("tmp")) {
|
||||
cSetDialogLastPath(Global::DownloadPath().left(Global::DownloadPath().size() - (Global::DownloadPath().endsWith('/') ? 1 : 0)));
|
||||
}
|
||||
if (filedialogGetDir(path, lang(lng_download_path_choose))) {
|
||||
if (!path.isEmpty()) {
|
||||
|
@ -149,10 +130,10 @@ void DownloadPathBox::onEditPath() {
|
|||
}
|
||||
|
||||
void DownloadPathBox::onSave() {
|
||||
cSetDownloadPath(_default.checked() ? QString() : (_temp.checked() ? qsl("tmp") : _path));
|
||||
cSetDownloadPathBookmark((_default.checked() || _temp.checked()) ? QByteArray() : _pathBookmark);
|
||||
Global::SetDownloadPath(_default.checked() ? QString() : (_temp.checked() ? qsl("tmp") : _path));
|
||||
Global::SetDownloadPathBookmark((_default.checked() || _temp.checked()) ? QByteArray() : _pathBookmark);
|
||||
Local::writeUserSettings();
|
||||
internal::creator.notify(DownloadPathUpdate());
|
||||
Global::RefDownloadPathChanged().notify();
|
||||
onClose();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,21 +23,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "abstractbox.h"
|
||||
#include "core/observer.h"
|
||||
|
||||
// Just a notification that cDownloadPath() has changed.
|
||||
struct DownloadPathUpdate {
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
using DownloadPathUpdateHandler = Function<void, const DownloadPathUpdate&>;
|
||||
Notify::ConnectionId plainRegisterObserver(DownloadPathUpdateHandler &&handler);
|
||||
} // namespace internal
|
||||
|
||||
template <typename ObserverType>
|
||||
void registerDownloadPathObserver(ObserverType *observer, void (ObserverType::*handler)(const DownloadPathUpdate &)) {
|
||||
auto connection = internal::plainRegisterObserver(func(observer, handler));
|
||||
Notify::observerRegistered(observer, connection);
|
||||
}
|
||||
|
||||
class DownloadPathBox : public AbstractBox {
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -747,11 +747,9 @@ enum DBIDefaultAttach {
|
|||
dbidaPhoto = 1,
|
||||
};
|
||||
|
||||
struct ConnectionProxy {
|
||||
ConnectionProxy() : port(0) {
|
||||
}
|
||||
struct ProxyData {
|
||||
QString host;
|
||||
uint32 port;
|
||||
uint32 port = 0;
|
||||
QString user, password;
|
||||
};
|
||||
|
||||
|
|
|
@ -331,12 +331,10 @@ public:
|
|||
using Handler = typename CommonObservableData<EventType>::Handler;
|
||||
|
||||
Subscription subscribe(Handler &&handler) {
|
||||
if (_data) {
|
||||
_data->append(std_::forward<Handler>(handler));
|
||||
} else {
|
||||
_data = MakeShared<ObservableData<EventType>>(this, std_::forward<Handler>(handler));
|
||||
if (!_data) {
|
||||
_data = MakeShared<ObservableData<EventType>>(this);
|
||||
}
|
||||
return _data->last();
|
||||
return _data->append(std_::forward<Handler>(handler));
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -352,9 +350,9 @@ private:
|
|||
template <typename EventType>
|
||||
class Observable : public internal::CommonObservable<EventType> {
|
||||
public:
|
||||
void notify(EventType &&event) {
|
||||
void notify(EventType &&event, bool sync = false) {
|
||||
if (_data) {
|
||||
_data->notify(std_::move(event));
|
||||
_data->notify(std_::move(event), sync);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,20 +365,18 @@ class CommonObservableData : public BaseObservableData {
|
|||
public:
|
||||
using Handler = SubscriptionHandler<EventType>;
|
||||
|
||||
CommonObservableData(CommonObservable<EventType> *observable, Handler &&handler) : _observable(observable)
|
||||
, _begin(new Node(observable->_data, std_::forward<Handler>(handler)))
|
||||
, _end(_begin) {
|
||||
CommonObservableData(CommonObservable<EventType> *observable) : _observable(observable) {
|
||||
}
|
||||
|
||||
void append(Handler &&handler) {
|
||||
Subscription append(Handler &&handler) {
|
||||
auto node = new Node(_observable->_data, std_::forward<Handler>(handler));
|
||||
|
||||
_end->next = node;
|
||||
node->prev = _end;
|
||||
_end = node;
|
||||
}
|
||||
|
||||
Subscription last() {
|
||||
if (_begin) {
|
||||
_end->next = node;
|
||||
node->prev = _end;
|
||||
_end = node;
|
||||
} else {
|
||||
_begin = _end = node;
|
||||
}
|
||||
return { _end, &CommonObservableData::destroyNode };
|
||||
}
|
||||
|
||||
|
@ -435,15 +431,15 @@ private:
|
|||
}
|
||||
} while (_current);
|
||||
|
||||
if (!_begin) {
|
||||
if (empty()) {
|
||||
_observable->_data.reset();
|
||||
}
|
||||
}
|
||||
|
||||
CommonObservable<EventType> *_observable = nullptr;
|
||||
Node *_begin;
|
||||
Node *_begin = nullptr;
|
||||
Node *_current = nullptr;
|
||||
Node *_end;
|
||||
Node *_end = nullptr;
|
||||
ObservableCallHandlers _callHandlers;
|
||||
|
||||
friend class ObservableData<EventType>;
|
||||
|
@ -455,16 +451,24 @@ class ObservableData : public CommonObservableData<EventType> {
|
|||
public:
|
||||
using CommonObservableData<EventType>::CommonObservableData;
|
||||
|
||||
void notify(EventType &&event) {
|
||||
if (!_callHandlers) {
|
||||
_callHandlers = [this]() {
|
||||
callHandlers();
|
||||
};
|
||||
void notify(EventType &&event, bool sync) {
|
||||
if (_handling) {
|
||||
sync = false;
|
||||
}
|
||||
if (_events.empty()) {
|
||||
RegisterPendingObservable(&_callHandlers);
|
||||
if (sync) {
|
||||
_events.push_back(std_::move(event));
|
||||
callHandlers();
|
||||
} else {
|
||||
if (!_callHandlers) {
|
||||
_callHandlers = [this]() {
|
||||
callHandlers();
|
||||
};
|
||||
}
|
||||
if (_events.empty()) {
|
||||
RegisterPendingObservable(&_callHandlers);
|
||||
}
|
||||
_events.push_back(std_::move(event));
|
||||
}
|
||||
_events.push_back(std_::move(event));
|
||||
}
|
||||
|
||||
~ObservableData() {
|
||||
|
@ -473,16 +477,19 @@ public:
|
|||
|
||||
private:
|
||||
void callHandlers() {
|
||||
_handling = true;
|
||||
auto events = createAndSwap(_events);
|
||||
for (auto &event : events) {
|
||||
notifyEnumerate([this, &event]() {
|
||||
_current->handler(event);
|
||||
});
|
||||
}
|
||||
_handling = false;
|
||||
UnregisterActiveObservable(&_callHandlers);
|
||||
}
|
||||
|
||||
std_::vector_of_moveable<EventType> _events;
|
||||
bool _handling = false;
|
||||
|
||||
};
|
||||
|
||||
|
@ -491,16 +498,24 @@ class ObservableData<void> : public CommonObservableData<void> {
|
|||
public:
|
||||
using CommonObservableData<void>::CommonObservableData;
|
||||
|
||||
void notify() {
|
||||
if (!_callHandlers) {
|
||||
_callHandlers = [this]() {
|
||||
callHandlers();
|
||||
};
|
||||
void notify(bool sync) {
|
||||
if (_handling) {
|
||||
sync = false;
|
||||
}
|
||||
if (!_eventsCount) {
|
||||
RegisterPendingObservable(&_callHandlers);
|
||||
if (sync) {
|
||||
++_eventsCount;
|
||||
callHandlers();
|
||||
} else {
|
||||
if (!_callHandlers) {
|
||||
_callHandlers = [this]() {
|
||||
callHandlers();
|
||||
};
|
||||
}
|
||||
if (!_eventsCount) {
|
||||
RegisterPendingObservable(&_callHandlers);
|
||||
}
|
||||
++_eventsCount;
|
||||
}
|
||||
++_eventsCount;
|
||||
}
|
||||
|
||||
~ObservableData() {
|
||||
|
@ -509,16 +524,19 @@ public:
|
|||
|
||||
private:
|
||||
void callHandlers() {
|
||||
_handling = true;
|
||||
auto eventsCount = createAndSwap(_eventsCount);
|
||||
for (int i = 0; i != eventsCount; ++i) {
|
||||
notifyEnumerate([this]() {
|
||||
_current->handler();
|
||||
});
|
||||
}
|
||||
_handling = false;
|
||||
UnregisterActiveObservable(&_callHandlers);
|
||||
}
|
||||
|
||||
int _eventsCount = 0;
|
||||
bool _handling = false;
|
||||
|
||||
};
|
||||
|
||||
|
@ -527,9 +545,9 @@ private:
|
|||
template <>
|
||||
class Observable<void> : public internal::CommonObservable<void> {
|
||||
public:
|
||||
void notify() {
|
||||
void notify(bool sync = false) {
|
||||
if (_data) {
|
||||
_data->notify();
|
||||
_data->notify(sync);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -553,6 +571,13 @@ protected:
|
|||
_subscriptions[index].destroy();
|
||||
}
|
||||
|
||||
~Subscriber() {
|
||||
auto subscriptions = createAndSwap(_subscriptions);
|
||||
for (auto &subscription : subscriptions) {
|
||||
subscription.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std_::vector_of_moveable<base::Subscription> _subscriptions;
|
||||
|
||||
|
|
|
@ -107,3 +107,7 @@ dialogsNewChatButton: RoundButton {
|
|||
textBg: transparent;
|
||||
textBgOver: transparent;
|
||||
}
|
||||
|
||||
settingsEditIcon: icon {
|
||||
{ "dialogs_new_chat", #b7b7b7, point(3px, 9px) }
|
||||
};
|
||||
|
|
|
@ -30,6 +30,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "boxes/confirmbox.h"
|
||||
#include "layerwidget.h"
|
||||
#include "lang.h"
|
||||
#include "core/observer.h"
|
||||
|
||||
Q_DECLARE_METATYPE(ClickHandlerPtr);
|
||||
Q_DECLARE_METATYPE(Qt::MouseButton);
|
||||
|
@ -407,7 +408,7 @@ struct Data {
|
|||
int32 LangSystem = languageDefault;
|
||||
|
||||
QByteArray LastCrashDump;
|
||||
ConnectionProxy PreLaunchProxy;
|
||||
ProxyData PreLaunchProxy;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
@ -525,7 +526,7 @@ uint64 UserTag() {
|
|||
DefineReadOnlyVar(Sandbox, QString, LangSystemISO);
|
||||
DefineReadOnlyVar(Sandbox, int32, LangSystem);
|
||||
DefineVar(Sandbox, QByteArray, LastCrashDump);
|
||||
DefineVar(Sandbox, ConnectionProxy, PreLaunchProxy);
|
||||
DefineVar(Sandbox, ProxyData, PreLaunchProxy);
|
||||
|
||||
} // namespace Sandbox
|
||||
|
||||
|
@ -581,6 +582,8 @@ struct Data {
|
|||
|
||||
Adaptive::Layout AdaptiveLayout = Adaptive::NormalLayout;
|
||||
bool AdaptiveForWide = true;
|
||||
base::Observable<void> AdaptiveChanged;
|
||||
|
||||
bool DialogsModeEnabled = false;
|
||||
Dialogs::Mode DialogsMode = Dialogs::Mode::All;
|
||||
bool ModerateModeEnabled = false;
|
||||
|
@ -626,6 +629,27 @@ struct Data {
|
|||
MTP::DcOptions DcOptions;
|
||||
|
||||
CircleMasksMap CircleMasks;
|
||||
|
||||
base::Observable<void> SelfChanged;
|
||||
|
||||
bool AskDownloadPath = false;
|
||||
QString DownloadPath;
|
||||
QByteArray DownloadPathBookmark;
|
||||
base::Observable<void> DownloadPathChanged;
|
||||
|
||||
bool SoundNotify = true;
|
||||
bool DesktopNotify = true;
|
||||
bool RestoreSoundNotifyFromTray = false;
|
||||
bool IncludeMuted = true;
|
||||
DBINotifyView NotifyView = dbinvShowPreview;
|
||||
bool WindowsNotifications = true;
|
||||
bool CustomNotifies = (cPlatform() == dbipMac) ? false : true;
|
||||
base::Observable<Notify::ChangeType> NotifySettingsChanged;
|
||||
|
||||
DBIConnectionType ConnectionType = dbictAuto;
|
||||
bool TryIPv6 = (cPlatform() == dbipWindows) ? false : true;
|
||||
ProxyData ConnectionProxy;
|
||||
base::Observable<void> ConnectionTypeChanged;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
@ -659,6 +683,8 @@ DefineRefVar(Global, SingleDelayedCall, HandleObservables);
|
|||
|
||||
DefineVar(Global, Adaptive::Layout, AdaptiveLayout);
|
||||
DefineVar(Global, bool, AdaptiveForWide);
|
||||
DefineRefVar(Global, base::Observable<void>, AdaptiveChanged);
|
||||
|
||||
DefineVar(Global, bool, DialogsModeEnabled);
|
||||
DefineVar(Global, Dialogs::Mode, DialogsMode);
|
||||
DefineVar(Global, bool, ModerateModeEnabled);
|
||||
|
@ -705,4 +731,25 @@ DefineVar(Global, MTP::DcOptions, DcOptions);
|
|||
|
||||
DefineRefVar(Global, CircleMasksMap, CircleMasks);
|
||||
|
||||
DefineRefVar(Global, base::Observable<void>, SelfChanged);
|
||||
|
||||
DefineVar(Global, bool, AskDownloadPath);
|
||||
DefineVar(Global, QString, DownloadPath);
|
||||
DefineVar(Global, QByteArray, DownloadPathBookmark);
|
||||
DefineRefVar(Global, base::Observable<void>, DownloadPathChanged);
|
||||
|
||||
DefineVar(Global, bool, SoundNotify);
|
||||
DefineVar(Global, bool, DesktopNotify);
|
||||
DefineVar(Global, bool, RestoreSoundNotifyFromTray);
|
||||
DefineVar(Global, bool, IncludeMuted);
|
||||
DefineVar(Global, DBINotifyView, NotifyView);
|
||||
DefineVar(Global, bool, WindowsNotifications);
|
||||
DefineVar(Global, bool, CustomNotifies);
|
||||
DefineRefVar(Global, base::Observable<Notify::ChangeType>, NotifySettingsChanged);
|
||||
|
||||
DefineVar(Global, DBIConnectionType, ConnectionType);
|
||||
DefineVar(Global, bool, TryIPv6);
|
||||
DefineVar(Global, ProxyData, ConnectionProxy);
|
||||
DefineRefVar(Global, base::Observable<void>, ConnectionTypeChanged);
|
||||
|
||||
} // namespace Global
|
||||
|
|
|
@ -21,6 +21,16 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#pragma once
|
||||
|
||||
class LayerWidget;
|
||||
namespace base {
|
||||
template <typename Type>
|
||||
class Observable;
|
||||
} // namespace base
|
||||
namespace InlineBots {
|
||||
namespace Layout {
|
||||
class ItemBase;
|
||||
} // namespace Layout
|
||||
} // namespace InlineBots
|
||||
|
||||
|
||||
namespace App {
|
||||
|
||||
|
@ -42,14 +52,6 @@ void logOutDelayed();
|
|||
|
||||
} // namespace App
|
||||
|
||||
namespace InlineBots {
|
||||
namespace Layout {
|
||||
|
||||
class ItemBase;
|
||||
|
||||
} // namespace Layout
|
||||
} // namespace InlineBots
|
||||
|
||||
namespace Ui {
|
||||
|
||||
void showMediaPreview(DocumentData *document);
|
||||
|
@ -142,6 +144,14 @@ void historyMuteUpdated(History *history);
|
|||
void handlePendingHistoryUpdate();
|
||||
void unreadCounterUpdated();
|
||||
|
||||
enum class ChangeType {
|
||||
SoundEnabled,
|
||||
IncludeMuted,
|
||||
DesktopEnabled,
|
||||
ViewParams,
|
||||
UseNative,
|
||||
};
|
||||
|
||||
} // namespace Notify
|
||||
|
||||
#define DeclareReadOnlyVar(Type, Name) const Type &Name();
|
||||
|
@ -163,7 +173,7 @@ uint64 UserTag();
|
|||
DeclareReadOnlyVar(QString, LangSystemISO);
|
||||
DeclareReadOnlyVar(int32, LangSystem);
|
||||
DeclareVar(QByteArray, LastCrashDump);
|
||||
DeclareVar(ConnectionProxy, PreLaunchProxy);
|
||||
DeclareVar(ProxyData, PreLaunchProxy);
|
||||
|
||||
} // namespace Sandbox
|
||||
|
||||
|
@ -234,6 +244,8 @@ DeclareRefVar(SingleDelayedCall, HandleObservables);
|
|||
|
||||
DeclareVar(Adaptive::Layout, AdaptiveLayout);
|
||||
DeclareVar(bool, AdaptiveForWide);
|
||||
DeclareRefVar(base::Observable<void>, AdaptiveChanged);
|
||||
|
||||
DeclareVar(bool, DialogsModeEnabled);
|
||||
DeclareVar(Dialogs::Mode, DialogsMode);
|
||||
DeclareVar(bool, ModerateModeEnabled);
|
||||
|
@ -283,10 +295,35 @@ DeclareVar(MTP::DcOptions, DcOptions);
|
|||
typedef QMap<uint64, QPixmap> CircleMasksMap;
|
||||
DeclareRefVar(CircleMasksMap, CircleMasks);
|
||||
|
||||
DeclareRefVar(base::Observable<void>, SelfChanged);
|
||||
|
||||
DeclareVar(bool, AskDownloadPath);
|
||||
DeclareVar(QString, DownloadPath);
|
||||
DeclareVar(QByteArray, DownloadPathBookmark);
|
||||
DeclareRefVar(base::Observable<void>, DownloadPathChanged);
|
||||
|
||||
DeclareVar(bool, SoundNotify);
|
||||
DeclareVar(bool, DesktopNotify);
|
||||
DeclareVar(bool, RestoreSoundNotifyFromTray);
|
||||
DeclareVar(bool, IncludeMuted);
|
||||
DeclareVar(DBINotifyView, NotifyView);
|
||||
DeclareVar(bool, WindowsNotifications);
|
||||
DeclareVar(bool, CustomNotifies);
|
||||
DeclareRefVar(base::Observable<Notify::ChangeType>, NotifySettingsChanged);
|
||||
|
||||
DeclareVar(DBIConnectionType, ConnectionType);
|
||||
DeclareVar(bool, TryIPv6);
|
||||
DeclareVar(ProxyData, ConnectionProxy);
|
||||
DeclareRefVar(base::Observable<void>, ConnectionTypeChanged);
|
||||
|
||||
} // namespace Global
|
||||
|
||||
namespace Adaptive {
|
||||
|
||||
inline base::Observable<void> &Changed() {
|
||||
return Global::RefAdaptiveChanged();
|
||||
}
|
||||
|
||||
inline bool OneColumn() {
|
||||
return Global::AdaptiveLayout() == OneColumnLayout;
|
||||
}
|
||||
|
|
|
@ -699,6 +699,14 @@ HistoryItem *Histories::addNewMessage(const MTPMessage &msg, NewMessageType type
|
|||
return result;
|
||||
}
|
||||
|
||||
int Histories::unreadBadge() const {
|
||||
return _unreadFull - (Global::IncludeMuted() ? 0 : _unreadMuted);
|
||||
}
|
||||
|
||||
bool Histories::unreadOnlyMuted() const {
|
||||
return Global::IncludeMuted() ? (_unreadMuted >= _unreadFull) : false;
|
||||
}
|
||||
|
||||
HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction, bool detachExistingItem) {
|
||||
MsgId msgId = 0;
|
||||
switch (msg.type()) {
|
||||
|
@ -1492,7 +1500,7 @@ void History::setUnreadCount(int newUnreadCount) {
|
|||
}
|
||||
if (inChatList(Dialogs::Mode::All)) {
|
||||
App::histories().unreadIncrement(newUnreadCount - _unreadCount, mute());
|
||||
if (!mute() || cIncludeMuted()) {
|
||||
if (!mute() || Global::IncludeMuted()) {
|
||||
Notify::unreadCounterUpdated();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,15 +62,11 @@ public:
|
|||
TypingHistories typing;
|
||||
Animation _a_typings;
|
||||
|
||||
int32 unreadBadge() const {
|
||||
return _unreadFull - (cIncludeMuted() ? 0 : _unreadMuted);
|
||||
}
|
||||
int32 unreadMutedCount() const {
|
||||
int unreadBadge() const;
|
||||
int unreadMutedCount() const {
|
||||
return _unreadMuted;
|
||||
}
|
||||
bool unreadOnlyMuted() const {
|
||||
return cIncludeMuted() ? (_unreadMuted >= _unreadFull) : false;
|
||||
}
|
||||
bool unreadOnlyMuted() const;
|
||||
void unreadIncrement(int32 count, bool muted) {
|
||||
_unreadFull += count;
|
||||
if (muted) {
|
||||
|
@ -86,7 +82,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
int32 _unreadFull, _unreadMuted;
|
||||
int _unreadFull, _unreadMuted;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "localstorage.h"
|
||||
#include "apiwrap.h"
|
||||
#include "window/top_bar_widget.h"
|
||||
#include "window/chat_background.h"
|
||||
#include "observer_peer.h"
|
||||
#include "playerwidget.h"
|
||||
|
||||
|
@ -361,7 +362,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
} else if (noHistoryDisplayed) {
|
||||
QPoint dogPos((width() - st::msgDogImg.pxWidth()) / 2, ((height() - st::msgDogImg.pxHeight()) * 4) / 9);
|
||||
p.drawPixmap(dogPos, *cChatDogImage());
|
||||
p.drawPixmap(dogPos, Window::chatBackground()->dog());
|
||||
}
|
||||
if (!noHistoryDisplayed) {
|
||||
adjustCurrent(r.top());
|
||||
|
@ -3149,6 +3150,8 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
|
|||
connect(&_attachDragPhoto, SIGNAL(dropped(const QMimeData*)), this, SLOT(onPhotoDrop(const QMimeData*)));
|
||||
|
||||
connect(&_updateEditTimeLeftDisplay, SIGNAL(timeout()), this, SLOT(updateField()));
|
||||
|
||||
subscribe(Adaptive::Changed(), [this]() { update(); });
|
||||
}
|
||||
|
||||
void HistoryWidget::start() {
|
||||
|
@ -5521,10 +5524,6 @@ void HistoryWidget::doneShow() {
|
|||
}
|
||||
}
|
||||
|
||||
void HistoryWidget::updateAdaptiveLayout() {
|
||||
update();
|
||||
}
|
||||
|
||||
void HistoryWidget::animStop() {
|
||||
if (!_a_show.animating()) return;
|
||||
_a_show.stop();
|
||||
|
@ -8692,8 +8691,8 @@ void HistoryWidget::paintEvent(QPaintEvent *e) {
|
|||
int fromy = (hasTopBar ? (-st::topBarHeight) : 0) + (hasPlayer ? (-st::playerHeight) : 0), x = 0, y = 0;
|
||||
QPixmap cached = App::main()->cachedBackground(fill, x, y);
|
||||
if (cached.isNull()) {
|
||||
const QPixmap &pix(*cChatBackground());
|
||||
if (cTileBackground()) {
|
||||
auto &pix = Window::chatBackground()->image();
|
||||
if (Window::chatBackground()->tile()) {
|
||||
int left = r.left(), top = r.top(), right = r.left() + r.width(), bottom = r.top() + r.height();
|
||||
float64 w = pix.width() / cRetinaFactor(), h = pix.height() / cRetinaFactor();
|
||||
int sx = qFloor(left / w), sy = qFloor((top - fromy) / h), cx = qCeil(right / w), cy = qCeil((bottom - fromy) / h);
|
||||
|
@ -8731,7 +8730,7 @@ void HistoryWidget::paintEvent(QPaintEvent *e) {
|
|||
if (_scroll.isHidden()) {
|
||||
p.setClipRect(_scroll.geometry());
|
||||
QPoint dogPos((width() - st::msgDogImg.pxWidth()) / 2, ((height() - _field.height() - 2 * st::sendPadding - st::msgDogImg.pxHeight()) * 4) / 9);
|
||||
p.drawPixmap(dogPos, *cChatDogImage());
|
||||
p.drawPixmap(dogPos, Window::chatBackground()->dog());
|
||||
}
|
||||
} else {
|
||||
style::font font(st::msgServiceFont);
|
||||
|
|
|
@ -520,7 +520,7 @@ public:
|
|||
EntitiesInText entitiesFromTextTags(const TextWithTags::Tags &tags);
|
||||
TextWithTags::Tags textTagsFromEntities(const EntitiesInText &entities);
|
||||
|
||||
class HistoryWidget : public TWidget, public RPCSender {
|
||||
class HistoryWidget : public TWidget, public RPCSender, private base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -614,7 +614,6 @@ public:
|
|||
void step_show(float64 ms, bool timer);
|
||||
void animStop();
|
||||
|
||||
void updateAdaptiveLayout();
|
||||
void doneShow();
|
||||
|
||||
QPoint clampMousePosition(QPoint point);
|
||||
|
|
|
@ -373,9 +373,6 @@ void IntroWidget::keyPressEvent(QKeyEvent *e) {
|
|||
}
|
||||
}
|
||||
|
||||
void IntroWidget::updateAdaptiveLayout() {
|
||||
}
|
||||
|
||||
void IntroWidget::rpcClear() {
|
||||
for (IntroStep *step : _stepHistory) {
|
||||
step->rpcClear();
|
||||
|
|
|
@ -34,8 +34,6 @@ public:
|
|||
void resizeEvent(QResizeEvent *e) override;
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
void updateAdaptiveLayout();
|
||||
|
||||
void animShow(const QPixmap &bgAnimCache, bool back = false);
|
||||
void step_show(float64 ms, bool timer);
|
||||
void stop_show();
|
||||
|
|
|
@ -281,9 +281,6 @@ void LayerStackWidget::resizeEvent(QResizeEvent *e) {
|
|||
updateLayerBox();
|
||||
}
|
||||
|
||||
void LayerStackWidget::updateAdaptiveLayout() {
|
||||
}
|
||||
|
||||
void LayerStackWidget::showLayer(LayerWidget *l) {
|
||||
clearLayers();
|
||||
appendLayer(l);
|
||||
|
|
|
@ -61,8 +61,6 @@ public:
|
|||
|
||||
void showFast();
|
||||
|
||||
void updateAdaptiveLayout();
|
||||
|
||||
void showLayer(LayerWidget *l);
|
||||
void showSpecialLayer(LayerWidget *l);
|
||||
void appendLayer(LayerWidget *l);
|
||||
|
|
|
@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "serialize/serialize_document.h"
|
||||
#include "serialize/serialize_common.h"
|
||||
#include "data/data_drafts.h"
|
||||
#include "window/chat_background.h"
|
||||
#include "observer_peer.h"
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
|
@ -910,7 +911,7 @@ namespace {
|
|||
stream >> v;
|
||||
if (!_checkStreamStatus(stream)) return false;
|
||||
|
||||
cSetSoundNotify(v == 1);
|
||||
Global::SetSoundNotify(v == 1);
|
||||
} break;
|
||||
|
||||
case dbiAutoDownload: {
|
||||
|
@ -960,7 +961,7 @@ namespace {
|
|||
stream >> v;
|
||||
if (!_checkStreamStatus(stream)) return false;
|
||||
|
||||
cSetIncludeMuted(v == 1);
|
||||
Global::SetIncludeMuted(v == 1);
|
||||
} break;
|
||||
|
||||
case dbiShowingSavedGifs: {
|
||||
|
@ -976,7 +977,7 @@ namespace {
|
|||
stream >> v;
|
||||
if (!_checkStreamStatus(stream)) return false;
|
||||
|
||||
cSetDesktopNotify(v == 1);
|
||||
Global::SetDesktopNotify(v == 1);
|
||||
if (App::wnd()) App::wnd()->updateTrayMenu();
|
||||
} break;
|
||||
|
||||
|
@ -985,9 +986,9 @@ namespace {
|
|||
stream >> v;
|
||||
if (!_checkStreamStatus(stream)) return false;
|
||||
|
||||
cSetWindowsNotifications(v == 1);
|
||||
Global::SetWindowsNotifications(v == 1);
|
||||
if (cPlatform() == dbipWindows) {
|
||||
cSetCustomNotifies((App::wnd() ? !App::wnd()->psHasNativeNotifications() : true) || !cWindowsNotifications());
|
||||
Global::SetCustomNotifies((App::wnd() ? !App::wnd()->psHasNativeNotifications() : true) || !Global::WindowsNotifications());
|
||||
}
|
||||
} break;
|
||||
|
||||
|
@ -1011,18 +1012,17 @@ namespace {
|
|||
switch (v) {
|
||||
case dbictHttpProxy:
|
||||
case dbictTcpProxy: {
|
||||
ConnectionProxy p;
|
||||
ProxyData p;
|
||||
qint32 port;
|
||||
stream >> p.host >> port >> p.user >> p.password;
|
||||
if (!_checkStreamStatus(stream)) return false;
|
||||
|
||||
p.port = uint32(port);
|
||||
cSetConnectionProxy(p);
|
||||
}
|
||||
cSetConnectionType(DBIConnectionType(v));
|
||||
break;
|
||||
Global::SetConnectionProxy(p);
|
||||
Global::SetConnectionType(DBIConnectionType(v));
|
||||
} break;
|
||||
case dbictHttpAuto:
|
||||
default: cSetConnectionType(dbictAuto); break;
|
||||
default: Global::SetConnectionType(dbictAuto); break;
|
||||
};
|
||||
} break;
|
||||
|
||||
|
@ -1031,7 +1031,7 @@ namespace {
|
|||
stream >> v;
|
||||
if (!_checkStreamStatus(stream)) return false;
|
||||
|
||||
cSetTryIPv6(v == 1);
|
||||
Global::SetTryIPv6(v == 1);
|
||||
} break;
|
||||
|
||||
case dbiSeenTrayTooltip: {
|
||||
|
@ -1148,10 +1148,8 @@ namespace {
|
|||
stream >> v;
|
||||
if (!_checkStreamStatus(stream)) return false;
|
||||
|
||||
cSetTileBackground(v == 1);
|
||||
if (version < 8005 && !_backgroundKey) {
|
||||
cSetTileBackground(false);
|
||||
}
|
||||
bool tile = (version < 8005 && !_backgroundKey) ? false : (v == 1);
|
||||
Window::chatBackground()->setTile(tile);
|
||||
} break;
|
||||
|
||||
case dbiAdaptiveForWide: {
|
||||
|
@ -1195,9 +1193,9 @@ namespace {
|
|||
if (!_checkStreamStatus(stream)) return false;
|
||||
|
||||
switch (v) {
|
||||
case dbinvShowNothing: cSetNotifyView(dbinvShowNothing); break;
|
||||
case dbinvShowName: cSetNotifyView(dbinvShowName); break;
|
||||
default: cSetNotifyView(dbinvShowPreview); break;
|
||||
case dbinvShowNothing: Global::SetNotifyView(dbinvShowNothing); break;
|
||||
case dbinvShowName: Global::SetNotifyView(dbinvShowName); break;
|
||||
default: Global::SetNotifyView(dbinvShowPreview); break;
|
||||
}
|
||||
} break;
|
||||
|
||||
|
@ -1206,7 +1204,7 @@ namespace {
|
|||
stream >> v;
|
||||
if (!_checkStreamStatus(stream)) return false;
|
||||
|
||||
cSetAskDownloadPath(v == 1);
|
||||
Global::SetAskDownloadPath(v == 1);
|
||||
} break;
|
||||
|
||||
case dbiDownloadPathOld: {
|
||||
|
@ -1215,8 +1213,9 @@ namespace {
|
|||
if (!_checkStreamStatus(stream)) return false;
|
||||
|
||||
if (!v.isEmpty() && v != qstr("tmp") && !v.endsWith('/')) v += '/';
|
||||
cSetDownloadPath(v);
|
||||
cSetDownloadPathBookmark(QByteArray());
|
||||
Global::SetDownloadPath(v);
|
||||
Global::SetDownloadPathBookmark(QByteArray());
|
||||
Global::RefDownloadPathChanged().notify();
|
||||
} break;
|
||||
|
||||
case dbiDownloadPath: {
|
||||
|
@ -1226,9 +1225,10 @@ namespace {
|
|||
if (!_checkStreamStatus(stream)) return false;
|
||||
|
||||
if (!v.isEmpty() && v != qstr("tmp") && !v.endsWith('/')) v += '/';
|
||||
cSetDownloadPath(v);
|
||||
cSetDownloadPathBookmark(bookmark);
|
||||
Global::SetDownloadPath(v);
|
||||
Global::SetDownloadPathBookmark(bookmark);
|
||||
psDownloadPathEnableAccess();
|
||||
Global::RefDownloadPathChanged().notify();
|
||||
} break;
|
||||
|
||||
case dbiCompressPastedImage: {
|
||||
|
@ -1554,7 +1554,7 @@ namespace {
|
|||
}
|
||||
|
||||
uint32 size = 18 * (sizeof(quint32) + sizeof(qint32));
|
||||
size += sizeof(quint32) + Serialize::stringSize(cAskDownloadPath() ? QString() : cDownloadPath()) + Serialize::bytearraySize(cAskDownloadPath() ? QByteArray() : cDownloadPathBookmark());
|
||||
size += sizeof(quint32) + Serialize::stringSize(Global::AskDownloadPath() ? QString() : Global::DownloadPath()) + Serialize::bytearraySize(Global::AskDownloadPath() ? QByteArray() : Global::DownloadPathBookmark());
|
||||
size += sizeof(quint32) + sizeof(qint32) + (cRecentEmojisPreload().isEmpty() ? cGetRecentEmojis().size() : cRecentEmojisPreload().size()) * (sizeof(uint64) + sizeof(ushort));
|
||||
size += sizeof(quint32) + sizeof(qint32) + cEmojiVariants().size() * (sizeof(uint32) + sizeof(uint64));
|
||||
size += sizeof(quint32) + sizeof(qint32) + (cRecentStickersPreload().isEmpty() ? cGetRecentStickers().size() : cRecentStickersPreload().size()) * (sizeof(uint64) + sizeof(ushort));
|
||||
|
@ -1567,19 +1567,19 @@ namespace {
|
|||
|
||||
EncryptedDescriptor data(size);
|
||||
data.stream << quint32(dbiSendKey) << qint32(cCtrlEnter() ? dbiskCtrlEnter : dbiskEnter);
|
||||
data.stream << quint32(dbiTileBackground) << qint32(cTileBackground() ? 1 : 0);
|
||||
data.stream << quint32(dbiTileBackground) << qint32(Window::chatBackground()->tile() ? 1 : 0);
|
||||
data.stream << quint32(dbiAdaptiveForWide) << qint32(Global::AdaptiveForWide() ? 1 : 0);
|
||||
data.stream << quint32(dbiAutoLock) << qint32(cAutoLock());
|
||||
data.stream << quint32(dbiReplaceEmojis) << qint32(cReplaceEmojis() ? 1 : 0);
|
||||
data.stream << quint32(dbiDefaultAttach) << qint32(cDefaultAttach());
|
||||
data.stream << quint32(dbiSoundNotify) << qint32(cSoundNotify());
|
||||
data.stream << quint32(dbiIncludeMuted) << qint32(cIncludeMuted());
|
||||
data.stream << quint32(dbiSoundNotify) << qint32(Global::SoundNotify());
|
||||
data.stream << quint32(dbiIncludeMuted) << qint32(Global::IncludeMuted());
|
||||
data.stream << quint32(dbiShowingSavedGifs) << qint32(cShowingSavedGifs());
|
||||
data.stream << quint32(dbiDesktopNotify) << qint32(cDesktopNotify());
|
||||
data.stream << quint32(dbiNotifyView) << qint32(cNotifyView());
|
||||
data.stream << quint32(dbiWindowsNotifications) << qint32(cWindowsNotifications());
|
||||
data.stream << quint32(dbiAskDownloadPath) << qint32(cAskDownloadPath());
|
||||
data.stream << quint32(dbiDownloadPath) << (cAskDownloadPath() ? QString() : cDownloadPath()) << (cAskDownloadPath() ? QByteArray() : cDownloadPathBookmark());
|
||||
data.stream << quint32(dbiDesktopNotify) << qint32(Global::DesktopNotify());
|
||||
data.stream << quint32(dbiNotifyView) << qint32(Global::NotifyView());
|
||||
data.stream << quint32(dbiWindowsNotifications) << qint32(Global::WindowsNotifications());
|
||||
data.stream << quint32(dbiAskDownloadPath) << qint32(Global::AskDownloadPath());
|
||||
data.stream << quint32(dbiDownloadPath) << (Global::AskDownloadPath() ? QString() : Global::DownloadPath()) << (Global::AskDownloadPath() ? QByteArray() : Global::DownloadPathBookmark());
|
||||
data.stream << quint32(dbiCompressPastedImage) << qint32(cCompressPastedImage());
|
||||
data.stream << quint32(dbiDialogLastPath) << cDialogLastPath();
|
||||
data.stream << quint32(dbiSongVolume) << qint32(qRound(Global::SongVolume() * 1e6));
|
||||
|
@ -2203,8 +2203,8 @@ namespace Local {
|
|||
size += sizeof(quint32) + Serialize::stringSize(cLangFile());
|
||||
|
||||
size += sizeof(quint32) + sizeof(qint32);
|
||||
if (cConnectionType() == dbictHttpProxy || cConnectionType() == dbictTcpProxy) {
|
||||
const ConnectionProxy &proxy(cConnectionProxy());
|
||||
if (Global::ConnectionType() == dbictHttpProxy || Global::ConnectionType() == dbictTcpProxy) {
|
||||
auto &proxy = Global::ConnectionProxy();
|
||||
size += Serialize::stringSize(proxy.host) + sizeof(qint32) + Serialize::stringSize(proxy.user) + Serialize::stringSize(proxy.password);
|
||||
}
|
||||
|
||||
|
@ -2231,12 +2231,12 @@ namespace Local {
|
|||
}
|
||||
data.stream << quint32(dbiLangFile) << cLangFile();
|
||||
|
||||
data.stream << quint32(dbiConnectionType) << qint32(cConnectionType());
|
||||
if (cConnectionType() == dbictHttpProxy || cConnectionType() == dbictTcpProxy) {
|
||||
const ConnectionProxy &proxy(cConnectionProxy());
|
||||
data.stream << quint32(dbiConnectionType) << qint32(Global::ConnectionType());
|
||||
if (Global::ConnectionType() == dbictHttpProxy || Global::ConnectionType() == dbictTcpProxy) {
|
||||
auto &proxy = Global::ConnectionProxy();
|
||||
data.stream << proxy.host << qint32(proxy.port) << proxy.user << proxy.password;
|
||||
}
|
||||
data.stream << quint32(dbiTryIPv6) << qint32(cTryIPv6());
|
||||
data.stream << quint32(dbiTryIPv6) << qint32(Global::TryIPv6());
|
||||
|
||||
TWindowPos pos(cWindowPos());
|
||||
data.stream << quint32(dbiWindowPosition) << qint32(pos.x) << qint32(pos.y) << qint32(pos.w) << qint32(pos.h) << qint32(pos.moncrc) << qint32(pos.maximized);
|
||||
|
@ -3609,8 +3609,8 @@ namespace Local {
|
|||
bg.stream >> id;
|
||||
if (!id || id == DefaultChatBackground) {
|
||||
if (bg.version < 8005) {
|
||||
if (!id) cSetTileBackground(!DefaultChatBackground);
|
||||
App::initBackground(DefaultChatBackground, QImage(), true);
|
||||
if (!id) Window::chatBackground()->setTile(!DefaultChatBackground);
|
||||
} else {
|
||||
App::initBackground(id, QImage(), true);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "media/media_audio.h"
|
||||
#include "core/qthelp_regex.h"
|
||||
#include "core/qthelp_url.h"
|
||||
#include "window/chat_background.h"
|
||||
|
||||
StackItemSection::StackItemSection(std_::unique_ptr<Window::SectionMemento> &&memento) : StackItem(nullptr)
|
||||
, _memento(std_::move(memento)) {
|
||||
|
@ -103,8 +104,16 @@ MainWidget::MainWidget(MainWindow *window) : TWidget(window)
|
|||
_webPageUpdater.setSingleShot(true);
|
||||
connect(&_webPageUpdater, SIGNAL(timeout()), this, SLOT(webPagesUpdate()));
|
||||
|
||||
subscribe(Window::chatBackground(), [this](const Window::ChatBackgroundUpdate &update) {
|
||||
using Update = Window::ChatBackgroundUpdate;
|
||||
if (update.type == Update::Type::New || update.type == Update::Type::Changed) {
|
||||
clearCachedBackground();
|
||||
}
|
||||
});
|
||||
connect(&_cacheBackgroundTimer, SIGNAL(timeout()), this, SLOT(onCacheBackground()));
|
||||
|
||||
subscribe(Adaptive::Changed(), [this]() { updateAdaptiveLayout(); });
|
||||
|
||||
_dialogs->show();
|
||||
if (Adaptive::OneColumn()) {
|
||||
_history->hide();
|
||||
|
@ -1007,8 +1016,8 @@ bool MainWidget::sendMessageFail(const RPCError &error) {
|
|||
}
|
||||
|
||||
void MainWidget::onCacheBackground() {
|
||||
const QPixmap &bg(*cChatBackground());
|
||||
if (cTileBackground()) {
|
||||
auto &bg = Window::chatBackground()->image();
|
||||
if (Window::chatBackground()->tile()) {
|
||||
QImage result(_willCacheFor.width() * cIntRetinaFactor(), _willCacheFor.height() * cIntRetinaFactor(), QImage::Format_RGB32);
|
||||
result.setDevicePixelRatio(cRetinaFactor());
|
||||
{
|
||||
|
@ -1508,9 +1517,10 @@ void MainWidget::loadFailed(mtpFileLoader *loader, bool started, const char *ret
|
|||
}
|
||||
|
||||
void MainWidget::onDownloadPathSettings() {
|
||||
cSetDownloadPath(QString());
|
||||
cSetDownloadPathBookmark(QByteArray());
|
||||
Global::SetDownloadPath(QString());
|
||||
Global::SetDownloadPathBookmark(QByteArray());
|
||||
Ui::showLayer(new DownloadPathBox());
|
||||
Global::RefDownloadPathChanged().notify();
|
||||
}
|
||||
|
||||
void MainWidget::onSharePhoneWithBot(PeerData *recipient) {
|
||||
|
@ -1766,6 +1776,7 @@ bool MainWidget::isIdle() const {
|
|||
void MainWidget::clearCachedBackground() {
|
||||
_cachedBackground = QPixmap();
|
||||
_cacheBackgroundTimer.stop();
|
||||
update();
|
||||
}
|
||||
|
||||
QPixmap MainWidget::cachedBackground(const QRect &forRect, int &x, int &y) {
|
||||
|
@ -1782,7 +1793,7 @@ QPixmap MainWidget::cachedBackground(const QRect &forRect, int &x, int &y) {
|
|||
}
|
||||
|
||||
void MainWidget::backgroundParams(const QRect &forRect, QRect &to, QRect &from) const {
|
||||
const QSize &bg(cChatBackground()->size());
|
||||
auto &bg = Window::chatBackground()->image().size();
|
||||
if (uint64(bg.width()) * forRect.height() > uint64(bg.height()) * forRect.width()) {
|
||||
float64 pxsize = forRect.height() / float64(bg.height());
|
||||
int takewidth = qCeil(forRect.width() / pxsize);
|
||||
|
@ -2689,11 +2700,6 @@ void MainWidget::keyPressEvent(QKeyEvent *e) {
|
|||
void MainWidget::updateAdaptiveLayout() {
|
||||
showAll();
|
||||
_sideShadow.setVisible(!Adaptive::OneColumn());
|
||||
if (_wideSection) {
|
||||
_wideSection->updateAdaptiveLayout();
|
||||
}
|
||||
_topBar->updateAdaptiveLayout();
|
||||
_history->updateAdaptiveLayout();
|
||||
}
|
||||
|
||||
bool MainWidget::needBackButton() {
|
||||
|
|
|
@ -127,7 +127,7 @@ class ItemBase;
|
|||
} // namespace Layout
|
||||
} // namespace InlineBots
|
||||
|
||||
class MainWidget : public TWidget, public RPCSender {
|
||||
class MainWidget : public TWidget, public RPCSender, private base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -138,7 +138,6 @@ public:
|
|||
void resizeEvent(QResizeEvent *e) override;
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
void updateAdaptiveLayout();
|
||||
bool needBackButton();
|
||||
|
||||
// Temporary methods, while top bar was not done inside HistoryWidget / OverviewWidget.
|
||||
|
@ -318,7 +317,6 @@ public:
|
|||
|
||||
bool isIdle() const;
|
||||
|
||||
void clearCachedBackground();
|
||||
QPixmap cachedBackground(const QRect &forRect, int &x, int &y);
|
||||
void backgroundParams(const QRect &forRect, QRect &to, QRect &from) const;
|
||||
void updateScrollColors();
|
||||
|
@ -480,6 +478,8 @@ private slots:
|
|||
void onDeletePhotoSure();
|
||||
|
||||
private:
|
||||
void updateAdaptiveLayout();
|
||||
|
||||
void sendReadRequest(PeerData *peer, MsgId upTo);
|
||||
void channelReadDone(PeerData *peer, const MTPBool &result);
|
||||
void historyReadDone(PeerData *peer, const MTPmessages_AffectedMessages &result);
|
||||
|
@ -562,6 +562,8 @@ private:
|
|||
void overviewPreloaded(PeerData *data, const MTPmessages_Messages &result, mtpRequestId req);
|
||||
bool overviewFailed(PeerData *data, const RPCError &error, mtpRequestId req);
|
||||
|
||||
void clearCachedBackground();
|
||||
|
||||
Animation _a_show;
|
||||
QPixmap _cacheUnder, _cacheOver;
|
||||
anim::ivalue a_coordUnder, a_coordOver;
|
||||
|
|
|
@ -171,7 +171,7 @@ void NotifyWindow::updateNotifyDisplay() {
|
|||
p.fillRect(st::notifyBorderWidth, h - st::notifyBorderWidth, w - st::notifyBorderWidth, st::notifyBorderWidth, st::notifyBorder->b);
|
||||
p.fillRect(0, st::notifyBorderWidth, st::notifyBorderWidth, h - st::notifyBorderWidth, st::notifyBorder->b);
|
||||
|
||||
if (!App::passcoded() && cNotifyView() <= dbinvShowName) {
|
||||
if (!App::passcoded() && Global::NotifyView() <= dbinvShowName) {
|
||||
history->peer->loadUserpic(true, true);
|
||||
history->peer->paintUserpicLeft(p, st::notifyPhotoSize, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width());
|
||||
} else {
|
||||
|
@ -182,7 +182,7 @@ void NotifyWindow::updateNotifyDisplay() {
|
|||
int32 itemWidth = w - st::notifyPhotoPos.x() - st::notifyPhotoSize - st::notifyTextLeft - st::notifyClosePos.x() - st::notifyClose.width;
|
||||
|
||||
QRect rectForName(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyTextTop, itemWidth, st::msgNameFont->height);
|
||||
if (!App::passcoded() && cNotifyView() <= dbinvShowName) {
|
||||
if (!App::passcoded() && Global::NotifyView() <= dbinvShowName) {
|
||||
if (history->peer->isChat() || history->peer->isMegagroup()) {
|
||||
p.drawSprite(QPoint(rectForName.left() + st::dialogsChatImgPos.x(), rectForName.top() + st::dialogsChatImgPos.y()), st::dlgChatImg);
|
||||
rectForName.setLeft(rectForName.left() + st::dialogsImgSkip);
|
||||
|
@ -201,7 +201,7 @@ void NotifyWindow::updateNotifyDisplay() {
|
|||
p.setPen(st::dialogsDateFg);
|
||||
p.drawText(rectForName.left() + rectForName.width() + st::dialogsDateSkip, rectForName.top() + st::dialogsTextFont->ascent, dt);
|
||||
|
||||
if (!App::passcoded() && cNotifyView() <= dbinvShowPreview) {
|
||||
if (!App::passcoded() && Global::NotifyView() <= dbinvShowPreview) {
|
||||
const HistoryItem *textCachedFor = 0;
|
||||
Text itemTextCache(itemWidth);
|
||||
QRect r(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyItemTop + st::msgNameFont->height, itemWidth, 2 * st::dialogsTextFont->height);
|
||||
|
@ -226,7 +226,7 @@ void NotifyWindow::updateNotifyDisplay() {
|
|||
}
|
||||
|
||||
p.setPen(st::dialogsNameFg);
|
||||
if (!App::passcoded() && cNotifyView() <= dbinvShowName) {
|
||||
if (!App::passcoded() && Global::NotifyView() <= dbinvShowName) {
|
||||
history->peer->dialogName().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
} else {
|
||||
p.setFont(st::msgNameFont->f);
|
||||
|
@ -372,6 +372,19 @@ MainWindow::MainWindow() {
|
|||
iconbig32 = iconbig256.scaledToWidth(32, Qt::SmoothTransformation);
|
||||
iconbig64 = iconbig256.scaledToWidth(64, Qt::SmoothTransformation);
|
||||
|
||||
subscribe(Global::RefNotifySettingsChanged(), [this](const Notify::ChangeType &type) {
|
||||
if (type == Notify::ChangeType::DesktopEnabled) {
|
||||
updateTrayMenu();
|
||||
notifyClear();
|
||||
} else if (type == Notify::ChangeType::ViewParams) {
|
||||
notifyUpdateAll();
|
||||
} else if (type == Notify::ChangeType::UseNative) {
|
||||
notifyClearFast();
|
||||
} else if (type == Notify::ChangeType::IncludeMuted) {
|
||||
Notify::unreadCounterUpdated();
|
||||
}
|
||||
});
|
||||
|
||||
if (objectName().isEmpty()) {
|
||||
setObjectName(qsl("MainWindow"));
|
||||
}
|
||||
|
@ -396,6 +409,8 @@ MainWindow::MainWindow() {
|
|||
|
||||
connect(this, SIGNAL(imageLoaded()), this, SLOT(notifyUpdateAllPhotos()));
|
||||
|
||||
subscribe(Global::RefSelfChanged(), [this]() { updateGlobalMenu(); });
|
||||
|
||||
setAttribute(Qt::WA_NoSystemBackground);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
}
|
||||
|
@ -455,7 +470,7 @@ void MainWindow::firstShow() {
|
|||
#else
|
||||
trayIconMenu = new QMenu(this);
|
||||
#endif
|
||||
auto notificationItem = lang(cDesktopNotify()
|
||||
auto notificationItem = lang(Global::DesktopNotify()
|
||||
? lng_disable_notifications_from_tray : lng_enable_notifications_from_tray);
|
||||
|
||||
if (cPlatform() == dbipWindows || cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
|
||||
|
@ -716,7 +731,7 @@ void MainWindow::ui_hideSettingsAndLayer(ShowLayerOptions options) {
|
|||
void MainWindow::mtpStateChanged(int32 dc, int32 state) {
|
||||
if (dc == MTP::maindc()) {
|
||||
updateTitleStatus();
|
||||
// if (settings) settings->updateConnectionType(); TODO
|
||||
Global::RefConnectionTypeChanged().notify();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1108,7 +1123,7 @@ void MainWindow::updateTrayMenu(bool force) {
|
|||
if (!trayIconMenu || (cPlatform() == dbipWindows && !force)) return;
|
||||
|
||||
bool active = isActive(false);
|
||||
QString notificationItem = lang(cDesktopNotify()
|
||||
QString notificationItem = lang(Global::DesktopNotify()
|
||||
? lng_disable_notifications_from_tray : lng_enable_notifications_from_tray);
|
||||
|
||||
if (cPlatform() == dbipWindows || cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
|
||||
|
@ -1255,15 +1270,28 @@ void MainWindow::toggleDisplayNotifyFromTray() {
|
|||
Ui::showLayer(new InformBox(lang(lng_passcode_need_unblock)));
|
||||
return;
|
||||
}
|
||||
cSetDesktopNotify(!cDesktopNotify());
|
||||
if (settings) {
|
||||
// settings->updateDisplayNotify(); TODO
|
||||
} else {
|
||||
if (!cDesktopNotify()) {
|
||||
notifyClear();
|
||||
|
||||
bool soundNotifyChanged = false;
|
||||
Global::SetDesktopNotify(!Global::DesktopNotify());
|
||||
if (Global::DesktopNotify()) {
|
||||
if (Global::RestoreSoundNotifyFromTray() && !Global::SoundNotify()) {
|
||||
Global::SetSoundNotify(true);
|
||||
Global::SetRestoreSoundNotifyFromTray(false);
|
||||
soundNotifyChanged = true;
|
||||
}
|
||||
Local::writeUserSettings();
|
||||
updateTrayMenu();
|
||||
} else {
|
||||
if (Global::SoundNotify()) {
|
||||
Global::SetSoundNotify(false);
|
||||
Global::SetRestoreSoundNotifyFromTray(true);
|
||||
soundNotifyChanged = true;
|
||||
} else {
|
||||
Global::SetRestoreSoundNotifyFromTray(false);
|
||||
}
|
||||
}
|
||||
Local::writeUserSettings();
|
||||
Global::RefNotifySettingsChanged().notify(Notify::ChangeType::DesktopEnabled);
|
||||
if (soundNotifyChanged) {
|
||||
Global::RefNotifySettingsChanged().notify(Notify::ChangeType::SoundEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1294,7 +1322,7 @@ void MainWindow::resizeEvent(QResizeEvent *e) {
|
|||
}
|
||||
if (layout != Global::AdaptiveLayout()) {
|
||||
Global::SetAdaptiveLayout(layout);
|
||||
updateAdaptiveLayout();
|
||||
Adaptive::Changed().notify(true);
|
||||
}
|
||||
title->setGeometry(0, 0, width(), st::titleHeight);
|
||||
if (layerBg) layerBg->resize(width(), height());
|
||||
|
@ -1303,13 +1331,6 @@ void MainWindow::resizeEvent(QResizeEvent *e) {
|
|||
emit resized(QSize(width(), height() - st::titleHeight));
|
||||
}
|
||||
|
||||
void MainWindow::updateAdaptiveLayout() {
|
||||
title->updateAdaptiveLayout();
|
||||
if (main) main->updateAdaptiveLayout();
|
||||
if (intro) intro->updateAdaptiveLayout();
|
||||
if (layerBg) layerBg->updateAdaptiveLayout();
|
||||
}
|
||||
|
||||
MainWindow::TempDirState MainWindow::tempDirState() {
|
||||
if (_clearManager && _clearManager->hasTask(Local::ClearManagerDownloads)) {
|
||||
return TempDirRemoving;
|
||||
|
@ -1407,7 +1428,7 @@ void MainWindow::notifySchedule(History *history, HistoryItem *item) {
|
|||
|
||||
uint64 when = ms + delay;
|
||||
notifyWhenAlerts[history].insert(when, notifyByFrom);
|
||||
if (cDesktopNotify() && !psSkipDesktopNotify()) {
|
||||
if (Global::DesktopNotify() && !psSkipDesktopNotify()) {
|
||||
NotifyWhenMaps::iterator i = notifyWhenMaps.find(history);
|
||||
if (i == notifyWhenMaps.end()) {
|
||||
i = notifyWhenMaps.insert(history, NotifyWhenMap());
|
||||
|
@ -1553,14 +1574,14 @@ void MainWindow::notifyShowNext(NotifyWindow *remove) {
|
|||
App::playSound();
|
||||
}
|
||||
|
||||
if (cCustomNotifies()) {
|
||||
if (Global::CustomNotifies()) {
|
||||
for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) {
|
||||
int32 ind = (*i)->index();
|
||||
if (ind < 0) continue;
|
||||
--count;
|
||||
}
|
||||
}
|
||||
if (count <= 0 || notifyWaiters.isEmpty() || !cDesktopNotify() || psSkipDesktopNotify()) {
|
||||
if (count <= 0 || notifyWaiters.isEmpty() || !Global::DesktopNotify() || psSkipDesktopNotify()) {
|
||||
if (nextAlert) {
|
||||
notifyWaitTimer.start(nextAlert - ms);
|
||||
}
|
||||
|
@ -1656,7 +1677,7 @@ void MainWindow::notifyShowNext(NotifyWindow *remove) {
|
|||
} while (nextNotify);
|
||||
}
|
||||
|
||||
if (cCustomNotifies()) {
|
||||
if (Global::CustomNotifies()) {
|
||||
NotifyWindow *notify = new NotifyWindow(notifyItem, x, y, fwdCount);
|
||||
notifyWindows.push_back(notify);
|
||||
psNotifyShown(notify);
|
||||
|
@ -1689,7 +1710,7 @@ void MainWindow::notifyShowNext(NotifyWindow *remove) {
|
|||
}
|
||||
|
||||
void MainWindow::notifyItemRemoved(HistoryItem *item) {
|
||||
if (cCustomNotifies()) {
|
||||
if (Global::CustomNotifies()) {
|
||||
for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) {
|
||||
(*i)->itemRemoved(item);
|
||||
}
|
||||
|
@ -1697,7 +1718,7 @@ void MainWindow::notifyItemRemoved(HistoryItem *item) {
|
|||
}
|
||||
|
||||
void MainWindow::notifyStopHiding() {
|
||||
if (cCustomNotifies()) {
|
||||
if (Global::CustomNotifies()) {
|
||||
for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) {
|
||||
(*i)->stopHiding();
|
||||
}
|
||||
|
@ -1705,7 +1726,7 @@ void MainWindow::notifyStopHiding() {
|
|||
}
|
||||
|
||||
void MainWindow::notifyStartHiding() {
|
||||
if (cCustomNotifies()) {
|
||||
if (Global::CustomNotifies()) {
|
||||
for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) {
|
||||
(*i)->startHiding();
|
||||
}
|
||||
|
@ -1713,7 +1734,7 @@ void MainWindow::notifyStartHiding() {
|
|||
}
|
||||
|
||||
void MainWindow::notifyUpdateAllPhotos() {
|
||||
if (cCustomNotifies()) {
|
||||
if (Global::CustomNotifies()) {
|
||||
for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) {
|
||||
(*i)->updatePeerPhoto();
|
||||
}
|
||||
|
@ -1726,7 +1747,7 @@ void MainWindow::app_activateClickHandler(ClickHandlerPtr handler, Qt::MouseButt
|
|||
}
|
||||
|
||||
void MainWindow::notifyUpdateAll() {
|
||||
if (cCustomNotifies()) {
|
||||
if (Global::CustomNotifies()) {
|
||||
for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) {
|
||||
(*i)->updateNotifyDisplay();
|
||||
}
|
||||
|
@ -1735,7 +1756,7 @@ void MainWindow::notifyUpdateAll() {
|
|||
}
|
||||
|
||||
void MainWindow::notifyActivateAll() {
|
||||
if (cCustomNotifies()) {
|
||||
if (Global::CustomNotifies()) {
|
||||
for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) {
|
||||
psActivateNotify(*i);
|
||||
}
|
||||
|
@ -2758,7 +2779,7 @@ void LastCrashedWindow::updateControls() {
|
|||
}
|
||||
|
||||
void LastCrashedWindow::onNetworkSettings() {
|
||||
const ConnectionProxy &p(Sandbox::PreLaunchProxy());
|
||||
auto &p = Sandbox::PreLaunchProxy();
|
||||
NetworkSettingsWindow *box = new NetworkSettingsWindow(this, p.host, p.port ? p.port : 80, p.user, p.password);
|
||||
connect(box, SIGNAL(saved(QString, quint32, QString, QString)), this, SLOT(onNetworkSettingsSaved(QString, quint32, QString, QString)));
|
||||
box->show();
|
||||
|
|
|
@ -126,7 +126,7 @@ typedef QList<NotifyWindow*> NotifyWindows;
|
|||
|
||||
class MediaPreviewWidget;
|
||||
|
||||
class MainWindow : public Platform::MainWindow {
|
||||
class MainWindow : public Platform::MainWindow, private base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -151,7 +151,6 @@ public:
|
|||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void updateAdaptiveLayout();
|
||||
|
||||
void setupPasscode(bool anim);
|
||||
void clearPasscode();
|
||||
|
|
|
@ -773,17 +773,17 @@ PeerData *MediaView::ui_getPeerForMouseAction() {
|
|||
}
|
||||
|
||||
void MediaView::onDownload() {
|
||||
if (cAskDownloadPath()) {
|
||||
if (Global::AskDownloadPath()) {
|
||||
return onSaveAs();
|
||||
}
|
||||
|
||||
QString path;
|
||||
if (cDownloadPath().isEmpty()) {
|
||||
if (Global::DownloadPath().isEmpty()) {
|
||||
path = psDownloadPath();
|
||||
} else if (cDownloadPath() == qsl("tmp")) {
|
||||
} else if (Global::DownloadPath() == qsl("tmp")) {
|
||||
path = cTempDir();
|
||||
} else {
|
||||
path = cDownloadPath();
|
||||
path = Global::DownloadPath();
|
||||
}
|
||||
QString toName;
|
||||
if (_doc) {
|
||||
|
|
|
@ -513,7 +513,7 @@ QString ConnectionPrivate::transport() const {
|
|||
return QString();
|
||||
}
|
||||
QString result = (_conn4 ? _conn4 : _conn6)->transport();
|
||||
if (!result.isEmpty() && cTryIPv6()) result += (_conn4 ? "/IPv4" : "/IPv6");
|
||||
if (!result.isEmpty() && Global::TryIPv6()) result += (_conn4 ? "/IPv4" : "/IPv6");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1130,15 +1130,15 @@ void ConnectionPrivate::socketStart(bool afterConfig) {
|
|||
}
|
||||
}
|
||||
}
|
||||
bool noIPv4 = !port[IPv4address][HttpProtocol], noIPv6 = (!cTryIPv6() || !port[IPv6address][HttpProtocol]);
|
||||
bool noIPv4 = !port[IPv4address][HttpProtocol], noIPv6 = (!Global::TryIPv6() || !port[IPv6address][HttpProtocol]);
|
||||
if (noIPv4 && noIPv6) {
|
||||
if (afterConfig) {
|
||||
if (noIPv4) LOG(("MTP Error: DC %1 options for IPv4 over HTTP not found right after config load!").arg(dc));
|
||||
if (cTryIPv6() && noIPv6) LOG(("MTP Error: DC %1 options for IPv6 over HTTP not found right after config load!").arg(dc));
|
||||
if (Global::TryIPv6() && noIPv6) LOG(("MTP Error: DC %1 options for IPv6 over HTTP not found right after config load!").arg(dc));
|
||||
return restart();
|
||||
}
|
||||
if (noIPv4) DEBUG_LOG(("MTP Info: DC %1 options for IPv4 over HTTP not found, waiting for config").arg(dc));
|
||||
if (cTryIPv6() && noIPv6) DEBUG_LOG(("MTP Info: DC %1 options for IPv6 over HTTP not found, waiting for config").arg(dc));
|
||||
if (Global::TryIPv6() && noIPv6) DEBUG_LOG(("MTP Info: DC %1 options for IPv6 over HTTP not found, waiting for config").arg(dc));
|
||||
connect(configLoader(), SIGNAL(loaded()), this, SLOT(onConfigLoaded()));
|
||||
configLoader()->load();
|
||||
return;
|
||||
|
@ -1273,7 +1273,7 @@ void ConnectionPrivate::onPingSendForce() {
|
|||
}
|
||||
|
||||
void ConnectionPrivate::onWaitReceivedFailed() {
|
||||
if (cConnectionType() != dbictAuto && cConnectionType() != dbictTcpProxy) {
|
||||
if (Global::ConnectionType() != dbictAuto && Global::ConnectionType() != dbictTcpProxy) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,9 +78,9 @@ MTPResPQ AbstractConnection::readPQFakeReply(const mtpBuffer &buffer) {
|
|||
}
|
||||
|
||||
AbstractConnection *AbstractConnection::create(QThread *thread) {
|
||||
if (cConnectionType() == dbictHttpProxy) {
|
||||
if (Global::ConnectionType() == dbictHttpProxy) {
|
||||
return new HTTPConnection(thread);
|
||||
} else if (cConnectionType() == dbictTcpProxy) {
|
||||
} else if (Global::ConnectionType() == dbictTcpProxy) {
|
||||
return new TCPConnection(thread);
|
||||
}
|
||||
return new AutoConnection(thread);
|
||||
|
|
|
@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "boxes/photocropbox.h"
|
||||
#include "ui/filedialog.h"
|
||||
#include "window/top_bar_widget.h"
|
||||
#include "window/chat_background.h"
|
||||
#include "lang.h"
|
||||
#include "mainwindow.h"
|
||||
#include "mainwidget.h"
|
||||
|
@ -812,7 +813,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) {
|
|||
|
||||
if (_history->overview[_type].isEmpty() && (!_migrated || !_history->overviewLoaded(_type) || _migrated->overview[_type].isEmpty())) {
|
||||
QPoint dogPos((_width - st::msgDogImg.pxWidth()) / 2, ((height() - st::msgDogImg.pxHeight()) * 4) / 9);
|
||||
p.drawPixmap(dogPos, *cChatDogImage());
|
||||
p.drawPixmap(dogPos, Window::chatBackground()->dog());
|
||||
return;
|
||||
} else if (_inSearch && _searchResults.isEmpty() && _searchFull && (!_migrated || _searchFullMigrated) && !_searchTimer.isActive()) {
|
||||
p.setFont(st::noContactsFont->f);
|
||||
|
|
|
@ -483,12 +483,12 @@ void MainWindow::psNotifyShown(NotifyWindow *w) {
|
|||
}
|
||||
|
||||
void MainWindow::psPlatformNotify(HistoryItem *item, int32 fwdCount) {
|
||||
QString title = (!App::passcoded() && cNotifyView() <= dbinvShowName && !Global::ScreenIsLocked()) ? item->history()->peer->name : qsl("Telegram Desktop");
|
||||
QString subtitle = (!App::passcoded() && cNotifyView() <= dbinvShowName && !Global::ScreenIsLocked()) ? item->notificationHeader() : QString();
|
||||
QPixmap pix = (!App::passcoded() && cNotifyView() <= dbinvShowName && !Global::ScreenIsLocked()) ? item->history()->peer->genUserpic(st::notifyMacPhotoSize) : QPixmap();
|
||||
QString msg = (!App::passcoded() && cNotifyView() <= dbinvShowPreview && !Global::ScreenIsLocked()) ? (fwdCount < 2 ? item->notificationText() : lng_forward_messages(lt_count, fwdCount)) : lang(lng_notification_preview);
|
||||
QString title = (!App::passcoded() && Global::NotifyView() <= dbinvShowName && !Global::ScreenIsLocked()) ? item->history()->peer->name : qsl("Telegram Desktop");
|
||||
QString subtitle = (!App::passcoded() && Global::NotifyView() <= dbinvShowName && !Global::ScreenIsLocked()) ? item->notificationHeader() : QString();
|
||||
QPixmap pix = (!App::passcoded() && Global::NotifyView() <= dbinvShowName && !Global::ScreenIsLocked()) ? item->history()->peer->genUserpic(st::notifyMacPhotoSize) : QPixmap();
|
||||
QString msg = (!App::passcoded() && Global::NotifyView() <= dbinvShowPreview && !Global::ScreenIsLocked()) ? (fwdCount < 2 ? item->notificationText() : lng_forward_messages(lt_count, fwdCount)) : lang(lng_notification_preview);
|
||||
|
||||
bool withReply = !App::passcoded() && (cNotifyView() <= dbinvShowPreview && !Global::ScreenIsLocked()) && item->history()->peer->canWrite();
|
||||
bool withReply = !App::passcoded() && (Global::NotifyView() <= dbinvShowPreview && !Global::ScreenIsLocked()) && item->history()->peer->canWrite();
|
||||
|
||||
_private.showNotify(item->history()->peer->id, item->id, pix, title, subtitle, msg, withReply);
|
||||
}
|
||||
|
|
|
@ -886,9 +886,9 @@ bool MainWindow::psHasNativeNotifications() {
|
|||
Q_DECLARE_METATYPE(QMargins);
|
||||
void MainWindow::psFirstShow() {
|
||||
if (Toasts::supported()) {
|
||||
cSetCustomNotifies(!cWindowsNotifications());
|
||||
Global::SetCustomNotifies(!Global::WindowsNotifications());
|
||||
} else {
|
||||
cSetCustomNotifies(true);
|
||||
Global::SetCustomNotifies(true);
|
||||
}
|
||||
|
||||
_psShadowWindows.init(_shActive);
|
||||
|
@ -1088,10 +1088,10 @@ void MainWindow::psNotifyShown(NotifyWindow *w) {
|
|||
}
|
||||
|
||||
void MainWindow::psPlatformNotify(HistoryItem *item, int32 fwdCount) {
|
||||
QString title = (!App::passcoded() && cNotifyView() <= dbinvShowName) ? item->history()->peer->name : qsl("Telegram Desktop");
|
||||
QString subtitle = (!App::passcoded() && cNotifyView() <= dbinvShowName) ? item->notificationHeader() : QString();
|
||||
bool showpix = (!App::passcoded() && cNotifyView() <= dbinvShowName);
|
||||
QString msg = (!App::passcoded() && cNotifyView() <= dbinvShowPreview) ? (fwdCount < 2 ? item->notificationText() : lng_forward_messages(lt_count, fwdCount)) : lang(lng_notification_preview);
|
||||
QString title = (!App::passcoded() && Global::NotifyView() <= dbinvShowName) ? item->history()->peer->name : qsl("Telegram Desktop");
|
||||
QString subtitle = (!App::passcoded() && Global::NotifyView() <= dbinvShowName) ? item->notificationHeader() : QString();
|
||||
bool showpix = (!App::passcoded() && Global::NotifyView() <= dbinvShowName);
|
||||
QString msg = (!App::passcoded() && Global::NotifyView() <= dbinvShowPreview) ? (fwdCount < 2 ? item->notificationText() : lng_forward_messages(lt_count, fwdCount)) : lang(lng_notification_preview);
|
||||
|
||||
Toasts::create(item->history()->peer, item->id, showpix, title, subtitle, msg);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ Widget::Widget(QWidget *parent, PeerData *peer) : Window::SectionWidget(parent)
|
|||
_fixedBarShadow->setMode(ToggleableShadow::Mode::HiddenFast);
|
||||
_fixedBarShadow->raise();
|
||||
updateAdaptiveLayout();
|
||||
subscribe(Adaptive::Changed(), [this]() { updateAdaptiveLayout(); });
|
||||
|
||||
_scroll->setOwnedWidget(_inner);
|
||||
_scroll->move(0, _fixedBar->height());
|
||||
|
|
|
@ -48,8 +48,6 @@ public:
|
|||
|
||||
void setInnerFocus() override;
|
||||
|
||||
void updateAdaptiveLayout() override;
|
||||
|
||||
bool showInternal(const Window::SectionMemento *memento) override;
|
||||
std_::unique_ptr<Window::SectionMemento> createMemento() const override;
|
||||
|
||||
|
@ -65,6 +63,8 @@ private slots:
|
|||
void onScroll();
|
||||
|
||||
private:
|
||||
void updateAdaptiveLayout();
|
||||
|
||||
friend class SectionMemento;
|
||||
|
||||
ChildWidget<ScrollArea> _scroll;
|
||||
|
|
|
@ -47,11 +47,6 @@ QString gLangErrors;
|
|||
|
||||
QString gDialogLastPath, gDialogHelperPath; // optimize QFileDialog
|
||||
|
||||
bool gSoundNotify = true;
|
||||
bool gIncludeMuted = true;
|
||||
bool gDesktopNotify = true;
|
||||
DBINotifyView gNotifyView = dbinvShowPreview;
|
||||
bool gWindowsNotifications = true;
|
||||
bool gStartMinimized = false;
|
||||
bool gStartInTray = false;
|
||||
bool gAutoStart = false;
|
||||
|
@ -61,13 +56,6 @@ TWindowPos gWindowPos;
|
|||
LaunchMode gLaunchMode = LaunchModeNormal;
|
||||
bool gSupportTray = true;
|
||||
DBIWorkMode gWorkMode = dbiwmWindowAndTray;
|
||||
DBIConnectionType gConnectionType = dbictAuto;
|
||||
ConnectionProxy gConnectionProxy;
|
||||
#ifdef Q_OS_WIN
|
||||
bool gTryIPv6 = false;
|
||||
#else
|
||||
bool gTryIPv6 = true;
|
||||
#endif
|
||||
bool gSeenTrayTooltip = false;
|
||||
bool gRestartingUpdate = false, gRestarting = false, gRestartingToSettings = false, gWriteProtected = false;
|
||||
int32 gLastUpdateCheck = 0;
|
||||
|
@ -75,17 +63,9 @@ bool gNoStartUpdate = false;
|
|||
bool gStartToSettings = false;
|
||||
DBIDefaultAttach gDefaultAttach = dbidaDocument;
|
||||
bool gReplaceEmojis = true;
|
||||
bool gAskDownloadPath = false;
|
||||
QString gDownloadPath;
|
||||
QByteArray gDownloadPathBookmark;
|
||||
|
||||
bool gCtrlEnter = false;
|
||||
|
||||
QPixmapPointer gChatBackground = 0;
|
||||
int32 gChatBackgroundId = 0;
|
||||
QPixmapPointer gChatDogImage = 0;
|
||||
bool gTileBackground = false;
|
||||
|
||||
uint32 gConnectionsInSession = 1;
|
||||
QString gLoggedPhoneNumber;
|
||||
|
||||
|
@ -126,7 +106,6 @@ QString gLangFile;
|
|||
bool gRetina = false;
|
||||
float64 gRetinaFactor = 1.;
|
||||
int32 gIntRetinaFactor = 1;
|
||||
bool gCustomNotifies = true;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
DBIPlatform gPlatform = dbipWindows;
|
||||
|
@ -175,7 +154,6 @@ void settingsParseArgs(int argc, char *argv[]) {
|
|||
case dbipMac:
|
||||
gUpdateURL = QUrl(qsl("http://tdesktop.com/mac/tupdates/current"));
|
||||
gPlatformString = qsl("MacOS");
|
||||
gCustomNotifies = false;
|
||||
break;
|
||||
case dbipMacOld:
|
||||
gUpdateURL = QUrl(qsl("http://tdesktop.com/mac32/tupdates/current"));
|
||||
|
|
|
@ -91,20 +91,8 @@ inline const QString &cDialogHelperPathFinal() {
|
|||
}
|
||||
DeclareSetting(bool, CtrlEnter);
|
||||
|
||||
typedef QPixmap *QPixmapPointer;
|
||||
DeclareSetting(QPixmapPointer, ChatBackground);
|
||||
DeclareSetting(int32, ChatBackgroundId);
|
||||
DeclareSetting(QPixmapPointer, ChatDogImage);
|
||||
DeclareSetting(bool, TileBackground);
|
||||
|
||||
DeclareSetting(bool, SoundNotify);
|
||||
DeclareSetting(bool, IncludeMuted);
|
||||
DeclareSetting(bool, DesktopNotify);
|
||||
DeclareSetting(DBINotifyView, NotifyView);
|
||||
DeclareSetting(bool, AutoUpdate);
|
||||
|
||||
DeclareSetting(bool, WindowsNotifications);
|
||||
|
||||
struct TWindowPos {
|
||||
TWindowPos() : moncrc(0), maximized(0), x(0), y(0), w(0), h(0) {
|
||||
}
|
||||
|
@ -114,10 +102,7 @@ struct TWindowPos {
|
|||
DeclareSetting(TWindowPos, WindowPos);
|
||||
DeclareSetting(bool, SupportTray);
|
||||
DeclareSetting(DBIWorkMode, WorkMode);
|
||||
DeclareSetting(DBIConnectionType, ConnectionType);
|
||||
DeclareSetting(bool, TryIPv6);
|
||||
DeclareSetting(DBIDefaultAttach, DefaultAttach);
|
||||
DeclareSetting(ConnectionProxy, ConnectionProxy);
|
||||
DeclareSetting(bool, SeenTrayTooltip);
|
||||
DeclareSetting(bool, RestartingUpdate);
|
||||
DeclareSetting(bool, Restarting);
|
||||
|
@ -128,9 +113,7 @@ DeclareSetting(bool, NoStartUpdate);
|
|||
DeclareSetting(bool, StartToSettings);
|
||||
DeclareSetting(bool, ReplaceEmojis);
|
||||
DeclareReadSetting(bool, ManyInstance);
|
||||
DeclareSetting(bool, AskDownloadPath);
|
||||
DeclareSetting(QString, DownloadPath);
|
||||
DeclareSetting(QByteArray, DownloadPathBookmark);
|
||||
|
||||
DeclareSetting(QByteArray, LocalSalt);
|
||||
DeclareSetting(DBIScale, RealScale);
|
||||
DeclareSetting(DBIScale, ScreenScale);
|
||||
|
@ -279,7 +262,6 @@ DeclareSetting(QString, LangErrors);
|
|||
DeclareSetting(bool, Retina);
|
||||
DeclareSetting(float64, RetinaFactor);
|
||||
DeclareSetting(int32, IntRetinaFactor);
|
||||
DeclareSetting(bool, CustomNotifies);
|
||||
|
||||
DeclareReadSetting(DBIPlatform, Platform);
|
||||
DeclareReadSetting(QString, PlatformString);
|
||||
|
|
|
@ -20,6 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
*/
|
||||
using "basic.style";
|
||||
using "basic_types.style";
|
||||
using "dialogs/dialogs.style";
|
||||
|
||||
settingsMaxWidth: 520px;
|
||||
settingsMaxPadding: 48px;
|
||||
|
@ -82,6 +83,22 @@ settingsSecondaryButton: RoundButton(settingsPrimaryButton) {
|
|||
textBg: #ffffff;
|
||||
textBgOver: #f2f7fa;
|
||||
}
|
||||
settingsEditButton: RoundButton {
|
||||
width: 24px;
|
||||
height: 34px;
|
||||
icon: settingsEditIcon;
|
||||
|
||||
textTop: 0px;
|
||||
downTextTop: 1px;
|
||||
|
||||
textFg: transparent;
|
||||
textFgOver: transparent;
|
||||
secondaryTextFg: transparent;
|
||||
secondaryTextFgOver: transparent;
|
||||
textBg: transparent;
|
||||
textBgOver: transparent;
|
||||
}
|
||||
|
||||
|
||||
settingsBlocksTop: 7px;
|
||||
settingsBlocksBottom: 20px;
|
||||
|
@ -117,3 +134,5 @@ settingsSliderLabelTop: 17px;
|
|||
settingsSliderLabelFont: normalFont;
|
||||
settingsSliderLabelFg: #1485c2;
|
||||
settingsSliderDuration: 200;
|
||||
|
||||
settingsBackgroundSize: 120px;
|
||||
|
|
|
@ -32,6 +32,11 @@ namespace Settings {
|
|||
|
||||
AdvancedWidget::AdvancedWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_advanced_settings)) {
|
||||
createControls();
|
||||
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
subscribe(Global::RefConnectionTypeChanged(), [this]() {
|
||||
connectionTypeUpdated();
|
||||
});
|
||||
#endif // TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
}
|
||||
|
||||
void AdvancedWidget::createControls() {
|
||||
|
@ -43,6 +48,7 @@ void AdvancedWidget::createControls() {
|
|||
}
|
||||
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
addChildRow(_connectionType, marginLarge, lang(lng_connection_type), lang(lng_connection_auto_connecting));
|
||||
connectionTypeUpdated();
|
||||
connect(_connectionType->link(), SIGNAL(clicked()), this, SLOT(onConnectionType()));
|
||||
#endif // TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
if (self()) {
|
||||
|
@ -59,6 +65,23 @@ void AdvancedWidget::onManageLocalStorage() {
|
|||
}
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
void AdvancedWidget::connectionTypeUpdated() {
|
||||
QString connection;
|
||||
switch (Global::ConnectionType()) {
|
||||
case dbictAuto: {
|
||||
QString transport = MTP::dctransport();
|
||||
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);
|
||||
} break;
|
||||
}
|
||||
_connectionType->link()->setText(connection);
|
||||
resizeToWidth(width());
|
||||
}
|
||||
|
||||
void AdvancedWidget::onConnectionType() {
|
||||
Ui::showLayer(new ConnectionBox());
|
||||
}
|
||||
|
|
|
@ -43,6 +43,9 @@ private slots:
|
|||
|
||||
private:
|
||||
void createControls();
|
||||
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
void connectionTypeUpdated();
|
||||
#endif // TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
void supportGot(const MTPhelp_Support &support);
|
||||
|
||||
ChildWidget<LinkButton> _manageLocalStorage = { nullptr };
|
||||
|
|
|
@ -23,21 +23,237 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
|
||||
#include "styles/style_settings.h"
|
||||
#include "lang.h"
|
||||
#include "mainwidget.h"
|
||||
#include "boxes/backgroundbox.h"
|
||||
#include "ui/widgets/widget_slide_wrap.h"
|
||||
#include "localstorage.h"
|
||||
#include "mainwindow.h"
|
||||
#include "window/chat_background.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
BackgroundRow::BackgroundRow(QWidget *parent) : TWidget(parent)
|
||||
, _chooseFromGallery(this, lang(lng_settings_bg_from_gallery))
|
||||
, _chooseFromFile(this, lang(lng_settings_bg_from_file))
|
||||
, _radial(animation(this, &BackgroundRow::step_radial)) {
|
||||
Window::chatBackground()->initIfEmpty();
|
||||
|
||||
updateImage();
|
||||
|
||||
connect(_chooseFromGallery, SIGNAL(clicked()), this, SIGNAL(chooseFromGallery()));
|
||||
connect(_chooseFromFile, SIGNAL(clicked()), this, SIGNAL(chooseFromFile()));
|
||||
}
|
||||
|
||||
void BackgroundRow::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
|
||||
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(0, 0, _background);
|
||||
} else {
|
||||
const QPixmap &pix = App::main()->newBackgroundThumb()->pixBlurred(st::setBackgroundSize);
|
||||
p.drawPixmap(0, 0, st::setBackgroundSize, st::setBackgroundSize, pix, 0, (pix.height() - st::setBackgroundSize) / 2, st::setBackgroundSize, st::setBackgroundSize);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
p.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
p.drawEllipse(inner);
|
||||
p.setRenderHint(QPainter::HighQualityAntialiasing, false);
|
||||
|
||||
p.setOpacity(1);
|
||||
QRect arc(inner.marginsRemoved(QMargins(st::radialLine, st::radialLine, st::radialLine, st::radialLine)));
|
||||
_radial.draw(p, arc, st::radialLine, st::white);
|
||||
} else {
|
||||
p.drawPixmap(0, 0, _background);
|
||||
}
|
||||
}
|
||||
|
||||
int BackgroundRow::resizeGetHeight(int newWidth) {
|
||||
int linkLeft = st::settingsBackgroundSize + st::settingsSmallSkip;
|
||||
int linkWidth = newWidth - linkLeft;
|
||||
_chooseFromGallery->resizeToWidth(qMin(linkWidth, _chooseFromGallery->naturalWidth()));
|
||||
_chooseFromFile->resizeToWidth(qMin(linkWidth, _chooseFromFile->naturalWidth()));
|
||||
|
||||
_chooseFromGallery->moveToLeft(linkLeft, 0);
|
||||
_chooseFromFile->moveToLeft(linkLeft, _chooseFromGallery->height() + st::settingsSmallSkip);
|
||||
|
||||
return st::settingsBackgroundSize;
|
||||
}
|
||||
|
||||
float64 BackgroundRow::radialProgress() const {
|
||||
if (auto m = App::main()) {
|
||||
return m->chatBackgroundProgress();
|
||||
}
|
||||
return 1.;
|
||||
}
|
||||
|
||||
bool BackgroundRow::radialLoading() const {
|
||||
if (auto m = App::main()) {
|
||||
if (m->chatBackgroundLoading()) {
|
||||
m->checkChatBackground();
|
||||
if (m->chatBackgroundLoading()) {
|
||||
return true;
|
||||
} else {
|
||||
const_cast<BackgroundRow*>(this)->updateImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QRect BackgroundRow::radialRect() const {
|
||||
return QRect(0, 0, st::setBackgroundSize, st::setBackgroundSize);
|
||||
}
|
||||
|
||||
void BackgroundRow::radialStart() {
|
||||
if (radialLoading() && !_radial.animating()) {
|
||||
_radial.start(radialProgress());
|
||||
if (auto shift = radialTimeShift()) {
|
||||
_radial.update(radialProgress(), !radialLoading(), getms() + shift);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint64 BackgroundRow::radialTimeShift() const {
|
||||
return st::radialDuration;
|
||||
}
|
||||
|
||||
void BackgroundRow::step_radial(uint64 ms, bool timer) {
|
||||
_radial.update(radialProgress(), !radialLoading(), ms + radialTimeShift());
|
||||
if (timer && _radial.animating()) {
|
||||
rtlupdate(radialRect());
|
||||
}
|
||||
}
|
||||
|
||||
void BackgroundRow::updateImage() {
|
||||
int32 size = st::setBackgroundSize * cIntRetinaFactor();
|
||||
QImage back(size, size, QImage::Format_ARGB32_Premultiplied);
|
||||
back.setDevicePixelRatio(cRetinaFactor());
|
||||
{
|
||||
QPainter p(&back);
|
||||
auto &pix = Window::chatBackground()->image();
|
||||
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);
|
||||
}
|
||||
imageRound(back, ImageRoundRadius::Small);
|
||||
_background = App::pixmapFromImageInPlace(std_::move(back));
|
||||
_background.setDevicePixelRatio(cRetinaFactor());
|
||||
|
||||
rtlupdate(radialRect());
|
||||
|
||||
if (radialLoading()) {
|
||||
radialStart();
|
||||
}
|
||||
}
|
||||
|
||||
BackgroundWidget::BackgroundWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_background)) {
|
||||
refreshControls();
|
||||
FileDialog::registerObserver(this, &BackgroundWidget::notifyFileQueryUpdated);
|
||||
createControls();
|
||||
|
||||
subscribe(Window::chatBackground(), [this](const Window::ChatBackgroundUpdate &update) {
|
||||
using Update = Window::ChatBackgroundUpdate;
|
||||
if (update.type == Update::Type::New) {
|
||||
_background->updateImage();
|
||||
} else if (update.type == Update::Type::Start) {
|
||||
needBackgroundUpdate(update.tiled);
|
||||
}
|
||||
});
|
||||
subscribe(Adaptive::Changed(), [this]() {
|
||||
if (Global::AdaptiveLayout() == Adaptive::WideLayout) {
|
||||
_adaptive->slideDown();
|
||||
} else {
|
||||
_adaptive->slideUp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void BackgroundWidget::refreshControls() {
|
||||
void BackgroundWidget::createControls() {
|
||||
style::margins margin(0, 0, 0, st::settingsSmallSkip);
|
||||
style::margins slidedPadding(0, margin.bottom() / 2, 0, margin.bottom() - (margin.bottom() / 2));
|
||||
|
||||
addChildRow(_background, margin);
|
||||
connect(_background, SIGNAL(chooseFromGallery()), this, SLOT(onChooseFromGallery()));
|
||||
connect(_background, SIGNAL(chooseFromFile()), this, SLOT(onChooseFromFile()));
|
||||
|
||||
addChildRow(_tile, margin, lang(lng_settings_bg_tile), SLOT(onTile()), Window::chatBackground()->tile());
|
||||
addChildRow(_adaptive, margin, slidedPadding, lang(lng_settings_adaptive_wide), SLOT(onAdaptive()), Global::AdaptiveForWide());
|
||||
if (Global::AdaptiveLayout() != Adaptive::WideLayout) {
|
||||
_adaptive->hideFast();
|
||||
}
|
||||
}
|
||||
|
||||
int BackgroundWidget::resizeGetHeight(int newWidth) {
|
||||
int newHeight = contentTop();
|
||||
void BackgroundWidget::onChooseFromGallery() {
|
||||
Ui::showLayer(new BackgroundBox());
|
||||
}
|
||||
|
||||
newHeight += st::settingsBlockMarginBottom;
|
||||
return newHeight;
|
||||
void BackgroundWidget::needBackgroundUpdate(bool tile) {
|
||||
_tile->setChecked(tile);
|
||||
_background->updateImage();
|
||||
}
|
||||
|
||||
void BackgroundWidget::onChooseFromFile() {
|
||||
QStringList imgExtensions(cImgExtensions());
|
||||
QString filter(qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter());
|
||||
|
||||
_chooseFromFileQueryId = FileDialog::queryReadFile(lang(lng_choose_images), filter);
|
||||
}
|
||||
|
||||
void BackgroundWidget::notifyFileQueryUpdated(const FileDialog::QueryUpdate &update) {
|
||||
if (_chooseFromFileQueryId != update.queryId) {
|
||||
return;
|
||||
}
|
||||
_chooseFromFileQueryId = 0;
|
||||
|
||||
if (update.filePaths.isEmpty() && update.remoteContent.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QImage img;
|
||||
if (!update.remoteContent.isEmpty()) {
|
||||
img = App::readImage(update.remoteContent);
|
||||
} else {
|
||||
img = App::readImage(update.filePaths.front());
|
||||
}
|
||||
|
||||
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);
|
||||
_tile->setChecked(false);
|
||||
_background->updateImage();
|
||||
}
|
||||
|
||||
void BackgroundWidget::onTile() {
|
||||
Window::chatBackground()->setTile(_tile->checked());
|
||||
}
|
||||
|
||||
void BackgroundWidget::onAdaptive() {
|
||||
if (Global::AdaptiveForWide() != _adaptive->entity()->checked()) {
|
||||
Global::SetAdaptiveForWide(_adaptive->entity()->checked());
|
||||
Adaptive::Changed().notify();
|
||||
Local::writeUserSettings();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Settings
|
||||
|
|
|
@ -21,19 +21,72 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#pragma once
|
||||
|
||||
#include "settings/settings_block_widget.h"
|
||||
#include "ui/filedialog.h"
|
||||
|
||||
class LinkButton;
|
||||
class Checkbox;
|
||||
namespace Ui {
|
||||
template <typename Widget>
|
||||
class WidgetSlideWrap;
|
||||
} // namespace Ui;
|
||||
|
||||
namespace Settings {
|
||||
|
||||
class BackgroundRow : public TWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BackgroundRow(QWidget *parent);
|
||||
|
||||
void updateImage();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
int resizeGetHeight(int newWidth) override;
|
||||
|
||||
signals:
|
||||
void chooseFromGallery();
|
||||
void chooseFromFile();
|
||||
|
||||
private:
|
||||
float64 radialProgress() const;
|
||||
bool radialLoading() const;
|
||||
QRect radialRect() const;
|
||||
void radialStart();
|
||||
uint64 radialTimeShift() const;
|
||||
void step_radial(uint64 ms, bool timer);
|
||||
|
||||
QPixmap _background;
|
||||
ChildWidget<LinkButton> _chooseFromGallery;
|
||||
ChildWidget<LinkButton> _chooseFromFile;
|
||||
|
||||
RadialAnimation _radial;
|
||||
|
||||
};
|
||||
|
||||
class BackgroundWidget : public BlockWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BackgroundWidget(QWidget *parent, UserData *self);
|
||||
|
||||
protected:
|
||||
// Resizes content and counts natural widget height for the desired width.
|
||||
int resizeGetHeight(int newWidth) override;
|
||||
private slots:
|
||||
void onChooseFromGallery();
|
||||
void onChooseFromFile();
|
||||
void onTile();
|
||||
void onAdaptive();
|
||||
|
||||
private:
|
||||
void refreshControls();
|
||||
void createControls();
|
||||
void needBackgroundUpdate(bool tile);
|
||||
void notifyFileQueryUpdated(const FileDialog::QueryUpdate &update);
|
||||
|
||||
ChildWidget<BackgroundRow> _background = { nullptr };
|
||||
ChildWidget<Checkbox> _tile = { nullptr };
|
||||
ChildWidget<Ui::WidgetSlideWrap<Checkbox>> _adaptive = { nullptr };
|
||||
|
||||
FileDialog::QueryId _chooseFromFileQueryId = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ void BlockWidget::createChildRow(ChildWidget<Radiobutton> &child, style::margins
|
|||
|
||||
void BlockWidget::createChildRow(ChildWidget<LinkButton> &child, style::margins &margin, const QString &text, const char *slot) {
|
||||
child = new LinkButton(this, text);
|
||||
connect(child, SIGNAL(changed()), this, slot);
|
||||
connect(child, SIGNAL(clicked()), this, slot);
|
||||
}
|
||||
|
||||
} // namespace Settings
|
||||
|
|
|
@ -32,7 +32,7 @@ class WidgetSlideWrap;
|
|||
|
||||
namespace Settings {
|
||||
|
||||
class BlockWidget : public ScrolledWidget, public Notify::Observer, public base::Subscriber {
|
||||
class BlockWidget : public ScrolledWidget, public Notify::Observer, protected base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -36,8 +36,23 @@ namespace Settings {
|
|||
|
||||
ChatSettingsWidget::ChatSettingsWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_chat_settings)) {
|
||||
createControls();
|
||||
|
||||
subscribe(Global::RefDownloadPathChanged(), [this]() {
|
||||
_downloadPath->entity()->link()->setText(downloadPathText());
|
||||
resizeToWidth(width());
|
||||
});
|
||||
}
|
||||
|
||||
QString ChatSettingsWidget::downloadPathText() const {
|
||||
if (Global::DownloadPath().isEmpty()) {
|
||||
return lang(lng_download_path_default);
|
||||
} else if (Global::DownloadPath() == qsl("tmp")) {
|
||||
return lang(lng_download_path_temp);
|
||||
}
|
||||
return QDir::toNativeSeparators(Global::DownloadPath());
|
||||
};
|
||||
|
||||
|
||||
void ChatSettingsWidget::createControls() {
|
||||
style::margins marginSmall(0, 0, 0, st::settingsSmallSkip);
|
||||
style::margins marginSkip(0, 0, 0, st::settingsSkip);
|
||||
|
@ -48,18 +63,13 @@ void ChatSettingsWidget::createControls() {
|
|||
style::margins marginList(st::defaultCheckbox.textPosition.x(), 0, 0, st::settingsSkip);
|
||||
addChildRow(_viewList, marginList, slidedPadding, lang(lng_settings_view_emojis), SLOT(onViewList()));
|
||||
|
||||
addChildRow(_dontAskDownloadPath, marginSub, lang(lng_download_path_dont_ask), SLOT(onDontAskDownloadPath()), !cAskDownloadPath());
|
||||
auto downloadPathText = []() -> QString {
|
||||
if (cDownloadPath().isEmpty()) {
|
||||
return lang(lng_download_path_default);
|
||||
} else if (cDownloadPath() == qsl("tmp")) {
|
||||
return lang(lng_download_path_temp);
|
||||
}
|
||||
return QDir::toNativeSeparators(cDownloadPath());
|
||||
};
|
||||
addChildRow(_dontAskDownloadPath, marginSub, lang(lng_download_path_dont_ask), SLOT(onDontAskDownloadPath()), !Global::AskDownloadPath());
|
||||
style::margins marginPath(st::defaultCheckbox.textPosition.x(), 0, 0, st::settingsSkip);
|
||||
addChildRow(_downloadPath, marginPath, slidedPadding, lang(lng_download_path_label), downloadPathText());
|
||||
connect(_downloadPath->entity()->link(), SIGNAL(clicked()), this, SLOT(onDownloadPath()));
|
||||
if (Global::AskDownloadPath()) {
|
||||
_downloadPath->hideFast();
|
||||
}
|
||||
|
||||
addChildRow(_sendByEnter, marginSmall, qsl("send_key"), 0, lang(lng_settings_send_enter), SLOT(onSendByEnter()), !cCtrlEnter());
|
||||
addChildRow(_sendByCtrlEnter, marginSkip, qsl("send_key"), 1, lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_settings_send_cmdenter : lng_settings_send_ctrlenter), SLOT(onSendByCtrlEnter()), cCtrlEnter());
|
||||
|
@ -104,7 +114,7 @@ void ChatSettingsWidget::onViewList() {
|
|||
}
|
||||
|
||||
void ChatSettingsWidget::onDontAskDownloadPath() {
|
||||
cSetAskDownloadPath(!_dontAskDownloadPath->checked());
|
||||
Global::SetAskDownloadPath(!_dontAskDownloadPath->checked());
|
||||
Local::writeUserSettings();
|
||||
if (_dontAskDownloadPath->checked()) {
|
||||
_downloadPath->slideDown();
|
||||
|
|
|
@ -65,6 +65,7 @@ private slots:
|
|||
|
||||
private:
|
||||
void createControls();
|
||||
QString downloadPathText() const;
|
||||
|
||||
ChildWidget<Checkbox> _replaceEmoji = { nullptr };
|
||||
ChildWidget<Ui::WidgetSlideWrap<LinkButton>> _viewList = { nullptr };
|
||||
|
|
|
@ -42,6 +42,7 @@ CoverWidget::CoverWidget(QWidget *parent, UserData *self) : BlockWidget(parent,
|
|||
, _self(App::self())
|
||||
, _userpicButton(this, _self)
|
||||
, _name(this, st::settingsNameLabel)
|
||||
, _editNameInline(this, QString(), st::settingsEditButton)
|
||||
, _setPhoto(this, lang(lng_settings_upload), st::settingsPrimaryButton)
|
||||
, _editName(this, lang(lng_settings_edit), st::settingsSecondaryButton) {
|
||||
setAcceptDrops(true);
|
||||
|
@ -53,6 +54,7 @@ CoverWidget::CoverWidget(QWidget *parent, UserData *self) : BlockWidget(parent,
|
|||
connect(_setPhoto, SIGNAL(clicked()), this, SLOT(onSetPhoto()));
|
||||
_editName->setTextTransform(Ui::RoundButton::TextTransform::ToUpper);
|
||||
connect(_editName, SIGNAL(clicked()), this, SLOT(onEditName()));
|
||||
connect(_editNameInline, SIGNAL(clicked()), this, SLOT(onEditName()));
|
||||
|
||||
auto observeEvents = Notify::PeerUpdate::Flag::NameChanged;
|
||||
Notify::registerPeerObserver(observeEvents, this, &CoverWidget::notifyPeerUpdated);
|
||||
|
@ -97,8 +99,6 @@ int CoverWidget::resizeGetHeight(int newWidth) {
|
|||
|
||||
_userpicButton->moveToLeft(contentLeft() + st::settingsPhotoLeft, newHeight);
|
||||
|
||||
refreshNameGeometry(newWidth);
|
||||
|
||||
int infoLeft = _userpicButton->x() + _userpicButton->width();
|
||||
_statusPosition = QPoint(infoLeft + st::settingsStatusLeft, _userpicButton->y() + st::settingsStatusTop);
|
||||
if (_cancelPhotoUpload) {
|
||||
|
@ -109,12 +109,11 @@ int CoverWidget::resizeGetHeight(int newWidth) {
|
|||
int buttonsRight = newWidth - st::settingsButtonSkip;
|
||||
_setPhoto->moveToLeft(buttonLeft, _userpicButton->y() + st::settingsButtonTop);
|
||||
buttonLeft += _setPhoto->width() + st::settingsButtonSkip;
|
||||
_editName->moveToLeft(buttonLeft, _setPhoto->y()); // TODO
|
||||
if (buttonLeft + _editName->width() + st::settingsButtonSkip > newWidth) {
|
||||
_editName->hide();
|
||||
} else {
|
||||
_editName->show();
|
||||
}
|
||||
_editName->moveToLeft(buttonLeft, _setPhoto->y());
|
||||
_editNameVisible = (buttonLeft + _editName->width() + st::settingsButtonSkip <= newWidth);
|
||||
_editName->setVisible(_editNameVisible);
|
||||
|
||||
refreshNameGeometry(newWidth);
|
||||
|
||||
newHeight += st::settingsPhotoSize;
|
||||
newHeight += st::settingsMarginBottom;
|
||||
|
@ -133,9 +132,17 @@ void CoverWidget::refreshNameGeometry(int newWidth) {
|
|||
int nameLeft = infoLeft + st::settingsNameLeft - st::settingsNameLabel.margin.left();
|
||||
int nameTop = _userpicButton->y() + st::settingsNameTop - st::settingsNameLabel.margin.top();
|
||||
int nameWidth = newWidth - infoLeft - st::settingsNameLeft;
|
||||
auto editNameInlineVisible = !_editNameVisible;
|
||||
if (editNameInlineVisible) {
|
||||
nameWidth -= _editNameInline->width();
|
||||
}
|
||||
int marginsAdd = st::settingsNameLabel.margin.left() + st::settingsNameLabel.margin.right();
|
||||
|
||||
_name->resizeToWidth(qMin(nameWidth - marginsAdd, _name->naturalWidth()) + marginsAdd);
|
||||
_name->moveToLeft(nameLeft, nameTop);
|
||||
|
||||
_editNameInline->moveToLeft(nameLeft + _name->width(), nameTop);
|
||||
_editNameInline->setVisible(editNameInlineVisible);
|
||||
}
|
||||
|
||||
void CoverWidget::showFinished() {
|
||||
|
|
|
@ -93,6 +93,7 @@ private:
|
|||
ChildWidget<Profile::CoverDropArea> _dropArea = { nullptr };
|
||||
|
||||
ChildWidget<FlatLabel> _name;
|
||||
ChildWidget<Ui::RoundButton> _editNameInline;
|
||||
ChildWidget<LinkButton> _cancelPhotoUpload = { nullptr };
|
||||
|
||||
QPoint _statusPosition;
|
||||
|
@ -101,6 +102,7 @@ private:
|
|||
|
||||
ChildWidget<Ui::RoundButton> _setPhoto;
|
||||
ChildWidget<Ui::RoundButton> _editName;
|
||||
bool _editNameVisible = true;
|
||||
|
||||
int _dividerTop = 0;
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ QString currentVersion() {
|
|||
|
||||
GeneralWidget::GeneralWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_general))
|
||||
, _changeLanguage(this, lang(lng_settings_change_lang)) {
|
||||
connect(_changeLanguage, SIGNAL(clicked()), this, SLOT(onChangeLanguage()));
|
||||
refreshControls();
|
||||
}
|
||||
|
||||
|
@ -73,9 +74,9 @@ void GeneralWidget::refreshControls() {
|
|||
#endif // TDESKTOP_DISABLE_AUTOUPDATE
|
||||
|
||||
if (cPlatform() == dbipWindows || cSupportTray()) {
|
||||
addChildRow(_enableTrayIcon, marginSmall, lang(lng_settings_workmode_tray), SLOT(onWorkmodeChange()), (cWorkMode() == dbiwmTrayOnly || cWorkMode() == dbiwmWindowAndTray));
|
||||
addChildRow(_enableTrayIcon, marginSmall, lang(lng_settings_workmode_tray), SLOT(onEnableTrayIcon()), (cWorkMode() == dbiwmTrayOnly || cWorkMode() == dbiwmWindowAndTray));
|
||||
if (cPlatform() == dbipWindows) {
|
||||
addChildRow(_enableTaskbarIcon, marginLarge, lang(lng_settings_workmode_window), SLOT(onWorkmodeChange()), (cWorkMode() == dbiwmWindowOnly || cWorkMode() == dbiwmWindowAndTray));
|
||||
addChildRow(_enableTaskbarIcon, marginLarge, lang(lng_settings_workmode_window), SLOT(onEnableTaskbarIcon()), (cWorkMode() == dbiwmWindowOnly || cWorkMode() == dbiwmWindowAndTray));
|
||||
|
||||
addChildRow(_autoStart, marginSmall, lang(lng_settings_auto_start), SLOT(onAutoStart()), cAutoStart());
|
||||
addChildRow(_startMinimized, marginLarge, slidedPadding, lang(lng_settings_start_min), SLOT(onStartMinimized()), cStartMinimized());
|
||||
|
|
|
@ -37,18 +37,34 @@ namespace Settings {
|
|||
|
||||
InnerWidget::InnerWidget(QWidget *parent) : TWidget(parent)
|
||||
, _self(App::self()) {
|
||||
if (_self) {
|
||||
_cover = new CoverWidget(this, _self);
|
||||
}
|
||||
refreshBlocks();
|
||||
subscribe(Global::RefSelfChanged(), [this]() { selfUpdated(); });
|
||||
}
|
||||
|
||||
void InnerWidget::selfUpdated() {
|
||||
_self = App::self();
|
||||
refreshBlocks();
|
||||
|
||||
if (_cover) {
|
||||
_cover->setContentLeft(_contentLeft);
|
||||
_cover->resizeToWidth(width());
|
||||
}
|
||||
for_const (auto block, _blocks) {
|
||||
block->setContentLeft(_contentLeft);
|
||||
block->resizeToWidth(width());
|
||||
}
|
||||
onBlockHeightUpdated();
|
||||
}
|
||||
|
||||
void InnerWidget::refreshBlocks() {
|
||||
_cover.destroyDelayed();
|
||||
for_const (auto block, _blocks) {
|
||||
block->deleteLater();
|
||||
}
|
||||
_blocks.clear();
|
||||
|
||||
if (_self) {
|
||||
_cover = new CoverWidget(this, _self);
|
||||
_blocks.push_back(new Settings::InfoWidget(this, _self));
|
||||
_blocks.push_back(new Settings::NotificationsWidget(this, _self));
|
||||
}
|
||||
|
@ -60,7 +76,12 @@ void InnerWidget::refreshBlocks() {
|
|||
_blocks.push_back(new Settings::PrivacyWidget(this, _self));
|
||||
}
|
||||
_blocks.push_back(new Settings::AdvancedWidget(this, _self));
|
||||
|
||||
if (_cover) {
|
||||
_cover->show();
|
||||
}
|
||||
for_const (auto block, _blocks) {
|
||||
block->show();
|
||||
connect(block, SIGNAL(heightUpdated()), this, SLOT(onBlockHeightUpdated()));
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +123,7 @@ void InnerWidget::onBlockHeightUpdated() {
|
|||
int newHeight = refreshBlocksPositions();
|
||||
if (newHeight != height()) {
|
||||
resize(width(), newHeight);
|
||||
emit heightUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Settings {
|
|||
class CoverWidget;
|
||||
class BlockWidget;
|
||||
|
||||
class InnerWidget : public TWidget {
|
||||
class InnerWidget : public TWidget, private base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -42,6 +42,9 @@ public:
|
|||
|
||||
void showFinished();
|
||||
|
||||
signals:
|
||||
void heightUpdated();
|
||||
|
||||
private slots:
|
||||
void onBlockHeightUpdated();
|
||||
|
||||
|
@ -50,6 +53,7 @@ protected:
|
|||
int resizeGetHeight(int newWidth) override;
|
||||
|
||||
private:
|
||||
void selfUpdated();
|
||||
void refreshBlocks();
|
||||
|
||||
// Returns the new height value.
|
||||
|
|
|
@ -32,14 +32,24 @@ namespace Settings {
|
|||
|
||||
NotificationsWidget::NotificationsWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_notify)) {
|
||||
createControls();
|
||||
|
||||
subscribe(Global::RefNotifySettingsChanged(), [this](const Notify::ChangeType &type) {
|
||||
if (type == Notify::ChangeType::DesktopEnabled) {
|
||||
desktopEnabledUpdated();
|
||||
} else if (type == Notify::ChangeType::ViewParams) {
|
||||
viewParamUpdated();
|
||||
} else if (type == Notify::ChangeType::SoundEnabled) {
|
||||
_playSound->setChecked(Global::SoundNotify());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void NotificationsWidget::createControls() {
|
||||
style::margins margin(0, 0, 0, st::settingsSmallSkip);
|
||||
style::margins slidedPadding(0, margin.bottom() / 2, 0, margin.bottom() - (margin.bottom() / 2));
|
||||
addChildRow(_desktopNotifications, margin, lang(lng_settings_desktop_notify), SLOT(onDesktopNotifications()), cDesktopNotify());
|
||||
addChildRow(_showSenderName, margin, slidedPadding, lang(lng_settings_show_name), SLOT(onShowSenderName()), cNotifyView() <= dbinvShowName);
|
||||
addChildRow(_showMessagePreview, margin, slidedPadding, lang(lng_settings_show_preview), SLOT(onShowMessagePreview()), cNotifyView() <= dbinvShowPreview);
|
||||
addChildRow(_desktopNotifications, margin, lang(lng_settings_desktop_notify), SLOT(onDesktopNotifications()), Global::DesktopNotify());
|
||||
addChildRow(_showSenderName, margin, slidedPadding, lang(lng_settings_show_name), SLOT(onShowSenderName()), Global::NotifyView() <= dbinvShowName);
|
||||
addChildRow(_showMessagePreview, margin, slidedPadding, lang(lng_settings_show_preview), SLOT(onShowMessagePreview()), Global::NotifyView() <= dbinvShowPreview);
|
||||
if (!_showSenderName->entity()->checked()) {
|
||||
_showMessagePreview->hideFast();
|
||||
}
|
||||
|
@ -49,79 +59,105 @@ void NotificationsWidget::createControls() {
|
|||
}
|
||||
#ifdef Q_OS_WIN
|
||||
if (App::wnd()->psHasNativeNotifications()) {
|
||||
addChildRow(_windowsNative, margin, lang(lng_settings_use_windows), SLOT(onWindowsNative()), cWindowsNotifications());
|
||||
addChildRow(_windowsNative, margin, lang(lng_settings_use_windows), SLOT(onWindowsNative()), Global::WindowsNotifications());
|
||||
}
|
||||
#endif // Q_OS_WIN
|
||||
addChildRow(_playSound, margin, lang(lng_settings_sound_notify), SLOT(onPlaySound()), cSoundNotify());
|
||||
addChildRow(_includeMuted, margin, lang(lng_settings_include_muted), SLOT(onIncludeMuted()), cIncludeMuted());
|
||||
addChildRow(_playSound, margin, lang(lng_settings_sound_notify), SLOT(onPlaySound()), Global::SoundNotify());
|
||||
addChildRow(_includeMuted, margin, lang(lng_settings_include_muted), SLOT(onIncludeMuted()), Global::IncludeMuted());
|
||||
}
|
||||
|
||||
void NotificationsWidget::onDesktopNotifications() {
|
||||
cSetDesktopNotify(_desktopNotifications->checked());
|
||||
if (Global::DesktopNotify() == _desktopNotifications->checked()) {
|
||||
return;
|
||||
}
|
||||
Global::SetDesktopNotify(_desktopNotifications->checked());
|
||||
Local::writeUserSettings();
|
||||
if (App::wnd()) App::wnd()->updateTrayMenu();
|
||||
Global::RefNotifySettingsChanged().notify(Notify::ChangeType::DesktopEnabled);
|
||||
}
|
||||
|
||||
if (_desktopNotifications->checked()) {
|
||||
void NotificationsWidget::desktopEnabledUpdated() {
|
||||
_desktopNotifications->setChecked(Global::DesktopNotify());
|
||||
if (Global::DesktopNotify()) {
|
||||
_showSenderName->slideDown();
|
||||
if (_showSenderName->entity()->checked()) {
|
||||
_showMessagePreview->slideDown();
|
||||
}
|
||||
} else {
|
||||
App::wnd()->notifyClear();
|
||||
_showSenderName->slideUp();
|
||||
_showMessagePreview->slideUp();
|
||||
}
|
||||
}
|
||||
|
||||
void NotificationsWidget::onShowSenderName() {
|
||||
auto viewParam = ([this]() {
|
||||
if (!_showSenderName->entity()->checked()) {
|
||||
return dbinvShowNothing;
|
||||
} else if (!_showMessagePreview->entity()->checked()) {
|
||||
return dbinvShowName;
|
||||
}
|
||||
return dbinvShowPreview;
|
||||
})();
|
||||
if (viewParam == Global::NotifyView()) {
|
||||
return;
|
||||
}
|
||||
Global::SetNotifyView(viewParam);
|
||||
Local::writeUserSettings();
|
||||
Global::RefNotifySettingsChanged().notify(Notify::ChangeType::ViewParams);
|
||||
}
|
||||
|
||||
void NotificationsWidget::onShowMessagePreview() {
|
||||
auto viewParam = ([this]() {
|
||||
if (_showMessagePreview->entity()->checked()) {
|
||||
return dbinvShowPreview;
|
||||
} else if (_showSenderName->entity()->checked()) {
|
||||
return dbinvShowName;
|
||||
}
|
||||
return dbinvShowNothing;
|
||||
})();
|
||||
if (viewParam == Global::NotifyView()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Global::SetNotifyView(viewParam);
|
||||
Local::writeUserSettings();
|
||||
Global::RefNotifySettingsChanged().notify(Notify::ChangeType::ViewParams);
|
||||
}
|
||||
|
||||
void NotificationsWidget::viewParamUpdated() {
|
||||
if (_showSenderName->entity()->checked()) {
|
||||
_showMessagePreview->slideDown();
|
||||
} else {
|
||||
_showMessagePreview->slideUp();
|
||||
}
|
||||
|
||||
if (!_showSenderName->entity()->checked()) {
|
||||
cSetNotifyView(dbinvShowNothing);
|
||||
} else if (!_showMessagePreview->entity()->checked()) {
|
||||
cSetNotifyView(dbinvShowName);
|
||||
} else {
|
||||
cSetNotifyView(dbinvShowPreview);
|
||||
}
|
||||
Local::writeUserSettings();
|
||||
App::wnd()->notifyUpdateAll();
|
||||
}
|
||||
|
||||
void NotificationsWidget::onShowMessagePreview() {
|
||||
if (_showMessagePreview->entity()->checked()) {
|
||||
cSetNotifyView(dbinvShowPreview);
|
||||
} else if (_showSenderName->entity()->checked()) {
|
||||
cSetNotifyView(dbinvShowName);
|
||||
} else {
|
||||
cSetNotifyView(dbinvShowNothing);
|
||||
}
|
||||
Local::writeUserSettings();
|
||||
App::wnd()->notifyUpdateAll();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
void NotificationsWidget::onWindowsNative() {
|
||||
if (cPlatform() != dbipWindows) return;
|
||||
cSetWindowsNotifications(!cWindowsNotifications());
|
||||
App::wnd()->notifyClearFast();
|
||||
cSetCustomNotifies(!cWindowsNotifications());
|
||||
#ifdef Q_OS_WIN
|
||||
if (Global::WindowsNotifications() == _windowsNative->checked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Global::SetWindowsNotifications(_windowsNative->checked());
|
||||
Global::SetCustomNotifies(!Global::WindowsNotifications());
|
||||
Local::writeUserSettings();
|
||||
}
|
||||
Global::RefNotifySettingsChanged().notify(Notify::ChangeType::UseNative);
|
||||
#endif // Q_OS_WIN
|
||||
}
|
||||
|
||||
void NotificationsWidget::onPlaySound() {
|
||||
cSetSoundNotify(_playSound->checked());
|
||||
if (_playSound->checked() == Global::SoundNotify()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Global::SetSoundNotify(_playSound->checked());
|
||||
Local::writeUserSettings();
|
||||
Global::RefNotifySettingsChanged().notify(Notify::ChangeType::SoundEnabled);
|
||||
}
|
||||
|
||||
void NotificationsWidget::onIncludeMuted() {
|
||||
cSetIncludeMuted(_includeMuted->checked());
|
||||
Notify::unreadCounterUpdated();
|
||||
Global::SetIncludeMuted(_includeMuted->checked());
|
||||
Local::writeUserSettings();
|
||||
Global::RefNotifySettingsChanged().notify(Notify::ChangeType::IncludeMuted);
|
||||
}
|
||||
|
||||
} // namespace Settings
|
||||
|
|
|
@ -34,14 +34,14 @@ private slots:
|
|||
void onDesktopNotifications();
|
||||
void onShowSenderName();
|
||||
void onShowMessagePreview();
|
||||
#ifdef Q_OS_WIN
|
||||
void onWindowsNative();
|
||||
#endif // Q_OS_WIN
|
||||
void onPlaySound();
|
||||
void onIncludeMuted();
|
||||
|
||||
private:
|
||||
void createControls();
|
||||
void desktopEnabledUpdated();
|
||||
void viewParamUpdated();
|
||||
|
||||
ChildWidget<Checkbox> _desktopNotifications = { nullptr };
|
||||
ChildWidget<Ui::WidgetSlideWrap<Checkbox>> _showSenderName = { nullptr };
|
||||
|
|
|
@ -42,6 +42,8 @@ Widget::Widget() : LayerWidget()
|
|||
_fixedBarShadow1->move(0, _fixedBar->y() + st::settingsFixedBarHeight);
|
||||
_fixedBarShadow2->move(0, _fixedBarShadow1->y() + st::lineWidth);
|
||||
_scroll->move(0, st::settingsFixedBarHeight);
|
||||
|
||||
connect(_inner, SIGNAL(heightUpdated()), this, SLOT(onInnerHeightUpdated()));
|
||||
}
|
||||
|
||||
void Widget::parentResized() {
|
||||
|
@ -70,6 +72,17 @@ void Widget::parentResized() {
|
|||
// resize it here, not in the resizeEvent() handler.
|
||||
_inner->resizeToWidth(newWidth, newContentLeft);
|
||||
|
||||
resizeUsingInnerHeight(newWidth, newContentLeft);
|
||||
}
|
||||
|
||||
void Widget::onInnerHeightUpdated() {
|
||||
resizeUsingInnerHeight(width(), _contentLeft);
|
||||
}
|
||||
|
||||
void Widget::resizeUsingInnerHeight(int newWidth, int newContentLeft) {
|
||||
if (!App::wnd()) return;
|
||||
|
||||
int windowWidth = App::wnd()->width();
|
||||
int windowHeight = App::wnd()->height();
|
||||
int maxHeight = st::settingsFixedBarHeight + _inner->height();
|
||||
int newHeight = maxHeight;
|
||||
|
|
|
@ -28,6 +28,8 @@ class InnerWidget;
|
|||
class FixedBar;
|
||||
|
||||
class Widget : public LayerWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Widget();
|
||||
|
||||
|
@ -38,7 +40,12 @@ protected:
|
|||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void onInnerHeightUpdated();
|
||||
|
||||
private:
|
||||
void resizeUsingInnerHeight(int newWidth, int newContentLeft);
|
||||
|
||||
ChildWidget<ScrollArea> _scroll;
|
||||
ChildWidget<InnerWidget> _inner;
|
||||
ChildWidget<FixedBar> _fixedBar;
|
||||
|
|
|
@ -127,12 +127,12 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent)
|
|||
, _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())
|
||||
, _desktopNotify(this, lang(lng_settings_desktop_notify), Global::DesktopNotify())
|
||||
, _senderName(this, lang(lng_settings_show_name), Global::NotifyView() <= dbinvShowName)
|
||||
, _messagePreview(this, lang(lng_settings_show_preview), Global::NotifyView() <= dbinvShowPreview)
|
||||
, _windowsNotifications(this, lang(lng_settings_use_windows), Global::WindowsNotifications())
|
||||
, _soundNotify(this, lang(lng_settings_sound_notify), Global::SoundNotify())
|
||||
, _includeMuted(this, lang(lng_settings_include_muted), Global::IncludeMuted())
|
||||
|
||||
// general
|
||||
, _changeLanguage(this, lang(lng_settings_change_lang))
|
||||
|
@ -165,9 +165,9 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent)
|
|||
, _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())
|
||||
, _dontAskDownloadPath(this, lang(lng_download_path_dont_ask), false/*!cAskDownloadPath()*/)
|
||||
, _downloadPathWidth(st::linkFont->width(lang(lng_download_path_label)) + st::linkFont->spacew)
|
||||
, _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)))
|
||||
, _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))*/)
|
||||
, _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)))
|
||||
|
@ -185,7 +185,7 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent)
|
|||
// 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())
|
||||
, _tileBackground(this, lang(lng_settings_bg_tile), false/*cTileBackground()*/)
|
||||
, _adaptiveForWide(this, lang(lng_settings_adaptive_wide), Global::AdaptiveForWide())
|
||||
, _needBackgroundUpdate(false)
|
||||
, _radial(animation(this, &SettingsInner::step_radial))
|
||||
|
@ -208,7 +208,6 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent)
|
|||
, _logOut(this, lang(lng_settings_logout), st::btnRedLink)
|
||||
, _supportGetRequest(0) {
|
||||
Notify::registerPeerObserver(Notify::PeerUpdate::Flag::UsernameChanged, this, &SettingsInner::notifyPeerUpdated);
|
||||
registerDownloadPathObserver(this, &SettingsInner::notifyDownloadPathUpdated);
|
||||
|
||||
App::clearMousedItems();
|
||||
|
||||
|
@ -313,7 +312,7 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent)
|
|||
}
|
||||
|
||||
// chat background
|
||||
if (!cChatBackground()) App::initBackground();
|
||||
//if (!cChatBackground()) App::initBackground();
|
||||
updateChatBackground();
|
||||
connect(&_backFromGallery, SIGNAL(clicked()), this, SLOT(onBackFromGallery()));
|
||||
connect(&_backFromFile, SIGNAL(clicked()), this, SLOT(onBackFromFile()));
|
||||
|
@ -368,19 +367,6 @@ void SettingsInner::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
|||
}
|
||||
}
|
||||
|
||||
void SettingsInner::notifyDownloadPathUpdated(const DownloadPathUpdate &update) {
|
||||
QString path;
|
||||
if (cDownloadPath().isEmpty()) {
|
||||
path = lang(lng_download_path_default);
|
||||
} else if (cDownloadPath() == qsl("tmp")) {
|
||||
path = lang(lng_download_path_temp);
|
||||
} else {
|
||||
path = st::linkFont->elided(QDir::toNativeSeparators(cDownloadPath()), st::setWidth - st::setVersionLeft - _downloadPathWidth);
|
||||
}
|
||||
_downloadPathEdit.setText(path);
|
||||
showAll();
|
||||
}
|
||||
|
||||
void SettingsInner::peerUpdated(PeerData *data) {
|
||||
if (self() && data == self()) {
|
||||
if (self()->photoId && self()->photoId != UnknownPeerPhotoId) {
|
||||
|
@ -556,25 +542,25 @@ void SettingsInner::paintEvent(QPaintEvent *e) {
|
|||
top += _ctrlEnterSend.height() + st::setSectionSkip;
|
||||
|
||||
top += _dontAskDownloadPath.height();
|
||||
if (!cAskDownloadPath()) {
|
||||
top += st::setLittleSkip;
|
||||
p.setFont(st::linkFont->f);
|
||||
p.setPen(st::black->p);
|
||||
p.drawText(_left + st::cbDefFlat.textLeft, top + st::linkFont->ascent, lang(lng_download_path_label));
|
||||
if (cDownloadPath() == qsl("tmp")) {
|
||||
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();
|
||||
}
|
||||
//if (!cAskDownloadPath()) {
|
||||
// top += st::setLittleSkip;
|
||||
// p.setFont(st::linkFont->f);
|
||||
// p.setPen(st::black->p);
|
||||
// p.drawText(_left + st::cbDefFlat.textLeft, top + st::linkFont->ascent, lang(lng_download_path_label));
|
||||
// if (cDownloadPath() == qsl("tmp")) {
|
||||
// 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();
|
||||
//}
|
||||
top += st::setLittleSkip;
|
||||
top += _autoDownload.height();
|
||||
|
||||
|
@ -755,14 +741,14 @@ void SettingsInner::resizeEvent(QResizeEvent *e) {
|
|||
_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;
|
||||
_downloadPathEdit.move(_left + st::cbDefFlat.textLeft + _downloadPathWidth, top);
|
||||
if (cDownloadPath() == qsl("tmp")) {
|
||||
_downloadPathClear.move(_left + st::setWidth - _downloadPathClear.width(), top);
|
||||
}
|
||||
top += _downloadPathEdit.height();
|
||||
}
|
||||
//if (!cAskDownloadPath()) {
|
||||
// top += st::setLittleSkip;
|
||||
// _downloadPathEdit.move(_left + st::cbDefFlat.textLeft + _downloadPathWidth, top);
|
||||
// if (cDownloadPath() == qsl("tmp")) {
|
||||
// _downloadPathClear.move(_left + st::setWidth - _downloadPathClear.width(), top);
|
||||
// }
|
||||
// top += _downloadPathEdit.height();
|
||||
//}
|
||||
top += st::setLittleSkip;
|
||||
_autoDownload.move(_left + st::cbDefFlat.textLeft, top); top += _autoDownload.height();
|
||||
|
||||
|
@ -950,19 +936,19 @@ void SettingsInner::updateOnlineDisplay() {
|
|||
}
|
||||
|
||||
void SettingsInner::updateConnectionType() {
|
||||
QString connection;
|
||||
switch (cConnectionType()) {
|
||||
case dbictAuto: {
|
||||
QString transport = MTP::dctransport();
|
||||
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);
|
||||
} break;
|
||||
}
|
||||
_connectionType.setText(connection);
|
||||
//QString connection;
|
||||
//switch (cConnectionType()) {
|
||||
//case dbictAuto: {
|
||||
// QString transport = MTP::dctransport();
|
||||
// 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);
|
||||
//} break;
|
||||
//}
|
||||
//_connectionType.setText(connection);
|
||||
}
|
||||
|
||||
void SettingsInner::passcodeChanged() {
|
||||
|
@ -1128,17 +1114,17 @@ void SettingsInner::showAll() {
|
|||
_enterSend.show();
|
||||
_ctrlEnterSend.show();
|
||||
_dontAskDownloadPath.show();
|
||||
if (cAskDownloadPath()) {
|
||||
_downloadPathEdit.hide();
|
||||
_downloadPathClear.hide();
|
||||
} else {
|
||||
_downloadPathEdit.show();
|
||||
if (cDownloadPath() == qsl("tmp") && _tempDirClearState == TempDirExists) { // dir exists, not clearing right now
|
||||
_downloadPathClear.show();
|
||||
} else {
|
||||
_downloadPathClear.hide();
|
||||
}
|
||||
}
|
||||
//if (cAskDownloadPath()) {
|
||||
// _downloadPathEdit.hide();
|
||||
// _downloadPathClear.hide();
|
||||
//} else {
|
||||
// _downloadPathEdit.show();
|
||||
// if (cDownloadPath() == qsl("tmp") && _tempDirClearState == TempDirExists) { // dir exists, not clearing right now
|
||||
// _downloadPathClear.show();
|
||||
// } else {
|
||||
// _downloadPathClear.hide();
|
||||
// }
|
||||
//}
|
||||
_autoDownload.show();
|
||||
} else {
|
||||
_replaceEmojis.hide();
|
||||
|
@ -1547,36 +1533,36 @@ void SettingsInner::setScale(DBIScale newScale) {
|
|||
}
|
||||
|
||||
void SettingsInner::onSoundNotify() {
|
||||
cSetSoundNotify(_soundNotify.checked());
|
||||
Local::writeUserSettings();
|
||||
//cSetSoundNotify(_soundNotify.checked());
|
||||
//Local::writeUserSettings();
|
||||
}
|
||||
|
||||
void SettingsInner::onIncludeMuted() {
|
||||
cSetIncludeMuted(_includeMuted.checked());
|
||||
Notify::unreadCounterUpdated();
|
||||
Local::writeUserSettings();
|
||||
//cSetIncludeMuted(_includeMuted.checked());
|
||||
//Notify::unreadCounterUpdated();
|
||||
//Local::writeUserSettings();
|
||||
}
|
||||
|
||||
void SettingsInner::onWindowsNotifications() {
|
||||
if (cPlatform() != dbipWindows) return;
|
||||
cSetWindowsNotifications(!cWindowsNotifications());
|
||||
App::wnd()->notifyClearFast();
|
||||
cSetCustomNotifies(!cWindowsNotifications());
|
||||
Local::writeUserSettings();
|
||||
//if (cPlatform() != dbipWindows) return;
|
||||
//cSetWindowsNotifications(!cWindowsNotifications());
|
||||
//App::wnd()->notifyClearFast();
|
||||
//cSetCustomNotifies(!cWindowsNotifications());
|
||||
//Local::writeUserSettings();
|
||||
}
|
||||
|
||||
void SettingsInner::onDesktopNotify() {
|
||||
cSetDesktopNotify(_desktopNotify.checked());
|
||||
if (!_desktopNotify.checked()) {
|
||||
App::wnd()->notifyClear();
|
||||
_senderName.setDisabled(true);
|
||||
_messagePreview.setDisabled(true);
|
||||
} else {
|
||||
_senderName.setDisabled(false);
|
||||
_messagePreview.setDisabled(!_senderName.checked());
|
||||
}
|
||||
Local::writeUserSettings();
|
||||
if (App::wnd()) App::wnd()->updateTrayMenu();
|
||||
//cSetDesktopNotify(_desktopNotify.checked());
|
||||
//if (!_desktopNotify.checked()) {
|
||||
// App::wnd()->notifyClear();
|
||||
// _senderName.setDisabled(true);
|
||||
// _messagePreview.setDisabled(true);
|
||||
//} else {
|
||||
// _senderName.setDisabled(false);
|
||||
// _messagePreview.setDisabled(!_senderName.checked());
|
||||
//}
|
||||
//Local::writeUserSettings();
|
||||
//if (App::wnd()) App::wnd()->updateTrayMenu();
|
||||
}
|
||||
|
||||
void SettingsInner::enableDisplayNotify(bool enable)
|
||||
|
@ -1585,32 +1571,32 @@ void SettingsInner::enableDisplayNotify(bool enable)
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
Local::writeUserSettings();
|
||||
App::wnd()->notifyUpdateAll();
|
||||
}
|
||||
//_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);
|
||||
// }
|
||||
// Local::writeUserSettings();
|
||||
// App::wnd()->notifyUpdateAll();
|
||||
//}
|
||||
}
|
||||
|
||||
void SettingsInner::onMessagePreview() {
|
||||
if (_messagePreview.checked()) {
|
||||
cSetNotifyView(dbinvShowPreview);
|
||||
} else if (_senderName.checked()) {
|
||||
cSetNotifyView(dbinvShowName);
|
||||
} else {
|
||||
cSetNotifyView(dbinvShowNothing);
|
||||
}
|
||||
Local::writeUserSettings();
|
||||
App::wnd()->notifyUpdateAll();
|
||||
//if (_messagePreview.checked()) {
|
||||
// cSetNotifyView(dbinvShowPreview);
|
||||
//} else if (_senderName.checked()) {
|
||||
// cSetNotifyView(dbinvShowName);
|
||||
//} else {
|
||||
// cSetNotifyView(dbinvShowNothing);
|
||||
//}
|
||||
//Local::writeUserSettings();
|
||||
//App::wnd()->notifyUpdateAll();
|
||||
}
|
||||
|
||||
void SettingsInner::onReplaceEmojis() {
|
||||
|
@ -1649,12 +1635,12 @@ void SettingsInner::onCtrlEnterSend() {
|
|||
}
|
||||
|
||||
void SettingsInner::onBackFromGallery() {
|
||||
BackgroundBox *box = new BackgroundBox();
|
||||
box->setUpdateCallback([this, weak_this = weakThis()](bool tile) {
|
||||
if (!weak_this) return;
|
||||
needBackgroundUpdate(tile);
|
||||
});
|
||||
Ui::showLayer(box);
|
||||
//BackgroundBox *box = new BackgroundBox();
|
||||
//box->setUpdateCallback([this, weak_this = weakThis()](bool tile) {
|
||||
// if (!weak_this) return;
|
||||
// needBackgroundUpdate(tile);
|
||||
//});
|
||||
//Ui::showLayer(box);
|
||||
}
|
||||
|
||||
void SettingsInner::onBackFromFile() {
|
||||
|
@ -1735,23 +1721,23 @@ void SettingsInner::step_radial(uint64 ms, bool timer) {
|
|||
}
|
||||
|
||||
void SettingsInner::updateChatBackground() {
|
||||
int32 size = st::setBackgroundSize * cIntRetinaFactor();
|
||||
QImage back(size, size, QImage::Format_ARGB32_Premultiplied);
|
||||
back.setDevicePixelRatio(cRetinaFactor());
|
||||
{
|
||||
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);
|
||||
}
|
||||
_background = App::pixmapFromImageInPlace(std_::move(back));
|
||||
_background.setDevicePixelRatio(cRetinaFactor());
|
||||
_needBackgroundUpdate = false;
|
||||
//int32 size = st::setBackgroundSize * cIntRetinaFactor();
|
||||
//QImage back(size, size, QImage::Format_ARGB32_Premultiplied);
|
||||
//back.setDevicePixelRatio(cRetinaFactor());
|
||||
//{
|
||||
// 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);
|
||||
//}
|
||||
//_background = App::pixmapFromImageInPlace(std_::move(back));
|
||||
//_background.setDevicePixelRatio(cRetinaFactor());
|
||||
//_needBackgroundUpdate = false;
|
||||
|
||||
updateBackgroundRect();
|
||||
//updateBackgroundRect();
|
||||
}
|
||||
|
||||
void SettingsInner::needBackgroundUpdate(bool tile) {
|
||||
|
@ -1764,30 +1750,30 @@ void SettingsInner::needBackgroundUpdate(bool tile) {
|
|||
}
|
||||
|
||||
void SettingsInner::onTileBackground() {
|
||||
if (cTileBackground() != _tileBackground.checked()) {
|
||||
cSetTileBackground(_tileBackground.checked());
|
||||
if (App::main()) App::main()->clearCachedBackground();
|
||||
Local::writeUserSettings();
|
||||
}
|
||||
//if (cTileBackground() != _tileBackground.checked()) {
|
||||
// cSetTileBackground(_tileBackground.checked());
|
||||
// if (App::main()) App::main()->clearCachedBackground();
|
||||
// Local::writeUserSettings();
|
||||
//}
|
||||
}
|
||||
|
||||
void SettingsInner::onAdaptiveForWide() {
|
||||
if (Global::AdaptiveForWide() != _adaptiveForWide.checked()) {
|
||||
Global::SetAdaptiveForWide(_adaptiveForWide.checked());
|
||||
if (App::wnd()) {
|
||||
App::wnd()->updateAdaptiveLayout();
|
||||
}
|
||||
Local::writeUserSettings();
|
||||
}
|
||||
//if (Global::AdaptiveForWide() != _adaptiveForWide.checked()) {
|
||||
// Global::SetAdaptiveForWide(_adaptiveForWide.checked());
|
||||
// if (App::wnd()) {
|
||||
// App::wnd()->updateAdaptiveLayout();
|
||||
// }
|
||||
// Local::writeUserSettings();
|
||||
//}
|
||||
}
|
||||
|
||||
void SettingsInner::onDontAskDownloadPath() {
|
||||
cSetAskDownloadPath(!_dontAskDownloadPath.checked());
|
||||
Local::writeUserSettings();
|
||||
//cSetAskDownloadPath(!_dontAskDownloadPath.checked());
|
||||
//Local::writeUserSettings();
|
||||
|
||||
showAll();
|
||||
resizeEvent(0);
|
||||
update();
|
||||
//showAll();
|
||||
//resizeEvent(0);
|
||||
//update();
|
||||
}
|
||||
|
||||
void SettingsInner::onDownloadPathEdit() {
|
||||
|
@ -2041,7 +2027,7 @@ void SettingsWidget::updateAdaptiveLayout() {
|
|||
}
|
||||
|
||||
void SettingsWidget::updateDisplayNotify() {
|
||||
_inner.enableDisplayNotify(cDesktopNotify());
|
||||
//_inner.enableDisplayNotify(cDesktopNotify());
|
||||
}
|
||||
|
||||
void SettingsWidget::updateOnlineDisplay() {
|
||||
|
|
|
@ -194,7 +194,6 @@ private slots:
|
|||
|
||||
private:
|
||||
void notifyPeerUpdated(const Notify::PeerUpdate &update);
|
||||
void notifyDownloadPathUpdated(const DownloadPathUpdate &update);
|
||||
|
||||
void saveError(const QString &str = QString());
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#pragma clang diagnostic pop
|
||||
#endif // __clang__
|
||||
|
||||
|
||||
#include <QtWidgets/QtWidgets>
|
||||
#include <QtNetwork/QtNetwork>
|
||||
|
||||
|
|
|
@ -806,7 +806,7 @@ QString saveFileName(const QString &title, const QString &filter, const QString
|
|||
#elif defined Q_OS_LINUX
|
||||
name = name.replace(QRegularExpression(qsl("[\\/]")), qsl("_"));
|
||||
#endif
|
||||
if (cAskDownloadPath() || savingAs) {
|
||||
if (Global::AskDownloadPath() || savingAs) {
|
||||
if (!name.isEmpty() && name.at(0) == QChar::fromLatin1('.')) {
|
||||
name = filedialogDefaultName(prefix, name);
|
||||
} else if (dir.path() != qsl(".")) {
|
||||
|
@ -851,12 +851,12 @@ QString saveFileName(const QString &title, const QString &filter, const QString
|
|||
}
|
||||
|
||||
QString path;
|
||||
if (cDownloadPath().isEmpty()) {
|
||||
if (Global::DownloadPath().isEmpty()) {
|
||||
path = psDownloadPath();
|
||||
} else if (cDownloadPath() == qsl("tmp")) {
|
||||
} else if (Global::DownloadPath() == qsl("tmp")) {
|
||||
path = cTempDir();
|
||||
} else {
|
||||
path = cDownloadPath();
|
||||
path = Global::DownloadPath();
|
||||
}
|
||||
if (name.isEmpty()) name = qsl(".unknown");
|
||||
if (name.at(0) == QChar::fromLatin1('.')) {
|
||||
|
@ -1480,7 +1480,7 @@ QString DocumentData::filepath(FilePathResolveType type, bool forceSavingAs) con
|
|||
if (saveFromData) {
|
||||
if (type != FilePathResolveSaveFromData && type != FilePathResolveSaveFromDataSilent) {
|
||||
saveFromData = false;
|
||||
} else if (type == FilePathResolveSaveFromDataSilent && (cAskDownloadPath() || forceSavingAs)) {
|
||||
} else if (type == FilePathResolveSaveFromDataSilent && (Global::AskDownloadPath() || forceSavingAs)) {
|
||||
saveFromData = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,8 @@ TitleWidget::TitleWidget(MainWindow *window) : TWidget(window)
|
|||
Sandbox::connect(SIGNAL(updateReady()), this, SLOT(showUpdateBtn()));
|
||||
#endif
|
||||
|
||||
subscribe(Adaptive::Changed(), [this]() { updateAdaptiveLayout(); });
|
||||
|
||||
if (cPlatform() != dbipWindows) {
|
||||
_minimize.hide();
|
||||
_maximize.hide();
|
||||
|
|
|
@ -39,7 +39,7 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class TitleWidget : public TWidget {
|
||||
class TitleWidget : public TWidget, private base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -49,7 +49,6 @@ public:
|
|||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
void updateBackButton();
|
||||
void updateAdaptiveLayout();
|
||||
void updateCounter();
|
||||
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
|
@ -77,6 +76,7 @@ signals:
|
|||
void hiderClicked();
|
||||
|
||||
private:
|
||||
void updateAdaptiveLayout();
|
||||
|
||||
MainWindow *wnd;
|
||||
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop version of Telegram messaging app, see https://telegram.org
|
||||
|
||||
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.
|
||||
|
||||
In addition, as a special exception, the copyright holders give permission
|
||||
to link the code of portions of this program with the OpenSSL library.
|
||||
|
||||
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
||||
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#include "stdafx.h"
|
||||
#include "window/chat_background.h"
|
||||
|
||||
#include "mainwidget.h"
|
||||
#include "localstorage.h"
|
||||
|
||||
namespace Window {
|
||||
namespace {
|
||||
|
||||
NeverFreedPointer<ChatBackground> instance;
|
||||
|
||||
} // namespace
|
||||
|
||||
bool ChatBackground::empty() const {
|
||||
return _image.isNull();
|
||||
}
|
||||
|
||||
void ChatBackground::initIfEmpty() {
|
||||
if (empty()) {
|
||||
App::initBackground();
|
||||
}
|
||||
}
|
||||
|
||||
void ChatBackground::init(int32 id, QPixmap &&image, QPixmap &&dog) {
|
||||
_id = id;
|
||||
_image = std_::move(image);
|
||||
_dog = std_::move(dog);
|
||||
|
||||
notify(ChatBackgroundUpdate(ChatBackgroundUpdate::Type::New, _tile));
|
||||
}
|
||||
|
||||
void ChatBackground::reset() {
|
||||
_id = 0;
|
||||
_image = QPixmap();
|
||||
_dog = QPixmap();
|
||||
_tile = false;
|
||||
|
||||
notify(ChatBackgroundUpdate(ChatBackgroundUpdate::Type::New, _tile));
|
||||
}
|
||||
|
||||
int32 ChatBackground::id() const {
|
||||
return _id;
|
||||
}
|
||||
|
||||
const QPixmap &ChatBackground::image() const {
|
||||
return _image;
|
||||
}
|
||||
|
||||
const QPixmap &ChatBackground::dog() const {
|
||||
return _dog;
|
||||
}
|
||||
|
||||
bool ChatBackground::tile() const {
|
||||
return _tile;
|
||||
}
|
||||
|
||||
void ChatBackground::setTile(bool tile) {
|
||||
if (_tile != tile) {
|
||||
_tile = tile;
|
||||
Local::writeUserSettings();
|
||||
notify(ChatBackgroundUpdate(ChatBackgroundUpdate::Type::Changed, _tile));
|
||||
}
|
||||
}
|
||||
|
||||
ChatBackground *chatBackground() {
|
||||
instance.makeIfNull();
|
||||
return instance.data();
|
||||
}
|
||||
|
||||
} // namespace Window
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop version of Telegram messaging app, see https://telegram.org
|
||||
|
||||
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.
|
||||
|
||||
In addition, as a special exception, the copyright holders give permission
|
||||
to link the code of portions of this program with the OpenSSL library.
|
||||
|
||||
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
||||
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Window {
|
||||
|
||||
struct ChatBackgroundUpdate {
|
||||
enum class Type {
|
||||
New,
|
||||
Changed,
|
||||
Start,
|
||||
};
|
||||
|
||||
ChatBackgroundUpdate(Type type, bool tiled) : type(type), tiled(tiled) {
|
||||
}
|
||||
Type type;
|
||||
bool tiled;
|
||||
};
|
||||
|
||||
class ChatBackground : public base::Observable<ChatBackgroundUpdate> {
|
||||
public:
|
||||
bool empty() const;
|
||||
void initIfEmpty();
|
||||
void init(int32 id, QPixmap &&image, QPixmap &&dog);
|
||||
void reset();
|
||||
|
||||
int32 id() const;
|
||||
const QPixmap &image() const;
|
||||
const QPixmap &dog() const;
|
||||
bool tile() const;
|
||||
void setTile(bool tile);
|
||||
|
||||
private:
|
||||
int32 _id = 0;
|
||||
QPixmap _image;
|
||||
QPixmap _dog;
|
||||
bool _tile = false;
|
||||
|
||||
};
|
||||
|
||||
ChatBackground *chatBackground();
|
||||
|
||||
} // namespace Window
|
|
@ -32,7 +32,7 @@ struct SectionSlideParams {
|
|||
bool withTopBarShadow = false;
|
||||
};
|
||||
|
||||
class SectionWidget : public TWidget {
|
||||
class SectionWidget : public TWidget, protected base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -71,9 +71,6 @@ public:
|
|||
setFocus();
|
||||
}
|
||||
|
||||
virtual void updateAdaptiveLayout() {
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w)
|
|||
connect(_info, SIGNAL(clicked()), this, SLOT(onInfoClicked()));
|
||||
connect(_search, SIGNAL(clicked()), this, SLOT(onSearch()));
|
||||
|
||||
subscribe(Adaptive::Changed(), [this]() { updateAdaptiveLayout(); });
|
||||
|
||||
setCursor(style::cur_pointer);
|
||||
showAll();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ class IconedButton;
|
|||
|
||||
namespace Window {
|
||||
|
||||
class TopBarWidget : public TWidget {
|
||||
class TopBarWidget : public TWidget, private base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -51,8 +51,6 @@ public:
|
|||
void showAll();
|
||||
void showSelected(uint32 selCount, bool canDelete = false);
|
||||
|
||||
void updateAdaptiveLayout();
|
||||
|
||||
void updateMembersShowArea();
|
||||
|
||||
Ui::RoundButton *mediaTypeButton();
|
||||
|
@ -71,6 +69,8 @@ signals:
|
|||
void clicked();
|
||||
|
||||
private:
|
||||
void updateAdaptiveLayout();
|
||||
|
||||
MainWidget *main();
|
||||
anim::fvalue a_over = { 0. };
|
||||
Animation _a_appearance;
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
'<(src_loc)/application.h',
|
||||
'<(src_loc)/autoupdater.cpp',
|
||||
'<(src_loc)/autoupdater.h',
|
||||
'<(src_loc)/config.h',
|
||||
'<(src_loc)/dialogswidget.cpp',
|
||||
'<(src_loc)/dialogswidget.h',
|
||||
'<(src_loc)/dropdown.cpp',
|
||||
|
@ -427,6 +428,8 @@
|
|||
'<(src_loc)/ui/scrollarea.h',
|
||||
'<(src_loc)/ui/twidget.cpp',
|
||||
'<(src_loc)/ui/twidget.h',
|
||||
'<(src_loc)/window/chat_background.cpp',
|
||||
'<(src_loc)/window/chat_background.h',
|
||||
'<(src_loc)/window/main_window.cpp',
|
||||
'<(src_loc)/window/main_window.h',
|
||||
'<(src_loc)/window/section_widget.cpp',
|
||||
|
|
|
@ -20,6 +20,16 @@
|
|||
{
|
||||
'conditions': [
|
||||
[ 'build_win', {
|
||||
'defines': [
|
||||
'WIN32',
|
||||
'_WINDOWS',
|
||||
'_UNICODE',
|
||||
'UNICODE',
|
||||
'HAVE_STDINT_H',
|
||||
'ZLIB_WINAPI',
|
||||
'_SCL_SECURE_NO_WARNINGS',
|
||||
'_USING_V110_SDK71_',
|
||||
],
|
||||
'msvs_cygwin_shell': 0,
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
|
@ -29,16 +39,6 @@
|
|||
'/MP', # Enable multi process build.
|
||||
'/EHsc', # Catch C++ exceptions only, extern C functions never throw a C++ exception.
|
||||
],
|
||||
'PreprocessorDefinitions': [
|
||||
'WIN32',
|
||||
'_WINDOWS',
|
||||
'_UNICODE',
|
||||
'UNICODE',
|
||||
'HAVE_STDINT_H',
|
||||
'ZLIB_WINAPI',
|
||||
'_SCL_SECURE_NO_WARNINGS',
|
||||
'_USING_V110_SDK71_',
|
||||
],
|
||||
'TreatWChar_tAsBuiltInType': 'false',
|
||||
},
|
||||
'VCLinkerTool': {
|
||||
|
|
Loading…
Reference in New Issue