on xenial help sign in
Fix some nits, making the branch mostly work
commit90611f54f28263e846c28f9f80311e38ca946384 authorMichael Terry <michael.terry@canonical.com> dateMon 19 Aug 2013, 22:28 (13 years ago) parentdda4ff5
7 files changed+32−12
Launcher/LauncherDelegate.qml+1−1 Shell.qml+1 plugins/AccountsService/com.canonical.unity.AccountsService.xml+3−1 plugins/Unity/Launcher/backend/launcherbackend.cpp+23−7 plugins/Unity/Launcher/backend/launcherbackend.h+1−2 tests/mocks/Unity/Launcher/CMakeLists.txt+2 tests/mocks/Unity/Launcher/MockLauncherItem.cpp+1−1
Launcher/LauncherDelegate.qml+1−1
@@ -56,7 +56,7 @@ Item {
5656 id: iconImage
5757 sourceSize.width: iconShape.width
5858 sourceSize.height: iconShape.height
59− source: "../graphics/applicationIcons/" + root.iconName + ".png"
59+ source: root.iconName
6060 }
6161
6262 MouseArea {
Shell.qml+1
@@ -18,6 +18,7 @@ import QtQuick 2.0
1818import Ubuntu.Application 0.1
1919import Ubuntu.Components 0.1
2020import Ubuntu.Gestures 0.1
21+import Unity.Launcher 0.1
2122import LightDM 0.1 as LightDM
2223import AccountsService 0.1
2324import Powerd 0.1
plugins/AccountsService/com.canonical.unity.AccountsService.xml+3−1
@@ -13,7 +13,9 @@
1313 <annotation name="org.freedesktop.Accounts.DefaultValue" value="true"/>
1414 </property>
1515
16− <property name="launcher-items" type="as" access="readwrite"/>
16+ <property name="launcher-items" type="as" access="readwrite">
17+ <annotation name="org.freedesktop.Accounts.DefaultValue" value="[]"/>
18+ </property>
1719
1820 </interface>
1921</node>
plugins/Unity/Launcher/backend/launcherbackend.cpp+23−7
@@ -22,11 +22,6 @@
2222#include <QDir>
2323#include <QFileInfo>
2424
25−LauncherBackend::LauncherBackendItem::~LauncherBackendItem()
26−{
27− delete settings;
28−}
29−
3025LauncherBackend::LauncherBackend(QObject *parent):
3126 QObject(parent)
3227{
@@ -36,7 +31,15 @@ LauncherBackend::LauncherBackend(QObject *parent):
3631
3732LauncherBackend::~LauncherBackend()
3833{
34+ clearItems();
35+}
3936
37+void LauncherBackend::clearItems()
38+{
39+ for (int i = 0; i < m_storedApps.size(); i++) {
40+ delete m_storedApps[i].settings;
41+ }
42+ m_storedApps.clear();
4043}
4144
4245QStringList LauncherBackend::storedApplications() const
@@ -69,7 +72,8 @@ void LauncherBackend::setStoredApplications(const QStringList &appIds)
6972 }
7073 }
7174
72− m_storedApps.clear();
75+ clearItems();
76+
7377 for (auto appId: appIds) {
7478 loadDesktopFile(appId);
7579 }
@@ -101,7 +105,14 @@ QString LauncherBackend::icon(const QString &appId) const
101105 if (index < 0) {
102106 return "";
103107 } else {
104− return m_storedApps[index].settings->value("Desktop Entry/Icon").toString();
108+ auto iconName = m_storedApps[index].settings->value("Desktop Entry/Icon").toString();
109+ if (!iconName.isEmpty()) {
110+ QFileInfo iconFileInfo(iconName);
111+ if (iconFileInfo.isRelative()) {
112+ iconName = "image://gicon/" + iconName;
113+ }
114+ }
115+ return iconName;
105116 }
106117}
107118
@@ -187,6 +198,11 @@ void LauncherBackend::syncFromAccounts()
187198 }
188199
189200 setStoredApplications(appIds);
201+
202+ // Mark all apps as pinned (since we just refreshed the set)
203+ for (int i = 0; i < m_storedApps.size(); i++) {
204+ m_storedApps[i].pinned = true;
205+ }
190206}
191207
192208void LauncherBackend::syncToAccounts()
plugins/Unity/Launcher/backend/launcherbackend.h+1−2
@@ -136,12 +136,11 @@ private:
136136 int findItem(const QString &appId) const;
137137 void syncFromAccounts();
138138 void syncToAccounts();
139+ void clearItems();
139140
140141 class LauncherBackendItem
141142 {
142143 public:
143− ~LauncherBackendItem();
144−
145144 QSettings *settings;
146145 bool pinned;
147146 };
tests/mocks/Unity/Launcher/CMakeLists.txt+2
@@ -1,6 +1,8 @@
11include(FindPkgConfig)
22pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=2)
33
4+add_definitions(-DTOP_SRCDIR="${CMAKE_SOURCE_DIR}")
5+
46include_directories(
57 ${CMAKE_CURRENT_SOURCE_DIR}
68)
tests/mocks/Unity/Launcher/MockLauncherItem.cpp+1−1
@@ -27,7 +27,7 @@ MockLauncherItem::MockLauncherItem(const QString &appId, const QString& desktopF
2727 m_appId(appId),
2828 m_desktopFile(desktopFile),
2929 m_name(name),
30− m_icon(icon),
30+ m_icon(TOP_SRCDIR "/graphics/applicationIcons/" + icon + ".png"),
3131 m_pinned(false),
3232 m_running(false),
3333 m_recent(false),