Commit 9cbac6fe authored by Ismael Asensio's avatar Ismael Asensio

[kwinrules] Show defaults indicator in System Settings

The default is having no rules, so the indicator will show
whenever there is one or more rules in the list.
parent cdab4be1
......@@ -21,6 +21,15 @@ set(kwinrules_SRCS
kconfig_add_kcfg_files(kwinrules_SRCS ../../rulesettings.kcfgc)
kconfig_add_kcfg_files(kwinrules_SRCS ../../rulebooksettingsbase.kcfgc)
kcmutils_generate_module_data(
kwinrules_SRCS
MODULE_DATA_HEADER rulebookdata.h
MODULE_DATA_CLASS_NAME RuleBookData
SETTINGS_HEADERS rulebooksettings.h
SETTINGS_CLASSES RuleBookSettings
NAMESPACE KWin
)
add_library(KWinRulesObjects STATIC ${kwinrules_SRCS})
set(kwin_kcm_rules_XCB_LIBS
......@@ -34,6 +43,7 @@ set(kcm_libs
Qt5::QuickWidgets
KF5::I18n
KF5::KCMUtils
KF5::QuickAddons
KF5::WindowSystem
KF5::XmlGui
......
......@@ -7,6 +7,8 @@
#include "kcmrules.h"
#include "rulebookdata.h"
#include <QDBusConnection>
#include <QDBusMessage>
......@@ -233,7 +235,9 @@ void KCMKWinRules::importFromFile(const QUrl &path)
updateNeedsSave();
}
K_PLUGIN_CLASS_WITH_JSON(KCMKWinRules, "kcm_kwinrules.json");
K_PLUGIN_FACTORY_WITH_JSON(KCMKWinRulesFactory, "kcm_kwinrules.json",
registerPlugin<KWin::KCMKWinRules>();
registerPlugin<KWin::RuleBookData>(););
} // namespace
......
......@@ -6,13 +6,15 @@
#include "rulebookmodel.h"
#include "rulebookdata.h"
#include "rulebooksettings.h"
namespace KWin
{
RuleBookModel::RuleBookModel(QObject *parent)
: QAbstractListModel(parent)
, m_ruleBook(new RuleBookSettings(this))
, m_ruleBookData(new RuleBookData(this))
{
}
......@@ -70,7 +72,7 @@ bool RuleBookModel::insertRows(int row, int count, const QModelIndex &parent)
m_rules.insert(row + i, newRule);
}
m_ruleBook->setCount(m_rules.count());
m_ruleBookData->settings()->setCount(m_rules.count());
endInsertRows();
return true;
......@@ -87,7 +89,7 @@ bool RuleBookModel::removeRows(int row, int count, const QModelIndex &parent)
delete m_rules.at(row + i);
}
m_rules.remove(row, count);
m_ruleBook->setCount(m_rules.count());
m_ruleBookData->settings()->setCount(m_rules.count());
endRemoveRows();
return true;
......@@ -157,17 +159,17 @@ void RuleBookModel::load()
{
beginResetModel();
m_ruleBook->load();
m_ruleBookData->settings()->load();
qDeleteAll(m_rules);
m_rules = m_ruleBook->rules();
m_rules = m_ruleBookData->settings()->rules();
endResetModel();
}
void RuleBookModel::save()
{
m_ruleBook->setRules(m_rules);
m_ruleBook->save();
m_ruleBookData->settings()->setRules(m_rules);
m_ruleBookData->settings()->save();
}
} // namespace
......@@ -6,7 +6,6 @@
#pragma once
#include "rulebooksettings.h"
#include <rules.h>
#include <QAbstractListModel>
......@@ -15,6 +14,8 @@
namespace KWin
{
class RuleBookData;
class RuleBookModel : public QAbstractListModel
{
Q_OBJECT
......@@ -43,7 +44,7 @@ public:
void save();
private:
RuleBookSettings *m_ruleBook;
RuleBookData *m_ruleBookData;
QVector<Rules *> m_rules;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment