Commit b8762ede authored by Albert Astals Cid's avatar Albert Astals Cid Committed by Albert Astals Cid
Browse files

Kicker: Make menus grow (to a limit) if the text doesn't fit on the default width

Summary:
On my install i have various application names that don't fit on units.gridUnit * 14
so let the list grow if needed. It only grows to a limit, we don't want the list to
be huge for some weirdly long application name.

Test Plan:
Use the menu editor to rename Development to Development 22222222222222222222222222
Check the root menu shows all the name
Search and check the search bar sizing is correct at all times
Open submenus with applications whose name previously was cut and check now it displays correctly

Note: I get
	TextFieldStyle.qml:46:17: QML QQuickItem: Binding loop detected for property "implicitHeight"
when entering text on the search bar, but i can also reproduce this with a simple testcase like
https://paste.kde.org/pi1hopivh so it seems it's not a bug in my code. Also i can't see the search
bar misbehaving so it seems to be "harmless"

Reviewers: #plasma, hein

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D12171
parent 328855db
......@@ -35,6 +35,7 @@ Item {
signal actionTriggered(string actionId, variant actionArgument)
signal aboutToShowActionMenu(variant actionMenu)
readonly property real fullTextWidth: Math.ceil(icon.width + label.implicitWidth + arrow.width + row.anchors.leftMargin + row.anchors.rightMargin + row.actualSpacing)
property bool isSeparator: (model.isSeparator == true)
property bool hasChildren: (model.hasChildren == true)
property bool hasActionList: ((model.favoriteId != null)
......@@ -177,6 +178,8 @@ Item {
}
Row {
id: row
anchors.left: parent.left
anchors.leftMargin: highlightItemSvg.margins.left
anchors.right: parent.right
......@@ -185,6 +188,7 @@ Item {
height: parent.height
spacing: units.smallSpacing * 2
readonly property real actualSpacing: ((icon.visible ? 1 : 0) * spacing) + ((arrow.visible ? 1 : 0) * spacing)
LayoutMirroring.enabled: (Qt.application.layoutDirection == Qt.RightToLeft)
......@@ -211,8 +215,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter
width: (parent.width - icon.width - arrow.width
- ((icon.visible ? 1 : 0) * parent.spacing) - ((arrow.visible ? 1 : 0) * parent.spacing))
width: parent.width - icon.width - arrow.width - parent.actualSpacing
verticalAlignment: Text.AlignVCenter
......
......@@ -27,7 +27,10 @@ import org.kde.kquickcontrolsaddons 2.0
FocusScope {
id: itemList
width: units.gridUnit * 14
property real minimumWidth: units.gridUnit * 14
property real maximumWidth: minimumWidth * 2
width: minimumWidth
height: listView.contentHeight
signal exited
......@@ -144,7 +147,11 @@ FocusScope {
spacing: 0
keyNavigationWraps: (dialog != null)
delegate: ItemListDelegate {}
delegate: ItemListDelegate {
onFullTextWidthChanged: {
if (fullTextWidth > itemList.width) itemList.width = Math.min(fullTextWidth, itemList.maximumWidth);
}
}
highlight: PlasmaComponents.Highlight {
visible: listView.currentItem && !listView.currentItem.isSeparator
......
......@@ -28,8 +28,8 @@ FocusScope {
focus: true
Layout.minimumWidth: (sideBar.width + (sideBar.width ? mainRow.spacing : 0)
+ Math.max(units.gridUnit * 14, runnerColumns.width))
Layout.maximumWidth: Layout.minimumWidth
+ Math.max(searchField.defaultWidth, runnerColumns.width))
Layout.maximumWidth: Math.max(mainRow.width, Layout.minimumWidth); // mainRow.width is constrained by rootList.maximumWidth
Layout.minimumHeight: Math.max(((rootModel.count - rootModel.separatorCount) * rootList.itemHeight)
+ (rootModel.separatorCount * rootList.separatorHeight)
......@@ -175,7 +175,7 @@ FocusScope {
anchors.top: parent.top
width: root.width - sideBar.width - mainRow.spacing
minimumWidth: root.Layout.minimumWidth - sideBar.width - mainRow.spacing
height: ((rootModel.count - rootModel.separatorCount) * itemHeight) + (rootModel.separatorCount * separatorHeight)
visible: (searchField.text == "")
......@@ -309,7 +309,10 @@ FocusScope {
anchors.left: parent.left
anchors.leftMargin: sideBar.width + (sideBar.width ? mainRow.spacing : 0) + units.smallSpacing
width: (units.gridUnit * 14) - (2 * units.smallSpacing)
readonly property real defaultWidth: units.gridUnit * 14
width: (runnerColumnsRepeater.count != 0 ? runnerColumnsRepeater.itemAt(0).width
: (rootList.visible ? rootList.width : defaultWidth))
- units.smallSpacing
focus: true
......
Supports Markdown
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