mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
kwin: ensure there are no duplicate rules
because KStandardDirs::findAllResources() will return local and global rules thus if there is a global and local rule file with the same name there would be duplicates, using KStandardDirs::NoDuplicates flag will not solve that because the rules are merged into the main kwinrulesrc config Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
96a522adbd
commit
ac19d657ae
3 changed files with 16 additions and 2 deletions
|
@ -134,6 +134,7 @@ static int limit0to4(int i)
|
||||||
|
|
||||||
void Rules::readFromCfg(const KConfigGroup& cfg)
|
void Rules::readFromCfg(const KConfigGroup& cfg)
|
||||||
{
|
{
|
||||||
|
ruleid = cfg.readEntry("id", QByteArray());
|
||||||
description = cfg.readEntry("Description");
|
description = cfg.readEntry("Description");
|
||||||
if (description.isEmpty()) // capitalized first, lowercase for backwards compatibility
|
if (description.isEmpty()) // capitalized first, lowercase for backwards compatibility
|
||||||
description = cfg.readEntry("description");
|
description = cfg.readEntry("description");
|
||||||
|
@ -232,6 +233,7 @@ void Rules::readFromCfg(const KConfigGroup& cfg)
|
||||||
|
|
||||||
void Rules::write(KConfigGroup& cfg) const
|
void Rules::write(KConfigGroup& cfg) const
|
||||||
{
|
{
|
||||||
|
cfg.writeEntry("id", ruleid);
|
||||||
cfg.writeEntry("Description", description);
|
cfg.writeEntry("Description", description);
|
||||||
// always write wmclass
|
// always write wmclass
|
||||||
WRITE_MATCH_STRING(wmclass, (const char*), true);
|
WRITE_MATCH_STRING(wmclass, (const char*), true);
|
||||||
|
@ -972,21 +974,32 @@ void RuleBook::edit(Client* c, bool whole_app)
|
||||||
void RuleBook::load()
|
void RuleBook::load()
|
||||||
{
|
{
|
||||||
deleteAll();
|
deleteAll();
|
||||||
|
QList<QByteArray> ruleids;
|
||||||
KConfig cfg("kwinrulesrc", KConfig::NoGlobals);
|
KConfig cfg("kwinrulesrc", KConfig::NoGlobals);
|
||||||
int count = cfg.group("General").readEntry("count", 0);
|
int count = cfg.group("General").readEntry("count", 0);
|
||||||
for (int i = 1; i <= count; ++i) {
|
for (int i = 1; i <= count; ++i) {
|
||||||
KConfigGroup cg(&cfg, QString::number(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* rule = new Rules(cg);
|
||||||
m_rules.append(rule);
|
m_rules.append(rule);
|
||||||
|
ruleids.append(id);
|
||||||
}
|
}
|
||||||
const QStringList kwinrules = KGlobal::dirs()->findAllResources("data", "kwin/default_rules/*.kwinrules");
|
const QStringList kwinrules = KGlobal::dirs()->findAllResources("data", "kwin/default_rules/*.kwinrules");
|
||||||
foreach (const QString &kwinrule, kwinrules) {
|
foreach (const QString &kwinrule, kwinrules) {
|
||||||
KConfig cfg(kwinrule, KConfig::NoGlobals);
|
KConfig cfg(kwinrule, KConfig::NoGlobals);
|
||||||
int count = cfg.group("General").readEntry("count", 0);
|
count = cfg.group("General").readEntry("count", 0);
|
||||||
for (int i = 1; i <= count; ++i) {
|
for (int i = 1; i <= count; ++i) {
|
||||||
KConfigGroup cg(&cfg, QString::number(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* rule = new Rules(cg);
|
||||||
m_rules.append(rule);
|
m_rules.append(rule);
|
||||||
|
ruleids.append(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,6 +199,7 @@ private:
|
||||||
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;
|
||||||
QString description;
|
QString description;
|
||||||
QByteArray wmclass;
|
QByteArray wmclass;
|
||||||
StringMatch wmclassmatch;
|
StringMatch wmclassmatch;
|
||||||
|
|
|
@ -11,4 +11,4 @@ types=32
|
||||||
wmclass=plasma
|
wmclass=plasma
|
||||||
wmclasscomplete=false
|
wmclasscomplete=false
|
||||||
wmclassmatch=1
|
wmclassmatch=1
|
||||||
|
id=191497c49c1ad8700a041a08f204df2e6a6a2a97
|
||||||
|
|
Loading…
Add table
Reference in a new issue