[kcm/kwinrules] Improve export buttons

Summary:
Small UX improvements when exporting rules

Add a `Select All` button
Disable `Save` if no rules are selected
In export mode set button text to `Cancel Export`

Test Plan: {F8276279}

Reviewers: #kwin, #vdg, filipf

Reviewed By: #vdg, filipf

Subscribers: filipf, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29341
icc-effect-master
Ismael Asensio 2020-05-01 00:46:19 +02:00
parent 3092043be5
commit 1a3cb256d7
1 changed files with 18 additions and 4 deletions

View File

@ -79,11 +79,24 @@ ScrollViewKCM {
showCloseButton: true showCloseButton: true
text: i18n("Select the rules to export") text: i18n("Select the rules to export")
actions: [ actions: [
Kirigami.Action {
iconName: "object-select-symbolic"
text: checked ? i18n("Unselect All") : i18n("Select All")
checkable: true
checked: selectedIndexes.length == ruleBookView.count
onToggled: {
if (checked) {
selectedIndexes = [...Array(ruleBookView.count).keys()]
} else {
selectedIndexes = [];
}
}
}
,
Kirigami.Action { Kirigami.Action {
iconName: "document-save" iconName: "document-save"
text: i18n("Save Rules") text: i18n("Save Rules")
// FIXME: It does not update on selection changes enabled: selectedIndexes.length > 0
// enabled: selectedIndexes.length > 0
onTriggered: { onTriggered: {
exportDialog.active = true; exportDialog.active = true;
} }
@ -112,8 +125,8 @@ ScrollViewKCM {
} }
} }
QQC2.Button { QQC2.Button {
text: i18n("Export...") text: checked ? i18n("Cancel Export") : i18n("Export...")
icon.name: "document-export" icon.name: exportInfo.visible ? "dialog-cancel" : "document-export"
enabled: ruleBookView.count > 0 enabled: ruleBookView.count > 0
checkable: true checkable: true
checked: exportInfo.visible checked: exportInfo.visible
@ -213,6 +226,7 @@ ScrollViewKCM {
} else { } else {
if (position >= 0) { selectedIndexes.splice(position, 1); } if (position >= 0) { selectedIndexes.splice(position, 1); }
} }
selectedIndexesChanged();
} }
} }
} }