mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
kwin: de-duplcate rules loading/saving bits
for reference:
3d78c01c4b
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
fbcd357824
commit
c8926347cd
5 changed files with 98 additions and 156 deletions
|
@ -20,9 +20,9 @@
|
||||||
#include <kapplication.h>
|
#include <kapplication.h>
|
||||||
#include <kconfig.h>
|
#include <kconfig.h>
|
||||||
#include <klocalizedstring.h>
|
#include <klocalizedstring.h>
|
||||||
#include <kstandarddirs.h>
|
|
||||||
#include <kwindowsystem.h>
|
#include <kwindowsystem.h>
|
||||||
#include <QtDBus/QtDBus>
|
#include <QDBusMessage>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <fixx11h.h>
|
#include <fixx11h.h>
|
||||||
|
@ -35,58 +35,6 @@
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
static void loadRules(QList< Rules* >& rules)
|
|
||||||
{
|
|
||||||
QList<QByteArray> ruleids;
|
|
||||||
KConfig _cfg("kwinrulesrc");
|
|
||||||
KConfigGroup cfg(&_cfg, "General");
|
|
||||||
int count = cfg.readEntry("count", 0);
|
|
||||||
for (int i = 1; i <= count; ++i) {
|
|
||||||
cfg = KConfigGroup(&_cfg, QString::number(i));
|
|
||||||
const QByteArray id = cfg.readEntry("id", QByteArray());
|
|
||||||
if (ruleids.contains(id)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Rules* rule = new Rules(cfg);
|
|
||||||
rules.append(rule);
|
|
||||||
ruleids.append(id);
|
|
||||||
}
|
|
||||||
const QStringList kwinrules = KGlobal::dirs()->findAllResources("data", "kwin/default_rules/*.kwinrules");
|
|
||||||
foreach (const QString &kwinrule, kwinrules) {
|
|
||||||
KConfig cfg(kwinrule, KConfig::NoGlobals);
|
|
||||||
count = cfg.group("General").readEntry("count", 0);
|
|
||||||
for (int i = 1; i <= count; ++i) {
|
|
||||||
KConfigGroup cg(&cfg, QString::number(i));
|
|
||||||
const QByteArray id = cg.readEntry("id", QByteArray());
|
|
||||||
if (ruleids.contains(id)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Rules* rule = new Rules(cg);
|
|
||||||
rules.append(rule);
|
|
||||||
ruleids.append(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void saveRules(const QList< Rules* >& rules)
|
|
||||||
{
|
|
||||||
KConfig cfg("kwinrulesrc");
|
|
||||||
QStringList groups = cfg.groupList();
|
|
||||||
for (QStringList::ConstIterator it = groups.constBegin();
|
|
||||||
it != groups.constEnd();
|
|
||||||
++it)
|
|
||||||
cfg.deleteGroup(*it);
|
|
||||||
cfg.group("General").writeEntry("count", rules.count());
|
|
||||||
int i = 1;
|
|
||||||
for (QList< Rules* >::ConstIterator it = rules.constBegin();
|
|
||||||
it != rules.constEnd();
|
|
||||||
++it) {
|
|
||||||
KConfigGroup cg(&cfg, QString::number(i));
|
|
||||||
(*it)->write(cg);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Rules* findRule(const QList< Rules* >& rules, Window wid, bool whole_app)
|
static Rules* findRule(const QList< Rules* >& rules, Window wid, bool whole_app)
|
||||||
{
|
{
|
||||||
KWindowInfo info = KWindowSystem::windowInfo(wid,
|
KWindowInfo info = KWindowSystem::windowInfo(wid,
|
||||||
|
@ -229,7 +177,7 @@ static Rules* findRule(const QList< Rules* >& rules, Window wid, bool whole_app)
|
||||||
static int edit(Window wid, bool whole_app)
|
static int edit(Window wid, bool whole_app)
|
||||||
{
|
{
|
||||||
QList< Rules* > rules;
|
QList< Rules* > rules;
|
||||||
loadRules(rules);
|
Rules::loadRules(rules);
|
||||||
Rules* orig_rule = findRule(rules, wid, whole_app);
|
Rules* orig_rule = findRule(rules, wid, whole_app);
|
||||||
RulesDialog dlg;
|
RulesDialog dlg;
|
||||||
if (whole_app)
|
if (whole_app)
|
||||||
|
@ -249,7 +197,7 @@ static int edit(Window wid, bool whole_app)
|
||||||
rules.prepend(edited_rule);
|
rules.prepend(edited_rule);
|
||||||
delete orig_rule;
|
delete orig_rule;
|
||||||
}
|
}
|
||||||
saveRules(rules);
|
Rules::saveRules(rules);
|
||||||
// Send signal to all kwin instances
|
// Send signal to all kwin instances
|
||||||
QDBusMessage message =
|
QDBusMessage message =
|
||||||
QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
|
QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
|
||||||
|
|
|
@ -68,7 +68,7 @@ KCMRulesList::KCMRulesList(QWidget* parent)
|
||||||
|
|
||||||
KCMRulesList::~KCMRulesList()
|
KCMRulesList::~KCMRulesList()
|
||||||
{
|
{
|
||||||
for (QVector< Rules* >::Iterator it = rules.begin();
|
for (QList< Rules* >::Iterator it = rules.begin();
|
||||||
it != rules.end();
|
it != rules.end();
|
||||||
++it)
|
++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
|
@ -190,7 +190,7 @@ void KCMRulesList::importClicked()
|
||||||
if (rules[i]->description == new_rule->description) {
|
if (rules[i]->description == new_rule->description) {
|
||||||
delete rules[i];
|
delete rules[i];
|
||||||
if (remove) {
|
if (remove) {
|
||||||
rules.remove(i);
|
rules.removeAt(i);
|
||||||
delete rules_listbox->takeItem(i);
|
delete rules_listbox->takeItem(i);
|
||||||
delete new_rule;
|
delete new_rule;
|
||||||
pos = qMax(0, rules_listbox->currentRow()); // might have changed!
|
pos = qMax(0, rules_listbox->currentRow()); // might have changed!
|
||||||
|
@ -220,40 +220,12 @@ void KCMRulesList::importClicked()
|
||||||
void KCMRulesList::load()
|
void KCMRulesList::load()
|
||||||
{
|
{
|
||||||
rules_listbox->clear();
|
rules_listbox->clear();
|
||||||
for (QVector< Rules* >::Iterator it = rules.begin(); it != rules.end(); ++it)
|
for (QList< Rules* >::Iterator it = rules.begin(); it != rules.end(); ++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
rules.clear();
|
rules.clear();
|
||||||
QList<QByteArray> ruleids;
|
Rules::loadRules(rules);
|
||||||
KConfig _cfg("kwinrulesrc");
|
foreach (const Rules* rule, rules) {
|
||||||
KConfigGroup cfg(&_cfg, "General");
|
|
||||||
int count = cfg.readEntry("count", 0);
|
|
||||||
rules.reserve(count);
|
|
||||||
for (int i = 1; i <= count; ++i) {
|
|
||||||
cfg = KConfigGroup(&_cfg, QString::number(i));
|
|
||||||
const QByteArray id = cfg.readEntry("id", QByteArray());
|
|
||||||
if (ruleids.contains(id)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Rules* rule = new Rules(cfg);
|
|
||||||
rules.append(rule);
|
|
||||||
rules_listbox->addItem(rule->description);
|
rules_listbox->addItem(rule->description);
|
||||||
ruleids.append(id);
|
|
||||||
}
|
|
||||||
const QStringList kwinrules = KGlobal::dirs()->findAllResources("data", "kwin/default_rules/*.kwinrules");
|
|
||||||
foreach (const QString &kwinrule, kwinrules) {
|
|
||||||
KConfig cfg(kwinrule, KConfig::NoGlobals);
|
|
||||||
count = cfg.group("General").readEntry("count", 0);
|
|
||||||
for (int i = 1; i <= count; ++i) {
|
|
||||||
KConfigGroup cg(&cfg, QString::number(i));
|
|
||||||
const QByteArray id = cg.readEntry("id", QByteArray());
|
|
||||||
if (ruleids.contains(id)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Rules* rule = new Rules(cg);
|
|
||||||
rules.append(rule);
|
|
||||||
rules_listbox->addItem(rule->description);
|
|
||||||
ruleids.append(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (rules.count() > 0)
|
if (rules.count() > 0)
|
||||||
rules_listbox->setCurrentItem(rules_listbox->item(0));
|
rules_listbox->setCurrentItem(rules_listbox->item(0));
|
||||||
|
@ -264,21 +236,7 @@ void KCMRulesList::load()
|
||||||
|
|
||||||
void KCMRulesList::save()
|
void KCMRulesList::save()
|
||||||
{
|
{
|
||||||
KConfig cfg(QLatin1String("kwinrulesrc"));
|
Rules::saveRules(rules);
|
||||||
QStringList groups = cfg.groupList();
|
|
||||||
for (QStringList::ConstIterator it = groups.constBegin();
|
|
||||||
it != groups.constEnd();
|
|
||||||
++it)
|
|
||||||
cfg.deleteGroup(*it);
|
|
||||||
cfg.group("General").writeEntry("count", rules.count());
|
|
||||||
int i = 1;
|
|
||||||
for (QVector< Rules* >::ConstIterator it = rules.constBegin();
|
|
||||||
it != rules.constEnd();
|
|
||||||
++it) {
|
|
||||||
KConfigGroup cg(&cfg, QString::number(i));
|
|
||||||
(*it)->write(cg);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KCMRulesList::defaults()
|
void KCMRulesList::defaults()
|
||||||
|
|
|
@ -49,7 +49,7 @@ private slots:
|
||||||
void importClicked();
|
void importClicked();
|
||||||
void activeChanged();
|
void activeChanged();
|
||||||
private:
|
private:
|
||||||
QVector< Rules* > rules;
|
QList< Rules* > rules;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
109
kwin/rules.cpp
109
kwin/rules.cpp
|
@ -190,6 +190,68 @@ void Rules::readFromCfg(const KConfigGroup& cfg)
|
||||||
READ_SET_RULE(demandattention, , false);
|
READ_SET_RULE(demandattention, , false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Rules::loadRules(QList< Rules* >& rules)
|
||||||
|
{
|
||||||
|
Q_ASSERT(rules.size() == 0);
|
||||||
|
QList<QByteArray> ruleids;
|
||||||
|
KConfig _cfg("kwinrulesrc");
|
||||||
|
KConfigGroup cfg(&_cfg, "General");
|
||||||
|
int count = cfg.readEntry("count", 0);
|
||||||
|
rules.reserve(count);
|
||||||
|
for (int i = 1; i <= count; ++i) {
|
||||||
|
cfg = KConfigGroup(&_cfg, QString::number(i));
|
||||||
|
const QByteArray id = cfg.readEntry("id", QByteArray());
|
||||||
|
if (ruleids.contains(id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Rules* rule = new Rules(cfg);
|
||||||
|
rules.append(rule);
|
||||||
|
ruleids.append(id);
|
||||||
|
}
|
||||||
|
const QStringList kwinrules = KGlobal::dirs()->findAllResources("data", "kwin/default_rules/*.kwinrules");
|
||||||
|
foreach (const QString &kwinrule, kwinrules) {
|
||||||
|
KConfig cfg(kwinrule, KConfig::NoGlobals);
|
||||||
|
count = cfg.group("General").readEntry("count", 0);
|
||||||
|
for (int i = 1; i <= count; ++i) {
|
||||||
|
KConfigGroup cg(&cfg, QString::number(i));
|
||||||
|
const QByteArray id = cg.readEntry("id", QByteArray());
|
||||||
|
if (ruleids.contains(id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Rules* rule = new Rules(cg);
|
||||||
|
rules.append(rule);
|
||||||
|
ruleids.append(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Rules::saveRules(const QList< Rules* >& rules, const bool temporary)
|
||||||
|
{
|
||||||
|
#ifdef KCMRULES
|
||||||
|
Q_UNUSED(temporary);
|
||||||
|
#endif
|
||||||
|
KConfig cfg("kwinrulesrc");
|
||||||
|
QStringList groups = cfg.groupList();
|
||||||
|
for (QStringList::ConstIterator it = groups.constBegin();
|
||||||
|
it != groups.constEnd();
|
||||||
|
++it)
|
||||||
|
cfg.deleteGroup(*it);
|
||||||
|
cfg.group("General").writeEntry("count", rules.count());
|
||||||
|
int i = 1;
|
||||||
|
for (QList< Rules* >::ConstIterator it = rules.constBegin();
|
||||||
|
it != rules.constEnd();
|
||||||
|
++it) {
|
||||||
|
#ifndef KCMRULES
|
||||||
|
if (!temporary && (*it)->isTemporary())
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
KConfigGroup cg(&cfg, QString::number(i));
|
||||||
|
(*it)->write(cg);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#undef READ_MATCH_STRING
|
#undef READ_MATCH_STRING
|
||||||
#undef READ_SET_RULE
|
#undef READ_SET_RULE
|
||||||
#undef READ_FORCE_RULE
|
#undef READ_FORCE_RULE
|
||||||
|
@ -979,56 +1041,13 @@ void RuleBook::edit(Client* c, bool whole_app)
|
||||||
void RuleBook::load()
|
void RuleBook::load()
|
||||||
{
|
{
|
||||||
deleteAll();
|
deleteAll();
|
||||||
QList<QByteArray> ruleids;
|
Rules::loadRules(m_rules);
|
||||||
KConfig cfg("kwinrulesrc", KConfig::NoGlobals);
|
|
||||||
int count = cfg.group("General").readEntry("count", 0);
|
|
||||||
for (int i = 1; i <= count; ++i) {
|
|
||||||
KConfigGroup cg(&cfg, QString::number(i));
|
|
||||||
const QByteArray id = cg.readEntry("id", QByteArray());
|
|
||||||
if (ruleids.contains(id)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Rules* rule = new Rules(cg);
|
|
||||||
m_rules.append(rule);
|
|
||||||
ruleids.append(id);
|
|
||||||
}
|
|
||||||
const QStringList kwinrules = KGlobal::dirs()->findAllResources("data", "kwin/default_rules/*.kwinrules");
|
|
||||||
foreach (const QString &kwinrule, kwinrules) {
|
|
||||||
KConfig cfg(kwinrule, KConfig::NoGlobals);
|
|
||||||
count = cfg.group("General").readEntry("count", 0);
|
|
||||||
for (int i = 1; i <= count; ++i) {
|
|
||||||
KConfigGroup cg(&cfg, QString::number(i));
|
|
||||||
const QByteArray id = cg.readEntry("id", QByteArray());
|
|
||||||
if (ruleids.contains(id)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Rules* rule = new Rules(cg);
|
|
||||||
m_rules.append(rule);
|
|
||||||
ruleids.append(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuleBook::save()
|
void RuleBook::save()
|
||||||
{
|
{
|
||||||
m_updateTimer->stop();
|
m_updateTimer->stop();
|
||||||
KConfig cfg("kwinrulesrc", KConfig::NoGlobals);
|
Rules::saveRules(m_rules, false);
|
||||||
QStringList groups = cfg.groupList();
|
|
||||||
for (QStringList::ConstIterator it = groups.constBegin();
|
|
||||||
it != groups.constEnd();
|
|
||||||
++it)
|
|
||||||
cfg.deleteGroup(*it);
|
|
||||||
cfg.group("General").writeEntry("count", m_rules.count());
|
|
||||||
int i = 1;
|
|
||||||
for (QList< Rules* >::ConstIterator it = m_rules.constBegin();
|
|
||||||
it != m_rules.constEnd();
|
|
||||||
++it) {
|
|
||||||
if ((*it)->isTemporary())
|
|
||||||
continue;
|
|
||||||
KConfigGroup cg(&cfg, QString::number(i));
|
|
||||||
(*it)->write(cg);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuleBook::temporaryRulesMessage(const QString& message)
|
void RuleBook::temporaryRulesMessage(const QString& message)
|
||||||
|
|
29
kwin/rules.h
29
kwin/rules.h
|
@ -43,17 +43,18 @@ class Client;
|
||||||
class Rules;
|
class Rules;
|
||||||
|
|
||||||
#ifndef KCMRULES // only for kwin core
|
#ifndef KCMRULES // only for kwin core
|
||||||
|
|
||||||
class WindowRules
|
class WindowRules
|
||||||
: public KDecorationDefines
|
: public KDecorationDefines
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit WindowRules(const QVector< Rules* >& rules);
|
explicit WindowRules(const QVector< Rules* >& rules);
|
||||||
WindowRules();
|
WindowRules();
|
||||||
|
|
||||||
void update(Client*, int selection);
|
void update(Client*, int selection);
|
||||||
void discardTemporary();
|
void discardTemporary();
|
||||||
bool contains(const Rules* rule) const;
|
bool contains(const Rules* rule) const;
|
||||||
void remove(Rules* rule);
|
void remove(Rules* rule);
|
||||||
|
|
||||||
Placement::Policy checkPlacement(Placement::Policy placement) const;
|
Placement::Policy checkPlacement(Placement::Policy placement) const;
|
||||||
QRect checkGeometry(QRect rect, bool init = false) const;
|
QRect checkGeometry(QRect rect, bool init = false) const;
|
||||||
// use 'invalidPoint' with checkPosition, unlike QSize() and QRect(), QPoint() is a valid point
|
// use 'invalidPoint' with checkPosition, unlike QSize() and QRect(), QPoint() is a valid point
|
||||||
|
@ -88,13 +89,14 @@ public:
|
||||||
QString checkShortcut(QString s, bool init = false) const;
|
QString checkShortcut(QString s, bool init = false) const;
|
||||||
bool checkDisableGlobalShortcuts(bool disable) const;
|
bool checkDisableGlobalShortcuts(bool disable) const;
|
||||||
bool checkDemandAttention(bool demand, bool init = false) const;
|
bool checkDemandAttention(bool demand, bool init = false) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaximizeMode checkMaximizeVert(MaximizeMode mode, bool init) const;
|
MaximizeMode checkMaximizeVert(MaximizeMode mode, bool init) const;
|
||||||
MaximizeMode checkMaximizeHoriz(MaximizeMode mode, bool init) const;
|
MaximizeMode checkMaximizeHoriz(MaximizeMode mode, bool init) const;
|
||||||
|
|
||||||
QVector< Rules* > rules;
|
QVector< Rules* > rules;
|
||||||
};
|
};
|
||||||
|
#endif // KCMRULES
|
||||||
#endif
|
|
||||||
|
|
||||||
class Rules
|
class Rules
|
||||||
: public KDecorationDefines
|
: public KDecorationDefines
|
||||||
|
@ -103,6 +105,7 @@ public:
|
||||||
Rules();
|
Rules();
|
||||||
explicit Rules(const KConfigGroup&);
|
explicit Rules(const KConfigGroup&);
|
||||||
Rules(const QString&, bool temporary);
|
Rules(const QString&, bool temporary);
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
Position = 1<<0, Size = 1<<1, Desktop = 1<<2,
|
Position = 1<<0, Size = 1<<1, Desktop = 1<<2,
|
||||||
MaximizeVert = 1<<3, MaximizeHoriz = 1<<4, Minimize = 1<<5,
|
MaximizeVert = 1<<3, MaximizeHoriz = 1<<4, Minimize = 1<<5,
|
||||||
|
@ -112,6 +115,10 @@ public:
|
||||||
Screen = 1<<16, DemandAttention = 1<<17, All = 0xffffffff
|
Screen = 1<<16, DemandAttention = 1<<17, All = 0xffffffff
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(Types, Type)
|
Q_DECLARE_FLAGS(Types, Type)
|
||||||
|
|
||||||
|
static void loadRules(QList< Rules* >& rules);
|
||||||
|
static void saveRules(const QList< Rules* >& rules, bool temporary = true);
|
||||||
|
|
||||||
void write(KConfigGroup&) const;
|
void write(KConfigGroup&) const;
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
#ifndef KCMRULES
|
#ifndef KCMRULES
|
||||||
|
@ -120,6 +127,7 @@ public:
|
||||||
bool update(Client*, int selection);
|
bool update(Client*, int selection);
|
||||||
bool isTemporary() const;
|
bool isTemporary() const;
|
||||||
bool discardTemporary(bool force); // removes if temporary and forced or too old
|
bool discardTemporary(bool force); // removes if temporary and forced or too old
|
||||||
|
|
||||||
bool applyPlacement(Placement::Policy& placement) const;
|
bool applyPlacement(Placement::Policy& placement) const;
|
||||||
bool applyGeometry(QRect& rect, bool init) const;
|
bool applyGeometry(QRect& rect, bool init) const;
|
||||||
// use 'invalidPoint' with applyPosition, unlike QSize() and QRect(), QPoint() is a valid point
|
// use 'invalidPoint' with applyPosition, unlike QSize() and QRect(), QPoint() is a valid point
|
||||||
|
@ -155,13 +163,15 @@ public:
|
||||||
bool applyShortcut(QString& shortcut, bool init) const;
|
bool applyShortcut(QString& shortcut, bool init) const;
|
||||||
bool applyDisableGlobalShortcuts(bool& disable) const;
|
bool applyDisableGlobalShortcuts(bool& disable) const;
|
||||||
bool applyDemandAttention(bool& demand, bool init) const;
|
bool applyDemandAttention(bool& demand, bool init) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif // KCMRULES
|
||||||
bool matchType(NET::WindowType match_type) const;
|
bool matchType(NET::WindowType match_type) const;
|
||||||
bool matchWMClass(const QByteArray& match_class, const QByteArray& match_name) const;
|
bool matchWMClass(const QByteArray& match_class, const QByteArray& match_name) const;
|
||||||
bool matchRole(const QByteArray& match_role) const;
|
bool matchRole(const QByteArray& match_role) const;
|
||||||
bool matchTitle(const QString& match_title) const;
|
bool matchTitle(const QString& match_title) const;
|
||||||
bool matchClientMachine(const QByteArray& match_machine, bool local) const;
|
bool matchClientMachine(const QByteArray& match_machine, bool local) const;
|
||||||
|
|
||||||
// All these values are saved to the cfg file, and are also used in kstart!
|
// All these values are saved to the cfg file, and are also used in kstart!
|
||||||
enum {
|
enum {
|
||||||
Unused = 0,
|
Unused = 0,
|
||||||
|
@ -172,14 +182,17 @@ private:
|
||||||
ApplyNow, // apply immediatelly, then forget the setting
|
ApplyNow, // apply immediatelly, then forget the setting
|
||||||
ForceTemporarily // apply and force until the window is withdrawn
|
ForceTemporarily // apply and force until the window is withdrawn
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SetRule {
|
enum SetRule {
|
||||||
UnusedSetRule = Unused,
|
UnusedSetRule = Unused,
|
||||||
SetRuleDummy = 256 // so that it's at least short int
|
SetRuleDummy = 256 // so that it's at least short int
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ForceRule {
|
enum ForceRule {
|
||||||
UnusedForceRule = Unused,
|
UnusedForceRule = Unused,
|
||||||
ForceRuleDummy = 256 // so that it's at least short int
|
ForceRuleDummy = 256 // so that it's at least short int
|
||||||
};
|
};
|
||||||
|
|
||||||
enum StringMatch {
|
enum StringMatch {
|
||||||
FirstStringMatch,
|
FirstStringMatch,
|
||||||
UnimportantMatch = FirstStringMatch,
|
UnimportantMatch = FirstStringMatch,
|
||||||
|
@ -188,6 +201,7 @@ private:
|
||||||
RegExpMatch,
|
RegExpMatch,
|
||||||
LastStringMatch = RegExpMatch
|
LastStringMatch = RegExpMatch
|
||||||
};
|
};
|
||||||
|
|
||||||
void readFromCfg(const KConfigGroup& cfg);
|
void readFromCfg(const KConfigGroup& cfg);
|
||||||
static SetRule readSetRule(const KConfigGroup&, const QString& key);
|
static SetRule readSetRule(const KConfigGroup&, const QString& key);
|
||||||
static ForceRule readForceRule(const KConfigGroup&, const QString& key);
|
static ForceRule readForceRule(const KConfigGroup&, const QString& key);
|
||||||
|
@ -198,6 +212,7 @@ private:
|
||||||
static bool checkSetStop(SetRule rule);
|
static bool checkSetStop(SetRule rule);
|
||||||
static bool checkForceStop(ForceRule rule);
|
static bool checkForceStop(ForceRule rule);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int temporary_state; // e.g. for kstart
|
int temporary_state; // e.g. for kstart
|
||||||
QByteArray ruleid;
|
QByteArray ruleid;
|
||||||
QString description;
|
QString description;
|
||||||
|
@ -277,6 +292,7 @@ private:
|
||||||
ForceRule disableglobalshortcutsrule;
|
ForceRule disableglobalshortcutsrule;
|
||||||
bool demandattention;
|
bool demandattention;
|
||||||
SetRule demandattentionrule;
|
SetRule demandattentionrule;
|
||||||
|
|
||||||
friend QDebug& operator<<(QDebug& stream, const Rules*);
|
friend QDebug& operator<<(QDebug& stream, const Rules*);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -286,6 +302,7 @@ class RuleBook : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
virtual ~RuleBook();
|
virtual ~RuleBook();
|
||||||
|
|
||||||
WindowRules find(const Client*, bool);
|
WindowRules find(const Client*, bool);
|
||||||
void discardUsed(Client* c, bool withdraw);
|
void discardUsed(Client* c, bool withdraw);
|
||||||
void setUpdatesDisabled(bool disable);
|
void setUpdatesDisabled(bool disable);
|
||||||
|
@ -293,6 +310,7 @@ public:
|
||||||
void load();
|
void load();
|
||||||
void edit(Client* c, bool whole_app);
|
void edit(Client* c, bool whole_app);
|
||||||
void requestDiskStorage();
|
void requestDiskStorage();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void temporaryRulesMessage(const QString&);
|
void temporaryRulesMessage(const QString&);
|
||||||
void cleanupTemporaryRules();
|
void cleanupTemporaryRules();
|
||||||
|
@ -367,8 +385,7 @@ void WindowRules::remove(Rules* rule)
|
||||||
if (pos != rules.end())
|
if (pos != rules.end())
|
||||||
rules.erase(pos);
|
rules.erase(pos);
|
||||||
}
|
}
|
||||||
|
#endif // KCMRULES
|
||||||
#endif
|
|
||||||
|
|
||||||
QDebug& operator<<(QDebug& stream, const Rules*);
|
QDebug& operator<<(QDebug& stream, const Rules*);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue