2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Moved showLogoutConfirmation from MainWindow to Window::Controller.

This commit is contained in:
23rd
2021-02-03 05:49:26 +03:00
committed by John Preston
parent 1f80c297ec
commit b4af805521
8 changed files with 51 additions and 45 deletions

View File

@@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "api/api_updates.h"
#include "core/application.h"
#include "core/click_handler_types.h"
#include "export/export_manager.h"
#include "platform/platform_window_title.h"
#include "main/main_account.h"
#include "main/main_domain.h"
@@ -329,4 +330,33 @@ QPoint Controller::getPointForCallPanelCenter() const {
: _widget.windowHandle()->screen()->geometry().center();
}
void Controller::showLogoutConfirmation() {
const auto account = Core::App().passcodeLocked()
? nullptr
: sessionController()
? &sessionController()->session().account()
: nullptr;
const auto weak = base::make_weak(account);
const auto callback = [=] {
if (account && !weak) {
return;
}
if (account
&& account->sessionExists()
&& Core::App().exportManager().inProgress(&account->session())) {
Ui::hideLayer();
Core::App().exportManager().stopWithConfirmation([=] {
Core::App().logout(account);
});
} else {
Core::App().logout(account);
}
};
show(Box<ConfirmBox>(
tr::lng_sure_logout(tr::now),
tr::lng_settings_logout(tr::now),
st::attentionBoxButton,
callback));
}
} // namespace Window

View File

@@ -46,6 +46,8 @@ public:
void setupIntro();
void setupMain();
void showLogoutConfirmation();
void showSettings();
[[nodiscard]] int verticalShadowTop() const;

View File

@@ -120,7 +120,7 @@ PasscodeLockWidget::PasscodeLockWidget(
_submit->setClickedCallback([=] { submit(); });
_logout->setClickedCallback([=] {
window->widget()->showLogoutConfirmation();
window->showLogoutConfirmation();
});
}