From 3fd6d5d3e9e9ee8caf2af8ce8e7ffe7403a20801 Mon Sep 17 00:00:00 2001 From: tux3 Date: Thu, 4 Jun 2015 11:56:19 +0200 Subject: [PATCH] Implement logout button --- src/nexus.cpp | 16 ++++++++++++++-- src/nexus.h | 2 +- src/profile.cpp | 1 + src/widget/form/profileform.cpp | 5 ++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/nexus.cpp b/src/nexus.cpp index f6826ed4a..1a768a620 100644 --- a/src/nexus.cpp +++ b/src/nexus.cpp @@ -39,7 +39,8 @@ Nexus::~Nexus() #endif delete loginScreen; delete profile; - Settings::getInstance().save(); + if (profile) + Settings::getInstance().save(); } void Nexus::start() @@ -68,12 +69,23 @@ void Nexus::start() void Nexus::showLogin() { - ((QApplication*)qApp)->setQuitOnLastWindowClosed(true); +#ifdef Q_OS_ANDROID + delete androidui; + androidgui = nullptr; +#else + delete widget; + widget = nullptr; +#endif + + delete profile; + profile = nullptr; + loginScreen->reset(); #ifndef Q_OS_ANDROID loginScreen->move(QApplication::desktop()->screen()->rect().center() - loginScreen->rect().center()); #endif loginScreen->show(); + ((QApplication*)qApp)->setQuitOnLastWindowClosed(true); } void Nexus::showMainGUI() diff --git a/src/nexus.h b/src/nexus.h index 835ebe8b3..17a636372 100644 --- a/src/nexus.h +++ b/src/nexus.h @@ -17,7 +17,7 @@ class Nexus : public QObject Q_OBJECT public: void start(); ///< Sets up invariants and calls showLogin - void showLogin(); ///< Shows the login screen + void showLogin(); ///< Hides the man GUI, delete the profile, and shows the login screen /// Hides the login screen and shows the GUI for the given profile. /// Will delete the current GUI, if it exists. void showMainGUI(); diff --git a/src/profile.cpp b/src/profile.cpp index 6b71cef9b..f8c42d073 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -66,6 +66,7 @@ Profile::~Profile() { delete core; delete coreThread; + ProfileLocker::assertLock(); assert(ProfileLocker::getCurLockName() == name); ProfileLocker::unlock(); } diff --git a/src/widget/form/profileform.cpp b/src/widget/form/profileform.cpp index df6495e7c..095e6a1e1 100644 --- a/src/widget/form/profileform.cpp +++ b/src/widget/form/profileform.cpp @@ -310,7 +310,10 @@ void ProfileForm::onDeleteClicked() void ProfileForm::onLogoutClicked() { - /// TODO: Save and call Nexus show login? + Nexus& nexus = Nexus::getInstance(); + nexus.getProfile()->saveToxSave(); + Settings::getInstance().save(); + nexus.showLogin(); } void ProfileForm::onCopyQrClicked()