Changeset View
Changeset View
Standalone View
Standalone View
libs/widgetutils/xmlgui/kshortcutschemeseditor.cpp
Show All 13 Lines | 1 | /* This file is part of the KDE libraries | |||
---|---|---|---|---|---|
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301, USA. | 17 | Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | #include "kshortcutschemeseditor.h" | 19 | #include "kshortcutschemeseditor.h" | ||
20 | #include "KisShortcutsDialog_p.h" | 20 | #include "KisShortcutsDialog_p.h" | ||
21 | 21 | | |||
22 | #include <QDir> | | |||
23 | #include <QLabel> | 22 | #include <QLabel> | ||
24 | #include <QMenu> | 23 | #include <QMenu> | ||
25 | #include <QFile> | 24 | #include <QFile> | ||
26 | #include <QPushButton> | 25 | #include <QPushButton> | ||
27 | #include <QTextStream> | 26 | #include <QTextStream> | ||
28 | #include <QDomDocument> | 27 | #include <QDomDocument> | ||
29 | #include <QFileDialog> | | |||
30 | #include <QStandardPaths> | 28 | #include <QStandardPaths> | ||
31 | #include <QInputDialog> | 29 | #include <QInputDialog> | ||
32 | #include <QComboBox> | 30 | #include <QComboBox> | ||
33 | #include <QHBoxLayout> | 31 | #include <QHBoxLayout> | ||
34 | #include <QDebug> | 32 | #include <QDebug> | ||
35 | 33 | | |||
36 | #include <kconfiggroup.h> | 34 | #include <kconfiggroup.h> | ||
37 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> | ||
38 | #include <ksharedconfig.h> | 36 | #include <ksharedconfig.h> | ||
37 | #include <KoFileDialog.h> | ||||
39 | 38 | | |||
40 | #include "KisShortcutsDialog.h" | 39 | #include "KisShortcutsDialog.h" | ||
41 | #include "kshortcutschemeshelper_p.h" | 40 | #include "kshortcutschemeshelper_p.h" | ||
42 | #include "kactioncollection.h" | 41 | #include "kactioncollection.h" | ||
43 | #include "kxmlguiclient.h" | 42 | #include "kxmlguiclient.h" | ||
44 | 43 | | |||
45 | #include "KoResourcePaths.h" | 44 | #include "KoResourcePaths.h" | ||
46 | 45 | | |||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | |||||
151 | 150 | | |||
152 | QString KShortcutSchemesEditor::currentScheme() | 151 | QString KShortcutSchemesEditor::currentScheme() | ||
153 | { | 152 | { | ||
154 | return m_schemesList->currentText(); | 153 | return m_schemesList->currentText(); | ||
155 | } | 154 | } | ||
156 | 155 | | |||
157 | void KShortcutSchemesEditor::exportShortcutsScheme() | 156 | void KShortcutSchemesEditor::exportShortcutsScheme() | ||
158 | { | 157 | { | ||
159 | //ask user about dir | 158 | KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs"); | ||
160 | QFileDialog dlg(m_dialog, | 159 | QString proposedPath = group.readEntry("ExportShortcuts", KoResourcePaths::saveLocation("kis_shortcuts")); | ||
161 | i18n("Export Shortcuts"), | 160 | | ||
162 | KoResourcePaths::saveLocation("kis_shortcuts"), | 161 | KoFileDialog dialog(m_dialog, KoFileDialog::SaveFile, "ExportShortcuts"); | ||
163 | i18n("Shortcuts (*.shortcuts)")); | 162 | dialog.setCaption(i18n("Export Shortcuts")); | ||
164 | dlg.setDefaultSuffix(QStringLiteral(".shortcuts")); | 163 | dialog.setDefaultDir(proposedPath); | ||
165 | dlg.setAcceptMode(QFileDialog::AcceptSave); | 164 | dialog.setMimeTypeFilters(QStringList() << "application/x-krita-shortcuts", "application/x-krita-shortcuts"); | ||
166 | if (dlg.exec()) { | 165 | QString path = dialog.filename(); | ||
167 | auto path = dlg.selectedFiles().first(); | | |||
168 | 166 | | |||
169 | if (!path.isEmpty()) { | 167 | if (!path.isEmpty()) { | ||
170 | m_dialog->exportConfiguration(path); | 168 | m_dialog->exportConfiguration(path); | ||
171 | } | 169 | } | ||
172 | | ||||
173 | } | | |||
174 | } | 170 | } | ||
175 | 171 | | |||
176 | void KShortcutSchemesEditor::saveCustomShortcuts() | 172 | void KShortcutSchemesEditor::saveCustomShortcuts() | ||
177 | { | 173 | { | ||
178 | //ask user about dir | 174 | KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs"); | ||
179 | QFileDialog dlg(m_dialog, | 175 | QString proposedPath = group.readEntry("SaveCustomShortcuts", QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); | ||
180 | i18n("Save Shortcuts"), | 176 | | ||
181 | QDir::currentPath(), | 177 | KoFileDialog dialog(m_dialog, KoFileDialog::SaveFile, "SaveCustomShortcuts"); | ||
182 | i18n("Shortcuts (*.shortcuts)")); | 178 | dialog.setCaption(i18n("Save Shortcuts")); | ||
183 | dlg.setDefaultSuffix(QStringLiteral(".shortcuts")); | 179 | dialog.setDefaultDir(proposedPath); | ||
184 | dlg.setAcceptMode(QFileDialog::AcceptSave); | 180 | dialog.setMimeTypeFilters(QStringList() << "application/x-krita-shortcuts", "application/x-krita-shortcuts"); | ||
185 | if (dlg.exec()) { | 181 | QString path = dialog.filename(); | ||
186 | auto path = dlg.selectedFiles().first(); | | |||
187 | 182 | | |||
188 | if (!path.isEmpty()) { | 183 | if (!path.isEmpty()) { | ||
189 | m_dialog->saveCustomShortcuts(path); | 184 | m_dialog->saveCustomShortcuts(path); | ||
190 | } | 185 | } | ||
191 | } | 186 | } | ||
192 | } | 187 | | ||
193 | 188 | | |||
194 | 189 | | |||
195 | void KShortcutSchemesEditor::loadCustomShortcuts() | 190 | void KShortcutSchemesEditor::loadCustomShortcuts() | ||
196 | { | 191 | { | ||
197 | auto path = QFileDialog::getOpenFileName(m_dialog, | 192 | KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs"); | ||
198 | i18n("Import Shortcuts"), | 193 | QString proposedPath = group.readEntry("ImportShortcuts", QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); | ||
199 | QDir::currentPath(), | 194 | | ||
200 | i18n("Shortcuts (*.shortcuts)")); | 195 | KoFileDialog dialog(m_dialog, KoFileDialog::ImportFile, "ImportShortcuts"); | ||
196 | dialog.setCaption(i18n("Import Shortcuts")); | ||||
197 | dialog.setDefaultDir(proposedPath); | ||||
198 | dialog.setMimeTypeFilters(QStringList() << "application/x-krita-shortcuts", "application/x-krita-shortcuts"); | ||||
199 | QString path = dialog.filename(); | ||||
201 | 200 | | |||
202 | if (path.isEmpty()) { | 201 | if (path.isEmpty()) { | ||
203 | return; | 202 | return; | ||
204 | } | 203 | } | ||
205 | 204 | | |||
206 | // auto ar = KisActionRegistry::instance(); | 205 | // auto ar = KisActionRegistry::instance(); | ||
207 | // ar->loadCustomShortcuts(path); | 206 | // ar->loadCustomShortcuts(path); | ||
208 | m_dialog->loadCustomShortcuts(path); | 207 | m_dialog->loadCustomShortcuts(path); | ||
209 | 208 | | |||
210 | } | 209 | } | ||
211 | 210 | | |||
212 | void KShortcutSchemesEditor::importShortcutsScheme() | 211 | void KShortcutSchemesEditor::importShortcutsScheme() | ||
213 | { | 212 | { | ||
214 | //ask user about dir | 213 | KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs"); | ||
215 | QString path = QFileDialog::getOpenFileName(m_dialog, i18n("Import Shortcuts"), QDir::currentPath(), i18n("Shortcuts (*.shortcuts)")); | 214 | QString proposedPath = group.readEntry("ImportShortcuts", QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); | ||
215 | | ||||
216 | KoFileDialog dialog(m_dialog, KoFileDialog::ImportFile, "ImportShortcuts"); | ||||
217 | dialog.setCaption(i18n("Import Shortcuts")); | ||||
218 | dialog.setDefaultDir(proposedPath); | ||||
219 | dialog.setMimeTypeFilters(QStringList() << "application/x-krita-shortcuts", "application/x-krita-shortcuts"); | ||||
220 | QString path = dialog.filename(); | ||||
221 | | ||||
216 | if (path.isEmpty()) { | 222 | if (path.isEmpty()) { | ||
217 | return; | 223 | return; | ||
218 | } | 224 | } | ||
219 | 225 | | |||
220 | m_dialog->importConfiguration(path); | 226 | m_dialog->importConfiguration(path); | ||
221 | } | 227 | } | ||
222 | 228 | | |||
223 | #if 0 | 229 | #if 0 | ||
Show All 13 Lines |