Diffstat (limited to 'kaddressbook/kaddressbookmain.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/kaddressbookmain.cpp | 86 |
1 files changed, 25 insertions, 61 deletions
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index 8ebb93a..f48f214 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp @@ -201,71 +201,35 @@ void KAddressBookMain::closeEvent( QCloseEvent* ce ) { - QString mess = i18n( "Close KA/Pi?"); - if ( mCore->modified() ) - mess += i18n( "\n\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; - - default: - return; - break; - } + bool mModified = mCore->modified(); + bool mAskForQuit = KABPrefs::instance()->mAskForQuit; -#if 0 + QString mess = i18n( "Close KA/Pi?"); + if ( mModified == true ) + mess += i18n( "\nChanges will be saved!"); + else + mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); - if ( mCore->modified() ) { - QString text = i18n( "The address book has been modified.\nDo you want to save your changes?" ); + bool mQuit = true; -#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; - } -#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: - return; - default: - return; - break; - } -#endif //KAB_EMBEDDED + if (mAskForQuit) + { + + int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); + if (res == 0) + mQuit = true; + else + mQuit = false; } -#endif + if (mQuit == false) + return; + + if (mModified == true) + { + save(); + mCore->saveSettings(); + KABPrefs::instance()->writeConfig(); + } - save(); - mCore->saveSettings(); - KABPrefs::instance()->writeConfig(); ce->accept(); - } |