forked from qt-creator/qt-creator
TextEditor: Simplify ColorScheme::save() signature
Change-Id: I1ea25996a97e1cdbfb97f1f19231322e8a804cc6 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
#include "texteditorconstants.h"
|
#include "texteditorconstants.h"
|
||||||
#include "texteditortr.h"
|
#include "texteditortr.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@@ -216,7 +218,7 @@ void ColorScheme::clear()
|
|||||||
m_formats.clear();
|
m_formats.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ColorScheme::save(const FilePath &filePath, QWidget *parent) const
|
bool ColorScheme::save(const FilePath &filePath) const
|
||||||
{
|
{
|
||||||
FileSaver saver(filePath);
|
FileSaver saver(filePath);
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
@@ -262,7 +264,7 @@ bool ColorScheme::save(const FilePath &filePath, QWidget *parent) const
|
|||||||
|
|
||||||
saver.setResult(&w);
|
saver.setResult(&w);
|
||||||
}
|
}
|
||||||
return saver.finalize(parent);
|
return saver.finalize(Core::ICore::dialogParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@@ -97,7 +97,7 @@ public:
|
|||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
bool save(const Utils::FilePath &filePath, QWidget *parent) const;
|
bool save(const Utils::FilePath &filePath) const;
|
||||||
bool load(const Utils::FilePath &filePath);
|
bool load(const Utils::FilePath &filePath);
|
||||||
|
|
||||||
bool equals(const ColorScheme &cs) const
|
bool equals(const ColorScheme &cs) const
|
||||||
|
@@ -464,9 +464,9 @@ bool FontSettings::loadColorScheme(const Utils::FilePath &filePath,
|
|||||||
return loaded;
|
return loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FontSettings::saveColorScheme(const Utils::FilePath &fileName)
|
bool FontSettings::saveColorScheme(const FilePath &fileName)
|
||||||
{
|
{
|
||||||
const bool saved = m_scheme.save(fileName, Core::ICore::dialogParent());
|
const bool saved = m_scheme.save(fileName);
|
||||||
if (saved)
|
if (saved)
|
||||||
m_schemeFileName = fileName;
|
m_schemeFileName = fileName;
|
||||||
return saved;
|
return saved;
|
||||||
|
@@ -552,7 +552,7 @@ void FontSettingsPageWidget::copyColorScheme(const QString &name)
|
|||||||
|
|
||||||
ColorScheme scheme = m_value.colorScheme();
|
ColorScheme scheme = m_value.colorScheme();
|
||||||
scheme.setDisplayName(name);
|
scheme.setDisplayName(name);
|
||||||
if (scheme.save(filePath, Core::ICore::dialogParent()))
|
if (scheme.save(filePath))
|
||||||
m_value.setColorSchemeFileName(filePath);
|
m_value.setColorSchemeFileName(filePath);
|
||||||
|
|
||||||
refreshColorSchemeList();
|
refreshColorSchemeList();
|
||||||
@@ -629,7 +629,7 @@ void FontSettingsPageWidget::importScheme()
|
|||||||
ColorScheme scheme;
|
ColorScheme scheme;
|
||||||
if (scheme.load(importedFile)) {
|
if (scheme.load(importedFile)) {
|
||||||
scheme.setDisplayName(name);
|
scheme.setDisplayName(name);
|
||||||
scheme.save(saveFileName, Core::ICore::dialogParent());
|
scheme.save(saveFileName);
|
||||||
m_value.loadColorScheme(saveFileName, m_descriptions);
|
m_value.loadColorScheme(saveFileName, m_descriptions);
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Failed to import color scheme:" << importedFile;
|
qWarning() << "Failed to import color scheme:" << importedFile;
|
||||||
@@ -656,7 +656,7 @@ void FontSettingsPageWidget::exportScheme()
|
|||||||
Tr::tr("Color scheme (*.xml);;All files (*)"));
|
Tr::tr("Color scheme (*.xml);;All files (*)"));
|
||||||
|
|
||||||
if (!filePath.isEmpty())
|
if (!filePath.isEmpty())
|
||||||
m_value.colorScheme().save(filePath, Core::ICore::dialogParent());
|
m_value.colorScheme().save(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontSettingsPageWidget::maybeSaveColorScheme()
|
void FontSettingsPageWidget::maybeSaveColorScheme()
|
||||||
@@ -680,7 +680,7 @@ void FontSettingsPageWidget::maybeSaveColorScheme()
|
|||||||
|
|
||||||
if (messageBox.exec() == QMessageBox::Save) {
|
if (messageBox.exec() == QMessageBox::Save) {
|
||||||
const ColorScheme &scheme = m_schemeEdit->colorScheme();
|
const ColorScheme &scheme = m_schemeEdit->colorScheme();
|
||||||
scheme.save(m_value.colorSchemeFileName(), Core::ICore::dialogParent());
|
scheme.save(m_value.colorSchemeFileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,7 +726,7 @@ void FontSettingsPageWidget::apply()
|
|||||||
// Update the scheme and save it under the name it already has
|
// Update the scheme and save it under the name it already has
|
||||||
m_value.setColorScheme(m_schemeEdit->colorScheme());
|
m_value.setColorScheme(m_schemeEdit->colorScheme());
|
||||||
const ColorScheme &scheme = m_value.colorScheme();
|
const ColorScheme &scheme = m_value.colorScheme();
|
||||||
scheme.save(m_value.colorSchemeFileName(), Core::ICore::dialogParent());
|
scheme.save(m_value.colorSchemeFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
|
Reference in New Issue
Block a user