on xenial help sign in
Tweak app drawer a bit

Make delegates a bit wider to have more breath space Add a "tooltip" on hover for delegates whose text is truncated (LP: #1667570) Approved by: Lukáš Tinkl, Unity8 CI Bot

commit756d06255a7b3e95605a6a30ed17960f9288cd10 authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 4 Apr 2017, 22:54 (10 years ago) parente0227fe73e07dd
2 files changed+44−3
qml/Launcher/Drawer.qml+43−2 tests/mocks/Unity/Launcher/MockAppDrawerModel.cpp+1−1
qml/Launcher/Drawer.qml+43−2
@@ -28,6 +28,7 @@ FocusScope {
2828 property int panelWidth: 0
2929 readonly property bool moving: listLoader.item && listLoader.item.moving
3030 readonly property Item searchTextField: searchField
31+ readonly property real delegateWidth: units.gu(10)
3132
3233 signal applicationSelected(string appId)
3334
@@ -272,7 +273,7 @@ FocusScope {
272273
273274 model: sortProxyModel
274275
275− delegateWidth: units.gu(8)
276+ delegateWidth: root.delegateWidth
276277 delegateHeight: units.gu(10)
277278 delegate: drawerDelegateComponent
278279 }
@@ -332,7 +333,7 @@ FocusScope {
332333 filterLetter: model.letter
333334 dynamicSortFilter: false
334335 }
335− delegateWidth: units.gu(8)
336+ delegateWidth: root.delegateWidth
336337 delegateHeight: units.gu(10)
337338 delegate: drawerDelegateComponent
338339 }
@@ -352,6 +353,7 @@ FocusScope {
352353 readonly property bool focused: index === GridView.view.currentIndex && GridView.view.activeFocus
353354
354355 onClicked: root.applicationSelected(model.appId)
356+ z: loader.active ? 1 : 0
355357
356358 Column {
357359 width: units.gu(8)
@@ -384,11 +386,50 @@ FocusScope {
384386 }
385387
386388 Label {
389+ id: label
387390 text: model.name
388391 width: parent.width
389392 horizontalAlignment: Text.AlignHCenter
390393 fontSize: "small"
391394 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+ }
392433 }
393434 }
394435 }
tests/mocks/Unity/Launcher/MockAppDrawerModel.cpp+1−1
@@ -46,7 +46,7 @@ MockAppDrawerModel::MockAppDrawerModel(QObject *parent):
4646 m_list.append(item);
4747 item = new MockLauncherItem("calendar-app", "/usr/share/applications/calendar-app.desktop","Calendar", "calendar", this);
4848 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);
5050 m_list.append(item);
5151
5252 qsrand(QDateTime::currentMSecsSinceEpoch() / 1000);