added system view with time

This commit is contained in:
Hendrik Schutter 2020-08-07 22:52:11 +02:00
parent 1e4d9975c6
commit f4726bf08c
2 changed files with 31 additions and 16 deletions

View File

@ -39,11 +39,14 @@ private:
WINDOW *detailview;
WINDOW *overview;
WINDOW *systemview;
static void centerTitle(WINDOW *pwin, const char * title);
static WINDOW *createOverViewWindow( int iXSize, int iYSize);
static WINDOW *createDetailViewWindow( int iXSize, int iYSize, int iXStart, Drive drive);
static WINDOW *createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,string sModelFamily, string sModelName, string sCapacity, bool bSelected);
static WINDOW *createSystemStats(int iXSize, int iYSize, int iYStart);
};

View File

@ -54,7 +54,6 @@ void TUI::initTUI()
void TUI::updateTUI(vector <Drive>* pvecDrives, int32_t i32SelectedEntry)
{
int stdscrX, stdscrY;
getmaxyx(stdscr, stdscrY, stdscrX);
@ -66,6 +65,9 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, int32_t i32SelectedEntry)
overview=createOverViewWindow((int)(stdscrX/3), (stdscrY-15));
wrefresh(overview);
systemview=createSystemStats((int)(stdscrX/3), 10, (stdscrY-11));
wrefresh(systemview);
vector <Drive>::iterator it;
for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it)
{
@ -120,7 +122,6 @@ enum TUI::UserInput TUI::readUserInput()
return TUI::UserInput::Undefined;
}
void TUI::centerTitle(WINDOW *pwin, const char * title)
{
int x, maxX, stringSize;
@ -142,18 +143,7 @@ WINDOW* TUI::createOverViewWindow( int iXSize, int iYSize)
wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_OVERVIEW));
box(newWindow, ACS_VLINE, ACS_HLINE);
time_t rawtime;
struct tm * timeinfo;
char buffer[80];
time (&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer,sizeof(buffer),"%d-%m-%Y %H:%M:%S",timeinfo);
std::string str(buffer);
centerTitle(newWindow, str.c_str());
centerTitle(newWindow, "Detected Drives");
keypad(newWindow, TRUE);
return newWindow;
@ -229,8 +219,6 @@ WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
WINDOW *newWindow;
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
if(!bSelected)
{
// entry is NOT selected
@ -254,3 +242,27 @@ WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
return newWindow;
}
WINDOW* TUI::createSystemStats(int iXSize, int iYSize, int iYStart){
WINDOW *newWindow;
newWindow = newwin(iYSize, iXSize, iYStart, 2);
wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_OVERVIEW));
box(newWindow, ACS_VLINE, ACS_HLINE);
centerTitle(newWindow, "System");
time_t rawtime;
struct tm * timeinfo;
char buffer[80];
time (&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer,sizeof(buffer),"Date: %d-%m-%Y Time: %H:%M",timeinfo);
string time(buffer);
mvwaddstr(newWindow,2, 2, time.c_str());
keypad(newWindow, TRUE);
return newWindow;
}