Diffstat (limited to 'kaddressbook/kaddressbookmain.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kaddressbook/kaddressbookmain.cpp | 74 |
1 files changed, 19 insertions, 55 deletions
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index 8ebb93a..f48f214 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp @@ -199,75 +199,39 @@ void KAddressBookMain::configureKeys() void KAddressBookMain::closeEvent( QCloseEvent* ce ) { + bool mModified = mCore->modified(); + bool mAskForQuit = KABPrefs::instance()->mAskForQuit; + QString mess = i18n( "Close KA/Pi?"); - if ( mCore->modified() ) - mess += i18n( "\n\nChanges will be saved!"); + if ( mModified == true ) + mess += i18n( "\nChanges will be saved!"); else - mess += i18n( "\n\nNo unsaved changes detected!\nNothing will be saved!"); - - switch( QMessageBox::information( this, "KA/Pi", mess , - i18n("Yes!"), i18n("No"), 0, 0 ) ) { - case 0: - - break; - case 1: - return; - break; - case 2: - return; - break; + mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); - default: - return; - break; - } + bool mQuit = true; -#if 0 - if ( mCore->modified() ) { - QString text = i18n( "The address book has been modified.\nDo you want to save your changes?" ); + if (mAskForQuit) + { -#ifndef KAB_EMBEDDED - int ret = KMessageBox::warningYesNoCancel( this, text, "", - KStdGuiItem::yes(), - KStdGuiItem::no(), "AskForSave" ); - switch ( ret ) { - case KMessageBox::Yes: - save(); - break; - case KMessageBox::No: - return true; - break; - default: //cancel - return ; - break; + int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); + if (res == 0) + mQuit = true; + else + mQuit = false; } -#else //KAB_EMBEDDED - switch( QMessageBox::information( this, "KA/Pi", - text, - i18n("Yes!"), i18n("No"), 0, 0 ) ) { - case 0: - save(); - break; - case 1: - break; - case 2: + if (mQuit == false) return; - default: - return; - break; - } -#endif //KAB_EMBEDDED - } - -#endif + if (mModified == true) + { save(); mCore->saveSettings(); KABPrefs::instance()->writeConfig(); - ce->accept(); + } + ce->accept(); } #ifndef KAB_EMBEDDED |