forked from qt-creator/qt-creator
Core: Use more FilePath in ShortCutSettings and ActionManager
Change-Id: I0ef1afd554cf7785bb80417651f2bcf54d9cf6be Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -47,24 +47,13 @@ namespace Internal {
|
||||
|
||||
struct Context // XML parsing context with strings.
|
||||
{
|
||||
Context();
|
||||
|
||||
const QString mappingElement;
|
||||
const QString shortCutElement;
|
||||
const QString idAttribute;
|
||||
const QString keyElement;
|
||||
const QString valueAttribute;
|
||||
const QString mappingElement = "mapping";
|
||||
const QString shortCutElement = "shortcut";
|
||||
const QString idAttribute = "id";
|
||||
const QString keyElement = "key";
|
||||
const QString valueAttribute = "value";
|
||||
};
|
||||
|
||||
Context::Context() :
|
||||
mappingElement(QLatin1String("mapping")),
|
||||
shortCutElement(QLatin1String("shortcut")),
|
||||
idAttribute(QLatin1String("id")),
|
||||
keyElement(QLatin1String("key")),
|
||||
valueAttribute(QLatin1String("value"))
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\class Core::Internal::CommandsFile
|
||||
\internal
|
||||
@@ -76,8 +65,8 @@ Context::Context() :
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
CommandsFile::CommandsFile(const QString &filename)
|
||||
: m_filename(filename)
|
||||
CommandsFile::CommandsFile(const FilePath &filename)
|
||||
: m_filePath(filename)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -89,7 +78,7 @@ QMap<QString, QList<QKeySequence>> CommandsFile::importCommands() const
|
||||
{
|
||||
QMap<QString, QList<QKeySequence>> result;
|
||||
|
||||
QFile file(m_filename);
|
||||
QFile file(m_filePath.toString());
|
||||
if (!file.open(QIODevice::ReadOnly|QIODevice::Text))
|
||||
return result;
|
||||
|
||||
@@ -130,7 +119,7 @@ QMap<QString, QList<QKeySequence>> CommandsFile::importCommands() const
|
||||
|
||||
bool CommandsFile::exportCommands(const QList<ShortcutItem *> &items)
|
||||
{
|
||||
Utils::FileSaver saver(Utils::FilePath::fromString(m_filename), QIODevice::Text);
|
||||
FileSaver saver(m_filePath, QIODevice::Text);
|
||||
if (!saver.hasError()) {
|
||||
const Context ctx;
|
||||
QXmlStreamWriter w(saver.file());
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
@@ -41,13 +43,13 @@ class CommandsFile : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CommandsFile(const QString &filename);
|
||||
CommandsFile(const Utils::FilePath &filePath);
|
||||
|
||||
QMap<QString, QList<QKeySequence> > importCommands() const;
|
||||
bool exportCommands(const QList<ShortcutItem *> &items);
|
||||
|
||||
private:
|
||||
QString m_filename;
|
||||
Utils::FilePath m_filePath;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -490,10 +490,10 @@ void ShortcutSettingsWidget::resetToDefault()
|
||||
|
||||
void ShortcutSettingsWidget::importAction()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(ICore::dialogParent(),
|
||||
tr("Import Keyboard Mapping Scheme"),
|
||||
schemesPath().toString(),
|
||||
tr("Keyboard Mapping Scheme (*.kms)"));
|
||||
FilePath fileName = FileUtils::getOpenFilePath(nullptr,
|
||||
tr("Import Keyboard Mapping Scheme"),
|
||||
schemesPath(),
|
||||
tr("Keyboard Mapping Scheme (*.kms)"));
|
||||
if (!fileName.isEmpty()) {
|
||||
|
||||
CommandsFile cf(fileName);
|
||||
@@ -535,7 +535,7 @@ void ShortcutSettingsWidget::exportAction()
|
||||
schemesPath().toString(),
|
||||
tr("Keyboard Mapping Scheme (*.kms)"));
|
||||
if (!fileName.isEmpty()) {
|
||||
CommandsFile cf(fileName);
|
||||
CommandsFile cf(FilePath::fromString(fileName));
|
||||
cf.exportCommands(m_scitems);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user