From 673fea47bd295fb0cf2d2eac58eed178ffb8b159 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 12 Sep 2018 19:14:11 +0300 Subject: [PATCH] Don't close info settings with changes by click. --- Telegram/SourceFiles/info/info_layer_widget.cpp | 4 ++++ Telegram/SourceFiles/info/info_layer_widget.h | 2 ++ Telegram/SourceFiles/info/info_wrap_widget.cpp | 4 ++++ Telegram/SourceFiles/info/info_wrap_widget.h | 2 ++ Telegram/SourceFiles/window/layer_widget.cpp | 4 ++++ 5 files changed, 16 insertions(+) diff --git a/Telegram/SourceFiles/info/info_layer_widget.cpp b/Telegram/SourceFiles/info/info_layer_widget.cpp index f16c1627d..87aaa48fb 100644 --- a/Telegram/SourceFiles/info/info_layer_widget.cpp +++ b/Telegram/SourceFiles/info/info_layer_widget.cpp @@ -131,6 +131,10 @@ bool LayerWidget::showSectionInternal( return false; } +bool LayerWidget::closeByOutsideClick() const { + return _content->closeByOutsideClick(); +} + int LayerWidget::MinimalSupportedWidth() { auto minimalMargins = 2 * st::infoMinimalLayerMargin; return st::infoMinimalWidth + minimalMargins; diff --git a/Telegram/SourceFiles/info/info_layer_widget.h b/Telegram/SourceFiles/info/info_layer_widget.h index c3c331fb9..58cf63f62 100644 --- a/Telegram/SourceFiles/info/info_layer_widget.h +++ b/Telegram/SourceFiles/info/info_layer_widget.h @@ -37,6 +37,8 @@ public: not_null memento, const Window::SectionShow ¶ms) override; + bool closeByOutsideClick() const override; + static int MinimalSupportedWidth(); protected: diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index edd1b1d25..16b425bf2 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -448,6 +448,10 @@ void WrapWidget::addContentSaveButton() { }); } +bool WrapWidget::closeByOutsideClick() const { + return !_controller->canSaveChangesNow(); +} + void WrapWidget::addProfileCallsButton() { Expects(_topBar != nullptr); diff --git a/Telegram/SourceFiles/info/info_wrap_widget.h b/Telegram/SourceFiles/info/info_wrap_widget.h index 6a84fd9fc..b718c82f6 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.h +++ b/Telegram/SourceFiles/info/info_wrap_widget.h @@ -118,6 +118,8 @@ public: object_ptr createTopBarSurrogate(QWidget *parent); + bool closeByOutsideClick() const; + void updateGeometry(QRect newGeometry, int additionalScroll); int scrollTillBottom(int forHeight) const; rpl::producer scrollTillBottomChanges() const; diff --git a/Telegram/SourceFiles/window/layer_widget.cpp b/Telegram/SourceFiles/window/layer_widget.cpp index 91719c25e..106f9ebfb 100644 --- a/Telegram/SourceFiles/window/layer_widget.cpp +++ b/Telegram/SourceFiles/window/layer_widget.cpp @@ -377,6 +377,10 @@ void LayerStackWidget::mousePressEvent(QMouseEvent *e) { if (!layer->closeByOutsideClick()) { return; } + } else if (const auto special = _specialLayer.data()) { + if (!special->closeByOutsideClick()) { + return; + } } hideCurrent(anim::type::normal); }