Changeset View
Changeset View
Standalone View
Standalone View
kcms/keys/kglobalshortcutseditor.cpp
Show All 28 Lines | |||||
29 | #include <KConfig> | 29 | #include <KConfig> | ||
30 | #include <QDebug> | 30 | #include <QDebug> | ||
31 | #include <KGlobalAccel> | 31 | #include <KGlobalAccel> | ||
32 | #include <KConfigGroup> | 32 | #include <KConfigGroup> | ||
33 | #include <KMessageBox> | 33 | #include <KMessageBox> | ||
34 | #include <KStringHandler> | 34 | #include <KStringHandler> | ||
35 | #include <KLocalizedString> | 35 | #include <KLocalizedString> | ||
36 | #include <KService> | 36 | #include <KService> | ||
37 | #include <KServiceTypeTrader> | ||||
37 | #include <KRecursiveFilterProxyModel> | 38 | #include <KRecursiveFilterProxyModel> | ||
38 | #include <KServiceGroup> | 39 | #include <KServiceGroup> | ||
39 | #include <KDesktopFile> | 40 | #include <KDesktopFile> | ||
40 | #include <KCategorizedSortFilterProxyModel> | 41 | #include <KCategorizedSortFilterProxyModel> | ||
41 | #include <KCategoryDrawer> | 42 | #include <KCategoryDrawer> | ||
42 | 43 | | |||
43 | #include <QStackedWidget> | 44 | #include <QStackedWidget> | ||
44 | #include <QMenu> | 45 | #include <QMenu> | ||
▲ Show 20 Lines • Show All 379 Lines • ▼ Show 20 Line(s) | |||||
424 | { | 425 | { | ||
425 | KShortcutsEditor *editor; | 426 | KShortcutsEditor *editor; | ||
426 | // Check if this component is known | 427 | // Check if this component is known | ||
427 | QHash<QString, ComponentData*>::Iterator iter = d->components.find(friendlyName); | 428 | QHash<QString, ComponentData*>::Iterator iter = d->components.find(friendlyName); | ||
428 | if (iter == d->components.end()) { | 429 | if (iter == d->components.end()) { | ||
429 | // Unknown component. Create an editor. | 430 | // Unknown component. Create an editor. | ||
430 | editor = new KShortcutsEditor(this, d->actionTypes); | 431 | editor = new KShortcutsEditor(this, d->actionTypes); | ||
431 | d->stack->addWidget(editor); | 432 | d->stack->addWidget(editor); | ||
432 | 433 | KService::Ptr service = KService::serviceByStorageId(id); | |||
434 | if (!service) { | ||||
435 | // Do we have an application with that name? | ||||
436 | KService::List apps = KServiceTypeTrader::self()->query(QStringLiteral("Application"), | ||||
mlaurent: const KService::List | |||||
437 | QStringLiteral("Name == '%1' or Name == '%2'").arg(id, friendlyName)); | ||||
438 | if(!apps.isEmpty()) { | ||||
439 | service = apps[0]; | ||||
440 | } | ||||
441 | } | ||||
433 | // try to find one appropriate icon | 442 | // try to find one appropriate icon | ||
434 | QIcon icon = QIcon::fromTheme(id); | 443 | QIcon icon = QIcon::fromTheme(id); | ||
435 | if (icon.isNull()) { | 444 | if (icon.isNull()) { | ||
436 | KService::Ptr service = KService::serviceByStorageId(id); | | |||
437 | if (service) { | 445 | if (service) { | ||
438 | icon = QIcon::fromTheme(service->icon()); | 446 | icon = QIcon::fromTheme(service->icon()); | ||
439 | } | 447 | } | ||
440 | } | 448 | } | ||
441 | 449 | | |||
442 | // if NULL icon is returned, use the F.D.O "system-run" icon | 450 | // if NULL icon is returned, use the F.D.O "system-run" icon | ||
443 | if (icon.isNull()) { | 451 | if (icon.isNull()) { | ||
444 | icon = QIcon::fromTheme(QStringLiteral("system-run")); | 452 | icon = QIcon::fromTheme(QStringLiteral("system-run")); | ||
445 | } | 453 | } | ||
446 | 454 | | |||
447 | // Add to the component list | 455 | // Add to the component list | ||
448 | QStandardItem *item = new QStandardItem(icon, friendlyName); | 456 | QStandardItem *item = new QStandardItem(icon, friendlyName); | ||
449 | if (id.endsWith(QLatin1String(".desktop"))) { | 457 | if (service && service->isApplication()) { | ||
450 | item->setData(i18n("Application Launchers"), KCategorizedSortFilterProxyModel::CategoryDisplayRole); | 458 | item->setData(i18n("Applications"), KCategorizedSortFilterProxyModel::CategoryDisplayRole); | ||
451 | item->setData(0, KCategorizedSortFilterProxyModel::CategorySortRole); | 459 | item->setData(0, KCategorizedSortFilterProxyModel::CategorySortRole); | ||
452 | } else { | 460 | } else { | ||
453 | item->setData(i18n("Other Shortcuts"), KCategorizedSortFilterProxyModel::CategoryDisplayRole); | 461 | item->setData(i18n("Plasma"), KCategorizedSortFilterProxyModel::CategoryDisplayRole); | ||
454 | item->setData(1, KCategorizedSortFilterProxyModel::CategorySortRole); | 462 | item->setData(1, KCategorizedSortFilterProxyModel::CategorySortRole); | ||
455 | } | 463 | } | ||
456 | d->model->appendRow(item); | 464 | d->model->appendRow(item); | ||
457 | d->proxyModel->sort(0); | 465 | d->proxyModel->sort(0); | ||
458 | 466 | | |||
459 | // Add to our component registry | 467 | // Add to our component registry | ||
460 | ComponentData *cd = new ComponentData(id, objectPath, editor); | 468 | ComponentData *cd = new ComponentData(id, objectPath, editor); | ||
461 | d->components.insert(friendlyName, cd); | 469 | d->components.insert(friendlyName, cd); | ||
▲ Show 20 Lines • Show All 385 Lines • Show Last 20 Lines |
const KService::List