kwinrules: Show error when detected window is unmanaged

BUG: 340477
This commit is contained in:
Ismael Asensio 2020-08-20 20:50:01 +02:00
parent bf7e7b2130
commit 1829dce1a9
3 changed files with 25 additions and 2 deletions

View file

@ -91,9 +91,10 @@ ScrollViewKCM {
Layout.fillWidth: true
}
QQC2.Button {
id: detectButton
text: i18n("Detect Window Properties")
icon.name: "edit-find"
enabled: !propertySheet.sheetOpen
enabled: !propertySheet.sheetOpen && !errorSheet.sheetOpen
onClicked: {
overlayModel.onlySuggestions = true;
rulesModel.detectWindowProperties(Math.max(delaySpin.value * 1000,
@ -102,7 +103,7 @@ ScrollViewKCM {
}
QQC2.SpinBox {
id: delaySpin
enabled: !propertySheet.sheetOpen
enabled: detectButton.enabled
Layout.preferredWidth: Kirigami.Units.gridUnit * 8
from: 0
to: 30
@ -120,6 +121,23 @@ ScrollViewKCM {
overlayModel.onlySuggestions = true;
propertySheet.sheetOpen = true;
}
function onShowErrorMessage(message) {
errorLabel.text = message
errorSheet.open()
}
}
Kirigami.OverlaySheet {
id: errorSheet
header: Kirigami.Heading {
text: i18n("Error")
}
Kirigami.Heading {
id: errorLabel
level: 3
wrapMode: Text.WordWrap
Layout.fillWidth: true
}
}
Kirigami.OverlaySheet {

View file

@ -829,6 +829,9 @@ void RulesModel::selectX11Window()
QDBusPendingReply<QVariantMap> reply = *self;
self->deleteLater();
if (!reply.isValid()) {
if (reply.error().name() == QLatin1String("org.kde.KWin.Error.InvalidWindow")) {
emit showErrorMessage(i18n("Could not detect window properties. The window is not managed by KWin."));
}
return;
}
const QVariantMap windowInfo = reply.value();

View file

@ -81,7 +81,9 @@ public:
signals:
void descriptionChanged();
void warningMessageChanged();
void showSuggestions();
void showErrorMessage(const QString &message);
void virtualDesktopsUpdated();