Add a standardized close confirmation dialog

This commit is contained in:
Markus Gans 2017-10-30 20:56:00 +01:00
parent b0b44582e8
commit 686283cb01
16 changed files with 30 additions and 124 deletions

View File

@ -1,5 +1,6 @@
2017-10-30 Markus Gans <guru.mail@muenster.de> 2017-10-30 Markus Gans <guru.mail@muenster.de>
* Fix scrollview functionality with new inheritance structure * Fix scrollview functionality with new inheritance structure
* Add a standardized close confirmation dialog
2017-10-29 Markus Gans <guru.mail@muenster.de> 2017-10-29 Markus Gans <guru.mail@muenster.de>
* Adaptation of the inheritance diagrams in the header files * Adaptation of the inheritance diagrams in the header files

View File

@ -574,13 +574,7 @@ void Calc::onAccel (FAccelEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Calc::onClose (FCloseEvent* ev) void Calc::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit", FApplication::closeConfirmationDialog (this, ev);
"Do you really want\n"
"to quit the program ?",
FMessageBox::Yes,
FMessageBox::No );
( ret == FMessageBox::Yes ) ? ev->accept() : ev->ignore();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -161,15 +161,7 @@ Listbox::~Listbox() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Listbox::onClose (FCloseEvent* ev) void Listbox::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" FApplication::closeConfirmationDialog (this, ev);
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
ev->accept();
else
ev->ignore();
} }

View File

@ -159,15 +159,7 @@ Listview::~Listview() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Listview::onClose (FCloseEvent* ev) void Listview::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" FApplication::closeConfirmationDialog (this, ev);
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
ev->accept();
else
ev->ignore();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -126,16 +126,7 @@ void Mandelbrot::onAccel (FAccelEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Mandelbrot::onClose (FCloseEvent* ev) void Mandelbrot::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" FApplication::closeConfirmationDialog (this, ev);
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
ev->accept();
else
ev->ignore();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -263,16 +263,7 @@ void Menu::adjustSize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Menu::onClose (FCloseEvent* ev) void Menu::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" FApplication::closeConfirmationDialog (this, ev);
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
ev->accept();
else
ev->ignore();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -404,16 +404,7 @@ void MouseDraw::onAccel (FAccelEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MouseDraw::onClose (FCloseEvent* ev) void MouseDraw::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" FApplication::closeConfirmationDialog (this, ev);
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
ev->accept();
else
ev->ignore();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -257,16 +257,7 @@ void Scrollviewdemo::cb_quit (FWidget*, data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Scrollviewdemo::onClose (FCloseEvent* ev) void Scrollviewdemo::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" FApplication::closeConfirmationDialog (this, ev);
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
ev->accept();
else
ev->ignore();
} }

View File

@ -126,16 +126,7 @@ void AttribDlg::onWheel (FWheelEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDlg::onClose (FCloseEvent* ev) void AttribDlg::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" FApplication::closeConfirmationDialog (this, ev);
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
ev->accept();
else
ev->ignore();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -251,15 +251,7 @@ void MainWindow::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MainWindow::onClose (FCloseEvent* ev) void MainWindow::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" FApplication::closeConfirmationDialog (this, ev);
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
ev->accept();
else
ev->ignore();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -304,15 +304,7 @@ void Treeview::adjustSize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Treeview::onClose (FCloseEvent* ev) void Treeview::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" FApplication::closeConfirmationDialog (this, ev);
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
ev->accept();
else
ev->ignore();
} }

View File

@ -669,15 +669,7 @@ void MyDialog::adjustSize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::onClose (FCloseEvent* ev) void MyDialog::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" FApplication::closeConfirmationDialog (this, ev);
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
ev->accept();
else
ev->ignore();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -162,15 +162,7 @@ void Watch::onTimer (FTimerEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Watch::onClose (FCloseEvent* ev) void Watch::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" FApplication::closeConfirmationDialog (this, ev);
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
ev->accept();
else
ev->ignore();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -407,18 +407,7 @@ void Window::adjustSize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::onClose (FCloseEvent* ev) void Window::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" FApplication::closeConfirmationDialog (this, ev);
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
{
cb_closeWindows(0,0);
ev->accept();
}
else
ev->ignore();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -106,6 +106,7 @@ class FApplication : public FWidget
static bool eventInQueue(); static bool eventInQueue();
static bool removeQueuedEvent (const FObject*); static bool removeQueuedEvent (const FObject*);
static FWidget* showParameterUsage (const int&, char*[]); static FWidget* showParameterUsage (const int&, char*[]);
static void closeConfirmationDialog (FWidget*, FCloseEvent*);
// Callback method // Callback method
void cb_exitApp (FWidget*, data_ptr); void cb_exitApp (FWidget*, data_ptr);

View File

@ -23,6 +23,7 @@
#include "final/fapplication.h" #include "final/fapplication.h"
#include "final/fmenu.h" #include "final/fmenu.h"
#include "final/fmessagebox.h"
#include "final/fstatusbar.h" #include "final/fstatusbar.h"
#include "final/fwindow.h" #include "final/fwindow.h"
@ -329,12 +330,25 @@ FWidget* FApplication::showParameterUsage (const int& argc, char* argv[])
<< " Set the standard vga 8x16 font" << std::endl << " Set the standard vga 8x16 font" << std::endl
<< " --newfont " << " --newfont "
<< " Enables the graphical font" << std::endl; << " Enables the graphical font" << std::endl;
std::exit(EXIT_SUCCESS); std::exit(EXIT_SUCCESS);
} }
return 0; return 0;
} }
//----------------------------------------------------------------------
void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
{
int ret = FMessageBox::info ( w, "Quit"
, "Do you really want\n"
"to quit the program ?"
, FMessageBox::Yes
, FMessageBox::No );
if ( ret == FMessageBox::Yes )
ev->accept();
else
ev->ignore();
}
// private methods of FApplication // private methods of FApplication
//---------------------------------------------------------------------- //----------------------------------------------------------------------