Commit b20d5297 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Containment Actions Config] Cleanup layout and support multiple modifiers

Currently we only manage to display one modifier for each action but you can setup
multiple (which works fine, it's just the UI).
While at it, port it to a GridLayout to ensure action buttons adjust their width and
don't blow up the layout or truncate.

Differential Revision: https://phabricator.kde.org/D7624
parent d711ff0c
......@@ -47,48 +47,88 @@ Item {
configDialog.currentContainmentActionsModel.save();
}
Column {
Connections {
target: configDialog.currentContainmentActionsModel
onConfigurationChanged: root.configurationChanged()
}
GridLayout {
id: mainColumn
anchors {
top: parent.top
topMargin: 25
horizontalCenter: parent.horizontalCenter
}
flow: GridLayout.TopToBottom
y: 25
width: parent.width
Repeater {
id: actionsRepeater
model: configDialog.currentContainmentActionsModel
delegate: RowLayout {
width: root.width
MouseEventInputButton {
defaultText: prettyStrings ? (prettyStrings[model.action.split(';')[1]] ? prettyStrings[model.action.split(';')[1]] + "+" : "") + prettyStrings[model.action.split(';')[0]] : ""
eventString: model.action
onEventStringChanged: {
configDialog.currentContainmentActionsModel.update(index, eventString, model.pluginName);
}
MouseEventInputButton {
Layout.column: 0
Layout.row: index
Layout.fillWidth: true
Layout.minimumWidth: implicitWidth
defaultText: {
var splitAction = model.action.split(';');
var button = splitAction[0];
var modifiers = (splitAction[1] || "").split('|').filter(function (item) {
return item !== "NoModifier";
});
var parts = modifiers;
modifiers.push(button);
return parts.map(function (item) {
return prettyStrings[item] || item;
}).join(i18nc("Concatenation sign for shortcuts, e.g. Ctrl+Shift", "+"));
}
eventString: model.action
onEventStringChanged: {
configDialog.currentContainmentActionsModel.update(index, eventString, model.pluginName);
}
}
}
Repeater {
model: configDialog.currentContainmentActionsModel
QtControls.ComboBox {
id: pluginsCombo
Layout.fillWidth: true
model: configDialog.containmentActionConfigModel
textRole: "name"
property bool initialized: false
Component.onCompleted: {
for (var i = 0; i < configDialog.containmentActionConfigModel.count; ++i) {
if (configDialog.containmentActionConfigModel.get(i).pluginName == pluginName) {
pluginsCombo.currentIndex = i;
break;
}
QtControls.ComboBox {
id: pluginsCombo
Layout.fillWidth: true
Layout.column: 1
Layout.row: index
// both MouseEventInputButton and this ComboBox have fillWidth for a uniform layout
// however, their implicit sizes is taken into account and they compete against
// each other for available space. By setting an insane preferredWidth we give
// ComboBox a greater share of the available space
Layout.preferredWidth: 9000
model: configDialog.containmentActionConfigModel
textRole: "name"
property bool initialized: false
Component.onCompleted: {
for (var i = 0; i < configDialog.containmentActionConfigModel.count; ++i) {
if (configDialog.containmentActionConfigModel.get(i).pluginName == pluginName) {
pluginsCombo.currentIndex = i;
break;
}
pluginsCombo.initialized = true;
}
onCurrentIndexChanged: {
if (initialized && configDialog.containmentActionConfigModel.get(currentIndex).pluginName != pluginName) {
configDialog.currentContainmentActionsModel.update(index, action, configDialog.containmentActionConfigModel.get(currentIndex).pluginName);
root.configurationChanged();
}
pluginsCombo.initialized = true;
}
onCurrentIndexChanged: {
if (initialized && configDialog.containmentActionConfigModel.get(currentIndex).pluginName != pluginName) {
configDialog.currentContainmentActionsModel.update(index, action, configDialog.containmentActionConfigModel.get(currentIndex).pluginName);
}
}
}
}
Repeater {
model: configDialog.currentContainmentActionsModel
RowLayout {
Layout.column: 2
Layout.row: index
QtControls.Button {
iconName: "configure"
width: height
......@@ -109,17 +149,16 @@ Item {
width: height
onClicked: {
configDialog.currentContainmentActionsModel.remove(index);
root.configurationChanged();
}
}
}
}
MouseEventInputButton {
anchors.left: parent.left
defaultText: i18nd("plasma_shell_org.kde.plasma.desktop", "Add Action");
onEventStringChanged: {
configDialog.currentContainmentActionsModel.append(eventString, "org.kde.contextmenu");
root.configurationChanged();
}
}
}
......
......@@ -29,10 +29,6 @@ QtControls.Button {
checkable: true
property string eventString
implicitWidth: theme.mSize(theme.defaultFont).width * 15
Layout.minimumWidth: implicitWidth
Layout.maximumWidth: implicitWidth
onCheckedChanged: {
if (checked) {
text = i18nd("plasma_shell_org.kde.plasma.desktop", "Input Here");
......
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