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>
* Fix scrollview functionality with new inheritance structure
* Add a standardized close confirmation dialog
2017-10-29 Markus Gans <guru.mail@muenster.de>
* 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)
{
int ret = FMessageBox::info ( this, "Quit",
"Do you really want\n"
"to quit the program ?",
FMessageBox::Yes,
FMessageBox::No );
( ret == FMessageBox::Yes ) ? ev->accept() : ev->ignore();
FApplication::closeConfirmationDialog (this, ev);
}
//----------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -407,18 +407,7 @@ void Window::adjustSize()
//----------------------------------------------------------------------
void Window::onClose (FCloseEvent* ev)
{
int ret = FMessageBox::info ( this, "Quit"
, "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();
FApplication::closeConfirmationDialog (this, ev);
}
//----------------------------------------------------------------------

View File

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

View File

@ -23,6 +23,7 @@
#include "final/fapplication.h"
#include "final/fmenu.h"
#include "final/fmessagebox.h"
#include "final/fstatusbar.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
<< " --newfont "
<< " Enables the graphical font" << std::endl;
std::exit(EXIT_SUCCESS);
std::exit(EXIT_SUCCESS);
}
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
//----------------------------------------------------------------------