on xenial help sign in
Merge from trunk
611329aMichael Terry
Components/EdgeDemo.qml+2−1
@@ -218,8 +218,9 @@ Item {
218 d.finalEdgeDemo = d.overlay.createObject(demo.underlay, {
218 d.finalEdgeDemo = d.overlay.createObject(demo.underlay, {
219 "edge": "none",
219 "edge": "none",
220 "title": i18n.tr("Well done"),
220 "title": i18n.tr("Well done"),
221− "text": i18n.tr("You have now mastered the edge gestures and can start using the phone"),
221+ "text": i18n.tr("You have now mastered the edge gestures and can start using the phone<br><br>Tap anywhere to start"),
222 "anchors.fill": demo.dash,
222 "anchors.fill": demo.dash,
223+ "showSkip": false,
223 });
224 });
224 }
225 }
225 if (d.finalEdgeDemo) {
226 if (d.finalEdgeDemo) {
Components/EdgeDemoOverlay.qml+5
@@ -43,6 +43,11 @@ Showable {
43 */
43 */
44 property alias skipText: skipLabel.text
44 property alias skipText: skipLabel.text
45
45
46+ /*
47+ * This is the visible status of the skip button.
48+ */
49+ property alias showSkip: skipLabel.visible
50+
46 /*
51 /*
47 * Whether this demo is running currently.
52 * Whether this demo is running currently.
48 */
53 */
Dash/DashBar.qml+2−3
@@ -83,9 +83,8 @@ Item {
83 }
83 }
84
84
85 delegate:
85 delegate:
86− Item {
86+ // FIXME: Use Panel's integrated trigger() once that works again.
87− signal clicked()
87+ MouseArea {
88−
89 width: itemSize
88 width: itemSize
90 height: dashBar.height
89 height: dashBar.height
91 anchors.top: parent.top
90 anchors.top: parent.top
Greeter/Infographics.qml+1−2
@@ -286,9 +286,8 @@ Item {
286 objectName: "backgroundCircle"
286 objectName: "backgroundCircle"
287
287
288 anchors.fill: parent
288 anchors.fill: parent
289− opacity: 0.9
290
289
291− source: "graphics/infographic_circle.png"
290+ source: "graphics/infographic_circle_back.png"
292 }
291 }
293
292
294 Timer {
293 Timer {
Greeter/graphics/infographic_circle.pngdeleted

Binary file not shown.

Greeter/graphics/infographic_circle_back.pngnew file

Binary file not shown.

Panel/Indicators/DefaultIndicatorWidget.qml+1−1
@@ -24,7 +24,7 @@ import Unity.IndicatorsLegacy 0.1 as Indicators
24Indicators.IndicatorWidget {
24Indicators.IndicatorWidget {
25 id: indicatorWidget
25 id: indicatorWidget
26
26
27− width: itemRow.width + units.gu(1)
27+ width: itemRow.width + units.gu(0.5)
28
28
29 property alias label: itemLabel.text
29 property alias label: itemLabel.text
30 property alias iconSource: itemImage.source
30 property alias iconSource: itemImage.source
Panel/Indicators/DefaultIndicatorWidget2.qml+43−16
@@ -24,10 +24,11 @@ import Unity.Indicators 0.1 as Indicators
24Indicators.IndicatorWidget {
24Indicators.IndicatorWidget {
25 id: indicatorWidget
25 id: indicatorWidget
26
26
27− width: itemRow.width + units.gu(1)
27+ width: itemRow.width + units.gu(0.5)
28
28
29− property alias label: itemLabel.text
29+ property alias leftLabel: itemLeftLabel.text
30− property alias iconSource: itemImage.source
30+ property alias rightLabel: itemRightLabel.text
31+ property var icons: undefined
31
32
32 Row {
33 Row {
33 id: itemRow
34 id: itemRow
@@ -39,19 +40,43 @@ Indicators.IndicatorWidget {
39 }
40 }
40 spacing: units.gu(0.5)
41 spacing: units.gu(0.5)
41
42
42− // FIXME : Should us Ubuntu.Icon . results in low res images
43+ Label {
43− Image {
44+ id: itemLeftLabel
44− id: itemImage
45− objectName: "itemImage"
45+ objectName: "leftLabel"
46− visible: source != ""
46+ color: Theme.palette.selected.backgroundText
47− height: indicatorWidget.iconSize
47+ opacity: 0.8
48− width: indicatorWidget.iconSize
48+ font.family: "Ubuntu"
49+ fontSize: "medium"
49 anchors.verticalCenter: parent.verticalCenter
50 anchors.verticalCenter: parent.verticalCenter
51+ visible: text != ""
52+ }
53+
54+ Row {
55+ width: childrenRect.width
56+ anchors {
57+ top: parent.top
58+ bottom: parent.bottom
59+ }
60+ spacing: units.gu(0.5)
61+
62+ Repeater {
63+ model: indicatorWidget.icons
64+
65+ Image {
66+ id: itemImage
67+ objectName: "itemImage"
68+ visible: source != ""
69+ source: modelData
70+ height: indicatorWidget.iconSize
71+ width: indicatorWidget.iconSize
72+ anchors.verticalCenter: parent.verticalCenter
73+ }
74+ }
50 }
75 }
51
76
52 Label {
77 Label {
53− id: itemLabel
78+ id: itemRightLabel
54− objectName: "itemLabel"
79+ objectName: "rightLabel"
55 color: Theme.palette.selected.backgroundText
80 color: Theme.palette.selected.backgroundText
56 opacity: 0.8
81 opacity: 0.8
57 font.family: "Ubuntu"
82 font.family: "Ubuntu"
@@ -63,14 +88,16 @@ Indicators.IndicatorWidget {
63
88
64 onActionStateChanged: {
89 onActionStateChanged: {
65 if (actionState == undefined) {
90 if (actionState == undefined) {
66− label = "";
91+ leftLabel = "";
67− iconSource = "";
92+ rightLabel = "";
93+ icons = undefined;
68 enabled = false;
94 enabled = false;
69 return;
95 return;
70 }
96 }
71
97
72− label = actionState.label;
98+ leftLabel = actionState.leftLabel ? actionState.leftLabel : "";
99+ rightLabel = actionState.rightLabel ? actionState.rightLabel : "";
73− iconSource = actionState.icon;
100+ icons = actionState.icons;
74 enabled = actionState.visible;
101 enabled = actionState.visible;
75 }
102 }
76}
103}
Panel/Indicators/NetworkIndicatorWidget.qml+1−1
@@ -24,7 +24,7 @@ import Unity.IndicatorsLegacy 0.1 as Indicators
24Indicators.IndicatorWidget {
24Indicators.IndicatorWidget {
25 id: indicatorWidget
25 id: indicatorWidget
26
26
27− width: networkIcon.width + units.gu(1)
27+ width: networkIcon.width + units.gu(0.5)
28
28
29 property int signalStrength: 0
29 property int signalStrength: 0
30 property int connectionState: Indicators.NetworkConnection.Initial
30 property int connectionState: Indicators.NetworkConnection.Initial
build+9
@@ -57,6 +57,15 @@ mk_build_deps() {
57 [ ! -f unity8-build-deps*deb -o $CODE_DIR/debian/control -nt unity8-build-deps*deb ] && mk-build-deps --install --root-cmd sudo $CODE_DIR/debian/control
57 [ ! -f unity8-build-deps*deb -o $CODE_DIR/debian/control -nt unity8-build-deps*deb ] && mk-build-deps --install --root-cmd sudo $CODE_DIR/debian/control
58}
58}
59
59
60+if [ -f "/usr/bin/ccache" ] ; then
61+ if [ "x$CC" = "x" ]; then
62+ export CC='ccache gcc'
63+ fi
64+ if [ "x$CXX" = "x" ] ; then
65+ export CXX='ccache g++'
66+ fi
67+fi
68+
60if [ -f "/usr/bin/ninja" ] ; then
69if [ -f "/usr/bin/ninja" ] ; then
61 GENERATOR="-G Ninja"
70 GENERATOR="-G Ninja"
62 # Ninja does not need -j, it parallelizes automatically.
71 # Ninja does not need -j, it parallelizes automatically.
debian/changelog+38
@@ -1,3 +1,41 @@
1+unity8 (7.81.3+13.10.20130904.1-0ubuntu1) saucy; urgency=low
2+
3+ [ Nicolas d'Offay ]
4+ * Switched infographic background at design's request.
5+
6+ [ Ubuntu daily release ]
7+ * Automatic snapshot from revision 287
8+
9+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 04 Sep 2013 07:34:57 +0000
10+
11+unity8 (7.81.3+13.10.20130904-0ubuntu1) saucy; urgency=low
12+
13+ [ mhall119 ]
14+ * Add a little bit of text to the last step of the tour telling the
15+ user how to end it and get to their phone.
16+
17+ [ Jussi Pakkanen ]
18+ * Use CCache if it is installed.
19+
20+ [ Nick Dedekind ]
21+ * Multiple icon/label support for indicators.
22+
23+ [ Albert Astals ]
24+ * Remove unneeded role.
25+
26+ [ Lars Uebernickel ]
27+ * Fall back to "ubuntu-mobile" icon theme if $UBUNTU_ICON_THEME is
28+ unset.
29+
30+ [ Michael Zanetti ]
31+ * Use MouseAreas in DashBar to enable clicking again.
32+ * load launcher default config from existing dconf key.
33+
34+ [ Ubuntu daily release ]
35+ * Automatic snapshot from revision 285
36+
37+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 04 Sep 2013 03:02:57 +0000
38+
1unity8 (7.81.3+13.10.20130903.1-0ubuntu1) saucy; urgency=low
39unity8 (7.81.3+13.10.20130903.1-0ubuntu1) saucy; urgency=low
2
40
3 [ Michael Zanetti ]
41 [ Michael Zanetti ]
debian/control+1
@@ -9,6 +9,7 @@ Build-Depends: cmake,
9 libgl1-mesa-dev[!armhf] | libgl-dev[!armhf],
9 libgl1-mesa-dev[!armhf] | libgl-dev[!armhf],
10 libgl1-mesa-dri,
10 libgl1-mesa-dri,
11 libgles2-mesa-dev[armhf],
11 libgles2-mesa-dev[armhf],
12+ libgsettings-qt-dev,
12 libhud-client2-dev,
13 libhud-client2-dev,
13 libjson-perl,
14 libjson-perl,
14 libnih-dbus-dev,
15 libnih-dbus-dev,
main.cpp+3−2
@@ -65,9 +65,10 @@ void appendImportPaths(QQmlEngine *engine, const QStringList &paths)
65
65
66void resolveIconTheme() {
66void resolveIconTheme() {
67 const char *ubuntuIconTheme = getenv("UBUNTU_ICON_THEME");
67 const char *ubuntuIconTheme = getenv("UBUNTU_ICON_THEME");
68− if (ubuntuIconTheme != NULL) {
68+ if (ubuntuIconTheme == NULL) {
69− QIcon::setThemeName(ubuntuIconTheme);
69+ ubuntuIconTheme = "ubuntu-mobile";
70 }
70 }
71+ QIcon::setThemeName(ubuntuIconTheme);
71}
72}
72} // namespace {
73} // namespace {
73
74
plugins/Unity/Indicators/qml/MenuItemFactory.qml+1−16
@@ -73,23 +73,8 @@ Item {
73 'max-icon': 'icon'});
73 'max-icon': 'icon'});
74 }
74 }
75
75
76− // FIXME: The interval should be [0.0 - 1.0]. Unfortunately, when
77− // reaching the boundaries (0.0 or 1.0), the value is converted
78− // to an integer when automatically wrapped in a variant when
79− // passed to QStateAction::updateState(…). The server chokes on
80− // those values, complaining that they’re not of the right type…
81 onChangeState: {
76 onChangeState: {
82− if (value == Math.round(value)) {
83− if (value >= maximumValue) {
84− model.changeState(modelIndex, maximumValue - 0.000001);
85− } else if (value <= minimumValue) {
86− model.changeState(modelIndex, minimumValue + 0.000001);
77+ model.changeState(modelIndex, value);
87− } else {
88− model.changeState(modelIndex, value * 1.000001);
89− }
90− } else {
91− model.changeState(modelIndex, value);
92− }
93 }
78 }
94 }
79 }
95 }
80 }
plugins/Unity/Indicators/rootactionstate.cpp+44−14
@@ -108,25 +108,32 @@ bool RootActionState::isValid() const
108 return m_menu && m_menu->rowCount() > 0;
108 return m_menu && m_menu->rowCount() > 0;
109}
109}
110
110
111−QString RootActionState::label() const
111+QString RootActionState::leftLabel() const
112{
112{
113 if (!isValid()) return QString();
113 if (!isValid()) return QString();
114
114
115− return m_cachedState.value("label", QVariant::fromValue(QString())).toString();
115+ return m_cachedState.value("pre-label", QVariant::fromValue(QString())).toString();
116}
116}
117
117
118−QString RootActionState::icon() const
118+QString RootActionState::rightLabel() const
119{
119{
120 if (!isValid()) return QString();
120 if (!isValid()) return QString();
121
121
122− return m_cachedState.value("icon", QVariant::fromValue(QString())).toString();
122+ return m_cachedState.value("label", QVariant::fromValue(QString())).toString();
123+}
124+
125+QStringList RootActionState::icons() const
126+{
127+ if (!isValid()) return QStringList();
128+
129+ return m_cachedState.value("icons", QVariant::fromValue(QStringList())).toStringList();
123}
130}
124
131
125QString RootActionState::accessibleName() const
132QString RootActionState::accessibleName() const
126{
133{
127 if (!isValid()) return QString();
134 if (!isValid()) return QString();
128
135
129− return m_cachedState.value("accessible-name", QVariant::fromValue(QString())).toString();
136+ return m_cachedState.value("accessible-desc", QVariant::fromValue(QString())).toString();
130}
137}
131
138
132bool RootActionState::isVisible() const
139bool RootActionState::isVisible() const
@@ -198,16 +205,39 @@ QVariant RootActionState::toQVariant(GVariant* state) const
198 while (g_variant_iter_loop (&iter, "{sv}", &key, &vvalue))
205 while (g_variant_iter_loop (&iter, "{sv}", &key, &vvalue))
199 {
206 {
200 QString str = QString::fromUtf8(key);
207 QString str = QString::fromUtf8(key);
201− if (str == "icon") {
208+ if (str == "icon" && !qmap.contains("icons")) {
209+ QStringList icons;
210+
202 // FIXME - should be sending a url.
211 // FIXME - should be sending a url.
203− GIcon *icon = g_icon_deserialize (vvalue);
212+ GIcon *gicon = g_icon_deserialize (vvalue);
204− if (icon) {
213+ if (gicon) {
205− qmap.insert(str, iconUri(icon));
214+ icons << iconUri(gicon);
206− g_object_unref (icon);
215+ g_object_unref (gicon);
207 }
216 }
208− else {
209− qmap.insert(str, QVariant(""));
217+ qmap.insert("icons", icons);
218+
219+ } else if (str == "icons") {
220+
221+ QStringList icons;
222+
223+ if (g_variant_type_is_array(g_variant_get_type(vvalue))) {
224+
225+
226+ for (int i = 0, iMax = g_variant_n_children(vvalue); i < iMax; i++) {
227+ GVariant *child = g_variant_get_child_value(vvalue, i);
228+
229+ // FIXME - should be sending a url.
230+ GIcon *gicon = g_icon_deserialize (child);
231+ if (gicon) {
232+ icons << iconUri(gicon);
233+ g_object_unref (gicon);
234+ }
235+ g_variant_unref(child);
236+ }
210 }
237 }
238+ // will overwrite icon.
239+ qmap.insert("icons", icons);
240+
211 } else {
241 } else {
212 qmap.insert(str, ActionStateParser::toQVariant(vvalue));
242 qmap.insert(str, ActionStateParser::toQVariant(vvalue));
213 }
243 }
@@ -230,12 +260,12 @@ QVariant RootActionState::toQVariant(GVariant* state) const
230 &visible);
260 &visible);
231
261
232 qmap["label"] = label ? QString::fromUtf8(label) : "";
262 qmap["label"] = label ? QString::fromUtf8(label) : "";
233− qmap["accessible-name"] = accessible_name ? QString::fromUtf8(accessible_name) : "";
263+ qmap["accessible-desc"] = accessible_name ? QString::fromUtf8(accessible_name) : "";
234 qmap["visible"] = visible;
264 qmap["visible"] = visible;
235
265
236 gicon = g_icon_new_for_string (icon, NULL);
266 gicon = g_icon_new_for_string (icon, NULL);
237 if (gicon) {
267 if (gicon) {
238− qmap["icon"] = iconUri(gicon);
268+ qmap["icons"] = QStringList() << iconUri(gicon);
239 g_object_unref (gicon);
269 g_object_unref (gicon);
240 }
270 }
241
271
plugins/Unity/Indicators/rootactionstate.h+9−6
@@ -32,8 +32,9 @@ class UNITYINDICATORS_EXPORT RootActionState : public ActionStateParser
32 Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
32 Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
33
33
34 Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
34 Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
35− Q_PROPERTY(QString label READ label NOTIFY labelChanged)
35+ Q_PROPERTY(QString leftLabel READ leftLabel NOTIFY leftLabelChanged)
36− Q_PROPERTY(QString icon READ icon NOTIFY iconChanged)
36+ Q_PROPERTY(QString rightLabel READ rightLabel NOTIFY rightLabelChanged)
37+ Q_PROPERTY(QStringList icons READ icons NOTIFY iconsChanged)
37 Q_PROPERTY(QString accessibleName READ accessibleName NOTIFY accessibleNameChanged)
38 Q_PROPERTY(QString accessibleName READ accessibleName NOTIFY accessibleNameChanged)
38 Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged)
39 Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged)
39public:
40public:
@@ -47,8 +48,9 @@ public:
47 void setIndex(int index);
48 void setIndex(int index);
48
49
49 bool isValid() const;
50 bool isValid() const;
50− QString label() const;
51+ QString leftLabel() const;
51− QString icon() const;
52+ QString rightLabel() const;
53+ QStringList icons() const;
52 QString accessibleName() const;
54 QString accessibleName() const;
53 bool isVisible() const;
55 bool isVisible() const;
54
56
@@ -62,8 +64,9 @@ Q_SIGNALS:
62 void indexChanged();
64 void indexChanged();
63
65
64 void validChanged();
66 void validChanged();
65− void labelChanged();
67+ void leftLabelChanged();
66− void iconChanged();
68+ void rightLabelChanged();
69+ void iconsChanged();
67 void accessibleNameChanged();
70 void accessibleNameChanged();
68 void visibleChanged();
71 void visibleChanged();
69
72
plugins/Unity/Launcher/CMakeLists.txt+4
@@ -1,11 +1,13 @@
1include(FindPkgConfig)
1include(FindPkgConfig)
2pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=2)
2pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=2)
3+pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
3
4
4add_definitions(-DSM_BUSNAME=systemBus)
5add_definitions(-DSM_BUSNAME=systemBus)
5
6
6include_directories(
7include_directories(
7 ${CMAKE_CURRENT_SOURCE_DIR}
8 ${CMAKE_CURRENT_SOURCE_DIR}
8 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
9 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
10+ ${GSETTINGS_QT_INCLUDE_DIRS}
9)
11)
10
12
11set(QMLLAUNCHERPLUGIN_SRC
13set(QMLLAUNCHERPLUGIN_SRC
@@ -25,6 +27,8 @@ add_library(UnityLauncher-qml MODULE
25 ${QMLLAUNCHERPLUGIN_SRC}
27 ${QMLLAUNCHERPLUGIN_SRC}
26 )
28 )
27
29
30+target_link_libraries(UnityLauncher-qml ${GSETTINGS_QT_LDFLAGS})
31+
28qt5_use_modules(UnityLauncher-qml DBus Qml)
32qt5_use_modules(UnityLauncher-qml DBus Qml)
29
33
30# export the qmldir and qmltypes files
34# export the qmldir and qmltypes files
plugins/Unity/Launcher/backend/launcherbackend.cpp+159−99
@@ -24,6 +24,18 @@
24#include <QDir>
24#include <QDir>
25#include <QDBusArgument>
25#include <QDBusArgument>
26#include <QFileInfo>
26#include <QFileInfo>
27+#include <QGSettings>
28+
29+class LauncherBackendItem
30+{
31+public:
32+ LauncherBackendItem(): pinned(false) {}
33+
34+ QString desktopFile;
35+ QString displayName;
36+ QString icon;
37+ bool pinned;
38+};
27
39
28LauncherBackend::LauncherBackend(bool useStorage, QObject *parent):
40LauncherBackend::LauncherBackend(bool useStorage, QObject *parent):
29 QObject(parent),
41 QObject(parent),
@@ -32,95 +44,109 @@ LauncherBackend::LauncherBackend(bool useStorage, QObject *parent):
32 if (useStorage) {
44 if (useStorage) {
33 m_accounts = new AccountsService(this);
45 m_accounts = new AccountsService(this);
34 }
46 }
35− setUser(qgetenv("USER"));
47+ m_user = qgetenv("USER");
48+ syncFromAccounts();
36}
49}
37
50
38LauncherBackend::~LauncherBackend()
51LauncherBackend::~LauncherBackend()
39{
52{
40− clearItems();
53+ m_storedApps.clear();
41−}
42
54
43−void LauncherBackend::clearItems()
44−{
45− for (LauncherBackendItem &app: m_storedApps) {
55+ Q_FOREACH(LauncherBackendItem *item, m_itemCache) {
46− delete app.settings;
56+ delete item;
47 }
57 }
48− m_storedApps.clear();
58+ m_itemCache.clear();
49}
59}
50
60
51QStringList LauncherBackend::storedApplications() const
61QStringList LauncherBackend::storedApplications() const
52{
62{
53− auto files = QStringList();
54− for (const LauncherBackendItem &app: m_storedApps) {
55− files << app.settings->fileName();
56− }
57− return files;
63+ return m_storedApps;
58}
64}
59
65
60void LauncherBackend::setStoredApplications(const QStringList &appIds)
66void LauncherBackend::setStoredApplications(const QStringList &appIds)
61{
67{
62− // Record all existing pinned apps, so we can notice them in new list
68+ if (appIds.count() < m_storedApps.count()) {
63− auto pinnedItems = QStringList();
69+ Q_FOREACH(const QString &appId, m_storedApps) {
64− for (LauncherBackendItem &app: m_storedApps) {
70+ if (!appIds.contains(appId)) {
65− if (app.pinned) {
71+ delete m_itemCache.take(appId);
66− pinnedItems.append(app.settings->fileName());
72+ }
67 }
73 }
68 }
74 }
69−
75+ m_storedApps = appIds;
70− clearItems();
71−
72− for (const QString &appId: appIds) {
73− loadApp(makeAppDetails(appId, pinnedItems.contains(desktopFile(appId))));
74− }
75−
76 syncToAccounts();
76 syncToAccounts();
77}
77}
78
78
79QString LauncherBackend::desktopFile(const QString &appId) const
79QString LauncherBackend::desktopFile(const QString &appId) const
80{
80{
81− QFileInfo fileInfo(QDir("/usr/share/applications"), appId);
81+ LauncherBackendItem *item = m_itemCache.value(appId);
82− return fileInfo.absoluteFilePath();
82+ if (item) {
83+ return item->desktopFile;
84+ }
85+
86+ return findDesktopFile(appId);
83}
87}
84
88
85QString LauncherBackend::displayName(const QString &appId) const
89QString LauncherBackend::displayName(const QString &appId) const
86{
90{
87− auto desktopFile = parseDesktopFile(appId);
91+ LauncherBackendItem *item = m_itemCache.value(appId);
88− auto displayName = desktopFile->value("Desktop Entry/Name").toString();
92+ if (item) {
89− delete desktopFile;
93+ return item->displayName;
94+ }
95+
96+ QString df = findDesktopFile(appId);
97+ if (!df.isEmpty()) {
98+ LauncherBackendItem *item = parseDesktopFile(df);
99+ m_itemCache.insert(appId, item);
100+ return item->displayName;
101+ }
102+
90− return displayName;
103+ return QString();
91}
104}
92
105
93QString LauncherBackend::icon(const QString &appId) const
106QString LauncherBackend::icon(const QString &appId) const
94{
107{
95− auto desktopFile = parseDesktopFile(appId);
108+ QString iconName;
96− auto iconName = desktopFile->value("Desktop Entry/Icon").toString();
109+ LauncherBackendItem *item = m_itemCache.value(appId);
97− delete desktopFile;
110+ if (item) {
98−
111+ iconName = item->icon;
112+ } else {
113+ QString df = findDesktopFile(appId);
99− if (!iconName.isEmpty()) {
114+ if (!df.isEmpty()) {
100− QFileInfo iconFileInfo(iconName);
115+ LauncherBackendItem *item = parseDesktopFile(df);
101− if (iconFileInfo.isRelative()) {
116+ m_itemCache.insert(appId, item);
102− iconName = "image://theme/" + iconName;
117+ iconName = item->icon;
103 }
118 }
104 }
119 }
105
120
121+ QFileInfo info(iconName);
122+ if (info.exists()) {
123+ return info.absoluteFilePath();
124+ }
106− return iconName;
125+ return "image://theme/" + iconName;
107}
126}
108
127
109bool LauncherBackend::isPinned(const QString &appId) const
128bool LauncherBackend::isPinned(const QString &appId) const
110{
129{
111− auto index = findItem(appId);
130+ LauncherBackendItem *item = m_itemCache.value(appId);
112− if (index < 0) {
131+ if (item) {
113− return false;
132+ return item->pinned;
114− } else {
115− return m_storedApps[index].pinned;
116 }
133 }
134+ return false;
117}
135}
118
136
119void LauncherBackend::setPinned(const QString &appId, bool pinned)
137void LauncherBackend::setPinned(const QString &appId, bool pinned)
120{
138{
121− auto index = findItem(appId);
139+ if (!m_storedApps.contains(appId)) {
122− if (index >= 0 && !m_storedApps[index].pinned) {
140+ return;
141+ }
142+
143+ LauncherBackendItem *item = m_itemCache.value(appId);
144+ if (!item) {
145+ item = new LauncherBackendItem();
146+ m_itemCache.insert(appId, item);
147+ }
148+ if (item->pinned != pinned) {
123− m_storedApps[index].pinned = pinned;
149+ item->pinned = pinned;
124 syncToAccounts();
150 syncToAccounts();
125 }
151 }
126}
152}
@@ -153,8 +179,10 @@ int LauncherBackend::count(const QString &appId) const
153
179
154void LauncherBackend::setUser(const QString &username)
180void LauncherBackend::setUser(const QString &username)
155{
181{
182+ if (qgetenv("USER") == "lightdm" && m_user != username) {
156− m_user = username;
183+ m_user = username;
157− syncFromAccounts();
184+ syncFromAccounts();
185+ }
158}
186}
159
187
160void LauncherBackend::triggerQuickListAction(const QString &appId, const QString &quickListId)
188void LauncherBackend::triggerQuickListAction(const QString &appId, const QString &quickListId)
@@ -169,75 +197,118 @@ void LauncherBackend::syncFromAccounts()
169 QList<QVariantMap> apps;
197 QList<QVariantMap> apps;
170 bool defaults = true;
198 bool defaults = true;
171
199
172− clearItems();
200+ m_storedApps.clear();
173
201
174− if (m_user != "" && m_accounts != nullptr) {
202+ if (m_accounts && m_user.isEmpty()) {
175− auto variant = m_accounts->getUserProperty(m_user, "launcher-items");
203+ QVariant variant = m_accounts->getUserProperty(m_user, "launcher-items");
176 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());
204 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());
177 defaults = isDefaultsItem(apps);
205 defaults = isDefaultsItem(apps);
178 }
206 }
179
207
180− // TODO: load default pinned ones from default config, instead of hardcoding here...
208+ if (m_accounts && defaults) { // Checking accounts as it'll be null when !useStorage
181− if (defaults) {
209+ QGSettings gSettings("com.canonical.Unity.Launcher", "/com/canonical/unity/launcher/");
182− apps <<
210+ Q_FOREACH(const QString &entry, gSettings.get("favorites").toStringList()) {
183− makeAppDetails("dialer-app.desktop", true) <<
211+ if (entry.startsWith("application://")) {
184− makeAppDetails("messaging-app.desktop", true) <<
212+ QString appId = entry;
185− makeAppDetails("address-book-app.desktop", true) <<
213+ appId.remove("application://");
186− makeAppDetails("camera-app.desktop", true) <<
214+ QString df = findDesktopFile(appId);
187− makeAppDetails("gallery-app.desktop", true) <<
215+
188− makeAppDetails("facebook-webapp.desktop", true) <<
216+ if (!df.isEmpty()) {
189− makeAppDetails("webbrowser-app.desktop", true) <<
217+ m_storedApps << appId;
190− makeAppDetails("twitter-webapp.desktop", true) <<
218+
191− makeAppDetails("gmail-webapp.desktop", true) <<
219+ if (!m_itemCache.contains(appId)) {
192− makeAppDetails("ubuntu-weather-app.desktop", true) <<
220+ m_itemCache.insert(appId, parseDesktopFile(df));
193− makeAppDetails("notes-app.desktop", true) <<
221+ }
194− makeAppDetails("calendar-app.desktop", true);
222+ m_itemCache.value(appId)->pinned = true;
195− }
223+ }
196−
224+ }
225+ }
226+ } else {
197− for (const QVariant &app: apps) {
227+ for (const QVariant &app: apps) {
198− loadApp(app.toMap());
228+ loadFromVariant(app.toMap());
229+ }
199 }
230 }
200}
231}
201
232
202void LauncherBackend::syncToAccounts()
233void LauncherBackend::syncToAccounts()
203{
234{
204− if (m_user != "" && m_accounts != nullptr) {
235+ if (m_accounts && !m_user.isEmpty()) {
205 QList<QVariantMap> items;
236 QList<QVariantMap> items;
206
237
207− for (LauncherBackendItem &app: m_storedApps) {
238+ Q_FOREACH(const QString &appId, m_storedApps) {
208− items << makeAppDetails(app.settings->fileName(), app.pinned);
239+ items << itemToVariant(appId);
209 }
240 }
210
241
211 m_accounts->setUserProperty(m_user, "launcher-items", QVariant::fromValue(items));
242 m_accounts->setUserProperty(m_user, "launcher-items", QVariant::fromValue(items));
212 }
243 }
213}
244}
214
245
215−QSettings *LauncherBackend::parseDesktopFile(const QString &appId) const
246+QString LauncherBackend::findDesktopFile(const QString &appId) const
216{
247{
217− auto fullAppId = desktopFile(appId);
248+ int dashPos = -1;
218− return new QSettings(fullAppId, QSettings::IniFormat);
249+ QString helper = appId;
250+
251+ do {
252+ if (dashPos != -1) {
253+ helper = helper.replace(dashPos, 1, '/');
254+ }
255+
256+ QFileInfo fileInfo(QDir("/usr/share/applications"), helper);
257+ if (fileInfo.exists()) {
258+ return fileInfo.absoluteFilePath();
259+ }
260+
261+ dashPos = helper.indexOf("-");
262+ } while (dashPos != -1);
263+
264+ return QString();
219}
265}
220
266
221−void LauncherBackend::loadApp(const QVariantMap &details)
267+LauncherBackendItem* LauncherBackend::parseDesktopFile(const QString &desktopFile) const
222{
268{
223− auto appId = details.value("id").toString();
269+ QSettings settings(desktopFile, QSettings::IniFormat);
224− auto isPinned = details.value("is-pinned").toBool();
270+
225
271
226− if (appId.isEmpty()) {
272+ LauncherBackendItem* item = new LauncherBackendItem();
273+ item->desktopFile = desktopFile;
274+ item->displayName = settings.value("Desktop Entry/Name").toString();
275+ item->icon = settings.value("Desktop Entry/Icon").toString();
276+ item->pinned = false;
277+ return item;
278+}
279+
280+void LauncherBackend::loadFromVariant(const QVariantMap &details)
281+{
282+ if (!details.contains("id")) {
227 return;
283 return;
228 }
284 }
285+ QString appId = details.value("id").toString();
286+
287+ LauncherBackendItem *item = m_itemCache.value(appId);
288+ if (item) {
289+ delete item;
290+ }
291+
292+ item = new LauncherBackendItem();
293+
294+ item->desktopFile = details.value("desktopFile").toString();
295+ item->displayName = details.value("name").toString();
296+ item->icon = details.value("icon").toString();
297+ item->pinned = details.value("is-pinned").toBool();
229
298
230− LauncherBackendItem item;
299+ m_itemCache.insert(appId, item);
231− item.settings = parseDesktopFile(appId);
232− item.pinned = isPinned;
233− m_storedApps.append(item);
300+ m_storedApps.append(appId);
234}
301}
235
302
236−QVariantMap LauncherBackend::makeAppDetails(const QString &appId, bool pinned) const
303+QVariantMap LauncherBackend::itemToVariant(const QString &appId) const
237{
304{
305+ LauncherBackendItem *item = m_itemCache.value(appId);
238 QVariantMap details;
306 QVariantMap details;
239 details.insert("id", appId);
307 details.insert("id", appId);
308+ details.insert("name", item->displayName);
309+ details.insert("icon", item->icon);
310+ details.insert("desktopFile", item->desktopFile);
240− details.insert("is-pinned", pinned);
311+ details.insert("is-pinned", item->pinned);
241 return details;
312 return details;
242}
313}
243
314
@@ -248,14 +319,3 @@ bool LauncherBackend::isDefaultsItem(const QList<QVariantMap> &apps) const
248 // list of one item with the 'defaults' field set to true.
319 // list of one item with the 'defaults' field set to true.
249 return (apps.size() == 1 && apps[0].value("defaults").toBool());
320 return (apps.size() == 1 && apps[0].value("defaults").toBool());
250}
321}
251−
252−int LauncherBackend::findItem(const QString &appId) const
253−{
254− auto fullAppId = desktopFile(appId);
255− for (int i = 0; i < m_storedApps.size(); ++i) {
256− if (m_storedApps[i].settings->fileName() == fullAppId) {
257− return i;
258− }
259− }
260− return -1;
261−}
plugins/Unity/Launcher/backend/launcherbackend.h+10−12
@@ -31,6 +31,8 @@ class AccountsService;
31 * @brief An interface that provides all the data needed by the launcher.
31 * @brief An interface that provides all the data needed by the launcher.
32 */
32 */
33
33
34+class LauncherBackendItem;
35+
34class LauncherBackend : public QObject
36class LauncherBackend : public QObject
35{
37{
36 Q_OBJECT
38 Q_OBJECT
@@ -141,23 +143,19 @@ Q_SIGNALS:
141 void countChanged(const QString &appId, int count);
143 void countChanged(const QString &appId, int count);
142
144
143private:
145private:
146+ QString findDesktopFile(const QString &appId) const;
144− QSettings *parseDesktopFile(const QString &appId) const;
147+ LauncherBackendItem* parseDesktopFile(const QString &desktopFile) const;
148+
145− QVariantMap makeAppDetails(const QString &appId, bool pinned) const;
149+ QVariantMap itemToVariant(const QString &appId) const;
146− void loadApp(const QVariantMap &details);
150+ void loadFromVariant(const QVariantMap &details);
147− int findItem(const QString &appId) const;
151+
148 bool isDefaultsItem(const QList<QVariantMap> &apps) const;
152 bool isDefaultsItem(const QList<QVariantMap> &apps) const;
149 void syncFromAccounts();
153 void syncFromAccounts();
150 void syncToAccounts();
154 void syncToAccounts();
151− void clearItems();
152
155
156+ QList<QString> m_storedApps;
153− class LauncherBackendItem
157+ mutable QHash<QString, LauncherBackendItem*> m_itemCache;
154− {
155− public:
156− QSettings *settings;
157− bool pinned;
158− };
159
158
160− QList<LauncherBackendItem> m_storedApps;
161 AccountsService *m_accounts;
159 AccountsService *m_accounts;
162 QString m_user;
160 QString m_user;
163};
161};
plugins/Unity/categories.cpp−3
@@ -43,7 +43,6 @@ Categories::Categories(QObject* parent)
43 m_roles[Categories::RoleHints] = "hints";
43 m_roles[Categories::RoleHints] = "hints";
44 m_roles[Categories::RoleResults] = "results";
44 m_roles[Categories::RoleResults] = "results";
45 m_roles[Categories::RoleCount] = "count";
45 m_roles[Categories::RoleCount] = "count";
46− m_roles[Categories::RoleCategoryIndex] = "categoryIndex";
47
46
48 // TODO This should not be needed but accumulatting the count changes
47 // TODO This should not be needed but accumulatting the count changes
49 // makes the visualization more stable and also makes crashes on fast
48 // makes the visualization more stable and also makes crashes on fast
@@ -222,8 +221,6 @@ Categories::data(const QModelIndex& index, int role) const
222 return QVariant::fromValue(m_overriddenCategories[id]->rowCount());
221 return QVariant::fromValue(m_overriddenCategories[id]->rowCount());
223 }
222 }
224 return QVariant::fromValue(getResults(index.row())->rowCount());
223 return QVariant::fromValue(getResults(index.row())->rowCount());
225− case RoleCategoryIndex:
226− return QVariant::fromValue(index.row());
227 default:
224 default:
228 return QVariant();
225 return QVariant();
229 }
226 }
plugins/Unity/categories.h+1−2
@@ -50,8 +50,7 @@ public:
50 RoleProgressSource,
50 RoleProgressSource,
51 RoleHints,
51 RoleHints,
52 RoleResults,
52 RoleResults,
53− RoleCount,
53+ RoleCount
54− RoleCategoryIndex
55 };
54 };
56
55
57 Q_INVOKABLE void overrideResults(const QString& categoryId, QAbstractItemModel* model);
56 Q_INVOKABLE void overrideResults(const QString& categoryId, QAbstractItemModel* model);
tests/mocks/Unity/fake_categories.cpp−3
@@ -36,7 +36,6 @@ Categories::Categories(QObject* parent)
36 m_roles[Categories::RoleHints] = "hints";
36 m_roles[Categories::RoleHints] = "hints";
37 m_roles[Categories::RoleResults] = "results";
37 m_roles[Categories::RoleResults] = "results";
38 m_roles[Categories::RoleCount] = "count";
38 m_roles[Categories::RoleCount] = "count";
39− m_roles[Categories::RoleCategoryIndex] = "categoryIndex";
40
39
41 // TODO This should not be needed but accumulatting the count changes
40 // TODO This should not be needed but accumulatting the count changes
42 // makes the visualization more stable and also makes crashes on fast
41 // makes the visualization more stable and also makes crashes on fast
@@ -173,8 +172,6 @@ Categories::data(const QModelIndex& index, int role) const
173 return QVariant::fromValue(getFilter(index.row()));
172 return QVariant::fromValue(getFilter(index.row()));
174 case RoleCount:
173 case RoleCount:
175 return QVariant::fromValue(getFilter(index.row())->rowCount());
174 return QVariant::fromValue(getFilter(index.row())->rowCount());
176− case RoleCategoryIndex:
177− return QVariant::fromValue(index.row());
178 default:
175 default:
179 return QVariant();
176 return QVariant();
180 }
177 }
tests/mocks/Unity/fake_categories.h+1−2
@@ -41,8 +41,7 @@ public:
41 RoleContentType,
41 RoleContentType,
42 RoleHints,
42 RoleHints,
43 RoleResults,
43 RoleResults,
44− RoleCount,
44+ RoleCount
45− RoleCategoryIndex
46 };
45 };
47
46
48 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
47 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
tests/plugins/Unity/Launcher/CMakeLists.txt+4
@@ -1,8 +1,11 @@
1+pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
2+
1include_directories(
3include_directories(
2 ${CMAKE_CURRENT_BINARY_DIR}
4 ${CMAKE_CURRENT_BINARY_DIR}
3 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
5 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
4 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher
6 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher
5 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend
7 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend
8+ ${GSETTINGS_QT_INCLUDE_DIRS}
6 )
9 )
7
10
8add_definitions(-DSM_BUSNAME=sessionBus)
11add_definitions(-DSM_BUSNAME=sessionBus)
@@ -19,4 +22,5 @@ add_executable(launcherbackendtestExec
19 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend/launcherbackend.cpp
22 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend/launcherbackend.cpp
20 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/common/quicklistentry.cpp
23 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/common/quicklistentry.cpp
21 )
24 )
25+target_link_libraries(launcherbackendtestExec ${GSETTINGS_QT_LDFLAGS})
22qt5_use_modules(launcherbackendtestExec Test Core DBus)
26qt5_use_modules(launcherbackendtestExec Test Core DBus)
tests/plugins/Unity/Launcher/launcherbackendtest.cpp+1−34
@@ -32,46 +32,13 @@ private Q_SLOTS:
32 LauncherBackend backend(false);
32 LauncherBackend backend(false);
33
33
34 backend.setStoredApplications(QStringList() << "relative.path" << "/full/path");
34 backend.setStoredApplications(QStringList() << "relative.path" << "/full/path");
35− QCOMPARE(backend.storedApplications(), QStringList() << "/usr/share/applications/relative.path" << "/full/path");
35+ QCOMPARE(backend.storedApplications(), QStringList() << "relative.path" << "/full/path");
36−
37− QCOMPARE(backend.desktopFile("one.desktop"), QString("/usr/share/applications/one.desktop"));
38− QCOMPARE(backend.desktopFile("two"), QString("/usr/share/applications/two"));
39− QCOMPARE(backend.desktopFile("/full"), QString("/full"));
40−
41− QCOMPARE(backend.desktopFile("/usr/share/applications/one.desktop"), QString("/usr/share/applications/one.desktop"));
42− }
43−
44− void testDesktopReading()
45− {
46− LauncherBackend backend(false);
47−
48− QCOMPARE(backend.displayName(SRCDIR "/rel-icon.desktop"), QString("Relative Icon"));
49− QCOMPARE(backend.icon(SRCDIR "/rel-icon.desktop"), QString("image://theme/rel-icon"));
50−
51− QCOMPARE(backend.displayName(SRCDIR "/abs-icon.desktop"), QString("Absolute Icon"));
52− QCOMPARE(backend.icon(SRCDIR "/abs-icon.desktop"), QString("/path/to/icon.png"));
53−
54− QCOMPARE(backend.displayName(SRCDIR "/no-icon.desktop"), QString("No Icon"));
55− QCOMPARE(backend.icon(SRCDIR "/no-icon.desktop"), QString(""));
56−
57− QCOMPARE(backend.displayName(SRCDIR "/no-name.desktop"), QString(""));
58− QCOMPARE(backend.icon(SRCDIR "/no-name.desktop"), QString("image://theme/no-name"));
59−
60− QCOMPARE(backend.displayName(SRCDIR "/no-exist.desktop"), QString(""));
61− QCOMPARE(backend.icon(SRCDIR "/no-exist.desktop"), QString(""));
62 }
36 }
63
37
64 void testPinning()
38 void testPinning()
65 {
39 {
66 LauncherBackend backend(false);
40 LauncherBackend backend(false);
67
41
68− // Confirm that default entries are all pinned
69− auto defaultApps = backend.storedApplications();
70− QVERIFY(defaultApps.size() > 0);
71− for (auto app: defaultApps) {
72− QCOMPARE(backend.isPinned(app), true);
73− }
74−
75 backend.setStoredApplications(QStringList() << "one" << "two");
42 backend.setStoredApplications(QStringList() << "one" << "two");
76 QCOMPARE(backend.isPinned("one"), false);
43 QCOMPARE(backend.isPinned("one"), false);
77 QCOMPARE(backend.isPinned("two"), false);
44 QCOMPARE(backend.isPinned("two"), false);