diff --git a/kcms/cursortheme/CMakeLists.txt b/kcms/cursortheme/CMakeLists.txt
--- a/kcms/cursortheme/CMakeLists.txt
+++ b/kcms/cursortheme/CMakeLists.txt
@@ -21,6 +21,7 @@
set(kcm_cursortheme_PART_SRCS kcmcursortheme.cpp ${libnoinst_SRCS})
+kconfig_add_kcfg_files(kcm_cursortheme_PART_SRCS cursorthemesettings.kcfgc GENERATE_MOC)
add_library(kcm_cursortheme MODULE ${kcm_cursortheme_PART_SRCS})
@@ -55,6 +56,7 @@
########### install files ###############
+install(FILES cursorthemesettings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
install( FILES kcm_cursortheme.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )
install( FILES xcursor/xcursor.knsrc DESTINATION ${KDE_INSTALL_KNSRCDIR} )
diff --git a/kcms/cursortheme/cursorthemesettings.kcfg b/kcms/cursortheme/cursorthemesettings.kcfg
new file mode 100644
--- /dev/null
+++ b/kcms/cursortheme/cursorthemesettings.kcfg
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ breeze_cursors
+
+
+
+ 0
+
+
+
diff --git a/kcms/cursortheme/cursorthemesettings.kcfgc b/kcms/cursortheme/cursorthemesettings.kcfgc
new file mode 100644
--- /dev/null
+++ b/kcms/cursortheme/cursorthemesettings.kcfgc
@@ -0,0 +1,5 @@
+File=cursorthemesettings.kcfg
+ClassName=CursorThemeSettings
+Mutators=true
+DefaultValueGetters=true
+GenerateProperties=true
diff --git a/kcms/cursortheme/kcmcursortheme.h b/kcms/cursortheme/kcmcursortheme.h
--- a/kcms/cursortheme/kcmcursortheme.h
+++ b/kcms/cursortheme/kcmcursortheme.h
@@ -1,5 +1,6 @@
/*
* Copyright © 2003-2007 Fredrik Höglund
+ * Copyright © 2019 Benjamin Port
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,6 +29,7 @@
class CursorThemeModel;
class SortProxyModel;
class CursorTheme;
+class CursorThemeSettings;
namespace KIO
{
@@ -120,6 +122,7 @@
CursorThemeModel *m_model;
SortProxyModel *m_proxyModel;
QStandardItemModel *m_sizesModel;
+ CursorThemeSettings *m_settings;
int m_appliedSize;
// This index refers to the CursorThemeModel, not the proxy or the view
diff --git a/kcms/cursortheme/kcmcursortheme.cpp b/kcms/cursortheme/kcmcursortheme.cpp
--- a/kcms/cursortheme/kcmcursortheme.cpp
+++ b/kcms/cursortheme/kcmcursortheme.cpp
@@ -1,5 +1,6 @@
/*
* Copyright © 2003-2007 Fredrik Höglund
+ * Copyright © 2019 Benjamin Port
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,8 +30,6 @@
#include
#include
#include
-#include
-#include
#include
#include
#include
@@ -48,6 +47,7 @@
#include
#include
+#include "cursorthemesettings.h"
#include
#ifdef HAVE_XFIXES
@@ -58,6 +58,7 @@
CursorThemeConfig::CursorThemeConfig(QObject *parent, const QVariantList &args)
: KQuickAddons::ConfigModule(parent, args),
+ m_settings(new CursorThemeSettings),
m_appliedSize(0),
m_preferredSize(0),
m_selectedThemeRow(-1),
@@ -67,6 +68,8 @@
m_canResize(true),
m_canConfigure(true)
{
+ // Unfortunately doesn't generate a ctor taking the parent as parameter
+ m_settings->setParent(this);
qmlRegisterType("org.kde.private.kcm_cursortheme", 1, 0, "PreviewWidget");
qmlRegisterType();
@@ -284,9 +287,7 @@
}
// enable or disable the combobox
- KConfig c("kcminputrc");
- KConfigGroup cg(&c, "Mouse");
- if (cg.isEntryImmutable("cursorSize")) {
+ if (m_settings->isImmutable("cursorSize")) {
setCanResize(false);
} else {
setCanResize(m_sizesModel->rowCount() > 0);
@@ -358,13 +359,12 @@
{
const CursorTheme *theme = selectedIndex().isValid() ? m_proxyModel->theme(selectedIndex()) : nullptr;
- KConfig config("kcminputrc");
- KConfigGroup c(&config, "Mouse");
if (theme) {
- c.writeEntry("cursorTheme", theme->name());
+ m_settings->setCursorTheme(theme->name());
}
- c.writeEntry("cursorSize", m_preferredSize);
- c.sync();
+ m_settings->setCursorSize(m_preferredSize);
+
+ m_settings->save();
if (!applyTheme(theme, m_preferredSize)) {
emit showInfoMessage(i18n("You have to restart the Plasma session for these changes to take effect."));
@@ -380,17 +380,8 @@
void CursorThemeConfig::load()
{
-
- // Get the name of the theme libXcursor currently uses
- QString currentTheme;
- if (QX11Info::isPlatformX11()) {
- currentTheme = XcursorGetTheme(QX11Info::display());
- }
-
// Get the name of the theme KDE is configured to use
- KConfig c("kcminputrc");
- KConfigGroup cg(&c, "Mouse");
- currentTheme = cg.readEntry("cursorTheme", currentTheme);
+ QString currentTheme = m_settings->cursorTheme();
// Find the theme in the listview
if (!currentTheme.isEmpty()) {
@@ -400,16 +391,16 @@
}
// Disable the listview and the buttons if we're in kiosk mode
- if (cg.isEntryImmutable("cursorTheme")) {
+ if (m_settings->isImmutable( QStringLiteral( "cursorTheme" ))) {
setCanConfigure(false);
setCanInstall(false);
}
setSelectedThemeRow(m_appliedIndex.row());
m_originalSelectedThemeRow = m_selectedThemeRow;
// Load cursor size
- int size = cg.readEntry("cursorSize", 0);
+ int size = m_settings->cursorSize();
if (size <= 0) {
m_preferredSize = 0;
} else {
@@ -427,9 +418,9 @@
void CursorThemeConfig::defaults()
{
- QModelIndex defaultIndex = m_proxyModel->findIndex("breeze_cursors");
+ QModelIndex defaultIndex = m_proxyModel->findIndex(m_settings->defaultCursorThemeValue());
setSelectedThemeRow(defaultIndex.row());
- m_preferredSize = 0;
+ m_preferredSize = m_settings->defaultCursorSizeValue();
updateSizeComboBox();
setNeedsSave(m_originalSelectedThemeRow != m_selectedThemeRow || m_originalPreferredSize != m_preferredSize);
}