Changeset View
Changeset View
Standalone View
Standalone View
menuinfo.cpp
Show All 20 Lines | |||||
21 | 21 | | |||
22 | #include <QRegExp> | 22 | #include <QRegExp> | ||
23 | 23 | | |||
24 | #include <KDesktopFile> | 24 | #include <KDesktopFile> | ||
25 | 25 | | |||
26 | #include <KConfigGroup> | 26 | #include <KConfigGroup> | ||
27 | #include <QStandardPaths> | 27 | #include <QStandardPaths> | ||
28 | 28 | | |||
29 | #include "globalaccel.h" | ||||
29 | #include "menufile.h" | 30 | #include "menufile.h" | ||
30 | #ifdef WITH_HOTKEYS | | |||
31 | #include "khotkeys.h" | | |||
32 | #endif | | |||
33 | 31 | | |||
34 | // | 32 | // | ||
35 | // MenuFolderInfo | 33 | // MenuFolderInfo | ||
36 | // | 34 | // | ||
37 | 35 | | |||
38 | static QStringList *s_newShortcuts = nullptr; | 36 | static QStringList *s_newShortcuts = nullptr; | ||
39 | static QStringList *s_freeShortcuts = nullptr; | 37 | static QStringList *s_freeShortcuts = nullptr; | ||
40 | static QStringList *s_deletedApps = nullptr; | 38 | static QStringList *s_deletedApps = nullptr; | ||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Line(s) | |||||
173 | 171 | | |||
174 | void MenuFolderInfo::setDirty() | 172 | void MenuFolderInfo::setDirty() | ||
175 | { | 173 | { | ||
176 | dirty = true; | 174 | dirty = true; | ||
177 | } | 175 | } | ||
178 | 176 | | |||
179 | void MenuFolderInfo::save(MenuFile *menuFile) | 177 | void MenuFolderInfo::save(MenuFile *menuFile) | ||
180 | { | 178 | { | ||
181 | if (s_deletedApps) { | 179 | if (s_deletedApps) { | ||
182 | #ifdef WITH_HOTKEYS | | |||
183 | // Remove hotkeys for applications that have been deleted | 180 | // Remove hotkeys for applications that have been deleted | ||
mlaurent: you can remove this ifdef | |||||
184 | for (QStringList::ConstIterator it = s_deletedApps->constBegin(); | 181 | for (QStringList::ConstIterator it = s_deletedApps->constBegin(); | ||
185 | it != s_deletedApps->constEnd(); ++it) { | 182 | it != s_deletedApps->constEnd(); ++it) { | ||
186 | // The shorcut is deleted if we set a empty sequence | 183 | // The shorcut is deleted if we set a empty sequence | ||
187 | KHotKeys::changeMenuEntryShortcut(*it, QLatin1String("")); | 184 | GlobalAccel::changeMenuEntryShortcut(*it, QKeySequence()); | ||
188 | } | 185 | } | ||
189 | #endif | | |||
190 | delete s_deletedApps; | 186 | delete s_deletedApps; | ||
191 | s_deletedApps = nullptr; | 187 | s_deletedApps = nullptr; | ||
192 | } | 188 | } | ||
193 | 189 | | |||
194 | if (dirty) { | 190 | if (dirty) { | ||
195 | QString local = KDesktopFile::locateLocal(directoryFile); | 191 | QString local = KDesktopFile::locateLocal(directoryFile); | ||
196 | 192 | | |||
197 | KDesktopFile *df = nullptr; | 193 | KDesktopFile *df = nullptr; | ||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | |||||
322 | } | 318 | } | ||
323 | 319 | | |||
324 | void MenuEntryInfo::save() | 320 | void MenuEntryInfo::save() | ||
325 | { | 321 | { | ||
326 | if (dirty) { | 322 | if (dirty) { | ||
327 | m_desktopFile->sync(); | 323 | m_desktopFile->sync(); | ||
328 | dirty = false; | 324 | dirty = false; | ||
329 | } | 325 | } | ||
330 | #ifdef WITH_HOTKEYS | | |||
331 | if (shortcutDirty) { | 326 | if (shortcutDirty) { | ||
332 | if (KHotKeys::present()) { | 327 | GlobalAccel::changeMenuEntryShortcut(service->storageId(), shortCut); | ||
333 | KHotKeys::changeMenuEntryShortcut(service->storageId(), shortCut.toString()); | | |||
334 | } | | |||
335 | shortcutDirty = false; | 328 | shortcutDirty = false; | ||
336 | } | 329 | } | ||
337 | #endif | | |||
338 | } | 330 | } | ||
339 | 331 | | |||
340 | void MenuEntryInfo::setCaption(const QString &_caption) | 332 | void MenuEntryInfo::setCaption(const QString &_caption) | ||
341 | { | 333 | { | ||
342 | if (caption == _caption) { | 334 | if (caption == _caption) { | ||
343 | return; | 335 | return; | ||
344 | } | 336 | } | ||
345 | caption = _caption; | 337 | caption = _caption; | ||
Show All 19 Lines | 353 | { | |||
365 | 357 | | |||
366 | icon = _icon; | 358 | icon = _icon; | ||
367 | setDirty(); | 359 | setDirty(); | ||
368 | desktopFile()->desktopGroup().writeEntry("Icon", icon); | 360 | desktopFile()->desktopGroup().writeEntry("Icon", icon); | ||
369 | } | 361 | } | ||
370 | 362 | | |||
371 | QKeySequence MenuEntryInfo::shortcut() | 363 | QKeySequence MenuEntryInfo::shortcut() | ||
372 | { | 364 | { | ||
373 | #ifdef WITH_HOTKEYS | | |||
374 | if (!shortcutLoaded) { | 365 | if (!shortcutLoaded) { | ||
375 | shortcutLoaded = true; | 366 | shortcutLoaded = true; | ||
376 | if (KHotKeys::present()) { | 367 | shortCut = GlobalAccel::getMenuEntryShortcut(service->storageId()); | ||
377 | shortCut = QKeySequence(KHotKeys::getMenuEntryShortcut(service->storageId())); | | |||
378 | } | | |||
379 | } | 368 | } | ||
380 | #endif | | |||
381 | return shortCut; | 369 | return shortCut; | ||
382 | } | 370 | } | ||
383 | 371 | | |||
384 | static void freeShortcut(const QKeySequence &shortCut) | 372 | static void freeShortcut(const QKeySequence &shortCut) | ||
385 | { | 373 | { | ||
386 | if (!shortCut.isEmpty()) { | 374 | if (!shortCut.isEmpty()) { | ||
387 | QString shortcutKey = shortCut.toString(); | 375 | QString shortcutKey = shortCut.toString(); | ||
388 | if (s_newShortcuts) { | 376 | if (s_newShortcuts) { | ||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |
you can remove this ifdef