//---------------------------------------------------------------------- // Check if data needs saving on exit and prompt user for action //---------------------------------------------------------------------- bool MainWindow::saveRideExitDialog() { QList<RideItem*> dirtyList; // have we been told to not warn on exit? if (warnExit() == false) return true; // just close regardless! for (int i=0; i<allRides->childCount(); i++) { RideItem *curr = (RideItem *)allRides->child(i); if (curr->isDirty() == true) dirtyList.append(curr); } // we have some files to save... if (dirtyList.count() > 0) { SaveOnExitDialogWidget dialog(this, dirtyList); int result = dialog.exec(); if (result == QDialog::Rejected) return false; // cancel that closeEvent! } // You can exit and close now return true; }
void ui ( void ) { // main menu uint8_t selected ( 1 ); uint8_t defaultHeight ( 5 ); uint8_t defaultWidth ( 5 ); uint8_t defaultAlignWinSize ( 5 ); uint8_t defaultAlignWinTotal ( 1 ); uint8_t defaultAI_prof ( 3 ); int32_t Key; uint8_t row , col; while ( true ) { clear (); getmaxyx ( stdscr , row , col ); if ( selected < 1 ) selected = 1; if ( selected > 3 ) selected = 3; attron ( A_BOLD ); mvprintw ( row / 4 , ( col - STR_TITLE_GAME.length () + 1 ) / 2 , STR_TITLE_GAME.c_str () ); mvprintw ( ( row / 2 ) + ( ( selected - 1 ) * 2 ) , 5 * col / 20 , STR_ARROW_RIGHT.c_str () ); mvprintw ( ( row / 2 ) + ( ( selected - 1 ) * 2 ) , 15 * col / 20 , STR_ARROW_LEFT.c_str () ); mvprintw ( 2 , 2 , STR_HELP.c_str () ); attroff ( A_BOLD ); mvprintw ( row / 2 , ( col - STR_PLAY.length () + 1 ) / 2 , STR_PLAY.c_str () ); mvprintw ( ( row / 2 ) + 2 , ( col - STR_OPTIONS.length () + 1 ) / 2 , STR_OPTIONS.c_str () ); mvprintw ( ( row / 2 ) + 4 , ( col - STR_EXIT.length () + 1 ) / 2 , STR_EXIT.c_str () ); refresh(); Key = getch (); if ( Key == KEY_DOWN ) selected += 1; if ( Key == KEY_UP ) selected -= 1; if ( Key == ENTER ) { if ( selected == 1 ) { play_menu ( defaultHeight , defaultWidth , defaultAlignWinSize , defaultAlignWinTotal , defaultAI_prof ); } if ( selected == 2 ) options ( defaultHeight , defaultWidth , defaultAlignWinSize , defaultAlignWinTotal , defaultAI_prof ); if ( selected == 3 ) { if ( warnExit () ) { endwin (); return; } } } if ( Key == KEY_P ) { play_menu ( defaultHeight , defaultWidth , defaultAlignWinSize , defaultAlignWinTotal , defaultAI_prof ); } if ( Key == KEY_O ) options ( defaultHeight , defaultWidth , defaultAlignWinSize , defaultAlignWinTotal , defaultAI_prof ); if ( Key == ESC || Key == KEY_E ) { if ( warnExit () ) { endwin (); return; } } if ( Key == KEY_F ( 5 ) ) ui_help (); } }