on xenial help sign in
Fix the buttons. A new variable to control the max width of buttons.
3f15ccaYing-Chun Liu
Dash/DashPreview.qml+2−2
@@ -63,6 +63,7 @@ Rectangle {
63
63
64 Item {
64 Item {
65 id: headerIcon
65 id: headerIcon
66+ height: childrenRect.height
66 anchors {
67 anchors {
67 left: parent.left
68 left: parent.left
68 right: parent.right
69 right: parent.right
@@ -71,7 +72,6 @@ Rectangle {
71 topMargin: root.contentSpacing
72 topMargin: root.contentSpacing
72 rightMargin: root.contentSpacing
73 rightMargin: root.contentSpacing
73 }
74 }
74− height: childrenRect.height
75 Loader {
75 Loader {
76 id: headerLoader
76 id: headerLoader
77 anchors.left: parent.left
77 anchors.left: parent.left
@@ -82,7 +82,7 @@ Rectangle {
82
82
83 Item {
83 Item {
84 id: headerRow
84 id: headerRow
85− height: childrenRect.height
85+ height: childrenRect.height
86 anchors {
86 anchors {
87 top: headerIcon.bottom
87 top: headerIcon.bottom
88 left: parent.left
88 left: parent.left
Dash/Generic/GenericPreview.qml+5−3
@@ -67,13 +67,15 @@ DashPreview {
67 id: buttons
67 id: buttons
68 model: genericPreview.previewData.actions
68 model: genericPreview.previewData.actions
69
69
70− property int numOfRows: (count + 1) / 2
70+ property int buttonMaxWidth: units.gu(34)
71+ property int numOfColumns: Math.ceil((width + spacing) / (buttonMaxWidth + spacing))
72+ property int numOfRows: Math.ceil(count / numOfColumns)
71 property int spacing: units.gu(1)
73 property int spacing: units.gu(1)
72 height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
74 height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
73
75
74− cellWidth: Math.max(units.gu(9), width / 2)
76+ cellWidth: width / numOfColumns
75 cellHeight: buttonHeight + spacing
77 cellHeight: buttonHeight + spacing
76− property int buttonWidth: Math.max(0, width / 2 - spacing)
78+ property int buttonWidth: cellWidth - spacing / 2
77 property int buttonHeight: units.gu(4)
79 property int buttonHeight: units.gu(4)
78
80
79 delegate: Button {
81 delegate: Button {