on xenial help sign in
add pin() function
commit89de1816ed8caf72dfd09aac8ccff866dd730aca authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 2 Jul 2013, 13:13 (13 years ago) parentf598fb9
2 files changed+13
plugins/Unity/Launcher/launchermodel.cpp+12 plugins/Unity/Launcher/launchermodel.h+1
plugins/Unity/Launcher/launchermodel.cpp+12
@@ -93,6 +93,18 @@ void LauncherModel::move(int oldIndex, int newIndex)
9393 m_backend->setFavoriteApplications(appIds);
9494}
9595
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+
96108QHash<int, QByteArray> LauncherModel::roleNames() const
97109{
98110 QHash<int, QByteArray> roles;
plugins/Unity/Launcher/launchermodel.h+1
@@ -45,6 +45,7 @@ public:
4545
4646 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const;
4747 Q_INVOKABLE void move(int oldIndex, int newIndex);
48+ Q_INVOKABLE void pin(int index);
4849
4950 QHash<int, QByteArray> roleNames() const;
5051