kcms/rules: Use Kirigami.Dialog for error messages

This commit is contained in:
Ismael Asensio 2022-12-05 23:10:35 +01:00
parent 1d5b3a3c89
commit bee2c65918

View file

@ -4,10 +4,10 @@
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/ */
import QtQuick 2.14 import QtQuick 2.15
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.15
import QtQuick.Controls 2.14 as QQC2 import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami 2.12 as Kirigami import org.kde.kirigami 2.19 as Kirigami
import org.kde.kcm 1.2 import org.kde.kcm 1.2
import org.kde.kitemmodels 1.0 import org.kde.kitemmodels 1.0
import org.kde.kcms.kwinrules 1.0 import org.kde.kcms.kwinrules 1.0
@ -97,7 +97,7 @@ ScrollViewKCM {
id: detectButton id: detectButton
text: i18n("Detect Window Properties") text: i18n("Detect Window Properties")
icon.name: "edit-find" icon.name: "edit-find"
enabled: !propertySheet.sheetOpen && !errorSheet.sheetOpen enabled: !propertySheet.sheetOpen && !errorDialog.visible
onClicked: { onClicked: {
overlayModel.onlySuggestions = true; overlayModel.onlySuggestions = true;
kcm.rulesModel.detectWindowProperties(Math.max(delaySpin.value * 1000, kcm.rulesModel.detectWindowProperties(Math.max(delaySpin.value * 1000,
@ -132,26 +132,38 @@ ScrollViewKCM {
Connections { Connections {
target: kcm.rulesModel target: kcm.rulesModel
function onShowSuggestions() { function onShowSuggestions() {
if (errorDialog.visible) {
return;
}
overlayModel.onlySuggestions = true; overlayModel.onlySuggestions = true;
propertySheet.sheetOpen = true; propertySheet.sheetOpen = true;
} }
function onShowErrorMessage(title, message) { function onShowErrorMessage(title, message) {
errorSheet.title = title errorDialog.title = title
errorSheet.message = message errorDialog.message = message
errorSheet.open() errorDialog.open()
} }
} }
Kirigami.OverlaySheet { Kirigami.Dialog {
id: errorSheet id: errorDialog
property alias message: errorLabel.text property alias message: errorLabel.text
Kirigami.Heading { preferredWidth: rulesEditor.width - Kirigami.Units.gridUnit * 6
id: errorLabel maximumWidth: Kirigami.Units.gridUnit * 35
level: 3 footer: null // Just use the close button on top
wrapMode: Text.WordWrap
Layout.fillWidth: true ColumnLayout {
// Wrap it in a Layout so we can apply margins to the text while keeping implicit sizes
Kirigami.Heading {
id: errorLabel
level: 4
wrapMode: Text.WordWrap
Layout.fillWidth: true
Layout.margins: Kirigami.Units.largeSpacing
}
} }
} }