Changeset View
Changeset View
Standalone View
Standalone View
kcms/keys/kglobalshortcutseditor.cpp
Show All 24 Lines | |||||
25 | #include "kglobalaccel_interface.h" | 25 | #include "kglobalaccel_interface.h" | ||
26 | #include "kglobalaccel_component_interface.h" | 26 | #include "kglobalaccel_component_interface.h" | ||
27 | 27 | | |||
28 | #include <KActionCollection> | 28 | #include <KActionCollection> | ||
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 <KIconLoader> | | |||
34 | #include <KMessageBox> | 33 | #include <KMessageBox> | ||
35 | #include <KStringHandler> | 34 | #include <KStringHandler> | ||
36 | #include <KLocalizedString> | 35 | #include <KLocalizedString> | ||
37 | #include <KService> | 36 | #include <KService> | ||
38 | #include <KRecursiveFilterProxyModel> | 37 | #include <KRecursiveFilterProxyModel> | ||
39 | #include <KServiceGroup> | 38 | #include <KServiceGroup> | ||
40 | #include <KDesktopFile> | 39 | #include <KDesktopFile> | ||
41 | #include <KCategorizedSortFilterProxyModel> | 40 | #include <KCategorizedSortFilterProxyModel> | ||
▲ Show 20 Lines • Show All 384 Lines • ▼ Show 20 Line(s) | 424 | { | |||
426 | KShortcutsEditor *editor; | 425 | KShortcutsEditor *editor; | ||
427 | // Check if this component is known | 426 | // Check if this component is known | ||
428 | QHash<QString, ComponentData*>::Iterator iter = d->components.find(friendlyName); | 427 | QHash<QString, ComponentData*>::Iterator iter = d->components.find(friendlyName); | ||
429 | if (iter == d->components.end()) { | 428 | if (iter == d->components.end()) { | ||
430 | // Unknown component. Create an editor. | 429 | // Unknown component. Create an editor. | ||
431 | editor = new KShortcutsEditor(this, d->actionTypes); | 430 | editor = new KShortcutsEditor(this, d->actionTypes); | ||
432 | d->stack->addWidget(editor); | 431 | d->stack->addWidget(editor); | ||
433 | 432 | | |||
434 | // try to find one appropriate icon ( allowing NULL pixmap to be returned) | 433 | // try to find one appropriate icon | ||
435 | QPixmap pixmap = KIconLoader::global()->loadIcon(id, KIconLoader::Small, 0, | 434 | QIcon icon = QIcon::fromTheme(id); | ||
436 | KIconLoader::DefaultState, QStringList(), nullptr, true); | 435 | if (icon.isNull()) { | ||
437 | if (pixmap.isNull()) { | | |||
438 | KService::Ptr service = KService::serviceByStorageId(id); | 436 | KService::Ptr service = KService::serviceByStorageId(id); | ||
439 | if(service) { | 437 | if (service) { | ||
440 | pixmap = KIconLoader::global()->loadIcon(service->icon(), KIconLoader::Small, 0, | 438 | icon = QIcon::fromTheme(service->icon()); | ||
441 | KIconLoader::DefaultState, QStringList(), nullptr, true); | | |||
442 | } | 439 | } | ||
443 | } | 440 | } | ||
444 | // if NULL pixmap is returned, use the F.D.O "system-run" icon | 441 | | ||
445 | if (pixmap.isNull()) { | 442 | // if NULL icon is returned, use the F.D.O "system-run" icon | ||
446 | pixmap = KIconLoader::global()->loadIcon(QStringLiteral("system-run"), KIconLoader::Small); | 443 | if (icon.isNull()) { | ||
444 | icon = QIcon::fromTheme(QStringLiteral("system-run")); | ||||
447 | } | 445 | } | ||
448 | 446 | | |||
449 | // Add to the component list | 447 | // Add to the component list | ||
450 | QStandardItem *item = new QStandardItem(pixmap, friendlyName); | 448 | QStandardItem *item = new QStandardItem(icon, friendlyName); | ||
451 | if (id.endsWith(QLatin1String(".desktop"))) { | 449 | if (id.endsWith(QLatin1String(".desktop"))) { | ||
452 | item->setData(i18n("Application Launchers"), KCategorizedSortFilterProxyModel::CategoryDisplayRole); | 450 | item->setData(i18n("Application Launchers"), KCategorizedSortFilterProxyModel::CategoryDisplayRole); | ||
453 | item->setData(0, KCategorizedSortFilterProxyModel::CategorySortRole); | 451 | item->setData(0, KCategorizedSortFilterProxyModel::CategorySortRole); | ||
454 | } else { | 452 | } else { | ||
455 | item->setData(i18n("Other Shortcuts"), KCategorizedSortFilterProxyModel::CategoryDisplayRole); | 453 | item->setData(i18n("Other Shortcuts"), KCategorizedSortFilterProxyModel::CategoryDisplayRole); | ||
456 | item->setData(1, KCategorizedSortFilterProxyModel::CategorySortRole); | 454 | item->setData(1, KCategorizedSortFilterProxyModel::CategorySortRole); | ||
457 | } | 455 | } | ||
458 | d->model->appendRow(item); | 456 | d->model->appendRow(item); | ||
▲ Show 20 Lines • Show All 390 Lines • Show Last 20 Lines |