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
This commit is contained in:
Ismael Asensio 2020-10-28 23:10:38 +01:00
parent f26eeb9706
commit bf7e7b2130
3 changed files with 8 additions and 6 deletions

View file

@ -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

View file

@ -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()

View file

@ -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();