From eaef61e1c4174c34c76f20cd1e662b63f18436d7 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Thu, 30 Apr 2020 10:25:50 -0400 Subject: [PATCH] Add DBus call setDefaultProfile() to ViewManager This allows the user to set the default Konsole profile via D-Bus. Differential Revision: https://phabricator.kde.org/D29236 --- src/ViewManager.cpp | 10 ++++++++++ src/ViewManager.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index a91a415c..376c2ad6 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -1081,6 +1081,16 @@ QString ViewManager::defaultProfile() return ProfileManager::instance()->defaultProfile()->name(); } +void ViewManager::setDefaultProfile(const QString &profileName) +{ + const QList profiles = ProfileManager::instance()->allProfiles(); + for (const Profile::Ptr &profile : profiles) { + if (profile->name() == profileName) { + ProfileManager::instance()->setDefaultProfile(profile); + } + } +} + QStringList ViewManager::profileList() { return ProfileManager::instance()->availableProfileNames(); diff --git a/src/ViewManager.h b/src/ViewManager.h index 2f8a2331..43a7c51f 100644 --- a/src/ViewManager.h +++ b/src/ViewManager.h @@ -284,6 +284,10 @@ public Q_SLOTS: // DBus slot that returns the name of default profile Q_SCRIPTABLE QString defaultProfile(); + // TODO: its semantic is application-wide. Move it to more appropriate place + // DBus slot that sets the default profile + Q_SCRIPTABLE void setDefaultProfile(const QString &profile); + // TODO: its semantic is application-wide. Move it to more appropriate place // DBus slot that returns a string list of defined (known) profiles Q_SCRIPTABLE QStringList profileList();