Changeset View
Changeset View
Standalone View
Standalone View
applets/taskmanager/plugin/smartlaunchers/smartlauncheritem.cpp
Show All 13 Lines | |||||
14 | * You should have received a copy of the GNU General Public License * | 14 | * You should have received a copy of the GNU General Public License * | ||
15 | * along with this program; if not, write to the * | 15 | * along with this program; if not, write to the * | ||
16 | * Free Software Foundation, Inc., * | 16 | * Free Software Foundation, Inc., * | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||
18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
19 | 19 | | |||
20 | #include "smartlauncheritem.h" | 20 | #include "smartlauncheritem.h" | ||
21 | 21 | | |||
22 | #include <KDesktopFile> | ||||
22 | #include <KService> | 23 | #include <KService> | ||
23 | 24 | | |||
24 | using namespace SmartLauncher; | 25 | using namespace SmartLauncher; | ||
25 | 26 | | |||
26 | Item::Item(QObject *parent) : QObject(parent) | 27 | Item::Item(QObject *parent) : QObject(parent) | ||
27 | { | 28 | { | ||
28 | m_backendPtr = s_backend.toStrongRef(); | 29 | m_backendPtr = s_backend.toStrongRef(); | ||
29 | if (!m_backendPtr) { | 30 | if (!m_backendPtr) { | ||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | |||||
113 | } | 114 | } | ||
114 | 115 | | |||
115 | void Item::setLauncherUrl(const QUrl &launcherUrl) | 116 | void Item::setLauncherUrl(const QUrl &launcherUrl) | ||
116 | { | 117 | { | ||
117 | if (launcherUrl != m_launcherUrl) { | 118 | if (launcherUrl != m_launcherUrl) { | ||
118 | m_launcherUrl = launcherUrl; | 119 | m_launcherUrl = launcherUrl; | ||
119 | emit launcherUrlChanged(launcherUrl); | 120 | emit launcherUrlChanged(launcherUrl); | ||
120 | 121 | | |||
121 | KService::Ptr service = KService::serviceByDesktopPath(launcherUrl.toLocalFile()); | 122 | m_storageId.clear(); | ||
123 | | ||||
124 | if (launcherUrl.scheme() == QStringLiteral("applications")) { | ||||
125 | const KService::Ptr service = KService::serviceByMenuId(launcherUrl.path()); | ||||
126 | | ||||
127 | if (service && launcherUrl.path() == service->menuId()) { | ||||
128 | m_storageId = service->menuId(); | ||||
129 | } | ||||
130 | } | ||||
131 | | ||||
132 | if (launcherUrl.isLocalFile() && KDesktopFile::isDesktopFile(launcherUrl.toLocalFile())) { | ||||
133 | KDesktopFile f(launcherUrl.toLocalFile()); | ||||
134 | | ||||
135 | const KService::Ptr service = KService::serviceByStorageId(f.fileName()); | ||||
122 | if (service) { | 136 | if (service) { | ||
123 | m_storageId = service->storageId(); | 137 | m_storageId = service->storageId(); | ||
124 | } | 138 | } | ||
139 | } | ||||
140 | | ||||
141 | if (m_storageId.isEmpty()) { | ||||
142 | return; | ||||
anthonyfieroni: This check should be before init()? m_storageId can be empty but it can has an override one, no? | |||||
unityMappingRules().value(m_storageId); ← if m_storageId is empty, this call makes no sense? broulik: `unityMappingRules().value(m_storageId);` ← if `m_storageId` is empty, this call makes no sense? | |||||
But yeah I guess I'll move it to before init since the mapping rule might overwrite it to be empty broulik: But yeah I guess I'll move it to before `init` since the mapping rule might overwrite it to be… | |||||
143 | } | ||||
125 | 144 | | |||
126 | if (m_backendPtr) { | 145 | if (m_backendPtr) { | ||
127 | // check if we have a mapping to a different desktop file | 146 | // check if we have a mapping to a different desktop file | ||
128 | const QString &overrideStorageId = m_backendPtr->unityMappingRules().value(m_storageId); | 147 | const QString &overrideStorageId = m_backendPtr->unityMappingRules().value(m_storageId); | ||
129 | if (!overrideStorageId.isEmpty()) { | 148 | if (!overrideStorageId.isEmpty()) { | ||
130 | m_storageId = overrideStorageId; | 149 | m_storageId = overrideStorageId; | ||
131 | } | 150 | } | ||
132 | } | 151 | } | ||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |
This check should be before init()? m_storageId can be empty but it can has an override one, no?