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()
#endif #endif
delete loginScreen; delete loginScreen;
delete profile; delete profile;
Settings::getInstance().save(); if (profile)
Settings::getInstance().save();
} }
void Nexus::start() void Nexus::start()
@ -68,12 +69,23 @@ void Nexus::start()
void Nexus::showLogin() 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(); loginScreen->reset();
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
loginScreen->move(QApplication::desktop()->screen()->rect().center() - loginScreen->rect().center()); loginScreen->move(QApplication::desktop()->screen()->rect().center() - loginScreen->rect().center());
#endif #endif
loginScreen->show(); loginScreen->show();
((QApplication*)qApp)->setQuitOnLastWindowClosed(true);
} }
void Nexus::showMainGUI() void Nexus::showMainGUI()

2
src/nexus.h

@ -17,7 +17,7 @@ class Nexus : public QObject
Q_OBJECT Q_OBJECT
public: public:
void start(); ///< Sets up invariants and calls showLogin 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. /// Hides the login screen and shows the GUI for the given profile.
/// Will delete the current GUI, if it exists. /// Will delete the current GUI, if it exists.
void showMainGUI(); void showMainGUI();

1
src/profile.cpp

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

5
src/widget/form/profileform.cpp

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

Loading…
Cancel
Save