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.
|
struct Context // XML parsing context with strings.
|
||||||
{
|
{
|
||||||
Context();
|
const QString mappingElement = "mapping";
|
||||||
|
const QString shortCutElement = "shortcut";
|
||||||
const QString mappingElement;
|
const QString idAttribute = "id";
|
||||||
const QString shortCutElement;
|
const QString keyElement = "key";
|
||||||
const QString idAttribute;
|
const QString valueAttribute = "value";
|
||||||
const QString keyElement;
|
|
||||||
const QString valueAttribute;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Context::Context() :
|
|
||||||
mappingElement(QLatin1String("mapping")),
|
|
||||||
shortCutElement(QLatin1String("shortcut")),
|
|
||||||
idAttribute(QLatin1String("id")),
|
|
||||||
keyElement(QLatin1String("key")),
|
|
||||||
valueAttribute(QLatin1String("value"))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Core::Internal::CommandsFile
|
\class Core::Internal::CommandsFile
|
||||||
\internal
|
\internal
|
||||||
@@ -76,8 +65,8 @@ Context::Context() :
|
|||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
CommandsFile::CommandsFile(const QString &filename)
|
CommandsFile::CommandsFile(const FilePath &filename)
|
||||||
: m_filename(filename)
|
: m_filePath(filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -89,7 +78,7 @@ QMap<QString, QList<QKeySequence>> CommandsFile::importCommands() const
|
|||||||
{
|
{
|
||||||
QMap<QString, QList<QKeySequence>> result;
|
QMap<QString, QList<QKeySequence>> result;
|
||||||
|
|
||||||
QFile file(m_filename);
|
QFile file(m_filePath.toString());
|
||||||
if (!file.open(QIODevice::ReadOnly|QIODevice::Text))
|
if (!file.open(QIODevice::ReadOnly|QIODevice::Text))
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
@@ -130,7 +119,7 @@ QMap<QString, QList<QKeySequence>> CommandsFile::importCommands() const
|
|||||||
|
|
||||||
bool CommandsFile::exportCommands(const QList<ShortcutItem *> &items)
|
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()) {
|
if (!saver.hasError()) {
|
||||||
const Context ctx;
|
const Context ctx;
|
||||||
QXmlStreamWriter w(saver.file());
|
QXmlStreamWriter w(saver.file());
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
@@ -41,13 +43,13 @@ class CommandsFile : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CommandsFile(const QString &filename);
|
CommandsFile(const Utils::FilePath &filePath);
|
||||||
|
|
||||||
QMap<QString, QList<QKeySequence> > importCommands() const;
|
QMap<QString, QList<QKeySequence> > importCommands() const;
|
||||||
bool exportCommands(const QList<ShortcutItem *> &items);
|
bool exportCommands(const QList<ShortcutItem *> &items);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_filename;
|
Utils::FilePath m_filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -490,9 +490,9 @@ void ShortcutSettingsWidget::resetToDefault()
|
|||||||
|
|
||||||
void ShortcutSettingsWidget::importAction()
|
void ShortcutSettingsWidget::importAction()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(ICore::dialogParent(),
|
FilePath fileName = FileUtils::getOpenFilePath(nullptr,
|
||||||
tr("Import Keyboard Mapping Scheme"),
|
tr("Import Keyboard Mapping Scheme"),
|
||||||
schemesPath().toString(),
|
schemesPath(),
|
||||||
tr("Keyboard Mapping Scheme (*.kms)"));
|
tr("Keyboard Mapping Scheme (*.kms)"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
|
|
||||||
@@ -535,7 +535,7 @@ void ShortcutSettingsWidget::exportAction()
|
|||||||
schemesPath().toString(),
|
schemesPath().toString(),
|
||||||
tr("Keyboard Mapping Scheme (*.kms)"));
|
tr("Keyboard Mapping Scheme (*.kms)"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
CommandsFile cf(fileName);
|
CommandsFile cf(FilePath::fromString(fileName));
|
||||||
cf.exportCommands(m_scitems);
|
cf.exportCommands(m_scitems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user