Changeset View
Changeset View
Standalone View
Standalone View
src/kshortcutschemeseditor.cpp
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 45 | { | |||
---|---|---|---|---|---|
46 | KConfigGroup group(KSharedConfig::openConfig(), "Shortcut Schemes"); | 46 | KConfigGroup group(KSharedConfig::openConfig(), "Shortcut Schemes"); | ||
47 | 47 | | |||
48 | QStringList schemes; | 48 | QStringList schemes; | ||
49 | schemes << QStringLiteral("Default"); | 49 | schemes << QStringLiteral("Default"); | ||
50 | // List files in the shortcuts subdir, each one is a scheme. See KShortcutSchemesHelper::{shortcutSchemeFileName,exportActionCollection} | 50 | // List files in the shortcuts subdir, each one is a scheme. See KShortcutSchemesHelper::{shortcutSchemeFileName,exportActionCollection} | ||
51 | const QStringList shortcutsDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QCoreApplication::applicationName() + QLatin1String("/shortcuts"), QStandardPaths::LocateDirectory); | 51 | const QStringList shortcutsDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QCoreApplication::applicationName() + QLatin1String("/shortcuts"), QStandardPaths::LocateDirectory); | ||
52 | qCDebug(DEBUG_KXMLGUI) << "shortcut scheme dirs:" << shortcutsDirs; | 52 | qCDebug(DEBUG_KXMLGUI) << "shortcut scheme dirs:" << shortcutsDirs; | ||
53 | for (const QString &dir : shortcutsDirs) { | 53 | for (const QString &dir : shortcutsDirs) { | ||
54 | Q_FOREACH (const QString &file, QDir(dir).entryList(QDir::Files | QDir::NoDotAndDotDot)) { | 54 | const auto files = QDir(dir).entryList(QDir::Files | QDir::NoDotAndDotDot); | ||
55 | for (const QString &file : files) { | ||||
55 | qCDebug(DEBUG_KXMLGUI) << "shortcut scheme file:" << file; | 56 | qCDebug(DEBUG_KXMLGUI) << "shortcut scheme file:" << file; | ||
56 | schemes << file; | 57 | schemes << file; | ||
57 | } | 58 | } | ||
58 | } | 59 | } | ||
59 | 60 | | |||
60 | const QString currentScheme = group.readEntry("Current Scheme", "Default"); | 61 | const QString currentScheme = group.readEntry("Current Scheme", "Default"); | ||
61 | qCDebug(DEBUG_KXMLGUI) << "Current Scheme" << currentScheme; | 62 | qCDebug(DEBUG_KXMLGUI) << "Current Scheme" << currentScheme; | ||
62 | 63 | | |||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | |||||
149 | Note that this will not remove any system wide shortcut schemes.", currentScheme())) == KMessageBox::No) { | 150 | Note that this will not remove any system wide shortcut schemes.", currentScheme())) == KMessageBox::No) { | ||
150 | return; | 151 | return; | ||
151 | } | 152 | } | ||
152 | 153 | | |||
153 | //delete the scheme for the app itself | 154 | //delete the scheme for the app itself | ||
154 | QFile::remove(KShortcutSchemesHelper::writableApplicationShortcutSchemeFileName(currentScheme())); | 155 | QFile::remove(KShortcutSchemesHelper::writableApplicationShortcutSchemeFileName(currentScheme())); | ||
155 | 156 | | |||
156 | //delete all scheme files we can find for xmlguiclients in the user directories | 157 | //delete all scheme files we can find for xmlguiclients in the user directories | ||
157 | foreach (KActionCollection *collection, m_dialog->actionCollections()) { | 158 | const auto dialogCollections = m_dialog->actionCollections(); | ||
159 | for (KActionCollection *collection : dialogCollections) { | ||||
158 | const KXMLGUIClient *client = collection->parentGUIClient(); | 160 | const KXMLGUIClient *client = collection->parentGUIClient(); | ||
159 | if (!client) { | 161 | if (!client) { | ||
160 | continue; | 162 | continue; | ||
161 | } | 163 | } | ||
162 | QFile::remove(KShortcutSchemesHelper::writableShortcutSchemeFileName(client->componentName(), currentScheme())); | 164 | QFile::remove(KShortcutSchemesHelper::writableShortcutSchemeFileName(client->componentName(), currentScheme())); | ||
163 | } | 165 | } | ||
164 | 166 | | |||
165 | m_schemesList->removeItem(m_schemesList->findText(currentScheme())); | 167 | m_schemesList->removeItem(m_schemesList->findText(currentScheme())); | ||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |