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 227 Lines • ▼ Show 20 Line(s) | 528 | { | |||
540 | dialog.setDirectoryUrl(QUrl()); | 541 | dialog.setDirectoryUrl(QUrl()); | ||
541 | dialog.selectFile(QStringLiteral("global_shortcuts") + QStringLiteral(".") + filenameExtension); | 542 | dialog.selectFile(QStringLiteral("global_shortcuts") + QStringLiteral(".") + filenameExtension); | ||
542 | dialog.setDefaultSuffix(QStringLiteral(".") + filenameExtension); | 543 | dialog.setDefaultSuffix(QStringLiteral(".") + filenameExtension); | ||
543 | 544 | | |||
544 | if (dialog.exec() == QFileDialog::Accepted) { | 545 | if (dialog.exec() == QFileDialog::Accepted) { | ||
545 | const QUrl url = dialog.selectedUrls().constFirst(); | 546 | const QUrl url = dialog.selectedUrls().constFirst(); | ||
546 | if (!url.isEmpty()) { | 547 | if (!url.isEmpty()) { | ||
547 | KConfig config(url.path(), KConfig::SimpleConfig); | 548 | KConfig config(url.path(), KConfig::SimpleConfig); | ||
548 | // TODO: Bug ossi to provide a method for this | 549 | // TODO: Bug ossi to provide a method for this | ||
549 | Q_FOREACH(const QString &group, config.groupList()) | 550 | const auto groupList = config.groupList(); | ||
bport: { on same line | |||||
550 | { | 551 | for (const QString &group : groupList) { | ||
551 | // do not overwrite the Settings group. That makes it possible to | 552 | // do not overwrite the Settings group. That makes it possible to | ||
552 | // update the standard scheme kksrc file with the editor. | 553 | // update the standard scheme kksrc file with the editor. | ||
553 | if (group == QLatin1String("Settings")) continue; | 554 | if (group == QLatin1String("Settings")) continue; | ||
554 | config.deleteGroup(group); | 555 | config.deleteGroup(group); | ||
555 | } | 556 | } | ||
556 | exportConfiguration(dia.selectedComponents(), &config); | 557 | exportConfiguration(dia.selectedComponents(), &config); | ||
557 | } | 558 | } | ||
558 | } | 559 | } | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 626 | if (!componentsRc.isValid()) | |||
634 | } | 635 | } | ||
635 | 636 | | |||
636 | KMessageBox::sorry( | 637 | KMessageBox::sorry( | ||
637 | this, | 638 | this, | ||
638 | i18n("Failed to contact the KDE global shortcuts daemon\n") | 639 | i18n("Failed to contact the KDE global shortcuts daemon\n") | ||
639 | + errorString ); | 640 | + errorString ); | ||
640 | return; | 641 | return; | ||
641 | } | 642 | } | ||
642 | QList<QDBusObjectPath> components = componentsRc; | | |||
643 | 643 | | |||
644 | Q_FOREACH(const QDBusObjectPath &componentPath, components) { | 644 | const QList<QDBusObjectPath> components = componentsRc; | ||
645 | for (const QDBusObjectPath &componentPath : components) { | ||||
645 | d->loadComponent(componentPath); | 646 | d->loadComponent(componentPath); | ||
646 | } // Q_FOREACH(component) | 647 | } | ||
647 | } | 648 | } | ||
648 | 649 | | |||
649 | 650 | | |||
650 | void KGlobalShortcutsEditor::save() | 651 | void KGlobalShortcutsEditor::save() | ||
651 | { | 652 | { | ||
652 | // The editors are responsible for the saving | 653 | // The editors are responsible for the saving | ||
653 | //qDebug() << "Save the changes"; | 654 | //qDebug() << "Save the changes"; | ||
654 | Q_FOREACH (ComponentData *cd, d->components) { | 655 | for (ComponentData *cd : qAsConst(d->components)) { | ||
655 | cd->editor()->commit(); | 656 | cd->editor()->commit(); | ||
656 | } | 657 | } | ||
657 | } | 658 | } | ||
658 | 659 | | |||
659 | 660 | | |||
660 | void KGlobalShortcutsEditor::importConfiguration(KConfigBase *config) | 661 | void KGlobalShortcutsEditor::importConfiguration(KConfigBase *config) | ||
661 | { | 662 | { | ||
662 | //qDebug() << config->groupList(); | 663 | //qDebug() << config->groupList(); | ||
663 | 664 | | |||
664 | // In a first step clean out the current configurations. We do this | 665 | // In a first step clean out the current configurations. We do this | ||
665 | // because we want to minimize the chance of conflicts. | 666 | // because we want to minimize the chance of conflicts. | ||
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 | //qDebug() << cd->uniqueName() << group.name(); | 669 | //qDebug() << cd->uniqueName() << group.name(); | ||
669 | if (group.exists()) { | 670 | if (group.exists()) { | ||
670 | //qDebug() << "Removing" << cd->uniqueName(); | 671 | //qDebug() << "Removing" << cd->uniqueName(); | ||
671 | cd->editor()->clearConfiguration(); | 672 | cd->editor()->clearConfiguration(); | ||
672 | } | 673 | } | ||
673 | } | 674 | } | ||
674 | 675 | | |||
675 | // Now import the new configurations. | 676 | // Now import the new configurations. | ||
676 | Q_FOREACH (ComponentData *cd, d->components) { | 677 | for (ComponentData *cd : qAsConst(d->components)) { | ||
677 | KConfigGroup group(config, cd->uniqueName()); | 678 | KConfigGroup group(config, cd->uniqueName()); | ||
678 | if (group.exists()) { | 679 | if (group.exists()) { | ||
679 | //qDebug() << "Importing" << cd->uniqueName(); | 680 | //qDebug() << "Importing" << cd->uniqueName(); | ||
680 | cd->editor()->importConfiguration(&group); | 681 | cd->editor()->importConfiguration(&group); | ||
681 | } | 682 | } | ||
682 | } | 683 | } | ||
683 | } | 684 | } | ||
684 | 685 | | |||
685 | void KGlobalShortcutsEditor::exportConfiguration(QStringList components, KConfig *config) const | 686 | void KGlobalShortcutsEditor::exportConfiguration(const QStringList &components, KConfig *config) const | ||
686 | { | 687 | { | ||
687 | Q_FOREACH (const QString &componentFriendly, components) | 688 | for (const QString &componentFriendly : components) | ||
688 | { | 689 | { | ||
689 | QHash<QString, ComponentData*>::Iterator iter = d->components.find(componentFriendly); | 690 | QHash<QString, ComponentData*>::Iterator iter = d->components.find(componentFriendly); | ||
690 | if (iter == d->components.end()) | 691 | if (iter == d->components.end()) | ||
691 | { | 692 | { | ||
692 | Q_ASSERT(iter != d->components.end()); | 693 | Q_ASSERT(iter != d->components.end()); | ||
693 | continue; | 694 | continue; | ||
694 | } | 695 | } | ||
695 | else | 696 | else | ||
696 | { | 697 | { | ||
697 | KConfigGroup group(config, (*iter)->uniqueName()); | 698 | KConfigGroup group(config, (*iter)->uniqueName()); | ||
698 | (*iter)->editor()->exportConfiguration(&group); | 699 | (*iter)->editor()->exportConfiguration(&group); | ||
699 | } | 700 | } | ||
700 | } | 701 | } | ||
701 | } | 702 | } | ||
702 | 703 | | |||
703 | 704 | | |||
704 | void KGlobalShortcutsEditor::undo() | 705 | void KGlobalShortcutsEditor::undo() | ||
705 | { | 706 | { | ||
706 | // The editors are responsible for the undo | 707 | // The editors are responsible for the undo | ||
707 | //qDebug() << "Undo the changes"; | 708 | //qDebug() << "Undo the changes"; | ||
708 | Q_FOREACH (ComponentData *cd, d->components) { | 709 | for (ComponentData *cd : qAsConst(d->components)) { | ||
709 | cd->editor()->undoChanges(); | 710 | cd->editor()->undoChanges(); | ||
710 | } | 711 | } | ||
711 | } | 712 | } | ||
712 | 713 | | |||
713 | 714 | | |||
714 | bool KGlobalShortcutsEditor::isModified() const | 715 | bool KGlobalShortcutsEditor::isModified() const | ||
715 | { | 716 | { | ||
716 | Q_FOREACH (ComponentData *cd, d->components) { | 717 | 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'. | |||||
717 | if (cd->editor()->isModified()) { | 718 | if (cd->editor()->isModified()) { | ||
718 | return true; | 719 | return true; | ||
719 | } | 720 | } | ||
720 | } | 721 | } | ||
721 | return false; | 722 | return false; | ||
722 | } | 723 | } | ||
723 | 724 | | |||
724 | 725 | | |||
Show All 24 Lines | 739 | { | |||
749 | // Get the shortcut contexts. | 750 | // Get the shortcut contexts. | ||
750 | QDBusReply<QStringList> shortcutContextsRc = component.getShortcutContexts(); | 751 | QDBusReply<QStringList> shortcutContextsRc = component.getShortcutContexts(); | ||
751 | if (!shortcutContextsRc.isValid()) { | 752 | if (!shortcutContextsRc.isValid()) { | ||
752 | //qDebug() << "Failed to get contexts for component " | 753 | //qDebug() << "Failed to get contexts for component " | ||
753 | //<< componentPath.path() <<"! Skipping!"; | 754 | //<< componentPath.path() <<"! Skipping!"; | ||
754 | //qDebug() << shortcutContextsRc.error(); | 755 | //qDebug() << shortcutContextsRc.error(); | ||
755 | return false; | 756 | return false; | ||
756 | } | 757 | } | ||
757 | QStringList shortcutContexts = shortcutContextsRc; | 758 | const QStringList shortcutContexts = shortcutContextsRc; | ||
758 | 759 | | |||
759 | // We add the shortcuts for all shortcut contexts to the editor. This | 760 | // We add the shortcuts for all shortcut contexts to the editor. This | ||
760 | // way the user keeps full control of it's shortcuts. | 761 | // way the user keeps full control of it's shortcuts. | ||
761 | Q_FOREACH (const QString &shortcutContext, shortcutContexts) { | 762 | for (const QString &shortcutContext : shortcutContexts) { | ||
762 | 763 | | |||
763 | QDBusReply< QList<KGlobalShortcutInfo> > shortcutsRc = | 764 | QDBusReply< QList<KGlobalShortcutInfo> > shortcutsRc = | ||
764 | component.allShortcutInfos(shortcutContext); | 765 | component.allShortcutInfos(shortcutContext); | ||
765 | if (!shortcutsRc.isValid()) | 766 | if (!shortcutsRc.isValid()) | ||
766 | { | 767 | { | ||
767 | //qDebug() << "allShortcutInfos() failed for " << componentPath.path() << shortcutContext; | 768 | //qDebug() << "allShortcutInfos() failed for " << componentPath.path() << shortcutContext; | ||
768 | continue; | 769 | continue; | ||
769 | } | 770 | } | ||
770 | QList<KGlobalShortcutInfo> shortcuts = shortcutsRc; | 771 | const QList<KGlobalShortcutInfo> shortcuts = shortcutsRc; | ||
771 | // Shouldn't happen. But you never know | 772 | // Shouldn't happen. But you never know | ||
772 | if (shortcuts.isEmpty()) { | 773 | if (shortcuts.isEmpty()) { | ||
773 | //qDebug() << "Got shortcut context" << shortcutContext << "without shortcuts for" | 774 | //qDebug() << "Got shortcut context" << shortcutContext << "without shortcuts for" | ||
774 | //<< componentPath.path(); | 775 | //<< componentPath.path(); | ||
775 | continue; | 776 | continue; | ||
776 | } | 777 | } | ||
777 | 778 | | |||
778 | // It's safe now | 779 | // It's safe now | ||
779 | const QString componentUnique = shortcuts[0].componentUniqueName(); | 780 | const QString componentUnique = shortcuts[0].componentUniqueName(); | ||
780 | QString componentContextId = componentUnique; | 781 | QString componentContextId = componentUnique; | ||
781 | // kglobalaccel knows that '|' is our separator between | 782 | // kglobalaccel knows that '|' is our separator between | ||
782 | // component and context | 783 | // component and context | ||
783 | if (shortcutContext != QLatin1String("default")) { | 784 | if (shortcutContext != QLatin1String("default")) { | ||
784 | componentContextId += QLatin1String("|") + shortcutContext; | 785 | componentContextId += QLatin1String("|") + shortcutContext; | ||
785 | } | 786 | } | ||
786 | 787 | | |||
787 | // Create a action collection for our current component:context | 788 | // Create a action collection for our current component:context | ||
788 | KActionCollection* col = new KActionCollection( | 789 | KActionCollection* col = new KActionCollection( | ||
789 | q, | 790 | q, | ||
790 | componentContextId); | 791 | componentContextId); | ||
791 | 792 | | |||
792 | // Now add the shortcuts. | 793 | // Now add the shortcuts. | ||
793 | Q_FOREACH (const KGlobalShortcutInfo &shortcut, shortcuts) { | 794 | for (const KGlobalShortcutInfo &shortcut : shortcuts) { | ||
794 | 795 | | |||
795 | const QString &objectName = shortcut.uniqueName(); | 796 | const QString &objectName = shortcut.uniqueName(); | ||
796 | QAction *action = col->addAction(objectName); | 797 | QAction *action = col->addAction(objectName); | ||
797 | action->setProperty("isConfigurationAction", QVariant(true)); // see KAction::~KAction | 798 | action->setProperty("isConfigurationAction", QVariant(true)); // see KAction::~KAction | ||
798 | action->setProperty("componentDisplayName", shortcut.componentFriendlyName()); | 799 | action->setProperty("componentDisplayName", shortcut.componentFriendlyName()); | ||
799 | action->setText(shortcut.friendlyName()); | 800 | action->setText(shortcut.friendlyName()); | ||
800 | 801 | | |||
801 | // Always call this to enable global shortcuts for the action. The editor widget | 802 | // Always call this to enable global shortcuts for the action. The editor widget | ||
802 | // checks it. | 803 | // checks it. | ||
803 | // Also actually loads the shortcut using the KAction::Autoloading mechanism. | 804 | // Also actually loads the shortcut using the KAction::Autoloading mechanism. | ||
804 | // Avoid setting the default shortcut; it would just be written to the global | 805 | // Avoid setting the default shortcut; it would just be written to the global | ||
805 | // configuration so we would not get the real one below. | 806 | // configuration so we would not get the real one below. | ||
806 | KGlobalAccel::self()->setShortcut(action, QList<QKeySequence>()); | 807 | KGlobalAccel::self()->setShortcut(action, QList<QKeySequence>()); | ||
807 | 808 | | |||
808 | // The default shortcut will never be loaded because it's pointless in a real | 809 | // The default shortcut will never be loaded because it's pointless in a real | ||
809 | // application. There are no scarce resources [i.e. physical keys] to manage | 810 | // application. There are no scarce resources [i.e. physical keys] to manage | ||
810 | // so applications can set them at will and there's no autoloading. | 811 | // so applications can set them at will and there's no autoloading. | ||
811 | QList<QKeySequence> sc = shortcut.defaultKeys(); | 812 | QList<QKeySequence> sc = shortcut.defaultKeys(); | ||
812 | if (sc.count()>0) { | 813 | if (sc.count()>0) { | ||
813 | KGlobalAccel::self()->setDefaultShortcut(action, sc); | 814 | KGlobalAccel::self()->setDefaultShortcut(action, sc); | ||
814 | } | 815 | } | ||
815 | } // Q_FOREACH(shortcut) | 816 | } | ||
816 | 817 | | |||
817 | QString componentFriendlyName = shortcuts[0].componentFriendlyName(); | 818 | QString componentFriendlyName = shortcuts[0].componentFriendlyName(); | ||
818 | 819 | | |||
819 | if (shortcuts[0].contextUniqueName() != QLatin1String("default")) | 820 | if (shortcuts[0].contextUniqueName() != QLatin1String("default")) | ||
820 | { | 821 | { | ||
821 | componentFriendlyName += | 822 | componentFriendlyName += | ||
822 | QString('[') + shortcuts[0].contextFriendlyName() + QString(']'); | 823 | QString('[') + shortcuts[0].contextFriendlyName() + QString(']'); | ||
823 | } | 824 | } | ||
824 | 825 | | |||
825 | q->addCollection(col, componentPath, componentContextId, componentFriendlyName ); | 826 | q->addCollection(col, componentPath, componentContextId, componentFriendlyName ); | ||
826 | 827 | | |||
827 | } // Q_FOREACH(context) | 828 | } | ||
828 | 829 | | |||
829 | return true; | 830 | return true; | ||
830 | } | 831 | } | ||
831 | 832 | | |||
832 | 833 | | |||
833 | void KGlobalShortcutsEditor::KGlobalShortcutsEditorPrivate::removeComponent( | 834 | void KGlobalShortcutsEditor::KGlobalShortcutsEditorPrivate::removeComponent( | ||
834 | const QString &componentUnique ) | 835 | const QString &componentUnique ) | ||
835 | { | 836 | { | ||
836 | // TODO: Remove contexts too. | 837 | // TODO: Remove contexts too. | ||
837 | 838 | | |||
838 | Q_FOREACH (const QString &text, components.keys()) | 839 | const auto keys = components.keys(); | ||
bport: { same line | |||||
839 | { | 840 | for (const QString &text : keys) { | ||
840 | if (components.value(text)->uniqueName() == componentUnique) | 841 | if (components.value(text)->uniqueName() == componentUnique) { | ||
841 | { | | |||
842 | // Remove from QComboBox | 842 | // Remove from QComboBox | ||
843 | QModelIndexList results = proxyModel->match(proxyModel->index(0, 0), Qt::DisplayRole, text); | 843 | QModelIndexList results = proxyModel->match(proxyModel->index(0, 0), Qt::DisplayRole, text); | ||
844 | Q_ASSERT(!results.isEmpty()); | 844 | Q_ASSERT(!results.isEmpty()); | ||
845 | model->removeRow(proxyModel->mapToSource(results.first()).row()); | 845 | model->removeRow(proxyModel->mapToSource(results.first()).row()); | ||
846 | 846 | | |||
847 | // Remove from QStackedWidget | 847 | // Remove from QStackedWidget | ||
848 | stack->removeWidget(components[text]->editor()); | 848 | stack->removeWidget(components[text]->editor()); | ||
849 | 849 | | |||
850 | // Remove the componentData | 850 | // Remove the componentData | ||
851 | delete components.take(text); | 851 | delete components.take(text); | ||
852 | } | 852 | } | ||
853 | } | 853 | } | ||
854 | } | 854 | } | ||
855 | 855 | | |||
856 | 856 | |
you have an unneeded space after (