Commit 27678b4c authored by Anna Medonosova's avatar Anna Medonosova
Browse files

Remember last used dirs for shortcut import/export

Summary:
File dialogs in KShortcutSchemesEditor use KoFileDialog instead of
plain QFileDialog. This allows to remember last used directories for
load/save/import/export.

Load, save and import location now defaults to homedir, instead of the
directory where Krita started.

BUG:368360

Reviewers: #krita, rempt

Reviewed By: #krita, rempt

Subscribers: rempt

Tags: #krita

Differential Revision: https://phabricator.kde.org/D19964
parent ad1f2707
......@@ -262,6 +262,11 @@ void KisMimeDatabase::fillMimeData()
mimeType.suffixes = QStringList() << "krf";
s_mimeDatabase << mimeType;
mimeType.mimeType = "application/x-krita-shortcuts";
mimeType.description = i18nc("description of a file type", "Krita Shortcut Scheme");
mimeType.suffixes = QStringList() << "shortcuts";
s_mimeDatabase << mimeType;
mimeType.mimeType = "image/x-krita-raw";
mimeType.description = i18nc("description of a file type", "Camera Raw Files");
mimeType.suffixes = QStringList() << "bay" << "bmq" << "cr2" << "crw" << "cs1" << "dc2" << "dcr" << "dng" << "erf" << "fff" << "hdr" << "k25" << "kdc" << "mdc" << "mos" << "mrw" << "nef" << "orf" << "pef" << "pxn" << "raf" << "raw" << "rdc" << "sr2" << "srf" << "x3f" << "arw" << "3fr" << "cine" << "ia" << "kc2" << "mef" << "nrw" << "qtk" << "rw2" << "sti" << "rwl" << "srw";
......
......@@ -19,14 +19,12 @@
#include "kshortcutschemeseditor.h"
#include "KisShortcutsDialog_p.h"
#include <QDir>
#include <QLabel>
#include <QMenu>
#include <QFile>
#include <QPushButton>
#include <QTextStream>
#include <QDomDocument>
#include <QFileDialog>
#include <QStandardPaths>
#include <QInputDialog>
#include <QComboBox>
......@@ -36,6 +34,7 @@
#include <kconfiggroup.h>
#include <kmessagebox.h>
#include <ksharedconfig.h>
#include <KoFileDialog.h>
#include "KisShortcutsDialog.h"
#include "kshortcutschemeshelper_p.h"
......@@ -156,48 +155,48 @@ QString KShortcutSchemesEditor::currentScheme()
void KShortcutSchemesEditor::exportShortcutsScheme()
{
//ask user about dir
QFileDialog dlg(m_dialog,
i18n("Export Shortcuts"),
KoResourcePaths::saveLocation("kis_shortcuts"),
i18n("Shortcuts (*.shortcuts)"));
dlg.setDefaultSuffix(QStringLiteral(".shortcuts"));
dlg.setAcceptMode(QFileDialog::AcceptSave);
if (dlg.exec()) {
auto path = dlg.selectedFiles().first();
if (!path.isEmpty()) {
m_dialog->exportConfiguration(path);
}
KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs");
QString proposedPath = group.readEntry("ExportShortcuts", KoResourcePaths::saveLocation("kis_shortcuts"));
KoFileDialog dialog(m_dialog, KoFileDialog::SaveFile, "ExportShortcuts");
dialog.setCaption(i18n("Export Shortcuts"));
dialog.setDefaultDir(proposedPath);
dialog.setMimeTypeFilters(QStringList() << "application/x-krita-shortcuts", "application/x-krita-shortcuts");
QString path = dialog.filename();
if (!path.isEmpty()) {
m_dialog->exportConfiguration(path);
}
}
void KShortcutSchemesEditor::saveCustomShortcuts()
{
//ask user about dir
QFileDialog dlg(m_dialog,
i18n("Save Shortcuts"),
QDir::currentPath(),
i18n("Shortcuts (*.shortcuts)"));
dlg.setDefaultSuffix(QStringLiteral(".shortcuts"));
dlg.setAcceptMode(QFileDialog::AcceptSave);
if (dlg.exec()) {
auto path = dlg.selectedFiles().first();
if (!path.isEmpty()) {
m_dialog->saveCustomShortcuts(path);
}
KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs");
QString proposedPath = group.readEntry("SaveCustomShortcuts", QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
KoFileDialog dialog(m_dialog, KoFileDialog::SaveFile, "SaveCustomShortcuts");
dialog.setCaption(i18n("Save Shortcuts"));
dialog.setDefaultDir(proposedPath);
dialog.setMimeTypeFilters(QStringList() << "application/x-krita-shortcuts", "application/x-krita-shortcuts");
QString path = dialog.filename();
if (!path.isEmpty()) {
m_dialog->saveCustomShortcuts(path);
}
}
void KShortcutSchemesEditor::loadCustomShortcuts()
{
auto path = QFileDialog::getOpenFileName(m_dialog,
i18n("Import Shortcuts"),
QDir::currentPath(),
i18n("Shortcuts (*.shortcuts)"));
KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs");
QString proposedPath = group.readEntry("ImportShortcuts", QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
KoFileDialog dialog(m_dialog, KoFileDialog::ImportFile, "ImportShortcuts");
dialog.setCaption(i18n("Import Shortcuts"));
dialog.setDefaultDir(proposedPath);
dialog.setMimeTypeFilters(QStringList() << "application/x-krita-shortcuts", "application/x-krita-shortcuts");
QString path = dialog.filename();
if (path.isEmpty()) {
return;
......@@ -211,8 +210,15 @@ void KShortcutSchemesEditor::loadCustomShortcuts()
void KShortcutSchemesEditor::importShortcutsScheme()
{
//ask user about dir
QString path = QFileDialog::getOpenFileName(m_dialog, i18n("Import Shortcuts"), QDir::currentPath(), i18n("Shortcuts (*.shortcuts)"));
KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs");
QString proposedPath = group.readEntry("ImportShortcuts", QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
KoFileDialog dialog(m_dialog, KoFileDialog::ImportFile, "ImportShortcuts");
dialog.setCaption(i18n("Import Shortcuts"));
dialog.setDefaultDir(proposedPath);
dialog.setMimeTypeFilters(QStringList() << "application/x-krita-shortcuts", "application/x-krita-shortcuts");
QString path = dialog.filename();
if (path.isEmpty()) {
return;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment