Browse Source

Implement logout button

pull/1793/head
tux3 10 years ago
parent
commit
3fd6d5d3e9
  1. 16
      src/nexus.cpp
  2. 2
      src/nexus.h
  3. 1
      src/profile.cpp
  4. 5
      src/widget/form/profileform.cpp

16
src/nexus.cpp

@ -39,7 +39,8 @@ Nexus::~Nexus() @@ -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() @@ -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()

2
src/nexus.h

@ -17,7 +17,7 @@ class Nexus : public QObject @@ -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();

1
src/profile.cpp

@ -66,6 +66,7 @@ Profile::~Profile() @@ -66,6 +66,7 @@ Profile::~Profile()
{
delete core;
delete coreThread;
ProfileLocker::assertLock();
assert(ProfileLocker::getCurLockName() == name);
ProfileLocker::unlock();
}

5
src/widget/form/profileform.cpp

@ -310,7 +310,10 @@ void ProfileForm::onDeleteClicked() @@ -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()

Loading…
Cancel
Save