fixed states if drive is no longer present
This commit is contained in:
58
src/tui.cpp
58
src/tui.cpp
@ -51,7 +51,7 @@ void TUI::initTUI()
|
||||
mvprintw(0, 2, "reHDD - HDD refurbishing tool - GPL 3.0 ");
|
||||
}
|
||||
|
||||
void TUI::updateTUI(vector <Drive>* pvecDrives, int32_t i32SelectedEntry)
|
||||
void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
||||
{
|
||||
int stdscrX, stdscrY;
|
||||
getmaxyx(stdscr, stdscrY, stdscrX);
|
||||
@ -79,10 +79,10 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, int32_t i32SelectedEntry)
|
||||
|
||||
bool bSelectedEntry = false;
|
||||
|
||||
if(i32SelectedEntry == (it - pvecDrives->begin()))
|
||||
if(u8SelectedEntry == (it - pvecDrives->begin()))
|
||||
{
|
||||
bSelectedEntry = true; //mark this drive in entries list
|
||||
displaySelectedDrive(pvecDrives->at(i32SelectedEntry), stdscrX, stdscrY);
|
||||
displaySelectedDrive(pvecDrives->at(u8SelectedEntry), stdscrX, stdscrY);
|
||||
}
|
||||
|
||||
|
||||
@ -114,6 +114,23 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, int32_t i32SelectedEntry)
|
||||
|
||||
WINDOW * tmp = createEntryWindow( ((int)(stdscrX/3) - 2), 5, 3, (5* (it - pvecDrives->begin()) )+3, sModelFamily, sModelName, sCapacity, sState, bSelectedEntry);
|
||||
wrefresh(tmp);
|
||||
}//end loop though drives
|
||||
|
||||
if(pvecDrives->size() == 0)
|
||||
{
|
||||
//no selected drive present
|
||||
struct MenuState menustate;
|
||||
menustate.bAbort = false;
|
||||
menustate.bConfirmDelete = false;
|
||||
menustate.bConfirmShred = false;
|
||||
menustate.bDelete = false;
|
||||
menustate.bShred = false;
|
||||
|
||||
menuview=createMenuView(((stdscrX)-(int)(stdscrX/3)-7), 10, (int)(stdscrX/3)+5,(stdscrY-11), menustate);
|
||||
wrefresh(menuview);
|
||||
|
||||
detailview=overwriteDetailViewWindow(((stdscrX)-(int)(stdscrX/3)-7), (stdscrY-15), (int)(stdscrX/3)+5);
|
||||
wrefresh(detailview);
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,6 +200,7 @@ WINDOW* TUI::createDetailViewWindow( int iXSize, int iYSize, int iXStart, Drive
|
||||
newWindow = newwin(iYSize, iXSize, 2, iXStart);
|
||||
wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_DETAIL));
|
||||
box(newWindow, ACS_VLINE, ACS_HLINE);
|
||||
|
||||
string title = "Selected Drive: " + drive.getModelName() + " " + drive.sCapacityToText();
|
||||
centerTitle(newWindow, title.c_str());
|
||||
|
||||
@ -242,6 +260,40 @@ WINDOW* TUI::createDetailViewWindow( int iXSize, int iYSize, int iXStart, Drive
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
WINDOW* TUI::overwriteDetailViewWindow( int iXSize, int iYSize, int iXStart)
|
||||
{
|
||||
WINDOW *newWindow;
|
||||
newWindow = newwin(iYSize, iXSize, 2, iXStart);
|
||||
wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_DETAIL));
|
||||
box(newWindow, ACS_VLINE, ACS_HLINE);
|
||||
|
||||
string title = "About this tool";
|
||||
centerTitle(newWindow, title.c_str());
|
||||
|
||||
string sLine01 = "Path: NextLine ";
|
||||
string sLine02 = "Path: NextLine ";
|
||||
string sLine03 = "Path: NextLine ";
|
||||
string sLine04 = "Path: NextLine ";
|
||||
string sLine05 = "Path: NextLine ";
|
||||
string sLine06 = "Path: NextLine ";
|
||||
string sLine07 = "Path: NextLine ";
|
||||
|
||||
uint16_t u16Line = 5;
|
||||
|
||||
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine01.size()/2), sLine01.c_str());
|
||||
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine02.size()/2), sLine02.c_str());
|
||||
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine03.size()/2), sLine03.c_str());
|
||||
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine04.size()/2), sLine04.c_str());
|
||||
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine05.size()/2), sLine05.c_str());
|
||||
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine06.size()/2), sLine06.c_str());
|
||||
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine07.size()/2), sLine07.c_str());
|
||||
|
||||
attroff(COLOR_PAIR(COLOR_AREA_DETAIL));
|
||||
|
||||
keypad(newWindow, TRUE);
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, string sModelFamily, string sModelName, string sCapacity, string sState, bool bSelected)
|
||||
{
|
||||
WINDOW *newWindow;
|
||||
|
Reference in New Issue
Block a user