From f360d0201671d458fe7fbbd19190c17e648e57d3 Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Sat, 8 Jul 2017 16:54:55 -0400 Subject: [PATCH] Add new DBus method newSession(profile) This seems more useful then newSession(profile, directory) as the working directory from the profile should be used. A lot of duplicated code ATM. --- src/ViewManager.cpp | 22 ++++++++++++++++++++++ src/ViewManager.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 8ba07bf8a..492229994 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -1107,6 +1107,28 @@ int ViewManager::newSession() return session->sessionId(); } +int ViewManager::newSession(const QString &profile) +{ + const QList profilelist = ProfileManager::instance()->allProfiles(); + Profile::Ptr profileptr = ProfileManager::instance()->defaultProfile(); + + for (const auto &i : profilelist) { + if (i->name() == profile) { + profileptr = i; + break; + } + } + + Session *session = SessionManager::instance()->createSession(profileptr); + + session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(managerId())); + + this->createView(session); + session->run(); + + return session->sessionId(); +} + int ViewManager::newSession(const QString &profile, const QString &directory) { const QList profilelist = ProfileManager::instance()->allProfiles(); diff --git a/src/ViewManager.h b/src/ViewManager.h index 067d01a23..16f48e826 100644 --- a/src/ViewManager.h +++ b/src/ViewManager.h @@ -234,6 +234,12 @@ public Q_SLOTS: /** DBus slot that returns the current (active) session window */ Q_SCRIPTABLE int currentSession(); + /** DBus slot that creates a new session in the current view. + * @param profile the name of the profile to be used + * started. + */ + Q_SCRIPTABLE int newSession(const QString &profile); + /** DBus slot that creates a new session in the current view. * @param profile the name of the profile to be used * @param directory the working directory where the session is