kwinrules: Do not force suggested property values
This is unnecesary and also causes a bug, overwriting previously set properties with the new detected values when calling for the menu `Edit window properties`.
This commit is contained in:
parent
a89b66a2e1
commit
335eca223a
5 changed files with 12 additions and 22 deletions
|
@ -125,11 +125,8 @@ QVariant RuleItem::suggestedValue() const
|
|||
return m_suggestedValue;
|
||||
}
|
||||
|
||||
void RuleItem::setSuggestedValue(QVariant value, bool forceValue)
|
||||
void RuleItem::setSuggestedValue(QVariant value)
|
||||
{
|
||||
if (forceValue) {
|
||||
setValue(value);
|
||||
}
|
||||
m_suggestedValue = value.isNull() ? QVariant() : typedValue(value);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
QVariant value() const;
|
||||
void setValue(QVariant value);
|
||||
QVariant suggestedValue() const;
|
||||
void setSuggestedValue(QVariant value, bool forceValue = false);
|
||||
void setSuggestedValue(QVariant value);
|
||||
|
||||
QVariant options() const;
|
||||
void setOptionsData(const QList<OptionsModel::Data> &data);
|
||||
|
|
|
@ -57,7 +57,7 @@ Rules* RulesDialog::edit(Rules* r, const QVariantMap& info, bool show_hints)
|
|||
|
||||
m_rulesModel->importFromRules(m_rules);
|
||||
if (!info.isEmpty()) {
|
||||
m_rulesModel->setWindowProperties(info, true);
|
||||
m_rulesModel->setSuggestedProperties(info);
|
||||
}
|
||||
|
||||
exec();
|
||||
|
|
|
@ -662,16 +662,16 @@ const QHash<QString, QString> RulesModel::x11PropertyHash()
|
|||
return propertyToRule;
|
||||
};
|
||||
|
||||
void RulesModel::setWindowProperties(const QVariantMap &info, bool forceValue)
|
||||
void RulesModel::setSuggestedProperties(const QVariantMap &info)
|
||||
{
|
||||
// Properties that cannot be directly applied via x11PropertyHash
|
||||
const QPoint position = QPoint(info.value("x").toInt(), info.value("y").toInt());
|
||||
const QSize size = QSize(info.value("width").toInt(), info.value("height").toInt());
|
||||
|
||||
m_rules["position"]->setSuggestedValue(position, forceValue);
|
||||
m_rules["size"]->setSuggestedValue(size, forceValue);
|
||||
m_rules["minsize"]->setSuggestedValue(size, forceValue);
|
||||
m_rules["maxsize"]->setSuggestedValue(size, forceValue);
|
||||
m_rules["position"]->setSuggestedValue(position);
|
||||
m_rules["size"]->setSuggestedValue(size);
|
||||
m_rules["minsize"]->setSuggestedValue(size);
|
||||
m_rules["maxsize"]->setSuggestedValue(size);
|
||||
|
||||
NET::WindowType window_type = static_cast<NET::WindowType>(info.value("type", 0).toInt());
|
||||
if (window_type == NET::Unknown) {
|
||||
|
@ -682,15 +682,10 @@ void RulesModel::setWindowProperties(const QVariantMap &info, bool forceValue)
|
|||
const QString wmsimpleclass = info.value("resourceClass").toString();
|
||||
const QString wmcompleteclass = QStringLiteral("%1 %2").arg(info.value("resourceName").toString(),
|
||||
info.value("resourceClass").toString());
|
||||
const bool isComplete = m_rules.value("wmclasscomplete")->value().toBool();
|
||||
|
||||
m_rules["wmclass"]->setSuggestedValue(wmsimpleclass);
|
||||
m_rules["wmclasshelper"]->setSuggestedValue(wmcompleteclass);
|
||||
|
||||
if (forceValue) {
|
||||
m_rules["wmclass"]->setValue(isComplete ? wmcompleteclass : wmsimpleclass);
|
||||
}
|
||||
|
||||
const auto ruleForProperty = x11PropertyHash();
|
||||
for (QString &property : info.keys()) {
|
||||
if (!ruleForProperty.contains(property)) {
|
||||
|
@ -699,13 +694,10 @@ void RulesModel::setWindowProperties(const QVariantMap &info, bool forceValue)
|
|||
const QString ruleKey = ruleForProperty.value(property, QString());
|
||||
Q_ASSERT(hasRule(ruleKey));
|
||||
|
||||
m_rules[ruleKey]->setSuggestedValue(info.value(property), forceValue);
|
||||
m_rules[ruleKey]->setSuggestedValue(info.value(property));
|
||||
}
|
||||
|
||||
emit dataChanged(index(0), index(rowCount()-1), {RulesModel::SuggestedValueRole});
|
||||
if (!forceValue) {
|
||||
emit suggestionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -840,7 +832,8 @@ void RulesModel::selectX11Window()
|
|||
return;
|
||||
}
|
||||
const QVariantMap windowInfo = reply.value();
|
||||
setWindowProperties(windowInfo);
|
||||
setSuggestedProperties(windowInfo);
|
||||
emit suggestionsChanged();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
void importFromRules(Rules *rules);
|
||||
Rules *exportToRules() const;
|
||||
|
||||
void setWindowProperties(const QVariantMap &info, bool forceValue = false);
|
||||
void setSuggestedProperties(const QVariantMap &info);
|
||||
|
||||
QString description() const;
|
||||
void setDescription(const QString &description);
|
||||
|
|
Loading…
Reference in a new issue