bool KateSessionManager::chooseSession() { bool success = true; // app config KConfig *c = KateApp::self()->config(); c->setGroup("General"); // get last used session, default to default session QString lastSession(c->readEntry("Last Session", "default.katesession")); QString sesStart(c->readEntry("Startup Session", "manual")); // uhh, just open last used session, show no chooser if(sesStart == "last") { activateSession(new KateSession(this, lastSession, ""), false, false); return success; } // start with empty new session if(sesStart == "new") { activateSession(new KateSession(this, "", ""), false, false); return success; } KateSessionChooser *chooser = new KateSessionChooser(0, lastSession); bool retry = true; int res = 0; while(retry) { res = chooser->exec(); switch(res) { case KateSessionChooser::resultOpen: { KateSession::Ptr s = chooser->selectedSession(); if(!s) { KMessageBox::error(chooser, i18n("No session selected to open."), i18n("No Session Selected")); break; } activateSession(s, false, false); retry = false; break; } // exit the app lateron case KateSessionChooser::resultQuit: success = false; retry = false; break; default: activateSession(new KateSession(this, "", ""), false, false); retry = false; break; } } // write back our nice boolean :) if(success && chooser->reopenLastSession()) { c->setGroup("General"); if(res == KateSessionChooser::resultOpen) c->writeEntry("Startup Session", "last"); else if(res == KateSessionChooser::resultNew) c->writeEntry("Startup Session", "new"); c->sync(); } delete chooser; return success; }
/** To get the id of the current last session. If the last session is null, then the id will be a null string as well. */ std::string lastSessionId () { CMTYLogonSystem::SessionPt session = lastSession (); return ((session == NULL) ? std::string (__NULL_STRING__) : session -> _id); }