[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
|
||||
)
|
||||
|
||||
kconfig_add_kcfg_files(kcm_kwin_virtualdesktops_PART_SRCS virtualdesktopssettings.kcfgc GENERATE_MOC)
|
||||
|
||||
add_library(kcm_kwin_virtualdesktops MODULE ${kcm_kwin_virtualdesktops_PART_SRCS})
|
||||
|
||||
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 virtualdesktopssettings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
|
||||
install(TARGETS kcm_kwin_virtualdesktops DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms)
|
||||
install(FILES kcm_kwin_virtualdesktops.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
|
||||
kpackage_install_package(package kcm_kwin_virtualdesktops kcms)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "virtualdesktops.h"
|
||||
#include "animationsmodel.h"
|
||||
#include "desktopsmodel.h"
|
||||
#include "virtualdesktopssettings.h"
|
||||
|
||||
#include <KAboutApplicationDialog>
|
||||
#include <KAboutData>
|
||||
|
@ -32,7 +33,7 @@ namespace KWin
|
|||
|
||||
VirtualDesktops::VirtualDesktops(QObject *parent, const QVariantList &args)
|
||||
: KQuickAddons::ConfigModule(parent, args)
|
||||
, m_kwinConfig(KSharedConfig::openConfig("kwinrc"))
|
||||
, m_settings(new VirtualDesktopsSettings(this))
|
||||
, m_desktopsModel(new KWin::DesktopsModel(this))
|
||||
, m_navWraps(true)
|
||||
, m_osdEnabled(false)
|
||||
|
@ -135,15 +136,12 @@ QAbstractItemModel *VirtualDesktops::animationsModel() const
|
|||
|
||||
void VirtualDesktops::load()
|
||||
{
|
||||
KConfigGroup navConfig(m_kwinConfig, "Windows");
|
||||
setNavWraps(navConfig.readEntry<bool>("RollOverDesktops", true));
|
||||
setNavWraps(m_settings->rollOverDesktop());
|
||||
|
||||
KConfigGroup osdConfig(m_kwinConfig, "Plugins");
|
||||
setOsdEnabled(osdConfig.readEntry("desktopchangeosdEnabled", false));
|
||||
setOsdEnabled(m_settings->desktopChangeOsdEnabled());
|
||||
|
||||
KConfigGroup osdSettings(m_kwinConfig, "Script-desktopchangeosd");
|
||||
setOsdDuration(osdSettings.readEntry("PopupHideDelay", 1000));
|
||||
setOsdTextOnly(osdSettings.readEntry("TextOnly", false));
|
||||
setOsdDuration(m_settings->popupHideDelay());
|
||||
setOsdTextOnly(m_settings->textOnly());
|
||||
|
||||
m_animationsModel->load();
|
||||
}
|
||||
|
@ -153,17 +151,12 @@ void VirtualDesktops::save()
|
|||
m_desktopsModel->syncWithServer();
|
||||
m_animationsModel->save();
|
||||
|
||||
KConfigGroup navConfig(m_kwinConfig, "Windows");
|
||||
navConfig.writeEntry("RollOverDesktops", m_navWraps);
|
||||
m_settings->setRollOverDesktop(m_navWraps);
|
||||
m_settings->setDesktopChangeOsdEnabled(m_osdEnabled);
|
||||
m_settings->setPopupHideDelay(m_osdDuration);
|
||||
m_settings->setTextOnly(m_osdTextOnly);
|
||||
|
||||
KConfigGroup osdConfig(m_kwinConfig, "Plugins");
|
||||
osdConfig.writeEntry("desktopchangeosdEnabled", m_osdEnabled);
|
||||
|
||||
KConfigGroup osdSettings(m_kwinConfig, "Script-desktopchangeosd");
|
||||
osdSettings.writeEntry("PopupHideDelay", m_osdDuration);
|
||||
osdSettings.writeEntry("TextOnly", m_osdTextOnly);
|
||||
|
||||
m_kwinConfig->sync();
|
||||
m_settings->save();
|
||||
|
||||
QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"),
|
||||
QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig"));
|
||||
|
@ -254,25 +247,19 @@ void VirtualDesktops::updateNeedsSave()
|
|||
needsSave = true;
|
||||
}
|
||||
|
||||
KConfigGroup navConfig(m_kwinConfig, "Windows");
|
||||
|
||||
if (m_navWraps != navConfig.readEntry<bool>("RollOverDesktops", true)) {
|
||||
if (m_navWraps != m_settings->rollOverDesktop()) {
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
KConfigGroup osdConfig(m_kwinConfig, "Plugins");
|
||||
|
||||
if (m_osdEnabled != osdConfig.readEntry("desktopchangeosdEnabled", false)) {
|
||||
if (m_osdEnabled != m_settings->desktopChangeOsdEnabled()) {
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
KConfigGroup osdSettings(m_kwinConfig, "Script-desktopchangeosd");
|
||||
|
||||
if (m_osdDuration != osdSettings.readEntry("PopupHideDelay", 1000)) {
|
||||
if (m_osdDuration != m_settings->popupHideDelay()) {
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
if (m_osdTextOnly != osdSettings.readEntry("TextOnly", false)) {
|
||||
if (m_osdTextOnly != m_settings->textOnly()) {
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include <KQuickAddons/ConfigModule>
|
||||
#include <KSharedConfig>
|
||||
|
||||
class VirtualDesktopsSettings;
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
|
@ -77,7 +79,7 @@ private Q_SLOTS:
|
|||
void updateNeedsSave();
|
||||
|
||||
private:
|
||||
KSharedConfigPtr m_kwinConfig;
|
||||
VirtualDesktopsSettings *m_settings;
|
||||
DesktopsModel *m_desktopsModel;
|
||||
bool m_navWraps;
|
||||
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