diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index e6b3c22f0..4ddf6aa6b 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -348,6 +348,7 @@ namespace Sandbox { struct GlobalDataStruct { uint64 LaunchId = 0; Adaptive::Layout AdaptiveLayout = Adaptive::NormalLayout; + bool AdaptiveForWide = true; }; GlobalDataStruct *GlobalData = 0; @@ -370,5 +371,6 @@ namespace Global { DefineReadOnlyVar(Global, uint64, LaunchId); DefineVar(Global, Adaptive::Layout, AdaptiveLayout); + DefineVar(Global, bool, AdaptiveForWide); }; diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 328773f2d..5d54267d5 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -139,6 +139,7 @@ namespace Global { DeclareReadOnlyVar(uint64, LaunchId); DeclareVar(Adaptive::Layout, AdaptiveLayout); + DeclareVar(bool, AdaptiveForWide); }; @@ -150,6 +151,6 @@ namespace Adaptive { return Global::AdaptiveLayout() == NormalLayout; } inline bool Wide() { - return Global::AdaptiveLayout() == WideLayout; + return Global::AdaptiveForWide() && (Global::AdaptiveLayout() == WideLayout); } } diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 35ca99daa..e0883fe37 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -4690,6 +4690,7 @@ void HistoryWidget::doneShow() { void HistoryWidget::updateAdaptiveLayout() { _sideShadow.setVisible(!Adaptive::OneColumn()); + update(); } void HistoryWidget::animStop() { diff --git a/Telegram/SourceFiles/localstorage.cpp b/Telegram/SourceFiles/localstorage.cpp index da64f2cb9..bc7757d13 100644 --- a/Telegram/SourceFiles/localstorage.cpp +++ b/Telegram/SourceFiles/localstorage.cpp @@ -1121,6 +1121,14 @@ namespace { } } break; + case dbiAdaptiveForWide: { + qint32 v; + stream >> v; + if (!_checkStreamStatus(stream)) return false; + + Global::SetAdaptiveForWide(v == 1); + } break; + case dbiAutoLock: { qint32 v; stream >> v; @@ -1506,6 +1514,7 @@ namespace { EncryptedDescriptor data(size); data.stream << quint32(dbiSendKey) << qint32(cCtrlEnter() ? dbiskCtrlEnter : dbiskEnter); data.stream << quint32(dbiTileBackground) << qint32(cTileBackground() ? 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()); diff --git a/Telegram/SourceFiles/settingswidget.cpp b/Telegram/SourceFiles/settingswidget.cpp index 36c4fa1df..89e0925c5 100644 --- a/Telegram/SourceFiles/settingswidget.cpp +++ b/Telegram/SourceFiles/settingswidget.cpp @@ -187,6 +187,7 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent) , _backFromGallery(this, lang(lng_settings_bg_from_gallery)) , _backFromFile(this, lang(lng_settings_bg_from_file)) , _tileBackground(this, lang(lng_settings_bg_tile), cTileBackground()) +, _adaptiveForWide(this, lang(lng_settings_adaptive_wide), Global::AdaptiveForWide()) , _needBackgroundUpdate(false) // advanced @@ -310,6 +311,7 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent) connect(&_backFromGallery, SIGNAL(clicked()), this, SLOT(onBackFromGallery())); connect(&_backFromFile, SIGNAL(clicked()), this, SLOT(onBackFromFile())); connect(&_tileBackground, SIGNAL(changed()), this, SLOT(onTileBackground())); + connect(&_adaptiveForWide, SIGNAL(changed()), this, SLOT(onAdaptiveForWide())); // advanced connect(&_passcodeEdit, SIGNAL(clicked()), this, SLOT(onPasscode())); @@ -635,6 +637,10 @@ void SettingsInner::paintEvent(QPaintEvent *e) { top += st::setBackgroundSize; top += st::setLittleSkip; top += _tileBackground.height(); + if (Global::AdaptiveLayout() == Adaptive::WideLayout) { + top += st::setLittleSkip; + top += _adaptiveForWide.height(); + } } // advanced @@ -753,6 +759,10 @@ void SettingsInner::resizeEvent(QResizeEvent *e) { top += st::setLittleSkip; _tileBackground.move(_left, top); top += _tileBackground.height(); + if (Global::AdaptiveLayout() == Adaptive::WideLayout) { + top += st::setLittleSkip; + _adaptiveForWide.move(_left, top); top += _adaptiveForWide.height(); + } } // advanced @@ -855,6 +865,11 @@ void SettingsInner::mousePressEvent(QMouseEvent *e) { void SettingsInner::contextMenuEvent(QContextMenuEvent *e) { } +void SettingsInner::updateAdaptiveLayout() { + showAll(); + resizeEvent(0); +} + void SettingsInner::step_photo(float64 ms, bool timer) { float64 dt = ms / st::setPhotoDuration; if (dt >= 1) { @@ -1093,10 +1108,16 @@ void SettingsInner::showAll() { _backFromGallery.show(); _backFromFile.show(); _tileBackground.show(); + if (Global::AdaptiveLayout() == Adaptive::WideLayout) { + _adaptiveForWide.show(); + } else { + _adaptiveForWide.hide(); + } } else { _backFromGallery.hide(); _backFromFile.hide(); _tileBackground.hide(); + _adaptiveForWide.hide(); } // advanced @@ -1628,6 +1649,16 @@ void SettingsInner::onTileBackground() { } } +void SettingsInner::onAdaptiveForWide() { + 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(); @@ -1898,10 +1929,11 @@ void SettingsWidget::updateAdaptiveLayout() { } else { _close.show(); } + _inner.updateAdaptiveLayout(); + resizeEvent(0); } -void SettingsWidget::updateDisplayNotify() -{ +void SettingsWidget::updateDisplayNotify() { _inner.enableDisplayNotify(cDesktopNotify()); } diff --git a/Telegram/SourceFiles/settingswidget.h b/Telegram/SourceFiles/settingswidget.h index 08499ca60..65e222fcb 100644 --- a/Telegram/SourceFiles/settingswidget.h +++ b/Telegram/SourceFiles/settingswidget.h @@ -71,6 +71,8 @@ public: void mousePressEvent(QMouseEvent *e); void contextMenuEvent(QContextMenuEvent *e); + void updateAdaptiveLayout(); + void step_photo(float64 ms, bool timer); void updateSize(int32 newWidth); @@ -156,6 +158,7 @@ public slots: void onBackFromGallery(); void onBackFromFile(); void onTileBackground(); + void onAdaptiveForWide(); void onLocalStorageClear(); @@ -273,7 +276,7 @@ private: // chat background QPixmap _background; LinkButton _backFromGallery, _backFromFile; - FlatCheckbox _tileBackground; + FlatCheckbox _tileBackground, _adaptiveForWide; bool _needBackgroundUpdate; // advanced diff --git a/Telegram/SourceFiles/types.h b/Telegram/SourceFiles/types.h index b93bf822d..99f12ef31 100644 --- a/Telegram/SourceFiles/types.h +++ b/Telegram/SourceFiles/types.h @@ -352,6 +352,7 @@ enum DataBlockId { dbiSavedGifsLimit = 0x35, dbiShowingSavedGifs = 0x36, dbiAutoPlay = 0x37, + dbiAdaptiveForWide = 0x38, dbiEncryptedWithSalt = 333, dbiEncrypted = 444,