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