Changeset View
Changeset View
Standalone View
Standalone View
src/kshortcutschemeseditor.cpp
Show All 35 Lines | |||||
36 | 36 | | |||
37 | #include "kshortcutsdialog.h" | 37 | #include "kshortcutsdialog.h" | ||
38 | #include "kshortcutschemeshelper_p.h" | 38 | #include "kshortcutschemeshelper_p.h" | ||
39 | #include "kactioncollection.h" | 39 | #include "kactioncollection.h" | ||
40 | #include "kxmlguiclient.h" | 40 | #include "kxmlguiclient.h" | ||
41 | #include <debug.h> | 41 | #include <debug.h> | ||
42 | 42 | | |||
43 | KShortcutSchemesEditor::KShortcutSchemesEditor(KShortcutsDialog *parent) | 43 | KShortcutSchemesEditor::KShortcutSchemesEditor(KShortcutsDialog *parent) | ||
44 | : QGroupBox(i18n("Shortcut Schemes"), parent), m_dialog(parent) | 44 | : QGroupBox(i18nc("@title:group", "Shortcut Schemes"), parent), m_dialog(parent) | ||
45 | { | 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; | ||
Show All 21 Lines | |||||
74 | if (schemeIdx > -1) { | 74 | if (schemeIdx > -1) { | ||
75 | m_schemesList->setCurrentIndex(schemeIdx); | 75 | m_schemesList->setCurrentIndex(schemeIdx); | ||
76 | } else { | 76 | } else { | ||
77 | qCWarning(DEBUG_KXMLGUI) << "Current scheme" << currentScheme << "not found in" << shortcutsDirs; | 77 | qCWarning(DEBUG_KXMLGUI) << "Current scheme" << currentScheme << "not found in" << shortcutsDirs; | ||
78 | } | 78 | } | ||
79 | schemesLabel->setBuddy(m_schemesList); | 79 | schemesLabel->setBuddy(m_schemesList); | ||
80 | l->addWidget(m_schemesList); | 80 | l->addWidget(m_schemesList); | ||
81 | 81 | | |||
82 | m_newScheme = new QPushButton(i18n("New...")); | 82 | m_newScheme = new QPushButton(i18nc("@action:button", "New...")); | ||
83 | l->addWidget(m_newScheme); | 83 | l->addWidget(m_newScheme); | ||
84 | 84 | | |||
85 | m_deleteScheme = new QPushButton(i18n("Delete")); | 85 | m_deleteScheme = new QPushButton(i18nc("@action:button", "Delete")); | ||
86 | l->addWidget(m_deleteScheme); | 86 | l->addWidget(m_deleteScheme); | ||
87 | 87 | | |||
88 | QPushButton *moreActions = new QPushButton(i18n("More Actions")); | 88 | QPushButton *moreActions = new QPushButton(i18nc("@action:button", "More Actions")); | ||
89 | l->addWidget(moreActions); | 89 | l->addWidget(moreActions); | ||
90 | 90 | | |||
91 | QMenu *moreActionsMenu = new QMenu(this); | 91 | QMenu *moreActionsMenu = new QMenu(this); | ||
92 | moreActionsMenu->addAction(i18n("Save shortcuts to scheme"), | 92 | moreActionsMenu->addAction(i18nc("@action:inmenu", "Save shortcuts to scheme"), | ||
93 | this, &KShortcutSchemesEditor::saveAsDefaultsForScheme); | 93 | this, &KShortcutSchemesEditor::saveAsDefaultsForScheme); | ||
94 | moreActionsMenu->addAction(i18n("Export Scheme..."), | 94 | moreActionsMenu->addAction(i18nc("@action:inmenu", "Export Scheme..."), | ||
95 | this, &KShortcutSchemesEditor::exportShortcutsScheme); | 95 | this, &KShortcutSchemesEditor::exportShortcutsScheme); | ||
96 | moreActionsMenu->addAction(i18n("Import Scheme..."), | 96 | moreActionsMenu->addAction(i18nc("@action:inmenu", "Import Scheme..."), | ||
97 | this, &KShortcutSchemesEditor::importShortcutsScheme); | 97 | this, &KShortcutSchemesEditor::importShortcutsScheme); | ||
98 | moreActions->setMenu(moreActionsMenu); | 98 | moreActions->setMenu(moreActionsMenu); | ||
99 | 99 | | |||
100 | l->addStretch(1); | 100 | l->addStretch(1); | ||
101 | 101 | | |||
102 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) | 102 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) | ||
103 | connect(m_schemesList, QOverload<const QString &>::of(&QComboBox::activated), | 103 | connect(m_schemesList, QOverload<const QString &>::of(&QComboBox::activated), | ||
104 | this, &KShortcutSchemesEditor::shortcutsSchemeChanged); | 104 | this, &KShortcutSchemesEditor::shortcutsSchemeChanged); | ||
105 | #else | 105 | #else | ||
106 | connect(m_schemesList, &QComboBox::textActivated, | 106 | connect(m_schemesList, &QComboBox::textActivated, | ||
107 | this, &KShortcutSchemesEditor::shortcutsSchemeChanged); | 107 | this, &KShortcutSchemesEditor::shortcutsSchemeChanged); | ||
108 | #endif | 108 | #endif | ||
109 | connect(m_newScheme, &QPushButton::clicked, this, &KShortcutSchemesEditor::newScheme); | 109 | connect(m_newScheme, &QPushButton::clicked, this, &KShortcutSchemesEditor::newScheme); | ||
110 | connect(m_deleteScheme, &QPushButton::clicked, this, &KShortcutSchemesEditor::deleteScheme); | 110 | connect(m_deleteScheme, &QPushButton::clicked, this, &KShortcutSchemesEditor::deleteScheme); | ||
111 | updateDeleteButton(); | 111 | updateDeleteButton(); | ||
112 | } | 112 | } | ||
113 | 113 | | |||
114 | void KShortcutSchemesEditor::newScheme() | 114 | void KShortcutSchemesEditor::newScheme() | ||
115 | { | 115 | { | ||
116 | bool ok; | 116 | bool ok; | ||
117 | const QString newName = QInputDialog::getText(this, i18n("Name for New Scheme"), | 117 | const QString newName = QInputDialog::getText(this, i18nc("@title:window", "Name for New Scheme"), | ||
118 | i18n("Name for new scheme:"), QLineEdit::Normal, i18n("New Scheme"), &ok); | 118 | i18n("Name for new scheme:"), QLineEdit::Normal, i18n("New Scheme"), &ok); | ||
119 | if (!ok) { | 119 | if (!ok) { | ||
120 | return; | 120 | return; | ||
121 | } | 121 | } | ||
122 | 122 | | |||
123 | if (m_schemesList->findText(newName) != -1) { | 123 | if (m_schemesList->findText(newName) != -1) { | ||
124 | KMessageBox::sorry(this, i18n("A scheme with this name already exists.")); | 124 | KMessageBox::sorry(this, i18n("A scheme with this name already exists.")); | ||
125 | return; | 125 | return; | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
177 | QString KShortcutSchemesEditor::currentScheme() | 177 | QString KShortcutSchemesEditor::currentScheme() | ||
178 | { | 178 | { | ||
179 | return m_schemesList->currentText(); | 179 | return m_schemesList->currentText(); | ||
180 | } | 180 | } | ||
181 | 181 | | |||
182 | void KShortcutSchemesEditor::exportShortcutsScheme() | 182 | void KShortcutSchemesEditor::exportShortcutsScheme() | ||
183 | { | 183 | { | ||
184 | //ask user about dir | 184 | //ask user about dir | ||
185 | QString path = QFileDialog::getSaveFileName(this, i18n("Export Shortcuts"), QDir::currentPath(), i18n("Shortcuts (*.shortcuts)")); | 185 | QString path = QFileDialog::getSaveFileName(this, i18nc("@title:window", "Export Shortcuts"), | ||
186 | QDir::currentPath(), i18n("Shortcuts (*.shortcuts)")); | ||||
186 | if (path.isEmpty()) { | 187 | if (path.isEmpty()) { | ||
187 | return; | 188 | return; | ||
188 | } | 189 | } | ||
189 | 190 | | |||
190 | m_dialog->exportConfiguration(path); | 191 | m_dialog->exportConfiguration(path); | ||
191 | } | 192 | } | ||
192 | 193 | | |||
193 | void KShortcutSchemesEditor::importShortcutsScheme() | 194 | void KShortcutSchemesEditor::importShortcutsScheme() | ||
194 | { | 195 | { | ||
195 | //ask user about dir | 196 | //ask user about dir | ||
196 | QString path = QFileDialog::getOpenFileName(this, i18n("Import Shortcuts"), QDir::currentPath(), i18n("Shortcuts (*.shortcuts)")); | 197 | QString path = QFileDialog::getOpenFileName(this, i18nc("@title:window", "Import Shortcuts"), | ||
198 | QDir::currentPath(), i18n("Shortcuts (*.shortcuts)")); | ||||
197 | if (path.isEmpty()) { | 199 | if (path.isEmpty()) { | ||
198 | return; | 200 | return; | ||
199 | } | 201 | } | ||
200 | 202 | | |||
201 | m_dialog->importConfiguration(path); | 203 | m_dialog->importConfiguration(path); | ||
202 | } | 204 | } | ||
203 | 205 | | |||
204 | void KShortcutSchemesEditor::saveAsDefaultsForScheme() | 206 | void KShortcutSchemesEditor::saveAsDefaultsForScheme() | ||
Show All 13 Lines |