Differential D7624 Diff 19306 desktoppackage/contents/configuration/ConfigurationContainmentActions.qml
Changeset View
Changeset View
Standalone View
Standalone View
desktoppackage/contents/configuration/ConfigurationContainmentActions.qml
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 30 | property var prettyStrings: { | |||
---|---|---|---|---|---|
42 | "AltModifier": i18nd("plasma_shell_org.kde.plasma.desktop", "Alt"), | 42 | "AltModifier": i18nd("plasma_shell_org.kde.plasma.desktop", "Alt"), | ||
43 | "MetaModifier": i18nd("plasma_shell_org.kde.plasma.desktop", "Meta") | 43 | "MetaModifier": i18nd("plasma_shell_org.kde.plasma.desktop", "Meta") | ||
44 | } | 44 | } | ||
45 | 45 | | |||
46 | function saveConfig() { | 46 | function saveConfig() { | ||
47 | configDialog.currentContainmentActionsModel.save(); | 47 | configDialog.currentContainmentActionsModel.save(); | ||
48 | } | 48 | } | ||
49 | 49 | | |||
50 | Column { | 50 | Connections { | ||
51 | id: mainColumn | 51 | target: configDialog.currentContainmentActionsModel | ||
52 | anchors { | 52 | onConfigurationChanged: root.configurationChanged() | ||
53 | top: parent.top | | |||
54 | topMargin: 25 | | |||
55 | horizontalCenter: parent.horizontalCenter | | |||
56 | } | 53 | } | ||
57 | 54 | | |||
55 | GridLayout { | ||||
56 | id: mainColumn | ||||
57 | flow: GridLayout.TopToBottom | ||||
58 | y: 25 | ||||
59 | width: parent.width | ||||
60 | | ||||
58 | Repeater { | 61 | Repeater { | ||
62 | id: actionsRepeater | ||||
59 | model: configDialog.currentContainmentActionsModel | 63 | model: configDialog.currentContainmentActionsModel | ||
60 | delegate: RowLayout { | 64 | | ||
61 | width: root.width | | |||
62 | MouseEventInputButton { | 65 | MouseEventInputButton { | ||
63 | defaultText: prettyStrings ? (prettyStrings[model.action.split(';')[1]] ? prettyStrings[model.action.split(';')[1]] + "+" : "") + prettyStrings[model.action.split(';')[0]] : "" | 66 | Layout.column: 0 | ||
67 | Layout.row: index | ||||
68 | Layout.fillWidth: true | ||||
69 | Layout.minimumWidth: implicitWidth | ||||
70 | defaultText: { | ||||
71 | var splitAction = model.action.split(';'); | ||||
72 | | ||||
73 | var button = splitAction[0]; | ||||
74 | var modifiers = (splitAction[1] || "").split('|').filter(function (item) { | ||||
75 | return item !== "NoModifier"; | ||||
76 | }); | ||||
77 | | ||||
78 | var parts = modifiers; | ||||
79 | modifiers.push(button); | ||||
80 | | ||||
81 | return parts.map(function (item) { | ||||
82 | return prettyStrings[item] || item; | ||||
83 | }).join(i18nc("Concatenation sign for shortcuts, e.g. Ctrl+Shift", "+")); | ||||
84 | } | ||||
64 | eventString: model.action | 85 | eventString: model.action | ||
65 | onEventStringChanged: { | 86 | onEventStringChanged: { | ||
66 | configDialog.currentContainmentActionsModel.update(index, eventString, model.pluginName); | 87 | configDialog.currentContainmentActionsModel.update(index, eventString, model.pluginName); | ||
67 | } | 88 | } | ||
68 | } | 89 | } | ||
90 | } | ||||
91 | | ||||
92 | Repeater { | ||||
93 | model: configDialog.currentContainmentActionsModel | ||||
69 | 94 | | |||
70 | QtControls.ComboBox { | 95 | QtControls.ComboBox { | ||
71 | id: pluginsCombo | 96 | id: pluginsCombo | ||
72 | Layout.fillWidth: true | 97 | Layout.fillWidth: true | ||
98 | Layout.column: 1 | ||||
99 | Layout.row: index | ||||
100 | // both MouseEventInputButton and this ComboBox have fillWidth for a uniform layout | ||||
101 | // however, their implicit sizes is taken into account and they compete against | ||||
102 | // each other for available space. By setting an insane preferredWidth we give | ||||
103 | // ComboBox a greater share of the available space | ||||
104 | Layout.preferredWidth: 9000 | ||||
73 | model: configDialog.containmentActionConfigModel | 105 | model: configDialog.containmentActionConfigModel | ||
74 | textRole: "name" | 106 | textRole: "name" | ||
75 | property bool initialized: false | 107 | property bool initialized: false | ||
76 | Component.onCompleted: { | 108 | Component.onCompleted: { | ||
77 | for (var i = 0; i < configDialog.containmentActionConfigModel.count; ++i) { | 109 | for (var i = 0; i < configDialog.containmentActionConfigModel.count; ++i) { | ||
78 | if (configDialog.containmentActionConfigModel.get(i).pluginName == pluginName) { | 110 | if (configDialog.containmentActionConfigModel.get(i).pluginName == pluginName) { | ||
79 | pluginsCombo.currentIndex = i; | 111 | pluginsCombo.currentIndex = i; | ||
80 | break; | 112 | break; | ||
81 | } | 113 | } | ||
82 | } | 114 | } | ||
83 | pluginsCombo.initialized = true; | 115 | pluginsCombo.initialized = true; | ||
84 | } | 116 | } | ||
85 | onCurrentIndexChanged: { | 117 | onCurrentIndexChanged: { | ||
86 | if (initialized && configDialog.containmentActionConfigModel.get(currentIndex).pluginName != pluginName) { | 118 | if (initialized && configDialog.containmentActionConfigModel.get(currentIndex).pluginName != pluginName) { | ||
87 | configDialog.currentContainmentActionsModel.update(index, action, configDialog.containmentActionConfigModel.get(currentIndex).pluginName); | 119 | configDialog.currentContainmentActionsModel.update(index, action, configDialog.containmentActionConfigModel.get(currentIndex).pluginName); | ||
88 | root.configurationChanged(); | | |||
89 | } | 120 | } | ||
90 | } | 121 | } | ||
91 | } | 122 | } | ||
123 | } | ||||
124 | | ||||
125 | Repeater { | ||||
126 | model: configDialog.currentContainmentActionsModel | ||||
127 | | ||||
128 | RowLayout { | ||||
129 | Layout.column: 2 | ||||
130 | Layout.row: index | ||||
131 | | ||||
92 | QtControls.Button { | 132 | QtControls.Button { | ||
93 | iconName: "configure" | 133 | iconName: "configure" | ||
94 | width: height | 134 | width: height | ||
95 | enabled: model.hasConfigurationInterface | 135 | enabled: model.hasConfigurationInterface | ||
96 | onClicked: { | 136 | onClicked: { | ||
97 | configDialog.currentContainmentActionsModel.showConfiguration(index, this); | 137 | configDialog.currentContainmentActionsModel.showConfiguration(index, this); | ||
98 | } | 138 | } | ||
99 | } | 139 | } | ||
100 | QtControls.Button { | 140 | QtControls.Button { | ||
101 | iconName: "dialog-information" | 141 | iconName: "dialog-information" | ||
102 | width: height | 142 | width: height | ||
103 | onClicked: { | 143 | onClicked: { | ||
104 | configDialog.currentContainmentActionsModel.showAbout(index, this); | 144 | configDialog.currentContainmentActionsModel.showAbout(index, this); | ||
105 | } | 145 | } | ||
106 | } | 146 | } | ||
107 | QtControls.Button { | 147 | QtControls.Button { | ||
108 | iconName: "list-remove" | 148 | iconName: "list-remove" | ||
109 | width: height | 149 | width: height | ||
110 | onClicked: { | 150 | onClicked: { | ||
111 | configDialog.currentContainmentActionsModel.remove(index); | 151 | configDialog.currentContainmentActionsModel.remove(index); | ||
112 | root.configurationChanged(); | | |||
113 | } | 152 | } | ||
114 | } | 153 | } | ||
115 | } | 154 | } | ||
116 | } | 155 | } | ||
156 | | ||||
117 | MouseEventInputButton { | 157 | MouseEventInputButton { | ||
118 | anchors.left: parent.left | 158 | anchors.left: parent.left | ||
119 | defaultText: i18nd("plasma_shell_org.kde.plasma.desktop", "Add Action"); | 159 | defaultText: i18nd("plasma_shell_org.kde.plasma.desktop", "Add Action"); | ||
120 | onEventStringChanged: { | 160 | onEventStringChanged: { | ||
121 | configDialog.currentContainmentActionsModel.append(eventString, "org.kde.contextmenu"); | 161 | configDialog.currentContainmentActionsModel.append(eventString, "org.kde.contextmenu"); | ||
122 | root.configurationChanged(); | | |||
123 | } | 162 | } | ||
124 | } | 163 | } | ||
125 | } | 164 | } | ||
126 | 165 | | |||
127 | } | 166 | } |