mirror of https://github.com/procxx/kepka.git
Add warning for unsaved Bio section closing.
This commit is contained in:
parent
fbf3c005ff
commit
165511fb14
|
@ -349,6 +349,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_settings_username_label" = "Username";
|
"lng_settings_username_label" = "Username";
|
||||||
"lng_settings_phone_label" = "Phone number";
|
"lng_settings_phone_label" = "Phone number";
|
||||||
"lng_settings_username_add" = "Add username";
|
"lng_settings_username_add" = "Add username";
|
||||||
|
"lng_settings_close_sure" = "Are you sure you want to close this page? You didn't save your changes.";
|
||||||
|
|
||||||
"lng_backgrounds_header" = "Choose your new chat background";
|
"lng_backgrounds_header" = "Choose your new chat background";
|
||||||
"lng_theme_sure_keep" = "Keep this theme?";
|
"lng_theme_sure_keep" = "Keep this theme?";
|
||||||
|
|
|
@ -277,6 +277,10 @@ rpl::producer<bool> Controller::canSaveChanges() const {
|
||||||
return _canSaveChanges.value();
|
return _canSaveChanges.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Controller::canSaveChangesNow() const {
|
||||||
|
return _canSaveChanges.current();
|
||||||
|
}
|
||||||
|
|
||||||
Controller::~Controller() = default;
|
Controller::~Controller() = default;
|
||||||
|
|
||||||
} // namespace Info
|
} // namespace Info
|
||||||
|
|
|
@ -190,6 +190,7 @@ public:
|
||||||
|
|
||||||
void setCanSaveChanges(rpl::producer<bool> can);
|
void setCanSaveChanges(rpl::producer<bool> can);
|
||||||
rpl::producer<bool> canSaveChanges() const;
|
rpl::producer<bool> canSaveChanges() const;
|
||||||
|
bool canSaveChangesNow() const;
|
||||||
|
|
||||||
void saveSearchState(not_null<ContentMemento*> memento);
|
void saveSearchState(not_null<ContentMemento*> memento);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_slide_animation.h"
|
#include "window/window_slide_animation.h"
|
||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
#include "boxes/peer_list_box.h"
|
#include "boxes/peer_list_box.h"
|
||||||
|
#include "boxes/confirm_box.h"
|
||||||
#include "auth_session.h"
|
#include "auth_session.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
@ -350,8 +351,8 @@ void WrapWidget::createTopBar() {
|
||||||
if (wrapValue == Wrap::Narrow || hasStackHistory()) {
|
if (wrapValue == Wrap::Narrow || hasStackHistory()) {
|
||||||
_topBar->enableBackButton();
|
_topBar->enableBackButton();
|
||||||
_topBar->backRequest(
|
_topBar->backRequest(
|
||||||
) | rpl::start_with_next([this] {
|
) | rpl::start_with_next([=] {
|
||||||
_controller->showBackFromStack();
|
checkBeforeClose([=] { _controller->showBackFromStack(); });
|
||||||
}, _topBar->lifetime());
|
}, _topBar->lifetime());
|
||||||
} else if (wrapValue == Wrap::Side) {
|
} else if (wrapValue == Wrap::Side) {
|
||||||
auto close = _topBar->addButton(
|
auto close = _topBar->addButton(
|
||||||
|
@ -368,7 +369,9 @@ void WrapWidget::createTopBar() {
|
||||||
_topBar,
|
_topBar,
|
||||||
st::infoLayerTopBarClose));
|
st::infoLayerTopBarClose));
|
||||||
close->addClickHandler([this] {
|
close->addClickHandler([this] {
|
||||||
_controller->parentController()->hideSpecialLayer();
|
checkBeforeClose([=] {
|
||||||
|
_controller->parentController()->hideSpecialLayer();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else if (requireTopBarSearch()) {
|
} else if (requireTopBarSearch()) {
|
||||||
auto search = _controller->searchFieldController();
|
auto search = _controller->searchFieldController();
|
||||||
|
@ -398,6 +401,22 @@ void WrapWidget::createTopBar() {
|
||||||
_topBar->show();
|
_topBar->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WrapWidget::checkBeforeClose(Fn<void()> close) {
|
||||||
|
const auto confirmed = [=] {
|
||||||
|
const auto copy = close;
|
||||||
|
Ui::hideLayer();
|
||||||
|
copy();
|
||||||
|
};
|
||||||
|
if (_controller->canSaveChangesNow()) {
|
||||||
|
Ui::show(Box<ConfirmBox>(
|
||||||
|
lang(lng_settings_close_sure),
|
||||||
|
lang(lng_close),
|
||||||
|
confirmed));
|
||||||
|
} else {
|
||||||
|
confirmed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WrapWidget::addTopBarMenuButton() {
|
void WrapWidget::addTopBarMenuButton() {
|
||||||
Expects(_topBar != nullptr);
|
Expects(_topBar != nullptr);
|
||||||
|
|
||||||
|
@ -950,7 +969,7 @@ void WrapWidget::resizeEvent(QResizeEvent *e) {
|
||||||
void WrapWidget::keyPressEvent(QKeyEvent *e) {
|
void WrapWidget::keyPressEvent(QKeyEvent *e) {
|
||||||
if (e->key() == Qt::Key_Escape) {
|
if (e->key() == Qt::Key_Escape) {
|
||||||
if (hasStackHistory() || wrap() != Wrap::Layer) {
|
if (hasStackHistory() || wrap() != Wrap::Layer) {
|
||||||
_controller->showBackFromStack();
|
checkBeforeClose([=] { _controller->showBackFromStack(); });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,7 @@ private:
|
||||||
void injectActiveFeedProfile(not_null<Data::Feed*> feed);
|
void injectActiveFeedProfile(not_null<Data::Feed*> feed);
|
||||||
void injectActiveProfileMemento(
|
void injectActiveProfileMemento(
|
||||||
std::unique_ptr<ContentMemento> memento);
|
std::unique_ptr<ContentMemento> memento);
|
||||||
|
void checkBeforeClose(Fn<void()> close);
|
||||||
void restoreHistoryStack(
|
void restoreHistoryStack(
|
||||||
std::vector<std::unique_ptr<ContentMemento>> stack);
|
std::vector<std::unique_ptr<ContentMemento>> stack);
|
||||||
bool hasStackHistory() const {
|
bool hasStackHistory() const {
|
||||||
|
|
Loading…
Reference in New Issue