Changeset View
Changeset View
Standalone View
Standalone View
kate/session/katesessionmanager.cpp
Show All 16 Lines | |||||
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | * Boston, MA 02110-1301, USA. | 18 | * Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "config.h" | 21 | #include "config.h" | ||
22 | 22 | | |||
23 | #include "katesessionmanager.h" | 23 | #include "katesessionmanager.h" | ||
24 | 24 | | |||
25 | #include "katesessionchooser.h" | | |||
26 | #include "katesessionmanagedialog.h" | 25 | #include "katesessionmanagedialog.h" | ||
27 | #include "katesessionopendialog.h" | | |||
28 | 26 | | |||
29 | #include "kateapp.h" | 27 | #include "kateapp.h" | ||
30 | #include "katepluginmanager.h" | 28 | #include "katepluginmanager.h" | ||
31 | #include "katerunninginstanceinfo.h" | 29 | #include "katerunninginstanceinfo.h" | ||
32 | 30 | | |||
33 | #include <KConfigGroup> | 31 | #include <KConfigGroup> | ||
34 | #include <KSharedConfig> | 32 | #include <KSharedConfig> | ||
35 | #include <KLocalizedString> | 33 | #include <KLocalizedString> | ||
Show All 29 Lines | 56 | { | |||
65 | // create dir if needed | 63 | // create dir if needed | ||
66 | QDir().mkpath(m_sessionsDir); | 64 | QDir().mkpath(m_sessionsDir); | ||
67 | 65 | | |||
68 | m_dirWatch = new KDirWatch(this); | 66 | m_dirWatch = new KDirWatch(this); | ||
69 | m_dirWatch->addDir(m_sessionsDir); | 67 | m_dirWatch->addDir(m_sessionsDir); | ||
70 | connect(m_dirWatch, SIGNAL(dirty(QString)), this, SLOT(updateSessionList())); | 68 | connect(m_dirWatch, SIGNAL(dirty(QString)), this, SLOT(updateSessionList())); | ||
71 | 69 | | |||
72 | updateSessionList(); | 70 | updateSessionList(); | ||
73 | | ||||
74 | m_activeSession = KateSession::createAnonymous(anonymousSessionFile()); | | |||
75 | } | 71 | } | ||
76 | 72 | | |||
77 | KateSessionManager::~KateSessionManager() | 73 | KateSessionManager::~KateSessionManager() | ||
78 | { | 74 | { | ||
79 | delete m_dirWatch; | 75 | delete m_dirWatch; | ||
80 | } | 76 | } | ||
81 | 77 | | |||
82 | void KateSessionManager::updateSessionList() | 78 | void KateSessionManager::updateSessionList() | ||
83 | { | 79 | { | ||
84 | QStringList list; | 80 | QStringList list; | ||
85 | 81 | | |||
86 | // Let's get a list of all session we have atm | 82 | // Let's get a list of all session we have atm | ||
87 | QDir dir(m_sessionsDir, QStringLiteral("*.katesession")); | 83 | QDir dir(m_sessionsDir, QStringLiteral("*.katesession")); | ||
88 | 84 | | |||
89 | for (unsigned int i = 0; i < dir.count(); ++i) { | 85 | for (unsigned int i = 0; i < dir.count(); ++i) { | ||
90 | QString name = dir[i]; | 86 | QString name = dir[i]; | ||
91 | name.chop(12); // .katesession | 87 | name.chop(12); // .katesession | ||
92 | list << QUrl::fromPercentEncoding(name.toLatin1()); | 88 | list << QUrl::fromPercentEncoding(name.toLatin1()); | ||
93 | } | 89 | } | ||
94 | 90 | | |||
95 | // write jump list actions to disk in the kate.desktop file | 91 | // write jump list actions to disk in the kate.desktop file | ||
96 | updateJumpListActions(list); | 92 | updateJumpListActions(list); | ||
97 | 93 | | |||
98 | // delete old items; | 94 | bool changed = false; | ||
99 | QMutableHashIterator<QString, KateSession::Ptr> i(m_sessions); | | |||
100 | 95 | | |||
101 | while (i.hasNext()) { | 96 | // Add new sessions to our list | ||
102 | i.next(); | 97 | for (const QString session : qAsConst(list)) { | ||
103 | const int idx = list.indexOf(i.key()); | 98 | if (!m_sessions.contains(session)) { | ||
104 | if (idx == -1) { // the key is invalid, remove it from m_session | 99 | const QString file = sessionFileForName(session); | ||
105 | if (i.value() != m_activeSession) { // if active, ignore missing config | 100 | m_sessions.insert(session, KateSession::create(file, session)); | ||
106 | i.remove(); | 101 | changed = true; | ||
102 | } | ||||
107 | } | 103 | } | ||
108 | } else { // remove it from scan list | 104 | // Remove gone sessions from our list | ||
109 | list.removeAt(idx); | 105 | for (const QString session : m_sessions.keys()) { | ||
106 | if ((list.indexOf(session) < 0) && (m_sessions.value(session) != activeSession())) { | ||||
107 | m_sessions.remove(session); | ||||
108 | changed = true; | ||||
110 | } | 109 | } | ||
111 | } | 110 | } | ||
112 | 111 | | |||
113 | // load the new ones | 112 | if (changed) { | ||
114 | foreach(const QString & newName, list) { | 113 | emit sessionListChanged(); | ||
115 | const QString file = sessionFileForName(newName); | | |||
116 | m_sessions[newName] = KateSession::create(file, newName); | | |||
117 | } | 114 | } | ||
118 | } | 115 | } | ||
119 | 116 | | |||
120 | bool KateSessionManager::activateSession(KateSession::Ptr session, | 117 | bool KateSessionManager::activateSession(KateSession::Ptr session, | ||
121 | const bool closeAndSaveLast, | 118 | const bool closeAndSaveLast, | ||
122 | const bool loadNew) | 119 | const bool loadNew) | ||
123 | { | 120 | { | ||
124 | if (m_activeSession == session) { | 121 | if (activeSession() == session) { | ||
125 | return true; | 122 | return true; | ||
126 | } | 123 | } | ||
127 | 124 | | |||
128 | if (!session->isAnonymous()) { | 125 | if (!session->isAnonymous()) { | ||
129 | //check if the requested session is already open in another instance | 126 | //check if the requested session is already open in another instance | ||
130 | KateRunningInstanceMap instances; | 127 | KateRunningInstanceMap instances; | ||
131 | if (!fillinRunningKateAppInstances(&instances)) { | 128 | if (!fillinRunningKateAppInstances(&instances)) { | ||
132 | KMessageBox::error(nullptr, i18n("Internal error: there is more than one instance open for a given session.")); | 129 | KMessageBox::error(nullptr, i18n("Internal error: there is more than one instance open for a given session.")); | ||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | 237 | { | |||
244 | 241 | | |||
245 | if (m_sessions.contains(name)) { | 242 | if (m_sessions.contains(name)) { | ||
246 | return m_sessions.value(name); | 243 | return m_sessions.value(name); | ||
247 | } | 244 | } | ||
248 | 245 | | |||
249 | KateSession::Ptr s = KateSession::create(sessionFileForName(name), name); | 246 | KateSession::Ptr s = KateSession::create(sessionFileForName(name), name); | ||
250 | saveSessionTo(s->config()); | 247 | saveSessionTo(s->config()); | ||
251 | m_sessions[name] = s; | 248 | m_sessions[name] = s; | ||
249 | // Due to this add to m_sessions will updateSessionList() no signal emit, | ||||
250 | // but it's importand to add. Otherwise could it be happen that m_activeSession | ||||
251 | // is not part of m_sessions but a double | ||||
252 | emit sessionListChanged(); | ||||
253 | | ||||
252 | return s; | 254 | return s; | ||
253 | } | 255 | } | ||
254 | 256 | | |||
255 | void KateSessionManager::deleteSession(KateSession::Ptr session) | 257 | bool KateSessionManager::deleteSession(KateSession::Ptr session) | ||
256 | { | 258 | { | ||
259 | if (sessionIsActive(session->name())) { | ||||
260 | return false; | ||||
261 | } | ||||
262 | | ||||
257 | QFile::remove(session->file()); | 263 | QFile::remove(session->file()); | ||
258 | if (session != activeSession()) { | | |||
259 | m_sessions.remove(session->name()); | 264 | m_sessions.remove(session->name()); | ||
260 | } | 265 | // Due to this remove from m_sessions will updateSessionList() no signal emit, | ||
266 | // but this way is there no delay between deletion and information | ||||
267 | emit sessionListChanged(); | ||||
268 | | ||||
269 | return true; | ||||
261 | } | 270 | } | ||
262 | 271 | | |||
263 | bool KateSessionManager::renameSession(KateSession::Ptr session, const QString &newName) | 272 | QString KateSessionManager::copySession(KateSession::Ptr session, const QString &newName) | ||
264 | { | 273 | { | ||
265 | Q_ASSERT(!newName.isEmpty()); | 274 | const QString name = askForNewSessionName(session, newName); | ||
266 | 275 | | |||
267 | if (session->name() == newName) { | 276 | if (name.isEmpty()) { | ||
268 | return true; | 277 | return name; | ||
269 | } | 278 | } | ||
270 | 279 | | |||
271 | const QString newFile = sessionFileForName(newName); | 280 | const QString newFile = sessionFileForName(name); | ||
272 | 281 | | |||
273 | if (QFile::exists(newFile)) { | 282 | KateSession::Ptr ns = KateSession::createFrom(session, newFile, name); | ||
274 | KMessageBox::sorry(QApplication::activeWindow(), | 283 | ns->config()->sync(); | ||
275 | i18n("The session could not be renamed to \"%1\", there already exists another session with the same name", newName), | 284 | | ||
276 | i18n("Session Renaming")); | 285 | return name; | ||
277 | return false; | | |||
278 | } | 286 | } | ||
279 | 287 | | |||
288 | QString KateSessionManager::renameSession(KateSession::Ptr session, const QString &newName) | ||||
289 | { | ||||
290 | const QString name = askForNewSessionName(session, newName); | ||||
291 | | ||||
292 | if (name.isEmpty()) { | ||||
293 | return name; | ||||
294 | } | ||||
295 | | ||||
296 | const QString newFile = sessionFileForName(name); | ||||
297 | | ||||
280 | session->config()->sync(); | 298 | session->config()->sync(); | ||
281 | 299 | | |||
282 | const QUrl srcUrl = QUrl::fromLocalFile(session->file()); | 300 | const QUrl srcUrl = QUrl::fromLocalFile(session->file()); | ||
283 | const QUrl dstUrl = QUrl::fromLocalFile(newFile); | 301 | const QUrl dstUrl = QUrl::fromLocalFile(newFile); | ||
284 | KIO::CopyJob *job = KIO::move(srcUrl, dstUrl, KIO::HideProgressInfo); | 302 | KIO::CopyJob *job = KIO::move(srcUrl, dstUrl, KIO::HideProgressInfo); | ||
285 | 303 | | |||
286 | if (!job->exec()) { | 304 | if (!job->exec()) { | ||
287 | KMessageBox::sorry(QApplication::activeWindow(), | 305 | KMessageBox::sorry(QApplication::activeWindow(), | ||
288 | i18n("The session could not be renamed to \"%1\". Failed to write to \"%2\"", newName, newFile), | 306 | i18n("The session could not be renamed to \"%1\". Failed to write to \"%2\"", newName, newFile), | ||
289 | i18n("Session Renaming")); | 307 | i18n("Session Renaming")); | ||
290 | return false; | 308 | return QString(); | ||
291 | } | 309 | } | ||
292 | 310 | | |||
293 | m_sessions[newName] = m_sessions.take(session->name()); | 311 | m_sessions[newName] = m_sessions.take(session->name()); | ||
294 | session->setName(newName); | 312 | session->setName(newName); | ||
295 | session->setFile(newFile); | 313 | session->setFile(newFile); | ||
314 | session->config()->sync(); | ||||
315 | // updateSessionList() will this edit not notice, so force signal | ||||
316 | emit sessionListChanged(); | ||||
296 | 317 | | |||
297 | if (session == activeSession()) { | 318 | if (session == activeSession()) { | ||
298 | emit sessionChanged(); | 319 | emit sessionChanged(); | ||
299 | } | 320 | } | ||
300 | 321 | | |||
301 | return true; | 322 | return name; | ||
302 | } | 323 | } | ||
303 | 324 | | |||
304 | void KateSessionManager::saveSessionTo(KConfig *sc) const | 325 | void KateSessionManager::saveSessionTo(KConfig *sc) const | ||
305 | { | 326 | { | ||
306 | // Clear the session file to avoid to accumulate outdated entries | 327 | // Clear the session file to avoid to accumulate outdated entries | ||
307 | for (auto group : sc->groupList()) { | 328 | for (auto group : sc->groupList()) { | ||
308 | sc->deleteGroup(group); | 329 | sc->deleteGroup(group); | ||
309 | } | 330 | } | ||
Show All 31 Lines | 361 | #else | |||
341 | fsync(fileToSync.handle()); | 362 | fsync(fileToSync.handle()); | ||
342 | #endif | 363 | #endif | ||
343 | #endif | 364 | #endif | ||
344 | } | 365 | } | ||
345 | } | 366 | } | ||
346 | 367 | | |||
347 | bool KateSessionManager::saveActiveSession(bool rememberAsLast) | 368 | bool KateSessionManager::saveActiveSession(bool rememberAsLast) | ||
348 | { | 369 | { | ||
370 | if (!activeSession()) { | ||||
371 | return false; | ||||
372 | } | ||||
373 | | ||||
349 | KConfig *sc = activeSession()->config(); | 374 | KConfig *sc = activeSession()->config(); | ||
350 | 375 | | |||
351 | saveSessionTo(sc); | 376 | saveSessionTo(sc); | ||
352 | 377 | | |||
353 | if (rememberAsLast) { | 378 | if (rememberAsLast && !activeSession()->isAnonymous()) { | ||
354 | KSharedConfigPtr c = KSharedConfig::openConfig(); | 379 | KSharedConfigPtr c = KSharedConfig::openConfig(); | ||
355 | c->group("General").writeEntry("Last Session", activeSession()->name()); | 380 | c->group("General").writeEntry("Last Session", activeSession()->name()); | ||
356 | c->sync(); | 381 | c->sync(); | ||
357 | } | 382 | } | ||
358 | return true; | 383 | return true; | ||
359 | } | 384 | } | ||
360 | 385 | | |||
361 | bool KateSessionManager::chooseSession() | 386 | bool KateSessionManager::chooseSession() | ||
Show All 11 Lines | 387 | { | |||
373 | } | 398 | } | ||
374 | 399 | | |||
375 | // start with empty new session or in case no sessions exist | 400 | // start with empty new session or in case no sessions exist | ||
376 | if (sesStart == QStringLiteral("new") || sessionList().size() == 0) { | 401 | if (sesStart == QStringLiteral("new") || sessionList().size() == 0) { | ||
377 | activateAnonymousSession(); | 402 | activateAnonymousSession(); | ||
378 | return true; | 403 | return true; | ||
379 | } | 404 | } | ||
380 | 405 | | |||
381 | QScopedPointer<KateSessionChooser> chooser(new KateSessionChooser(nullptr, lastSession)); | 406 | return QScopedPointer<KateSessionManageDialog>(new KateSessionManageDialog(nullptr, lastSession))->exec(); | ||
382 | const int res = chooser->exec(); | | |||
383 | bool success = true; | | |||
384 | | ||||
385 | switch (res) { | | |||
386 | case KateSessionChooser::resultOpen: { | | |||
387 | KateSession::Ptr s = chooser->selectedSession(); // dialog guarantees this to be valid | | |||
388 | success = activateSession(s, false); | | |||
389 | break; | | |||
390 | } | | |||
391 | | ||||
392 | case KateSessionChooser::resultCopy: { | | |||
393 | KateSession::Ptr s = chooser->selectedSession(); // dialog guarantees this to be valid | | |||
394 | KateSession::Ptr ns = KateSession::createAnonymousFrom(s, anonymousSessionFile()); | | |||
395 | activateSession(ns, false); | | |||
396 | break; | | |||
397 | } | 407 | } | ||
398 | 408 | | |||
399 | // exit the app lateron | 409 | void KateSessionManager::sessionNew() | ||
400 | case KateSessionChooser::resultQuit: | 410 | { | ||
401 | return false; | 411 | activateSession(giveSession(QString())); | ||
412 | } | ||||
402 | 413 | | |||
403 | case KateSessionChooser::resultNew: | 414 | void KateSessionManager::sessionSave() | ||
404 | default: | 415 | { | ||
405 | activateAnonymousSession(); | 416 | saveActiveSession(); // this is the optional point to handle saveSessionAs for anonymous session | ||
406 | break; | | |||
407 | } | 417 | } | ||
408 | 418 | | |||
409 | // write back our nice boolean :) | 419 | void KateSessionManager::sessionSaveAs() | ||
410 | if (success && chooser->reopenLastSession()) { | 420 | { | ||
411 | KConfigGroup generalConfig(KSharedConfig::openConfig(), QStringLiteral("General")); | 421 | const QString newName = askForNewSessionName(activeSession()); | ||
412 | 422 | | |||
413 | if (res == KateSessionChooser::resultOpen) { | 423 | if (newName.isEmpty()) { | ||
414 | generalConfig.writeEntry("Startup Session", "last"); | 424 | return; | ||
415 | } else if (res == KateSessionChooser::resultNew) { | | |||
416 | generalConfig.writeEntry("Startup Session", "new"); | | |||
417 | } | 425 | } | ||
418 | 426 | | |||
419 | generalConfig.sync(); | 427 | activeSession()->config()->sync(); | ||
420 | } | 428 | | ||
429 | KateSession::Ptr ns = KateSession::createFrom(activeSession(), sessionFileForName(newName), newName); | ||||
430 | m_activeSession = ns; | ||||
431 | saveActiveSession(); | ||||
421 | 432 | | |||
422 | return success; | 433 | emit sessionChanged(); | ||
423 | } | 434 | } | ||
424 | 435 | | |||
425 | void KateSessionManager::sessionNew() | 436 | QString KateSessionManager::askForNewSessionName(KateSession::Ptr session, const QString &newName) | ||
426 | { | 437 | { | ||
427 | activateSession(giveSession(QString())); | 438 | if (session->name() == newName && !session->isAnonymous()) { | ||
439 | return QString(); | ||||
428 | } | 440 | } | ||
429 | 441 | | |||
430 | void KateSessionManager::sessionOpen() | 442 | const QString messagePrompt = i18n("Session name:"); | ||
431 | { | 443 | const KLocalizedString messageExist = ki18n("There is already an existing session with your chosen name: %1\n" | ||
432 | QScopedPointer<KateSessionOpenDialog> chooser(new KateSessionOpenDialog(nullptr)); | 444 | "Please choose a different one."); | ||
445 | const QString messageEmpty = i18n("To save a session, you must specify a name."); | ||||
433 | 446 | | |||
434 | const int res = chooser->exec(); | 447 | QString messageTotal = messagePrompt; | ||
448 | QString name = newName; | ||||
435 | 449 | | |||
436 | if (res == KateSessionOpenDialog::resultCancel) { | 450 | while (true) { | ||
437 | return; | 451 | QString preset = name; | ||
452 | | ||||
453 | if (name.isEmpty()) { | ||||
454 | preset = suggestNewSessionName(session->name()); | ||||
455 | messageTotal = messageEmpty + QStringLiteral("\n\n") + messagePrompt; | ||||
456 | | ||||
457 | } else if (QFile::exists(sessionFileForName(name))) { | ||||
458 | preset = suggestNewSessionName(name); | ||||
459 | if (preset.isEmpty()) { | ||||
460 | // Very unlikely, but as fall back we keep users input | ||||
461 | preset = name; | ||||
462 | } | ||||
463 | messageTotal = messageExist.subs(name).toString() + QStringLiteral("\n\n") + messagePrompt; | ||||
464 | | ||||
465 | } else { | ||||
466 | return name; | ||||
438 | } | 467 | } | ||
439 | 468 | | |||
440 | KateSession::Ptr s = chooser->selectedSession(); | 469 | QInputDialog dlg(KateApp::self()->activeKateMainWindow()); | ||
470 | dlg.setInputMode(QInputDialog::TextInput); | ||||
471 | if (session->isAnonymous()) { | ||||
472 | dlg.setWindowTitle(i18n("Specify a name for this session")); | ||||
473 | } else { | ||||
474 | dlg.setWindowTitle(i18n("Specify a new name for session: %1", session->name())); | ||||
475 | } | ||||
476 | dlg.setLabelText(messageTotal); | ||||
477 | dlg.setTextValue(preset); | ||||
478 | dlg.resize(900,100); // FIXME Calc somehow a proper size | ||||
479 | bool ok = dlg.exec(); | ||||
480 | name = dlg.textValue(); | ||||
441 | 481 | | |||
442 | if (s) { | 482 | if (!ok) { | ||
443 | activateSession(s); | 483 | return QString(); | ||
484 | } | ||||
444 | } | 485 | } | ||
445 | } | 486 | } | ||
446 | 487 | | |||
447 | void KateSessionManager::sessionSave() | 488 | QString KateSessionManager::suggestNewSessionName(const QString &target) | ||
448 | { | 489 | { | ||
449 | saveActiveSession(); // this is the optional point to handle saveSessionAs for anonymous session | 490 | if (target.isEmpty()) { | ||
491 | // Here could also a default name set or the current session name used | ||||
492 | return QString(); | ||||
450 | } | 493 | } | ||
451 | 494 | | |||
452 | void KateSessionManager::sessionSaveAs() | 495 | const QString mask = QStringLiteral("%1 (%2)"); | ||
453 | { | 496 | QString name; | ||
454 | if (newSessionName()) { | 497 | | ||
455 | saveActiveSession(); | 498 | for (int i = 2; i < 1000000; i++) { // Should be enough to get an unique name | ||
456 | emit sessionChanged(); | 499 | name = mask.arg(target).arg(i); | ||
500 | | ||||
501 | if (!QFile::exists(sessionFileForName(name))) { | ||||
502 | return name; | ||||
503 | } | ||||
457 | } | 504 | } | ||
505 | | ||||
506 | return QString(); | ||||
458 | } | 507 | } | ||
459 | 508 | | |||
460 | bool KateSessionManager::newSessionName() | 509 | void KateSessionManager::sessionManage() | ||
461 | { | 510 | { | ||
462 | bool alreadyExists = false; | 511 | QScopedPointer<KateSessionManageDialog>(new KateSessionManageDialog(KateApp::self()->activeKateMainWindow()))->exec(); | ||
512 | } | ||||
463 | 513 | | |||
464 | do { | | |||
465 | bool ok = false; | | |||
466 | const QString name = QInputDialog::getText(QApplication::activeWindow(), | | |||
467 | i18n("Specify New Name for Current Session"), | | |||
468 | alreadyExists ? i18n("There is already an existing session with your chosen name.\nPlease choose a different one\nSession name:") : i18n("Session name:"), | | |||
469 | QLineEdit::Normal, activeSession()->name(), &ok); | | |||
470 | 514 | | |||
471 | if (!ok) { | 515 | bool KateSessionManager::sessionIsActive(const QString &session) | ||
516 | { | ||||
517 | // Try to avoid unneed action | ||||
518 | if (activeSession() && activeSession()->name() == session) { | ||||
519 | return true; | ||||
520 | } | ||||
521 | | ||||
522 | QDBusConnectionInterface *i = QDBusConnection::sessionBus().interface(); | ||||
523 | if (!i) { | ||||
472 | return false; | 524 | return false; | ||
473 | } | 525 | } | ||
474 | 526 | | |||
475 | if (name.isEmpty()) { | 527 | // look up all running kate instances and there sessions | ||
476 | KMessageBox::sorry(nullptr, i18n("To save a session, you must specify a name."), i18n("Missing Session Name")); | 528 | QDBusReply<QStringList> servicesReply = i->registeredServiceNames(); | ||
477 | continue; | 529 | QStringList services; | ||
530 | if (servicesReply.isValid()) { | ||||
531 | services = servicesReply.value(); | ||||
478 | } | 532 | } | ||
479 | 533 | | |||
480 | const QString file = sessionFileForName(name); | 534 | for (const QString &s : qAsConst(services)) { | ||
481 | if (QFile::exists(file)) { | 535 | if (!s.startsWith(QStringLiteral("org.kde.kate-"))) { | ||
482 | alreadyExists = true; | | |||
483 | continue; | 536 | continue; | ||
484 | } | 537 | } | ||
485 | 538 | | |||
486 | activeSession()->config()->sync(); | 539 | KateRunningInstanceInfo rii(s); | ||
487 | KateSession::Ptr ns = KateSession::createFrom(activeSession(), file, name); | 540 | if (rii.valid && rii.sessionName == session) { | ||
488 | m_activeSession = ns; | | |||
489 | | ||||
490 | emit sessionChanged(); | | |||
491 | | ||||
492 | alreadyExists = false; | | |||
493 | } while (alreadyExists); | | |||
494 | return true; | 541 | return true; | ||
495 | } | 542 | } | ||
543 | } | ||||
496 | 544 | | |||
497 | void KateSessionManager::sessionManage() | 545 | return false; | ||
498 | { | | |||
499 | QScopedPointer<KateSessionManageDialog>(new KateSessionManageDialog(nullptr))->exec(); | | |||
500 | } | 546 | } | ||
501 | 547 | | |||
548 | | ||||
502 | QString KateSessionManager::anonymousSessionFile() const | 549 | QString KateSessionManager::anonymousSessionFile() const | ||
503 | { | 550 | { | ||
504 | const QString file = m_sessionsDir + QStringLiteral("/../anonymous.katesession"); | 551 | const QString file = m_sessionsDir + QStringLiteral("/../anonymous.katesession"); | ||
505 | return QDir().cleanPath(file); | 552 | return QDir().cleanPath(file); | ||
506 | } | 553 | } | ||
507 | 554 | | |||
508 | QString KateSessionManager::sessionFileForName(const QString &name) const | 555 | QString KateSessionManager::sessionFileForName(const QString &name) const | ||
509 | { | 556 | { | ||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |