Changeset View
Changeset View
Standalone View
Standalone View
kate/session/katesessionmanager.cpp
Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Line(s) | 174 | { | |||
---|---|---|---|---|---|
184 | 184 | | |||
185 | if (loadDocs) { | 185 | if (loadDocs) { | ||
186 | KateApp::self()->documentManager()->restoreDocumentList(sc); | 186 | KateApp::self()->documentManager()->restoreDocumentList(sc); | ||
187 | } | 187 | } | ||
188 | 188 | | |||
189 | // window config | 189 | // window config | ||
190 | KConfigGroup c(sharedConfig, "General"); | 190 | KConfigGroup c(sharedConfig, "General"); | ||
191 | 191 | | |||
192 | if (c.readEntry("Restore Window Configuration", true)) { | | |||
193 | KConfig *cfg = sc; | 192 | KConfig *cfg = sc; | ||
194 | bool delete_cfg = false; | 193 | bool delete_cfg = false; | ||
195 | // a new, named session, read settings of the default session. | 194 | // a new, named session, read settings of the default session. | ||
196 | if (! sc->hasGroup("Open MainWindows")) { | 195 | if (! sc->hasGroup("Open MainWindows")) { | ||
197 | delete_cfg = true; | 196 | delete_cfg = true; | ||
198 | cfg = new KConfig(anonymousSessionFile(), KConfig::SimpleConfig); | 197 | cfg = new KConfig(anonymousSessionFile(), KConfig::SimpleConfig); | ||
199 | } | 198 | } | ||
200 | 199 | | |||
200 | if (c.readEntry("Restore Window Configuration", true)) { | ||||
201 | int wCount = cfg->group("Open MainWindows").readEntry("Count", 1); | 201 | int wCount = cfg->group("Open MainWindows").readEntry("Count", 1); | ||
202 | 202 | | |||
203 | for (int i = 0; i < wCount; ++i) { | 203 | for (int i = 0; i < wCount; ++i) { | ||
204 | if (i >= KateApp::self()->mainWindowsCount()) { | 204 | if (i >= KateApp::self()->mainWindowsCount()) { | ||
205 | KateApp::self()->newMainWindow(cfg, QStringLiteral("MainWindow%1").arg(i)); | 205 | KateApp::self()->newMainWindow(cfg, QStringLiteral("MainWindow%1").arg(i)); | ||
206 | } else { | 206 | } else { | ||
207 | KateApp::self()->mainWindow(i)->readProperties(KConfigGroup(cfg, QStringLiteral("MainWindow%1").arg(i))); | 207 | KateApp::self()->mainWindow(i)->readProperties(KConfigGroup(cfg, QStringLiteral("MainWindow%1").arg(i))); | ||
208 | } | 208 | } | ||
209 | 209 | | |||
210 | KateApp::self()->mainWindow(i)->restoreWindowConfig(KConfigGroup(cfg, QStringLiteral("MainWindow%1 Settings").arg(i))); | 210 | KateApp::self()->mainWindow(i)->restoreWindowConfig(KConfigGroup(cfg, QStringLiteral("MainWindow%1 Settings").arg(i))); | ||
211 | } | 211 | } | ||
212 | 212 | | |||
213 | if (delete_cfg) { | | |||
214 | delete cfg; | | |||
215 | } | | |||
216 | | ||||
217 | // remove mainwindows we need no longer... | 213 | // remove mainwindows we need no longer... | ||
218 | if (wCount > 0) { | 214 | if (wCount > 0) { | ||
219 | while (wCount < KateApp::self()->mainWindowsCount()) { | 215 | while (wCount < KateApp::self()->mainWindowsCount()) { | ||
220 | delete KateApp::self()->mainWindow(KateApp::self()->mainWindowsCount() - 1); | 216 | delete KateApp::self()->mainWindow(KateApp::self()->mainWindowsCount() - 1); | ||
221 | } | 217 | } | ||
222 | } | 218 | } | ||
219 | } else { | ||||
220 | const int windowsCount = KateApp::self()->mainWindowsCount(); | ||||
221 | for (int i = 0; i < windowsCount ; ++i) { | ||||
222 | // if there are no main windows, create one to call loadOpenRecent() | ||||
223 | if(i == windowsCount) { | ||||
224 | KateMainWindow *w = KateApp::self()->newMainWindow(); | ||||
225 | if (w !=nullptr) { | ||||
226 | w->loadOpenRecent(cfg); | ||||
227 | } | ||||
228 | } else { | ||||
229 | KateApp::self()->mainWindow(i)->loadOpenRecent(cfg); | ||||
230 | } | ||||
231 | } | ||||
232 | } | ||||
233 | | ||||
234 | if (delete_cfg) { | ||||
235 | delete cfg; | ||||
223 | } | 236 | } | ||
224 | } | 237 | } | ||
225 | 238 | | |||
226 | bool KateSessionManager::activateSession(const QString &name, const bool closeAndSaveLast, const bool loadNew) | 239 | bool KateSessionManager::activateSession(const QString &name, const bool closeAndSaveLast, const bool loadNew) | ||
227 | { | 240 | { | ||
228 | return activateSession(giveSession(name), closeAndSaveLast, loadNew); | 241 | return activateSession(giveSession(name), closeAndSaveLast, loadNew); | ||
229 | } | 242 | } | ||
230 | 243 | | |||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | 339 | { | |||
336 | KateApp::self()->documentManager()->saveDocumentList(sc); | 349 | KateApp::self()->documentManager()->saveDocumentList(sc); | ||
337 | 350 | | |||
338 | sc->group("Open MainWindows").writeEntry("Count", KateApp::self()->mainWindowsCount()); | 351 | sc->group("Open MainWindows").writeEntry("Count", KateApp::self()->mainWindowsCount()); | ||
339 | 352 | | |||
340 | // save config for all windows around ;) | 353 | // save config for all windows around ;) | ||
341 | bool saveWindowConfig = KConfigGroup(KSharedConfig::openConfig(), "General").readEntry("Restore Window Configuration", true); | 354 | bool saveWindowConfig = KConfigGroup(KSharedConfig::openConfig(), "General").readEntry("Restore Window Configuration", true); | ||
342 | for (int i = 0; i < KateApp::self()->mainWindowsCount(); ++i) { | 355 | for (int i = 0; i < KateApp::self()->mainWindowsCount(); ++i) { | ||
343 | KConfigGroup cg(sc, QStringLiteral("MainWindow%1").arg(i)); | 356 | KConfigGroup cg(sc, QStringLiteral("MainWindow%1").arg(i)); | ||
357 | // saveProperties() handles saving the "open recent" files list | ||||
344 | KateApp::self()->mainWindow(i)->saveProperties(cg); | 358 | KateApp::self()->mainWindow(i)->saveProperties(cg); | ||
345 | if (saveWindowConfig) { | 359 | if (saveWindowConfig) { | ||
346 | KateApp::self()->mainWindow(i)->saveWindowConfig(KConfigGroup(sc, QStringLiteral("MainWindow%1 Settings").arg(i))); | 360 | KateApp::self()->mainWindow(i)->saveWindowConfig(KConfigGroup(sc, QStringLiteral("MainWindow%1 Settings").arg(i))); | ||
347 | } | 361 | } | ||
348 | } | 362 | } | ||
349 | 363 | | |||
350 | sc->sync(); | 364 | sc->sync(); | ||
351 | 365 | | |||
▲ Show 20 Lines • Show All 288 Lines • Show Last 20 Lines |