on xenial help sign in
add pin() function
89de181Michael Zanetti
plugins/Unity/Launcher/launchermodel.cpp+12
@@ -93,6 +93,18 @@ void LauncherModel::move(int oldIndex, int newIndex)
93 m_backend->setFavoriteApplications(appIds);
93 m_backend->setFavoriteApplications(appIds);
94}
94}
95
95
96+void LauncherModel::pin(int index)
97+{
98+ QString appId = m_list.at(index)->desktopFile();
99+ if (!m_backend->favoriteApplications().contains(appId)) {
100+ QStringList oldList = m_backend->favoriteApplications();
101+ m_backend->setFavoriteApplications(oldList << appId);
102+ }
103+ if (!m_backend->isPinned(appId)) {
104+ m_backend->setPinned(appId, true);
105+ }
106+}
107+
96QHash<int, QByteArray> LauncherModel::roleNames() const
108QHash<int, QByteArray> LauncherModel::roleNames() const
97{
109{
98 QHash<int, QByteArray> roles;
110 QHash<int, QByteArray> roles;
plugins/Unity/Launcher/launchermodel.h+1
@@ -45,6 +45,7 @@ public:
45
45
46 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const;
46 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const;
47 Q_INVOKABLE void move(int oldIndex, int newIndex);
47 Q_INVOKABLE void move(int oldIndex, int newIndex);
48+ Q_INVOKABLE void pin(int index);
48
49
49 QHash<int, QByteArray> roleNames() const;
50 QHash<int, QByteArray> roleNames() const;
50
51