[KCM/Desktop] Use KConfig XT to store virtualdesktops related settings
Summary: Use a kcfg file to specify virtual desktops settings saved to kwinrc. Test Plan: kcmshell5 kcm_kwin_virtualdesktops Change something, check apply buttons works appropriately Save the settings and relaunch the kcm, the new settings are taken loaded correctly Reviewers: #kwin, ervin Reviewed By: ervin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D25871
This commit is contained in:
parent
f6128ec875
commit
930c2d69a7
5 changed files with 56 additions and 29 deletions
|
@ -13,6 +13,8 @@ set(kcm_kwin_virtualdesktops_PART_SRCS
|
||||||
virtualdesktops.cpp
|
virtualdesktops.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
kconfig_add_kcfg_files(kcm_kwin_virtualdesktops_PART_SRCS virtualdesktopssettings.kcfgc GENERATE_MOC)
|
||||||
|
|
||||||
add_library(kcm_kwin_virtualdesktops MODULE ${kcm_kwin_virtualdesktops_PART_SRCS})
|
add_library(kcm_kwin_virtualdesktops MODULE ${kcm_kwin_virtualdesktops_PART_SRCS})
|
||||||
|
|
||||||
target_link_libraries(kcm_kwin_virtualdesktops
|
target_link_libraries(kcm_kwin_virtualdesktops
|
||||||
|
@ -30,6 +32,7 @@ kcoreaddons_desktop_to_json(kcm_kwin_virtualdesktops "kcm_kwin_virtualdesktops.d
|
||||||
|
|
||||||
########### install files ###############
|
########### install files ###############
|
||||||
|
|
||||||
|
install(FILES virtualdesktopssettings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
|
||||||
install(TARGETS kcm_kwin_virtualdesktops DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms)
|
install(TARGETS kcm_kwin_virtualdesktops DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms)
|
||||||
install(FILES kcm_kwin_virtualdesktops.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
|
install(FILES kcm_kwin_virtualdesktops.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
|
||||||
kpackage_install_package(package kcm_kwin_virtualdesktops kcms)
|
kpackage_install_package(package kcm_kwin_virtualdesktops kcms)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "virtualdesktops.h"
|
#include "virtualdesktops.h"
|
||||||
#include "animationsmodel.h"
|
#include "animationsmodel.h"
|
||||||
#include "desktopsmodel.h"
|
#include "desktopsmodel.h"
|
||||||
|
#include "virtualdesktopssettings.h"
|
||||||
|
|
||||||
#include <KAboutApplicationDialog>
|
#include <KAboutApplicationDialog>
|
||||||
#include <KAboutData>
|
#include <KAboutData>
|
||||||
|
@ -32,7 +33,7 @@ namespace KWin
|
||||||
|
|
||||||
VirtualDesktops::VirtualDesktops(QObject *parent, const QVariantList &args)
|
VirtualDesktops::VirtualDesktops(QObject *parent, const QVariantList &args)
|
||||||
: KQuickAddons::ConfigModule(parent, args)
|
: KQuickAddons::ConfigModule(parent, args)
|
||||||
, m_kwinConfig(KSharedConfig::openConfig("kwinrc"))
|
, m_settings(new VirtualDesktopsSettings(this))
|
||||||
, m_desktopsModel(new KWin::DesktopsModel(this))
|
, m_desktopsModel(new KWin::DesktopsModel(this))
|
||||||
, m_navWraps(true)
|
, m_navWraps(true)
|
||||||
, m_osdEnabled(false)
|
, m_osdEnabled(false)
|
||||||
|
@ -135,15 +136,12 @@ QAbstractItemModel *VirtualDesktops::animationsModel() const
|
||||||
|
|
||||||
void VirtualDesktops::load()
|
void VirtualDesktops::load()
|
||||||
{
|
{
|
||||||
KConfigGroup navConfig(m_kwinConfig, "Windows");
|
setNavWraps(m_settings->rollOverDesktop());
|
||||||
setNavWraps(navConfig.readEntry<bool>("RollOverDesktops", true));
|
|
||||||
|
|
||||||
KConfigGroup osdConfig(m_kwinConfig, "Plugins");
|
setOsdEnabled(m_settings->desktopChangeOsdEnabled());
|
||||||
setOsdEnabled(osdConfig.readEntry("desktopchangeosdEnabled", false));
|
|
||||||
|
|
||||||
KConfigGroup osdSettings(m_kwinConfig, "Script-desktopchangeosd");
|
setOsdDuration(m_settings->popupHideDelay());
|
||||||
setOsdDuration(osdSettings.readEntry("PopupHideDelay", 1000));
|
setOsdTextOnly(m_settings->textOnly());
|
||||||
setOsdTextOnly(osdSettings.readEntry("TextOnly", false));
|
|
||||||
|
|
||||||
m_animationsModel->load();
|
m_animationsModel->load();
|
||||||
}
|
}
|
||||||
|
@ -153,17 +151,12 @@ void VirtualDesktops::save()
|
||||||
m_desktopsModel->syncWithServer();
|
m_desktopsModel->syncWithServer();
|
||||||
m_animationsModel->save();
|
m_animationsModel->save();
|
||||||
|
|
||||||
KConfigGroup navConfig(m_kwinConfig, "Windows");
|
m_settings->setRollOverDesktop(m_navWraps);
|
||||||
navConfig.writeEntry("RollOverDesktops", m_navWraps);
|
m_settings->setDesktopChangeOsdEnabled(m_osdEnabled);
|
||||||
|
m_settings->setPopupHideDelay(m_osdDuration);
|
||||||
|
m_settings->setTextOnly(m_osdTextOnly);
|
||||||
|
|
||||||
KConfigGroup osdConfig(m_kwinConfig, "Plugins");
|
m_settings->save();
|
||||||
osdConfig.writeEntry("desktopchangeosdEnabled", m_osdEnabled);
|
|
||||||
|
|
||||||
KConfigGroup osdSettings(m_kwinConfig, "Script-desktopchangeosd");
|
|
||||||
osdSettings.writeEntry("PopupHideDelay", m_osdDuration);
|
|
||||||
osdSettings.writeEntry("TextOnly", m_osdTextOnly);
|
|
||||||
|
|
||||||
m_kwinConfig->sync();
|
|
||||||
|
|
||||||
QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"),
|
QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"),
|
||||||
QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig"));
|
QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig"));
|
||||||
|
@ -254,25 +247,19 @@ void VirtualDesktops::updateNeedsSave()
|
||||||
needsSave = true;
|
needsSave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigGroup navConfig(m_kwinConfig, "Windows");
|
if (m_navWraps != m_settings->rollOverDesktop()) {
|
||||||
|
|
||||||
if (m_navWraps != navConfig.readEntry<bool>("RollOverDesktops", true)) {
|
|
||||||
needsSave = true;
|
needsSave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigGroup osdConfig(m_kwinConfig, "Plugins");
|
if (m_osdEnabled != m_settings->desktopChangeOsdEnabled()) {
|
||||||
|
|
||||||
if (m_osdEnabled != osdConfig.readEntry("desktopchangeosdEnabled", false)) {
|
|
||||||
needsSave = true;
|
needsSave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigGroup osdSettings(m_kwinConfig, "Script-desktopchangeosd");
|
if (m_osdDuration != m_settings->popupHideDelay()) {
|
||||||
|
|
||||||
if (m_osdDuration != osdSettings.readEntry("PopupHideDelay", 1000)) {
|
|
||||||
needsSave = true;
|
needsSave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_osdTextOnly != osdSettings.readEntry("TextOnly", false)) {
|
if (m_osdTextOnly != m_settings->textOnly()) {
|
||||||
needsSave = true;
|
needsSave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include <KQuickAddons/ConfigModule>
|
#include <KQuickAddons/ConfigModule>
|
||||||
#include <KSharedConfig>
|
#include <KSharedConfig>
|
||||||
|
|
||||||
|
class VirtualDesktopsSettings;
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -77,7 +79,7 @@ private Q_SLOTS:
|
||||||
void updateNeedsSave();
|
void updateNeedsSave();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KSharedConfigPtr m_kwinConfig;
|
VirtualDesktopsSettings *m_settings;
|
||||||
DesktopsModel *m_desktopsModel;
|
DesktopsModel *m_desktopsModel;
|
||||||
bool m_navWraps;
|
bool m_navWraps;
|
||||||
bool m_osdEnabled;
|
bool m_osdEnabled;
|
||||||
|
|
29
kcmkwin/kwindesktop/virtualdesktopssettings.kcfg
Normal file
29
kcmkwin/kwindesktop/virtualdesktopssettings.kcfg
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||||
|
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||||
|
<kcfgfile name="kwinrc"/>
|
||||||
|
<group name="Windows">
|
||||||
|
<entry name="rollOverDesktop" key="RollOverDesktops" type="bool">
|
||||||
|
<label>Whether or not, we circle through the virtual desktop when moving from one to the next</label>
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
<group name="Plugins">
|
||||||
|
<entry name="desktopChangeOsdEnabled" key="desktopchangeosdEnabled" type="bool">
|
||||||
|
<label>Display in an OSD the virtual desktop name when switching between virtual desktops</label>
|
||||||
|
<default>false</default>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
<group name="Script-desktopchangeosd">
|
||||||
|
<entry name="PopupHideDelay" key="PopupHideDelay" type="int">
|
||||||
|
<label>Duraton of the OSD</label>
|
||||||
|
<default>1000</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="TextOnly" key="TextOnly" type="bool">
|
||||||
|
<label>Whether or not to display desktop layout in the OSD</label>
|
||||||
|
<default>false</default>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
</kcfg>
|
6
kcmkwin/kwindesktop/virtualdesktopssettings.kcfgc
Normal file
6
kcmkwin/kwindesktop/virtualdesktopssettings.kcfgc
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
File=virtualdesktopssettings.kcfg
|
||||||
|
ClassName=VirtualDesktopsSettings
|
||||||
|
Mutators=true
|
||||||
|
DefaultValueGetters=true
|
||||||
|
GenerateProperties=true
|
||||||
|
ParentInConstructor=true
|
Loading…
Reference in a new issue