Replacement KCM to configure kwin rules, using a QML-based UI.
After some work on the task T12729, it is almost feature-par with the previous module, and adapted to the recent move to KConfigXT.
ngraham | |
davidedmundson | |
zzag |
Plasma | |
KWin | |
VDG |
Replacement KCM to configure kwin rules, using a QML-based UI.
After some work on the task T12729, it is almost feature-par with the previous module, and adapted to the recent move to KConfigXT.
No Linters Available |
No Unit Test Coverage |
Buildable 24534 | |
Build 24552: arc lint + arc unit |
This is a huge improvement over the UI of the old one, very nice! However I can't actually get it to work. I target Kate, select "Exact Match" on the window class, and apply some settings, but they don't take effect. Am I doing something wrong? I've restarted KWin after applying this patch.
kcmkwin/kwinrules/package/contents/ui/OptionsComboBox.qml | ||
---|---|---|
70 ↗ | (On Diff #78988) | would be nice if clicking anywhere in the row activated that row's checkbox |
kcmkwin/kwinrules/package/contents/ui/RuleItemDelegate.qml | ||
27 ↗ | (On Diff #78988) | These listitems shouldn't change their background colors on hover, since nothing happens when they're selected. You can see how I did that in https://cgit.kde.org/plasma-desktop.git/commit/?id=5a5e0bc0880b6b21c60b5f874f7eddc2a7939a48 |
kcmkwin/kwinrules/package/contents/ui/RulesEditor.qml | ||
44 ↗ | (On Diff #78988) | Perhaps this should be checked when creating a new rule, or else it looks like there aren't any properties you can apply to the window when creating the rule |
kcmkwin/kwinrules/package/contents/ui/RulesList.qml | ||
55 ↗ | (On Diff #78988) | Add a centered placeholder message using a disabled level 3 Heading in here when there are no rules |
104 ↗ | (On Diff #78988) | Disable this when there are no rules |
116 ↗ | (On Diff #78988) | All button text needs to begin with an action verb and end with an ellipsis if more actions are required to complete the action. So this should be "Add New..." |
kcmkwin/kwinrules/package/contents/ui/ValueEditor.qml | ||
137 ↗ | (On Diff #78988) | Give this a minimum width, or else the rowlayout gets wider with every digit added to the number and resizes the combobox next to it |
kcmkwin/kwinrules/rulesmodel.cpp | ||
216 ↗ | (On Diff #78988) | Maybe "Exact Match" should be the default settting so this message isn't always shown for every new rule you add |
Address some comments:
kcmkwin/kwinrules/package/contents/ui/RulesEditor.qml | ||
---|---|---|
44 ↗ | (On Diff #78988) | I have tried it, but it was a bit messy since the editor page does not differentiate when it's a new rule or any other. If I set it whenever no optional settings are enabled, it gives a confusing feeling with all the rows just appearing and dissapearing on a single check. Maye a hint like this suffice? |
Improve UX for new rules:
kcmkwin/kwinrules/rulesmodel.cpp | ||
---|---|---|
216 ↗ | (On Diff #78988) | Agree. I have set it in a simple way for new rules added. I would like though, to set this directly on the config schema defaults, but for that to work I'll need to modify some bits of the KConfigXT helper classes, which I have planned for a later patch along some other changes to improve integration. |
Something changed because now with the default System Setting window size, when I click on the create new rule button, I see this:
Also when I click on Detect window properties, it always enters the text "navigator" into the window class text field, but adds the window title into the window title text box which is hidden by default. Is that expected?
With respect to how to make the view less overwhelming, here's an idea: make each section header collapsible, and collapse all sections by default except for the Window Matching header, whose contents would be entirely visible by default. Then remember the expanded/collapsed state for each section globally, so a person who expands them all will always see them expanded in the future.
kcmkwin/kwinrules/package/contents/ui/OptionsComboBox.qml | ||
---|---|---|
70 ↗ | (On Diff #78988) | Hmm, this is not fixed yet for me. Probably you need to put a MouseArea inside the ItemDelegate that toggles the checkbox if clicked. |
kcmkwin/kwinrules/package/contents/ui/RuleItemDelegate.qml | ||
44 ↗ | (On Diff #78988) | Same here; would be nice if clicking on the icon or text also activated the checkbox. |
kcmkwin/kwinrules/package/contents/ui/RulesList.qml | ||
106 ↗ | (On Diff #78988) | Give it ellipses ("Import...") |
kcmkwin/kwinrules/package/contents/ui/ValueEditor.qml | ||
140 ↗ | (On Diff #78988) | Needs to be a bit bigger; the text still expands when set to 100%. |
Something changed because now with the default System Setting window size, when I click on the create new rule button, I see this:
I can reproduce it. I'm making the ConfigModule.columnWidth a bit wider to fix it for the default SySe size.
I'd like to set a different width for each page, but that's not possible currently, I think.
Also when I click on Detect window properties, it always enters the text "navigator" into the window class text field, but adds the window title into the window title text box which is hidden by default. Is that expected?
This is expected, yes. The detected properties only fill those fields that are disabled or empty, to not overwrite user's settings. The previous KCM had the same behavior, but also showed a (quite ugly) selection window only for the "matching" section. It's on my future TODO to add some UI to let the user apply or discard the detected properties.
With respect to how to make the view less overwhelming, here's an idea: make each section header collapsible, and collapse all sections by default except for the Window Matching header, whose contents would be entirely visible by default. Then remember the expanded/collapsed state for each section globally, so a person who expands them all will always see them expanded in the future.
I'll give it a try, but the current model is linear (, and grouped by a section role. It might be difficult to achieve it without fully changing model.
I wouldn't like to miss that by default, only the selected properties for each rule are shown, as properties "added" to a list. The con, of course is that it can be a bit harder to start editing a new rule.
kcmkwin/kwinrules/package/contents/ui/OptionsComboBox.qml | ||
---|---|---|
70 ↗ | (On Diff #78988) | oh, silly me! I did that on the main list selection when exporting.. will repeat it here |
kcmkwin/kwinrules/package/contents/ui/ValueEditor.qml | ||
140 ↗ | (On Diff #78988) | Ok. I might have a slightly smaller font. |
kcmkwin/kwinrules/package/contents/ui/ValueEditor.qml | ||
---|---|---|
140 ↗ | (On Diff #78988) | Allow me to introduce you to TextMetrics! It can be used for exactly this. Elisa uses it all over the place for just this purpose. |
kcmkwin/kwinrules/package/contents/ui/RuleItemDelegate.qml | ||
---|---|---|
44 ↗ | (On Diff #78988) | I'm not so sure here. Since this is a complex item, I find toggling selection on text click unexpected, and any misclick can be confusing. Deselecting will hide the item (it's like removing it from the list), and only activating on click would be very inconsistent. |
As suggested by @ngraham in the VDG channel, this changes the metaphor to select new properti>
Instead of a Show All filter, now we can add properties to the rule using an overlay sheet.
The Detect window properties option also uses the sheet to show and select them, which was a>
There are some UI/QML quirks with the overlay I'm not able to get rid of:
Wow, this is waaaaaay better. The workflow is really smooth. It's, like, incredibly great now. Also, the rules actually work for me now! So that's nice.
I really only have nitpicks:
kcmkwin/kwinrules/package/contents/ui/RuleItemDelegate.qml | ||
---|---|---|
64 ↗ | (On Diff #78988) | let's use edit-delete for this, as that uses a trashcan icon and we're moving towards using that everywhere |
kcmkwin/kwinrules/package/contents/ui/RulesEditor.qml | ||
43 ↗ | (On Diff #78988) | the list items are back to changing their background on hover, which isn't necessary |
49 ↗ | (On Diff #78988) | Might be a good idea to move the "Add properties... button right below this text so it's obvious to the user now they add more properties. When the placeholder message is not shown, the button could just be there at the bottom of the list, and maybe could change its text to "Add more properties..." The reason for this is to make it easy for the user to understand what they need to do. We do this in the online accounts KCM: |
74 ↗ | (On Diff #78988) | I would make this footer a header to mimic the natural flow. Typically you'll click the "detectwindow properties" button first to target a window, which means it should be at the top of the window to suggest that it's the first thing you want to click on. |
76 ↗ | (On Diff #78988) | Button titles use Title Case ("Detect Window Properties") |
97 ↗ | (On Diff #78988) | use Title Case and add ellipses ("Add Properties...") |
kcmkwin/kwinrules/package/contents/ui/OptionsComboBox.qml | ||
---|---|---|
62 ↗ | (On Diff #78988) | Use %1 instead of the hardcoded number 1 for the singular case (there are languages where e.g. the number 21 uses the singular form) |
69 ↗ | (On Diff #78988) | Is this necessary to manually assign? I thought LayoutMirroring.enabled got set automatically? |
109 ↗ | (On Diff #78988) | Can you add a TODO or FIXME comment indicating that this works around https://bugs.kde.org/show_bug.cgi?id=403153? |
114 ↗ | (On Diff #78988) | Add braces, either on the same line, or in the more conventional multi-line style |
kcmkwin/kwinrules/package/contents/ui/RuleItemDelegate.qml | ||
59 ↗ | (On Diff #78988) | elision only works when a label's maximum width is defined; you probably want to set that somehow, or make it not elide |
kcmkwin/kwinrules/package/contents/ui/RulesEditor.qml | ||
93–96 | That's correct; it's not required unless the spinbox is editable. | |
85 ↗ | (On Diff #78988) | In English at least, this minimum width isn't high enough to avoid the spinbox getting wider when going from 1 to 2. |
90 ↗ | (On Diff #78988) | Same deal for the singular case here; use %1 instead of 1 |
138 ↗ | (On Diff #78988) | always manually set width to the list view's width on delegates (e.g. width: overlayModel.width) |
149 ↗ | (On Diff #78988) | due to a Qt bug, left and right margins are not reversed in RTL mode. So whenever you set one of those, yo need to explicitly handle the RTL case like this: Layout.leftMargin: !LayoutMirroring.enabled? Kirigami.Units.smallSpacing : 0 Layout.rightMargin: LayoutMirroring.enabled? Kirigami.Units.smallSpacing : 0 (same for all other instances of using left and right margins on an item in a layout) |
174 ↗ | (On Diff #78988) | Needs to be vertically centered, or else this happens: (probably do the same for other items in this rowlayout as right now their being vertically centered is by chance rather than done explicitly) |
176 ↗ | (On Diff #78988) | Is there a reason to use opacity rather than visible here? |
195 ↗ | (On Diff #78988) | This doesn't do what you think it does. searchField.focus doesn't mean, "focus the search field", it means "allow the search field to *become* focused. The property is terribly mis-named. :( You probably want to set focus: true on the search field itself, and do searchField.forceActiveFocus() here. Then again I would imagine that the search field internally has focus: true set so setting it again here may be unnecessary. |
kcmkwin/kwinrules/package/contents/ui/RulesList.qml | ||
170 ↗ | (On Diff #78988) | Could we handle the tab key here too? |
kcmkwin/kwinrules/package/contents/ui/RulesEditor.qml | ||
---|---|---|
149 ↗ | (On Diff #78988) | We shouldn't be working round Qt bugs. Also..if you do that, what will happen when Qt does fix it? |
195 ↗ | (On Diff #78988) |
That's not right. focus does mean "become focussed". However, it means "become focussed within the parent focus scope". Focus Scopes are a super simple concept that are simultaneously very very very confusing, to the point that I can't explain them well. In this case ListView is our focus scope, so we also need to make the listview focussed in order for it to have any effect. forceActiveFocus() iterates through the tree doing that. |
I'm not 100% sure about this two, but they are uploaded now so you people can say:
kcmkwin/kwinrules/package/contents/ui/OptionsComboBox.qml | ||
---|---|---|
69 ↗ | (On Diff #78988) | You're right, it works automatically now! |
kcmkwin/kwinrules/package/contents/ui/RuleItemDelegate.qml | ||
68 | I reworked all the Layout hints to use preferredWidth instead of max/mins and it seems to work much better, including the elidedlabel. | |
kcmkwin/kwinrules/package/contents/ui/RulesEditor.qml | ||
43 ↗ | (On Diff #78988) | Having hoverEnabled: false does not allow to show the delete button on hover only. |
149 ↗ | (On Diff #78988) | As a kind of middle way, I set the two margins to the same value |
176 ↗ | (On Diff #78988) | It is to preserve the space of the button in the Layout when hidden |
176 ↗ | (On Diff #78988) | I'm not too proud of this, but it was required to avoid this overlapping |
kcmkwin/kwinrules/package/contents/ui/RulesEditor.qml | ||
---|---|---|
149 ↗ | (On Diff #78988) | good solution :) FYI: https://codereview.qt-project.org/c/qt/qtdeclarative/+/297558 |
UI refining:
If you haven't done so already, I would suggest attaching QAbstractItemModelTester to rulesModel and move stuff about. It's really good at finding technical quirks.
But in general +++ I couldn't find any real technical problems \o/
I say we try and merge it early so we can get some wider testing.
kcmkwin/kwinrules/rulesmodel.cpp | ||
---|---|---|
706 ↗ | (On Diff #78988) | This won't work on wayland, we will want to copy whatever we do in the virtual desktop KCM. I think this is not regression, as the current code does the same. |
Awesome work!
kcmkwin/kwinrules/package/contents/ui/RulesEditor.qml | ||
---|---|---|
93–96 | Hmm, okay. I just restated what Qt docs say. |
kcmkwin/kwinrules/rulesmodel.cpp | ||
---|---|---|
706 ↗ | (On Diff #78988) | I'll look into it. Thanks! |
@iasensio BTW, since this change landed, can we remove origin/iasensio/kcm_kwinrules?
EDIT: and origin/iasensio/kcm_kwinrules_xt
Sure. I didn't know how to remove them.
EDIT: I googled it, and those are now removed :)