on xenial help sign in
Move the 45 and 70gu to properties
commit790fb43997484c675cdc7e7678b5150e8c78864b authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 19 Aug 2016, 17:30 (10 years ago) parent1f0f2c9
2 files changed+14−7
qml/Dash/CardGrid.qml+1−1 qml/Dash/CardTool.qml+13−6
qml/Dash/CardGrid.qml+1−1
@@ -45,7 +45,7 @@ DashRenderer {
4545 ResponsiveGridView {
4646 id: grid
4747 anchors.fill: parent
48− minimumHorizontalSpacing: (cardTool.isAppLikeScopeAppCategory && cardTool.viewWidth >= units.gu(70)) ? units.gu(5) : units.gu(1)
48+ minimumHorizontalSpacing: (cardTool.isAppLikeScopeAppCategory && cardTool.isWideView) ? units.gu(5) : units.gu(1)
4949 delegateWidth: cardTool.cardWidth
5050 delegateHeight: cardTool.cardHeight
5151 verticalSpacing: units.gu(1)
qml/Dash/CardTool.qml+13−6
@@ -98,6 +98,13 @@ Item {
9898 height: 0
9999 clip: true
100100
101+ // We have 3 view "widths"
102+ // narrow <= 45gu
103+ // normal
104+ // wide >= 70gu
105+ readonly property bool isWideView: viewWidth >= units.gu(70)
106+ readonly property bool isNarrowView: viewWidth <= units.gu(45)
107+
101108 /*!
102109 type:real \brief Width to be enforced on the card in this configuration.
103110
@@ -105,8 +112,8 @@ Item {
105112 */
106113 readonly property real cardWidth: {
107114 if (isAppLikeScopeAppCategory) {
108− if (viewWidth > units.gu(45)) {
109− if (viewWidth >= units.gu(70)) {
115+ if (!isNarrowView) {
116+ if (isWideView) {
110117 return units.gu(11);
111118 } else {
112119 return units.gu(10);
@@ -123,16 +130,16 @@ Item {
123130 if (template["card-layout"] === "horizontal") size = "large";
124131 switch (size) {
125132 case "small": {
126− if (viewWidth <= units.gu(45)) return units.gu(12);
133+ if (isNarrowView) return units.gu(12);
127134 else return units.gu(14);
128135 }
129136 case "large": {
130− if (viewWidth >= units.gu(70)) return units.gu(42);
137+ if (isWideView) return units.gu(42);
131138 else return viewWidth - units.gu(2);
132139 }
133140 }
134− if (viewWidth <= units.gu(45)) return units.gu(18);
135− else if (viewWidth >= units.gu(70)) return units.gu(20);
141+ if (isNarrowView) return units.gu(18);
142+ else if (isWideView) return units.gu(20);
136143 else return units.gu(23);
137144 case "carousel":
138145 case "horizontal-list":