on xenial help sign in
Tweak app drawer a bit
756d062Albert Astals Cid
qml/Launcher/Drawer.qml+43−2
@@ -28,6 +28,7 @@ FocusScope {
28 property int panelWidth: 0
28 property int panelWidth: 0
29 readonly property bool moving: listLoader.item && listLoader.item.moving
29 readonly property bool moving: listLoader.item && listLoader.item.moving
30 readonly property Item searchTextField: searchField
30 readonly property Item searchTextField: searchField
31+ readonly property real delegateWidth: units.gu(10)
31
32
32 signal applicationSelected(string appId)
33 signal applicationSelected(string appId)
33
34
@@ -272,7 +273,7 @@ FocusScope {
272
273
273 model: sortProxyModel
274 model: sortProxyModel
274
275
275− delegateWidth: units.gu(8)
276+ delegateWidth: root.delegateWidth
276 delegateHeight: units.gu(10)
277 delegateHeight: units.gu(10)
277 delegate: drawerDelegateComponent
278 delegate: drawerDelegateComponent
278 }
279 }
@@ -332,7 +333,7 @@ FocusScope {
332 filterLetter: model.letter
333 filterLetter: model.letter
333 dynamicSortFilter: false
334 dynamicSortFilter: false
334 }
335 }
335− delegateWidth: units.gu(8)
336+ delegateWidth: root.delegateWidth
336 delegateHeight: units.gu(10)
337 delegateHeight: units.gu(10)
337 delegate: drawerDelegateComponent
338 delegate: drawerDelegateComponent
338 }
339 }
@@ -352,6 +353,7 @@ FocusScope {
352 readonly property bool focused: index === GridView.view.currentIndex && GridView.view.activeFocus
353 readonly property bool focused: index === GridView.view.currentIndex && GridView.view.activeFocus
353
354
354 onClicked: root.applicationSelected(model.appId)
355 onClicked: root.applicationSelected(model.appId)
356+ z: loader.active ? 1 : 0
355
357
356 Column {
358 Column {
357 width: units.gu(8)
359 width: units.gu(8)
@@ -384,11 +386,50 @@ FocusScope {
384 }
386 }
385
387
386 Label {
388 Label {
389+ id: label
387 text: model.name
390 text: model.name
388 width: parent.width
391 width: parent.width
389 horizontalAlignment: Text.AlignHCenter
392 horizontalAlignment: Text.AlignHCenter
390 fontSize: "small"
393 fontSize: "small"
391 elide: Text.ElideRight
394 elide: Text.ElideRight
395+
396+ Loader {
397+ id: loader
398+ x: {
399+ var aux = 0;
400+ if (item) {
401+ aux = label.width / 2 - item.width / 2;
402+ var containerXMap = mapToItem(contentContainer, aux, 0).x
403+ if (containerXMap < 0) {
404+ aux = aux - containerXMap;
405+ containerXMap = 0;
406+ }
407+ if (containerXMap + item.width > contentContainer.width) {
408+ aux = aux - (containerXMap + item.width - contentContainer.width);
409+ }
410+ }
411+ return aux;
412+ }
413+ y: -units.gu(0.5)
414+ active: label.truncated && (drawerDelegate.hovered || drawerDelegate.focused)
415+ sourceComponent: Rectangle {
416+ color: UbuntuColors.jet
417+ width: fullLabel.contentWidth + units.gu(1)
418+ height: fullLabel.height + units.gu(1)
419+ radius: units.dp(4)
420+ Label {
421+ id: fullLabel
422+ width: Math.min(root.delegateWidth * 2, implicitWidth)
423+ wrapMode: Text.Wrap
424+ horizontalAlignment: Text.AlignHCenter
425+ maximumLineCount: 3
426+ elide: Text.ElideRight
427+ anchors.centerIn: parent
428+ text: model.name
429+ fontSize: "small"
430+ }
431+ }
432+ }
392 }
433 }
393 }
434 }
394 }
435 }
tests/mocks/Unity/Launcher/MockAppDrawerModel.cpp+1−1
@@ -46,7 +46,7 @@ MockAppDrawerModel::MockAppDrawerModel(QObject *parent):
46 m_list.append(item);
46 m_list.append(item);
47 item = new MockLauncherItem("calendar-app", "/usr/share/applications/calendar-app.desktop","Calendar", "calendar", this);
47 item = new MockLauncherItem("calendar-app", "/usr/share/applications/calendar-app.desktop","Calendar", "calendar", this);
48 m_list.append(item);
48 m_list.append(item);
49− item = new MockLauncherItem("libreoffice", "/usr/share/applications/libreoffice.desktop","Libre Office", "libreoffice", this);
49+ item = new MockLauncherItem("libreoffice", "/usr/share/applications/libreoffice.desktop","Libre Office Writer", "libreoffice", this);
50 m_list.append(item);
50 m_list.append(item);
51
51
52 qsrand(QDateTime::currentMSecsSinceEpoch() / 1000);
52 qsrand(QDateTime::currentMSecsSinceEpoch() / 1000);