Commit bf7e7b21 authored by Ismael Asensio's avatar Ismael Asensio

kwinrules: Improvements on Detect Properties button

Slight UX and code improvents:

- Disable the detection button when property sheet is open.

- Add a minimum limit (smallDuration) to the delay before detecting
a window. Otherwise we freeze the window before even showing the
button release feedback, which can feel unexpected

- Prefer Q_INVOKABLE over public slot to expose method to QML
parent f26eeb97
......@@ -93,12 +93,16 @@ ScrollViewKCM {
QQC2.Button {
text: i18n("Detect Window Properties")
icon.name: "edit-find"
enabled: !propertySheet.sheetOpen
onClicked: {
rulesModel.detectWindowProperties(delaySpin.value);
overlayModel.onlySuggestions = true;
rulesModel.detectWindowProperties(Math.max(delaySpin.value * 1000,
Kirigami.Units.shortDuration));
}
}
QQC2.SpinBox {
id: delaySpin
enabled: !propertySheet.sheetOpen
Layout.preferredWidth: Kirigami.Units.gridUnit * 8
from: 0
to: 30
......
......@@ -809,9 +809,9 @@ QList<OptionsModel::Data> RulesModel::colorSchemesModelData() const
return modelData;
}
void RulesModel::detectWindowProperties(int secs)
void RulesModel::detectWindowProperties(int miliseconds)
{
QTimer::singleShot(secs*1000, this, &RulesModel::selectX11Window);
QTimer::singleShot(miliseconds, this, &RulesModel::selectX11Window);
}
void RulesModel::selectX11Window()
......
......@@ -76,9 +76,7 @@ public:
void setDescription(const QString &description);
QString warningMessage() const;
public slots:
void detectWindowProperties(int secs);
Q_INVOKABLE void detectWindowProperties(int miliseconds);
signals:
void descriptionChanged();
......
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