Commit 3e8c7dad authored by Gaston Haro's avatar Gaston Haro Committed by Nate Graham

Add .kksrc extension to the file name when global shorcuts scheme is exported

Summary:
The "Global shortcuts" (keys) kcm plugin does not add a corresponding
file extension to the explorted schemes, nevertheless the import
dialog filters files by the ".kksrc" extension causing that some users
are not able to find their exported files. This patch addresses that
situation.

BUG: 406932

Test Plan:
# Open "Global shortcuts" kcm module
# Select File->Export scheme...
# Check some random component(s)
# Click OK
# The save file dialog should have
## "All files" selected as filter
## "global_shortcuts.kksrc" as suggested file name

Reviewers: ngraham, mart

Reviewed By: ngraham, mart

Subscribers: davidre, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28547
parent 0cf73170
......@@ -533,18 +533,28 @@ void KGlobalShortcutsEditor::exportScheme()
return;
}
const QUrl url = QFileDialog::getSaveFileUrl(this, QString(), QUrl(), QStringLiteral("*.kksrc"));
if (!url.isEmpty()) {
KConfig config(url.path(), KConfig::SimpleConfig);
// TODO: Bug ossi to provide a method for this
Q_FOREACH(const QString &group, config.groupList())
{
// do not overwrite the Settings group. That makes it possible to
// update the standard scheme kksrc file with the editor.
if (group == QLatin1String("Settings")) continue;
config.deleteGroup(group);
}
exportConfiguration(dia.selectedComponents(), &config);
const QString filenameExtension = QStringLiteral("kksrc");
QFileDialog dialog(this);
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setDirectoryUrl(QUrl());
dialog.selectFile(QStringLiteral("global_shortcuts") + QStringLiteral(".") + filenameExtension);
dialog.setDefaultSuffix(QStringLiteral(".") + filenameExtension);
if (dialog.exec() == QFileDialog::Accepted) {
const QUrl url = dialog.selectedUrls().constFirst();
if (!url.isEmpty()) {
KConfig config(url.path(), KConfig::SimpleConfig);
// TODO: Bug ossi to provide a method for this
Q_FOREACH(const QString &group, config.groupList())
{
// do not overwrite the Settings group. That makes it possible to
// update the standard scheme kksrc file with the editor.
if (group == QLatin1String("Settings")) continue;
config.deleteGroup(group);
}
exportConfiguration(dia.selectedComponents(), &config);
}
}
}
......
Markdown is supported
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