Changeset View
Changeset View
Standalone View
Standalone View
kcms/keys/kglobalshortcutseditor.cpp
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 75 | public: | |||
---|---|---|---|---|---|
77 | ComponentData( | 77 | ComponentData( | ||
78 | const QString &uniqueName, | 78 | const QString &uniqueName, | ||
79 | const QDBusObjectPath &path, | 79 | const QDBusObjectPath &path, | ||
80 | KShortcutsEditor *_editor); | 80 | KShortcutsEditor *_editor); | ||
81 | 81 | | |||
82 | ~ComponentData(); | 82 | ~ComponentData(); | ||
83 | 83 | | |||
84 | QString uniqueName() const; | 84 | QString uniqueName() const; | ||
85 | KShortcutsEditor *editor(); | 85 | KShortcutsEditor *editor() const; | ||
86 | QDBusObjectPath dbusPath(); | 86 | QDBusObjectPath dbusPath() const; | ||
87 | 87 | | |||
88 | private: | 88 | private: | ||
89 | 89 | | |||
90 | QString _uniqueName; | 90 | QString _uniqueName; | ||
91 | QDBusObjectPath _path; | 91 | QDBusObjectPath _path; | ||
92 | QPointer<KShortcutsEditor> _editor; | 92 | QPointer<KShortcutsEditor> _editor; | ||
93 | }; | 93 | }; | ||
94 | 94 | | |||
Show All 15 Lines | |||||
110 | 110 | | |||
111 | 111 | | |||
112 | QString ComponentData::uniqueName() const | 112 | QString ComponentData::uniqueName() const | ||
113 | { | 113 | { | ||
114 | return _uniqueName; | 114 | return _uniqueName; | ||
115 | } | 115 | } | ||
116 | 116 | | |||
117 | 117 | | |||
118 | QDBusObjectPath ComponentData::dbusPath() | 118 | QDBusObjectPath ComponentData::dbusPath() const | ||
119 | { | 119 | { | ||
120 | return _path; | 120 | return _path; | ||
121 | } | 121 | } | ||
122 | 122 | | |||
123 | 123 | | |||
124 | KShortcutsEditor *ComponentData::editor() | 124 | KShortcutsEditor *ComponentData::editor() const | ||
125 | { | 125 | { | ||
126 | return _editor; | 126 | return _editor; | ||
127 | } | 127 | } | ||
128 | 128 | | |||
129 | 129 | | |||
130 | class KGlobalShortcutsEditor::KGlobalShortcutsEditorPrivate | 130 | class KGlobalShortcutsEditor::KGlobalShortcutsEditorPrivate | ||
131 | { | 131 | { | ||
132 | public: | 132 | public: | ||
Show All 27 Lines | |||||
160 | KCategorizedSortFilterProxyModel *proxyModel = nullptr; | 160 | KCategorizedSortFilterProxyModel *proxyModel = nullptr; | ||
161 | }; | 161 | }; | ||
162 | 162 | | |||
163 | void loadAppsCategory(KServiceGroup::Ptr group, QStandardItemModel *model, QStandardItem *item) | 163 | void loadAppsCategory(KServiceGroup::Ptr group, QStandardItemModel *model, QStandardItem *item) | ||
164 | { | 164 | { | ||
165 | if (group && group->isValid()) { | 165 | if (group && group->isValid()) { | ||
166 | KServiceGroup::List list = group->entries(); | 166 | KServiceGroup::List list = group->entries(); | ||
167 | 167 | | |||
168 | for( KServiceGroup::List::ConstIterator it = list.constBegin(); | 168 | for (KServiceGroup::List::ConstIterator it = list.constBegin(); | ||
bport: you have an unneeded space after ( | |||||
169 | it != list.constEnd(); ++it) { | 169 | it != list.constEnd(); ++it) { | ||
170 | const KSycocaEntry::Ptr p = (*it); | 170 | const KSycocaEntry::Ptr p = (*it); | ||
171 | 171 | | |||
172 | if (p->isType(KST_KService)) { | 172 | if (p->isType(KST_KService)) { | ||
173 | const KService::Ptr service(static_cast<KService*>(p.data())); | 173 | const KService::Ptr service(static_cast<KService*>(p.data())); | ||
174 | 174 | | |||
175 | if (!service->noDisplay()) { | 175 | if (!service->noDisplay()) { | ||
176 | QString genericName = service->genericName(); | 176 | QString genericName = service->genericName(); | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 258 | if (!desktopPath.isEmpty()) { | |||
261 | qWarning()<<QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/kglobalaccel/") + desktopFile; | 261 | qWarning()<<QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/kglobalaccel/") + desktopFile; | ||
262 | destinationDF->sync(); | 262 | destinationDF->sync(); | ||
263 | //TODO: a DBUS call to tell the daemon to refresh desktop files | 263 | //TODO: a DBUS call to tell the daemon to refresh desktop files | ||
264 | 264 | | |||
265 | 265 | | |||
266 | // Create a action collection for our current component:context | 266 | // Create a action collection for our current component:context | ||
267 | KActionCollection *col = new KActionCollection(q, desktopFile); | 267 | KActionCollection *col = new KActionCollection(q, desktopFile); | ||
268 | 268 | | |||
269 | foreach(const QString &actionId, sourceDF.readActions()) { | 269 | const auto actions = sourceDF.readActions(); | ||
270 | for (const QString &actionId : actions) { | ||||
270 | 271 | | |||
271 | const QString friendlyName = sourceDF.actionGroup(actionId).readEntry(QStringLiteral("Name")); | 272 | const QString friendlyName = sourceDF.actionGroup(actionId).readEntry(QStringLiteral("Name")); | ||
272 | QAction *action = col->addAction(actionId); | 273 | QAction *action = col->addAction(actionId); | ||
273 | action->setProperty("isConfigurationAction", QVariant(true)); // see KAction::~KAction | 274 | action->setProperty("isConfigurationAction", QVariant(true)); // see KAction::~KAction | ||
274 | action->setProperty("componentDisplayName", friendlyName); | 275 | action->setProperty("componentDisplayName", friendlyName); | ||
275 | action->setText(friendlyName); | 276 | action->setText(friendlyName); | ||
276 | 277 | | |||
277 | KGlobalAccel::self()->setShortcut(action, QList<QKeySequence>()); | 278 | KGlobalAccel::self()->setShortcut(action, QList<QKeySequence>()); | ||
278 | 279 | | |||
279 | QStringList sequencesStrings = sourceDF.actionGroup(actionId).readEntry(QStringLiteral("X-KDE-Shortcuts"), QString()).split(QLatin1Char('/')); | 280 | const QStringList sequencesStrings = sourceDF.actionGroup(actionId).readEntry(QStringLiteral("X-KDE-Shortcuts"), QString()).split(QLatin1Char('/')); | ||
280 | QList<QKeySequence> sequences; | 281 | QList<QKeySequence> sequences; | ||
281 | if (!sequencesStrings.isEmpty()) { | 282 | if (!sequencesStrings.isEmpty()) { | ||
282 | Q_FOREACH (const QString &seqString, sequencesStrings) { | 283 | for (const QString &seqString : sequencesStrings) { | ||
283 | sequences.append(QKeySequence(seqString)); | 284 | sequences.append(QKeySequence(seqString)); | ||
284 | } | 285 | } | ||
285 | } | 286 | } | ||
286 | 287 | | |||
287 | if (!sequences.isEmpty()) { | 288 | if (!sequences.isEmpty()) { | ||
288 | KGlobalAccel::self()->setDefaultShortcut(action, sequences); | 289 | KGlobalAccel::self()->setDefaultShortcut(action, sequences); | ||
289 | } | 290 | } | ||
290 | } | 291 | } | ||
291 | //Global launch action | 292 | //Global launch action | ||
292 | { | 293 | { | ||
293 | const QString friendlyName = i18n("Launch %1", sourceDF.readName()); | 294 | const QString friendlyName = i18n("Launch %1", sourceDF.readName()); | ||
294 | QAction *action = col->addAction(QStringLiteral("_launch")); | 295 | QAction *action = col->addAction(QStringLiteral("_launch")); | ||
295 | action->setProperty("isConfigurationAction", QVariant(true)); // see KAction::~KAction | 296 | action->setProperty("isConfigurationAction", QVariant(true)); // see KAction::~KAction | ||
296 | action->setProperty("componentDisplayName", friendlyName); | 297 | action->setProperty("componentDisplayName", friendlyName); | ||
297 | action->setText(friendlyName); | 298 | action->setText(friendlyName); | ||
298 | 299 | | |||
299 | KGlobalAccel::self()->setShortcut(action, QList<QKeySequence>()); | 300 | KGlobalAccel::self()->setShortcut(action, QList<QKeySequence>()); | ||
300 | 301 | | |||
301 | QStringList sequencesStrings = sourceDF.desktopGroup().readEntry(QStringLiteral("X-KDE-Shortcuts"), QString()).split(QLatin1Char('/')); | 302 | const QStringList sequencesStrings = sourceDF.desktopGroup().readEntry(QStringLiteral("X-KDE-Shortcuts"), QString()).split(QLatin1Char('/')); | ||
302 | QList<QKeySequence> sequences; | 303 | QList<QKeySequence> sequences; | ||
303 | if (!sequencesStrings.isEmpty()) { | 304 | if (!sequencesStrings.isEmpty()) { | ||
304 | Q_FOREACH (const QString &seqString, sequencesStrings) { | 305 | for (const QString &seqString : sequencesStrings) { | ||
305 | sequences.append(QKeySequence(seqString)); | 306 | sequences.append(QKeySequence(seqString)); | ||
306 | } | 307 | } | ||
307 | } | 308 | } | ||
308 | 309 | | |||
309 | if (!sequences.isEmpty()) { | 310 | if (!sequences.isEmpty()) { | ||
310 | KGlobalAccel::self()->setDefaultShortcut(action, sequences); | 311 | KGlobalAccel::self()->setDefaultShortcut(action, sequences); | ||
311 | } | 312 | } | ||
312 | } | 313 | } | ||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Line(s) | 528 | { | |||
532 | if (dia.exec() != KMessageBox::Ok) { | 533 | if (dia.exec() != KMessageBox::Ok) { | ||
533 | return; | 534 | return; | ||
534 | } | 535 | } | ||
535 | 536 | | |||
536 | const QUrl url = QFileDialog::getSaveFileUrl(this, QString(), QUrl(), QStringLiteral("*.kksrc")); | 537 | const QUrl url = QFileDialog::getSaveFileUrl(this, QString(), QUrl(), QStringLiteral("*.kksrc")); | ||
537 | if (!url.isEmpty()) { | 538 | if (!url.isEmpty()) { | ||
538 | KConfig config(url.path(), KConfig::SimpleConfig); | 539 | KConfig config(url.path(), KConfig::SimpleConfig); | ||
539 | // TODO: Bug ossi to provide a method for this | 540 | // TODO: Bug ossi to provide a method for this | ||
540 | Q_FOREACH(const QString &group, config.groupList()) | 541 | const auto groupList = config.groupList(); | ||
541 | { | 542 | for (const QString &group : groupList) { | ||
bport: { on same line | |||||
542 | // do not overwrite the Settings group. That makes it possible to | 543 | // do not overwrite the Settings group. That makes it possible to | ||
543 | // update the standard scheme kksrc file with the editor. | 544 | // update the standard scheme kksrc file with the editor. | ||
544 | if (group == QLatin1String("Settings")) continue; | 545 | if (group == QLatin1String("Settings")) continue; | ||
545 | config.deleteGroup(group); | 546 | config.deleteGroup(group); | ||
546 | } | 547 | } | ||
547 | exportConfiguration(dia.selectedComponents(), &config); | 548 | exportConfiguration(dia.selectedComponents(), &config); | ||
548 | } | 549 | } | ||
549 | } | 550 | } | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 616 | if (!componentsRc.isValid()) | |||
624 | } | 625 | } | ||
625 | 626 | | |||
626 | KMessageBox::sorry( | 627 | KMessageBox::sorry( | ||
627 | this, | 628 | this, | ||
628 | i18n("Failed to contact the KDE global shortcuts daemon\n") | 629 | i18n("Failed to contact the KDE global shortcuts daemon\n") | ||
629 | + errorString ); | 630 | + errorString ); | ||
630 | return; | 631 | return; | ||
631 | } | 632 | } | ||
632 | QList<QDBusObjectPath> components = componentsRc; | | |||
633 | 633 | | |||
634 | Q_FOREACH(const QDBusObjectPath &componentPath, components) { | 634 | const QList<QDBusObjectPath> components = componentsRc; | ||
635 | for (const QDBusObjectPath &componentPath : components) { | ||||
635 | d->loadComponent(componentPath); | 636 | d->loadComponent(componentPath); | ||
636 | } // Q_FOREACH(component) | 637 | } | ||
637 | } | 638 | } | ||
638 | 639 | | |||
639 | 640 | | |||
640 | void KGlobalShortcutsEditor::save() | 641 | void KGlobalShortcutsEditor::save() | ||
641 | { | 642 | { | ||
642 | // The editors are responsible for the saving | 643 | // The editors are responsible for the saving | ||
643 | //qDebug() << "Save the changes"; | 644 | //qDebug() << "Save the changes"; | ||
644 | Q_FOREACH (ComponentData *cd, d->components) { | 645 | for (ComponentData *cd : qAsConst(d->components)) { | ||
645 | cd->editor()->commit(); | 646 | cd->editor()->commit(); | ||
646 | } | 647 | } | ||
647 | } | 648 | } | ||
648 | 649 | | |||
649 | 650 | | |||
650 | void KGlobalShortcutsEditor::importConfiguration(KConfigBase *config) | 651 | void KGlobalShortcutsEditor::importConfiguration(KConfigBase *config) | ||
651 | { | 652 | { | ||
652 | //qDebug() << config->groupList(); | 653 | //qDebug() << config->groupList(); | ||
653 | 654 | | |||
654 | // In a first step clean out the current configurations. We do this | 655 | // In a first step clean out the current configurations. We do this | ||
655 | // because we want to minimize the chance of conflicts. | 656 | // because we want to minimize the chance of conflicts. | ||
656 | Q_FOREACH (ComponentData *cd, d->components) { | 657 | for (ComponentData *cd : qAsConst(d->components)) { | ||
657 | KConfigGroup group(config, cd->uniqueName()); | 658 | KConfigGroup group(config, cd->uniqueName()); | ||
658 | //qDebug() << cd->uniqueName() << group.name(); | 659 | //qDebug() << cd->uniqueName() << group.name(); | ||
659 | if (group.exists()) { | 660 | if (group.exists()) { | ||
660 | //qDebug() << "Removing" << cd->uniqueName(); | 661 | //qDebug() << "Removing" << cd->uniqueName(); | ||
661 | cd->editor()->clearConfiguration(); | 662 | cd->editor()->clearConfiguration(); | ||
662 | } | 663 | } | ||
663 | } | 664 | } | ||
664 | 665 | | |||
665 | // Now import the new configurations. | 666 | // Now import the new configurations. | ||
666 | Q_FOREACH (ComponentData *cd, d->components) { | 667 | for (ComponentData *cd : qAsConst(d->components)) { | ||
667 | KConfigGroup group(config, cd->uniqueName()); | 668 | KConfigGroup group(config, cd->uniqueName()); | ||
668 | if (group.exists()) { | 669 | if (group.exists()) { | ||
669 | //qDebug() << "Importing" << cd->uniqueName(); | 670 | //qDebug() << "Importing" << cd->uniqueName(); | ||
670 | cd->editor()->importConfiguration(&group); | 671 | cd->editor()->importConfiguration(&group); | ||
671 | } | 672 | } | ||
672 | } | 673 | } | ||
673 | } | 674 | } | ||
674 | 675 | | |||
675 | void KGlobalShortcutsEditor::exportConfiguration(QStringList components, KConfig *config) const | 676 | void KGlobalShortcutsEditor::exportConfiguration(const QStringList &components, KConfig *config) const | ||
676 | { | 677 | { | ||
677 | Q_FOREACH (const QString &componentFriendly, components) | 678 | for (const QString &componentFriendly : components) | ||
678 | { | 679 | { | ||
679 | QHash<QString, ComponentData*>::Iterator iter = d->components.find(componentFriendly); | 680 | QHash<QString, ComponentData*>::Iterator iter = d->components.find(componentFriendly); | ||
680 | if (iter == d->components.end()) | 681 | if (iter == d->components.end()) | ||
681 | { | 682 | { | ||
682 | Q_ASSERT(iter != d->components.end()); | 683 | Q_ASSERT(iter != d->components.end()); | ||
683 | continue; | 684 | continue; | ||
684 | } | 685 | } | ||
685 | else | 686 | else | ||
686 | { | 687 | { | ||
687 | KConfigGroup group(config, (*iter)->uniqueName()); | 688 | KConfigGroup group(config, (*iter)->uniqueName()); | ||
688 | (*iter)->editor()->exportConfiguration(&group); | 689 | (*iter)->editor()->exportConfiguration(&group); | ||
689 | } | 690 | } | ||
690 | } | 691 | } | ||
691 | } | 692 | } | ||
692 | 693 | | |||
693 | 694 | | |||
694 | void KGlobalShortcutsEditor::undo() | 695 | void KGlobalShortcutsEditor::undo() | ||
695 | { | 696 | { | ||
696 | // The editors are responsible for the undo | 697 | // The editors are responsible for the undo | ||
697 | //qDebug() << "Undo the changes"; | 698 | //qDebug() << "Undo the changes"; | ||
698 | Q_FOREACH (ComponentData *cd, d->components) { | 699 | for (ComponentData *cd : qAsConst(d->components)) { | ||
699 | cd->editor()->undoChanges(); | 700 | cd->editor()->undoChanges(); | ||
700 | } | 701 | } | ||
701 | } | 702 | } | ||
702 | 703 | | |||
703 | 704 | | |||
704 | bool KGlobalShortcutsEditor::isModified() const | 705 | bool KGlobalShortcutsEditor::isModified() const | ||
705 | { | 706 | { | ||
706 | Q_FOREACH (ComponentData *cd, d->components) { | 707 | for (const ComponentData *cd : qAsConst(d->components)) { | ||
I would make the ComponentData::editor() method const, then 'const ComponentData *cd'. ahmadsamir: I would make the ComponentData::editor() method const, then 'const ComponentData *cd'. | |||||
707 | if (cd->editor()->isModified()) { | 708 | if (cd->editor()->isModified()) { | ||
708 | return true; | 709 | return true; | ||
709 | } | 710 | } | ||
710 | } | 711 | } | ||
711 | return false; | 712 | return false; | ||
712 | } | 713 | } | ||
713 | 714 | | |||
714 | 715 | | |||
Show All 24 Lines | 729 | { | |||
739 | // Get the shortcut contexts. | 740 | // Get the shortcut contexts. | ||
740 | QDBusReply<QStringList> shortcutContextsRc = component.getShortcutContexts(); | 741 | QDBusReply<QStringList> shortcutContextsRc = component.getShortcutContexts(); | ||
741 | if (!shortcutContextsRc.isValid()) { | 742 | if (!shortcutContextsRc.isValid()) { | ||
742 | //qDebug() << "Failed to get contexts for component " | 743 | //qDebug() << "Failed to get contexts for component " | ||
743 | //<< componentPath.path() <<"! Skipping!"; | 744 | //<< componentPath.path() <<"! Skipping!"; | ||
744 | //qDebug() << shortcutContextsRc.error(); | 745 | //qDebug() << shortcutContextsRc.error(); | ||
745 | return false; | 746 | return false; | ||
746 | } | 747 | } | ||
747 | QStringList shortcutContexts = shortcutContextsRc; | 748 | const QStringList shortcutContexts = shortcutContextsRc; | ||
748 | 749 | | |||
749 | // We add the shortcuts for all shortcut contexts to the editor. This | 750 | // We add the shortcuts for all shortcut contexts to the editor. This | ||
750 | // way the user keeps full control of it's shortcuts. | 751 | // way the user keeps full control of it's shortcuts. | ||
751 | Q_FOREACH (const QString &shortcutContext, shortcutContexts) { | 752 | for (const QString &shortcutContext : shortcutContexts) { | ||
752 | 753 | | |||
753 | QDBusReply< QList<KGlobalShortcutInfo> > shortcutsRc = | 754 | QDBusReply< QList<KGlobalShortcutInfo> > shortcutsRc = | ||
754 | component.allShortcutInfos(shortcutContext); | 755 | component.allShortcutInfos(shortcutContext); | ||
755 | if (!shortcutsRc.isValid()) | 756 | if (!shortcutsRc.isValid()) | ||
756 | { | 757 | { | ||
757 | //qDebug() << "allShortcutInfos() failed for " << componentPath.path() << shortcutContext; | 758 | //qDebug() << "allShortcutInfos() failed for " << componentPath.path() << shortcutContext; | ||
758 | continue; | 759 | continue; | ||
759 | } | 760 | } | ||
760 | QList<KGlobalShortcutInfo> shortcuts = shortcutsRc; | 761 | const QList<KGlobalShortcutInfo> shortcuts = shortcutsRc; | ||
761 | // Shouldn't happen. But you never know | 762 | // Shouldn't happen. But you never know | ||
762 | if (shortcuts.isEmpty()) { | 763 | if (shortcuts.isEmpty()) { | ||
763 | //qDebug() << "Got shortcut context" << shortcutContext << "without shortcuts for" | 764 | //qDebug() << "Got shortcut context" << shortcutContext << "without shortcuts for" | ||
764 | //<< componentPath.path(); | 765 | //<< componentPath.path(); | ||
765 | continue; | 766 | continue; | ||
766 | } | 767 | } | ||
767 | 768 | | |||
768 | // It's safe now | 769 | // It's safe now | ||
769 | const QString componentUnique = shortcuts[0].componentUniqueName(); | 770 | const QString componentUnique = shortcuts[0].componentUniqueName(); | ||
770 | QString componentContextId = componentUnique; | 771 | QString componentContextId = componentUnique; | ||
771 | // kglobalaccel knows that '|' is our separator between | 772 | // kglobalaccel knows that '|' is our separator between | ||
772 | // component and context | 773 | // component and context | ||
773 | if (shortcutContext != QLatin1String("default")) { | 774 | if (shortcutContext != QLatin1String("default")) { | ||
774 | componentContextId += QLatin1String("|") + shortcutContext; | 775 | componentContextId += QLatin1String("|") + shortcutContext; | ||
775 | } | 776 | } | ||
776 | 777 | | |||
777 | // Create a action collection for our current component:context | 778 | // Create a action collection for our current component:context | ||
778 | KActionCollection* col = new KActionCollection( | 779 | KActionCollection* col = new KActionCollection( | ||
779 | q, | 780 | q, | ||
780 | componentContextId); | 781 | componentContextId); | ||
781 | 782 | | |||
782 | // Now add the shortcuts. | 783 | // Now add the shortcuts. | ||
783 | Q_FOREACH (const KGlobalShortcutInfo &shortcut, shortcuts) { | 784 | for (const KGlobalShortcutInfo &shortcut : shortcuts) { | ||
784 | 785 | | |||
785 | const QString &objectName = shortcut.uniqueName(); | 786 | const QString &objectName = shortcut.uniqueName(); | ||
786 | QAction *action = col->addAction(objectName); | 787 | QAction *action = col->addAction(objectName); | ||
787 | action->setProperty("isConfigurationAction", QVariant(true)); // see KAction::~KAction | 788 | action->setProperty("isConfigurationAction", QVariant(true)); // see KAction::~KAction | ||
788 | action->setProperty("componentDisplayName", shortcut.componentFriendlyName()); | 789 | action->setProperty("componentDisplayName", shortcut.componentFriendlyName()); | ||
789 | action->setText(shortcut.friendlyName()); | 790 | action->setText(shortcut.friendlyName()); | ||
790 | 791 | | |||
791 | // Always call this to enable global shortcuts for the action. The editor widget | 792 | // Always call this to enable global shortcuts for the action. The editor widget | ||
792 | // checks it. | 793 | // checks it. | ||
793 | // Also actually loads the shortcut using the KAction::Autoloading mechanism. | 794 | // Also actually loads the shortcut using the KAction::Autoloading mechanism. | ||
794 | // Avoid setting the default shortcut; it would just be written to the global | 795 | // Avoid setting the default shortcut; it would just be written to the global | ||
795 | // configuration so we would not get the real one below. | 796 | // configuration so we would not get the real one below. | ||
796 | KGlobalAccel::self()->setShortcut(action, QList<QKeySequence>()); | 797 | KGlobalAccel::self()->setShortcut(action, QList<QKeySequence>()); | ||
797 | 798 | | |||
798 | // The default shortcut will never be loaded because it's pointless in a real | 799 | // The default shortcut will never be loaded because it's pointless in a real | ||
799 | // application. There are no scarce resources [i.e. physical keys] to manage | 800 | // application. There are no scarce resources [i.e. physical keys] to manage | ||
800 | // so applications can set them at will and there's no autoloading. | 801 | // so applications can set them at will and there's no autoloading. | ||
801 | QList<QKeySequence> sc = shortcut.defaultKeys(); | 802 | QList<QKeySequence> sc = shortcut.defaultKeys(); | ||
802 | if (sc.count()>0) { | 803 | if (sc.count()>0) { | ||
803 | KGlobalAccel::self()->setDefaultShortcut(action, sc); | 804 | KGlobalAccel::self()->setDefaultShortcut(action, sc); | ||
804 | } | 805 | } | ||
805 | } // Q_FOREACH(shortcut) | 806 | } | ||
806 | 807 | | |||
807 | QString componentFriendlyName = shortcuts[0].componentFriendlyName(); | 808 | QString componentFriendlyName = shortcuts[0].componentFriendlyName(); | ||
808 | 809 | | |||
809 | if (shortcuts[0].contextUniqueName() != QLatin1String("default")) | 810 | if (shortcuts[0].contextUniqueName() != QLatin1String("default")) | ||
810 | { | 811 | { | ||
811 | componentFriendlyName += | 812 | componentFriendlyName += | ||
812 | QString('[') + shortcuts[0].contextFriendlyName() + QString(']'); | 813 | QString('[') + shortcuts[0].contextFriendlyName() + QString(']'); | ||
813 | } | 814 | } | ||
814 | 815 | | |||
815 | q->addCollection(col, componentPath, componentContextId, componentFriendlyName ); | 816 | q->addCollection(col, componentPath, componentContextId, componentFriendlyName ); | ||
816 | 817 | | |||
817 | } // Q_FOREACH(context) | 818 | } | ||
818 | 819 | | |||
819 | return true; | 820 | return true; | ||
820 | } | 821 | } | ||
821 | 822 | | |||
822 | 823 | | |||
823 | void KGlobalShortcutsEditor::KGlobalShortcutsEditorPrivate::removeComponent( | 824 | void KGlobalShortcutsEditor::KGlobalShortcutsEditorPrivate::removeComponent( | ||
824 | const QString &componentUnique ) | 825 | const QString &componentUnique ) | ||
825 | { | 826 | { | ||
826 | // TODO: Remove contexts too. | 827 | // TODO: Remove contexts too. | ||
827 | 828 | | |||
828 | Q_FOREACH (const QString &text, components.keys()) | 829 | const auto keys = components.keys(); | ||
bport: { same line | |||||
829 | { | 830 | for (const QString &text : keys) { | ||
830 | if (components.value(text)->uniqueName() == componentUnique) | 831 | if (components.value(text)->uniqueName() == componentUnique) { | ||
831 | { | | |||
832 | // Remove from QComboBox | 832 | // Remove from QComboBox | ||
833 | QModelIndexList results = proxyModel->match(proxyModel->index(0, 0), Qt::DisplayRole, text); | 833 | QModelIndexList results = proxyModel->match(proxyModel->index(0, 0), Qt::DisplayRole, text); | ||
834 | Q_ASSERT(!results.isEmpty()); | 834 | Q_ASSERT(!results.isEmpty()); | ||
835 | model->removeRow(proxyModel->mapToSource(results.first()).row()); | 835 | model->removeRow(proxyModel->mapToSource(results.first()).row()); | ||
836 | 836 | | |||
837 | // Remove from QStackedWidget | 837 | // Remove from QStackedWidget | ||
838 | stack->removeWidget(components[text]->editor()); | 838 | stack->removeWidget(components[text]->editor()); | ||
839 | 839 | | |||
840 | // Remove the componentData | 840 | // Remove the componentData | ||
841 | delete components.take(text); | 841 | delete components.take(text); | ||
842 | } | 842 | } | ||
843 | } | 843 | } | ||
844 | } | 844 | } | ||
845 | 845 | | |||
846 | 846 | |
you have an unneeded space after (