diff options
author | Michele Calgaro <[email protected]> | 2016-05-23 16:17:18 +1000 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2016-05-23 16:17:18 +1000 |
commit | 8644afed0d8e383cf3576c598b2ca76833a74e33 (patch) | |
tree | 720198d0f64d169f1b241d1cf02110c494e4ec20 /kate/app/kateapp.cpp | |
parent | 074f8c7ccb685fb9fa2a51dec5049637e727a9c2 (diff) | |
download | tdebase-8644afed0d8e383cf3576c598b2ca76833a74e33.tar.gz tdebase-8644afed0d8e383cf3576c598b2ca76833a74e33.zip |
Kate session panel: added support for switch/shutdown session options and fixed up logic where required.
Fixed Kate quit process to support correct shutdown. Improved handling of configuration option changes.
Some code rework.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'kate/app/kateapp.cpp')
-rw-r--r-- | kate/app/kateapp.cpp | 78 |
1 files changed, 62 insertions, 16 deletions
diff --git a/kate/app/kateapp.cpp b/kate/app/kateapp.cpp index aeecc5fac..18251ee09 100644 --- a/kate/app/kateapp.cpp +++ b/kate/app/kateapp.cpp @@ -83,6 +83,8 @@ KateApp::KateApp (TDECmdLineArgs *args) kdDebug()<<"Setting KATE_PID: '"<<getpid()<<"'"<<endl; ::setenv( "KATE_PID", TQString(TQString("%1").arg(getpid())).latin1(), 1 ); + connect(this, TQT_SIGNAL(aboutToQuit()), this, TQT_SLOT(slotAboutToQuit())); + // handle restore different if (isRestored()) { @@ -178,23 +180,16 @@ bool KateApp::startupKate() else { // check Kate session startup options - TDEConfig *kateCfg = KateApp::self()->config(); - kateCfg->setGroup("General"); - if (kateCfg->hasKey("Last Session")) + int startupOption = sessionManager()->getStartupOption(); + if (startupOption == KateSessionManager::STARTUP_NEW) { - // Delete no longer used entry (pre R14.1.0) - kateCfg->deleteEntry("Last Session"); + sessionManager()->newSession(); } - TQString startupOption(kateCfg->readEntry("Startup Session", "manual")); - if (startupOption == "last") + else if (startupOption == KateSessionManager::STARTUP_LAST) { sessionManager()->restoreLastSession(); } - else if (startupOption == "new") - { - sessionManager()->newSession(); - } - else // startupOption == "manual" + else // startupOption == KateSessionManager::STARTUP_MANUAL { KateSessionChooser *chooser = new KateSessionChooser(NULL); int result = chooser->exec(); @@ -308,12 +303,9 @@ bool KateApp::startupKate() void KateApp::shutdownKate(KateMainWindow *win) { - if (!win->queryClose_internal()) + if (!win->queryClose_internal() || !query_session_close()) return; - // Save current session here to make sure all GUI elements are saved correctly - sessionManager()->saveActiveSession(); - // detach the dcopClient dcopClient()->detach(); @@ -324,6 +316,60 @@ void KateApp::shutdownKate(KateMainWindow *win) quit (); } +bool KateApp::query_session_close() +{ + bool saveSessions = false; + int switchOption = m_sessionManager->getSwitchOption(); + if (switchOption == KateSessionManager::SWITCH_SAVE) + { + saveSessions = true; + } + else if (switchOption == KateSessionManager::SWITCH_ASK) + { + KDialogBase *dlg = new KDialogBase(i18n("Save Sessions"), + KDialogBase::Yes | KDialogBase::No | KDialogBase::Cancel, + KDialogBase::Cancel, KDialogBase::Cancel, NULL, NULL, true, false, + KStdGuiItem::save(), KStdGuiItem::del(), KStdGuiItem::cancel()); + bool dontAgain = false; + int res = KMessageBox::createKMessageBox(dlg, TQMessageBox::Warning, + i18n("<p>Do you want to save the existing sessions?<p>!!NOTE!!" + "<p>All existing sessions will be removed " + "if you choose \"Delete\""), TQStringList(), + i18n("Do not ask again"), &dontAgain, KMessageBox::Notify); + if (res == KDialogBase::Cancel) + { + return false; + } + if (dontAgain) + { + if (res == KDialogBase::No) + { + m_sessionManager->setSwitchOption(KateSessionManager::SWITCH_DISCARD); + } + else + { + m_sessionManager->setSwitchOption(KateSessionManager::SWITCH_SAVE); + } + } + if (res == KDialogBase::Yes) + { + saveSessions = true; + } + } + + if (saveSessions) + { + m_sessionManager->saveActiveSession(); + } + m_sessionManager->saveConfig(saveSessions); + return true; +} + +void KateApp::reparse_config() +{ + emit optionsChanged(); +} + KatePluginManager *KateApp::pluginManager() { return m_pluginManager; |