diff --git a/kcmkwin/kwinrules/package/contents/ui/RulesEditor.qml b/kcmkwin/kwinrules/package/contents/ui/RulesEditor.qml index 5c842f05ab..b118024229 100644 --- a/kcmkwin/kwinrules/package/contents/ui/RulesEditor.qml +++ b/kcmkwin/kwinrules/package/contents/ui/RulesEditor.qml @@ -225,7 +225,7 @@ ScrollViewKCM { return i18nc("Size (width, height)", "(%1, %2)", value.width, value.height); case RuleItem.Option: return options.textOfValue(value); - case RuleItem.FlagsOption: + case RuleItem.NetTypes: var selectedValue = value.toString(2).length - 1; return options.textOfValue(selectedValue); } diff --git a/kcmkwin/kwinrules/package/contents/ui/ValueEditor.qml b/kcmkwin/kwinrules/package/contents/ui/ValueEditor.qml index b0deab6928..9c858cc564 100644 --- a/kcmkwin/kwinrules/package/contents/ui/ValueEditor.qml +++ b/kcmkwin/kwinrules/package/contents/ui/ValueEditor.qml @@ -43,7 +43,7 @@ Loader { case RuleItem.String: return stringEditor case RuleItem.Integer: return integerEditor case RuleItem.Option: return optionEditor - case RuleItem.FlagsOption: return flagsEditor + case RuleItem.NetTypes: return netTypesEditor case RuleItem.Percentage: return percentageEditor case RuleItem.Point: return coordinateEditor case RuleItem.Size: return coordinateEditor @@ -113,12 +113,13 @@ Loader { } Component { - id: flagsEditor + id: netTypesEditor OptionsComboBox { flat: true model: ruleOptions multipleChoice: true - selectionMask: ruleValue + // If NET::AllTypesMask (-1), select everything + selectionMask: (ruleValue == -1) ? 0x3BF : ruleValue onActivated: { valueEditor.valueEdited(selectionMask); } diff --git a/kcmkwin/kwinrules/ruleitem.cpp b/kcmkwin/kwinrules/ruleitem.cpp index ff8047e71d..1c7f8a4eab 100644 --- a/kcmkwin/kwinrules/ruleitem.cpp +++ b/kcmkwin/kwinrules/ruleitem.cpp @@ -157,7 +157,7 @@ QVariant RuleItem::options() const void RuleItem::setOptionsData(const QList &data) { if (!m_options) { - if (m_type != Option && m_type != FlagsOption) { + if (m_type != Option && m_type != NetTypes) { return; } m_options = new OptionsModel(); @@ -202,12 +202,13 @@ QVariant RuleItem::typedValue(const QVariant &value, const RuleItem::Type type) case Integer: case Percentage: return value.toInt(); - case FlagsOption: - // HACK: Currently, the only user of this is "types" property - if (value.toInt() == -1) { //NET:AllTypesMask - return 0x3FF - 0x040; //All possible flags minus NET::Override (deprecated) + case NetTypes: { + const int usefulTypes = value.toInt() & 0x3BF; // remove NET::Override=0x040 (deprecated) + if (usefulTypes == 0 || usefulTypes == 0x3BF) { // if no flags or all of them are selected + return -1; // return NET:AllTypesMask } return value.toInt(); + } case Point: return value.toPoint(); case Size: diff --git a/kcmkwin/kwinrules/ruleitem.h b/kcmkwin/kwinrules/ruleitem.h index a8fe25ec23..c1c4399f7b 100644 --- a/kcmkwin/kwinrules/ruleitem.h +++ b/kcmkwin/kwinrules/ruleitem.h @@ -41,7 +41,7 @@ public: String, Integer, Option, - FlagsOption, + NetTypes, Percentage, Point, Size, diff --git a/kcmkwin/kwinrules/rulesmodel.cpp b/kcmkwin/kwinrules/rulesmodel.cpp index 0044837f1a..12dd4c775d 100644 --- a/kcmkwin/kwinrules/rulesmodel.cpp +++ b/kcmkwin/kwinrules/rulesmodel.cpp @@ -373,7 +373,7 @@ void RulesModel::populateRuleList() wmclasscomplete->setFlag(RuleItem::AlwaysEnabled); auto types = addRule(new RuleItem(QLatin1String("types"), - RulePolicy::NoPolicy, RuleItem::FlagsOption, + RulePolicy::NoPolicy, RuleItem::NetTypes, i18n("Window types"), i18n("Window matching"), QIcon::fromTheme("window-duplicate"))); types->setOptionsData(windowTypesModelData()); @@ -660,7 +660,7 @@ void RulesModel::setWindowProperties(const QVariantMap &info, bool forceValue) if (window_type == NET::Unknown) { window_type = NET::Normal; } - m_rules["types"]->setSuggestedValue(1 << window_type, forceValue); + m_rules["types"]->setSuggestedValue(1 << window_type); const QString wmsimpleclass = info.value("resourceClass").toString(); const QString wmcompleteclass = QStringLiteral("%1 %2").arg(info.value("resourceName").toString(),