Changeset View
Changeset View
Standalone View
Standalone View
kcms/activities/SwitchingTab.cpp
Show All 13 Lines | |||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "SwitchingTab.h" | 21 | #include "SwitchingTab.h" | ||
22 | #include "kactivitymanagerd_settings.h" | ||||
22 | 23 | | |||
23 | #include <KActionCollection> | 24 | #include <KActionCollection> | ||
24 | #include <KConfigGroup> | 25 | #include <KConfigGroup> | ||
25 | #include <KGlobalAccel> | 26 | #include <KGlobalAccel> | ||
26 | #include <KSharedConfig> | 27 | #include <KSharedConfig> | ||
27 | 28 | | |||
28 | #include "ui_SwitchingTabBase.h" | 29 | #include "ui_SwitchingTabBase.h" | ||
29 | 30 | | |||
30 | #include <utils/d_ptr_implementation.h> | 31 | #include <utils/d_ptr_implementation.h> | ||
31 | #include <KActivities/Consumer> | 32 | #include <KActivities/Consumer> | ||
32 | 33 | | |||
33 | class SwitchingTab::Private : public Ui::SwitchingTabBase { | 34 | class SwitchingTab::Private : public Ui::SwitchingTabBase { | ||
34 | public: | 35 | public: | ||
35 | KSharedConfig::Ptr mainConfig; | 36 | KActivityManagerdSettings mainConfig; | ||
36 | 37 | | |||
37 | KActionCollection *mainActionCollection; | 38 | KActionCollection *mainActionCollection; | ||
38 | KActivities::Consumer activities; | 39 | KActivities::Consumer activities; | ||
39 | 40 | | |||
40 | void createAction(const QString &actionName, const QString &actionText, | 41 | void createAction(const QString &actionName, const QString &actionText, | ||
41 | const QList<QKeySequence> &sequence) | 42 | const QList<QKeySequence> &sequence) | ||
42 | { | 43 | { | ||
43 | auto action = mainActionCollection->addAction(actionName); | 44 | auto action = mainActionCollection->addAction(actionName); | ||
Show All 9 Lines | |||||
53 | }; | 54 | }; | ||
54 | 55 | | |||
55 | SwitchingTab::SwitchingTab(QWidget *parent) | 56 | SwitchingTab::SwitchingTab(QWidget *parent) | ||
56 | : QWidget(parent) | 57 | : QWidget(parent) | ||
57 | , d() | 58 | , d() | ||
58 | { | 59 | { | ||
59 | d->setupUi(this); | 60 | d->setupUi(this); | ||
60 | 61 | | |||
61 | d->mainConfig = KSharedConfig::openConfig(QStringLiteral("kactivitymanagerdrc")); | | |||
62 | | ||||
63 | // Shortcut config. The shortcut belongs to the component "plasmashell"! | 62 | // Shortcut config. The shortcut belongs to the component "plasmashell"! | ||
64 | d->mainActionCollection = new KActionCollection(this, QStringLiteral("plasmashell")); | 63 | d->mainActionCollection = new KActionCollection(this, QStringLiteral("plasmashell")); | ||
65 | d->mainActionCollection->setComponentDisplayName(i18n("Activity switching")); | 64 | d->mainActionCollection->setComponentDisplayName(i18n("Activity switching")); | ||
66 | d->mainActionCollection->setConfigGlobal(true); | 65 | d->mainActionCollection->setConfigGlobal(true); | ||
67 | 66 | | |||
68 | d->createAction(QStringLiteral("next activity"), | 67 | d->createAction(QStringLiteral("next activity"), | ||
69 | i18nc("@action", "Walk through activities"), | 68 | i18nc("@action", "Walk through activities"), | ||
70 | { Qt::META + Qt::Key_Tab }); | 69 | { Qt::META + Qt::Key_Tab }); | ||
Show All 35 Lines | |||||
106 | 105 | | |||
107 | void SwitchingTab::defaults() | 106 | void SwitchingTab::defaults() | ||
108 | { | 107 | { | ||
109 | d->checkRememberVirtualDesktop->setChecked(false); | 108 | d->checkRememberVirtualDesktop->setChecked(false); | ||
110 | } | 109 | } | ||
111 | 110 | | |||
112 | void SwitchingTab::load() | 111 | void SwitchingTab::load() | ||
113 | { | 112 | { | ||
114 | auto pluginListConfig = d->mainConfig->group("Plugins"); | | |||
115 | 113 | | |||
116 | d->checkRememberVirtualDesktop->setChecked(pluginListConfig.readEntry( | 114 | d->checkRememberVirtualDesktop->setChecked(d->mainConfig.virtualDesktopSwitchEnabled()); | ||
117 | "org.kde.ActivityManager.VirtualDesktopSwitchEnabled", false)); | | |||
118 | } | 115 | } | ||
119 | 116 | | |||
120 | void SwitchingTab::save() | 117 | void SwitchingTab::save() | ||
121 | { | 118 | { | ||
122 | auto pluginListConfig = d->mainConfig->group("Plugins"); | 119 | d->mainConfig.setVirtualDesktopSwitchEnabled(d->checkRememberVirtualDesktop->isChecked()); | ||
123 | 120 | d->mainConfig.save(); | |||
124 | pluginListConfig.writeEntry( | | |||
125 | "org.kde.ActivityManager.VirtualDesktopSwitchEnabled", | | |||
126 | d->checkRememberVirtualDesktop->isChecked()); | | |||
127 | | ||||
128 | pluginListConfig.sync(); | | |||
129 | } | 121 | } |