From d7c8ee85d826e4c3abae71520729dff8fdac2229 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 10 Jan 2020 16:06:45 +0100 Subject: [PATCH] Add main application menu --- helpers/accounthelper.cpp | 7 +++++++ helpers/accounthelper.h | 1 + mainmenu.cpp | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/helpers/accounthelper.cpp b/helpers/accounthelper.cpp index 4613488..ef3d434 100644 --- a/helpers/accounthelper.cpp +++ b/helpers/accounthelper.cpp @@ -51,6 +51,13 @@ bool AccountHelper::signedIn() return mToken1.length() > 0 && mToken2.length() > 0 && mUserID > 0; } +void AccountHelper::SignOut() +{ + mToken1 = ""; + mToken2 = ""; + mUserID = -1; +} + bool AccountHelper::refreshUserID() { // Get current user ID diff --git a/helpers/accounthelper.h b/helpers/accounthelper.h index db2b2aa..9f00c24 100644 --- a/helpers/accounthelper.h +++ b/helpers/accounthelper.h @@ -26,6 +26,7 @@ public: static bool signedIn(); + static void SignOut(); static bool refreshUserID(); static int userID(); diff --git a/mainmenu.cpp b/mainmenu.cpp index 4a9a7ef..d5ef35d 100644 --- a/mainmenu.cpp +++ b/mainmenu.cpp @@ -6,6 +6,9 @@ #include +#include + +#include "loginscreen.h" #include "mainmenu.h" using namespace std; @@ -107,7 +110,21 @@ void showMainMenu() free_item(my_items[i]); endwin(); - cout << action << endl; + + /* Process requested action */ + int o = 0; + + // Logout + if(o++ == action) { + AccountHelper::SignOut(); + LoginScreen().exec(true); + } + + // Quit application + else { + cout << "Good bye !" << endl; + exit(0); + } } void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color)