forked from qt-creator/qt-creator
Beautifier: Use Aspects for part of settings
Change-Id: Icff60f5f1292ae6b2de2ce757d645d5fec47bcc6 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -5,7 +5,6 @@ add_qtc_plugin(Beautifier
|
|||||||
abstractsettings.cpp abstractsettings.h
|
abstractsettings.cpp abstractsettings.h
|
||||||
artisticstyle/artisticstyle.cpp artisticstyle/artisticstyle.h
|
artisticstyle/artisticstyle.cpp artisticstyle/artisticstyle.h
|
||||||
artisticstyle/artisticstyleconstants.h
|
artisticstyle/artisticstyleconstants.h
|
||||||
artisticstyle/artisticstyleoptionspage.cpp artisticstyle/artisticstyleoptionspage.h
|
|
||||||
artisticstyle/artisticstylesettings.cpp artisticstyle/artisticstylesettings.h
|
artisticstyle/artisticstylesettings.cpp artisticstyle/artisticstylesettings.h
|
||||||
beautifier.qrc
|
beautifier.qrc
|
||||||
beautifierabstracttool.h
|
beautifierabstracttool.h
|
||||||
@@ -14,7 +13,6 @@ add_qtc_plugin(Beautifier
|
|||||||
beautifiertr.h
|
beautifiertr.h
|
||||||
clangformat/clangformat.cpp clangformat/clangformat.h
|
clangformat/clangformat.cpp clangformat/clangformat.h
|
||||||
clangformat/clangformatconstants.h
|
clangformat/clangformatconstants.h
|
||||||
clangformat/clangformatoptionspage.cpp clangformat/clangformatoptionspage.h
|
|
||||||
clangformat/clangformatsettings.cpp clangformat/clangformatsettings.h
|
clangformat/clangformatsettings.cpp clangformat/clangformatsettings.h
|
||||||
configurationdialog.cpp configurationdialog.h
|
configurationdialog.cpp configurationdialog.h
|
||||||
configurationeditor.cpp configurationeditor.h
|
configurationeditor.cpp configurationeditor.h
|
||||||
@@ -22,6 +20,5 @@ add_qtc_plugin(Beautifier
|
|||||||
generalsettings.cpp generalsettings.h
|
generalsettings.cpp generalsettings.h
|
||||||
uncrustify/uncrustify.cpp uncrustify/uncrustify.h
|
uncrustify/uncrustify.cpp uncrustify/uncrustify.h
|
||||||
uncrustify/uncrustifyconstants.h
|
uncrustify/uncrustifyconstants.h
|
||||||
uncrustify/uncrustifyoptionspage.cpp uncrustify/uncrustifyoptionspage.h
|
|
||||||
uncrustify/uncrustifysettings.cpp uncrustify/uncrustifysettings.h
|
uncrustify/uncrustifysettings.cpp uncrustify/uncrustifysettings.h
|
||||||
)
|
)
|
||||||
|
@@ -26,9 +26,6 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace Beautifier::Internal {
|
namespace Beautifier::Internal {
|
||||||
|
|
||||||
const char COMMAND[] = "command";
|
|
||||||
const char SUPPORTED_MIME[] = "supportedMime";
|
|
||||||
|
|
||||||
class VersionUpdater
|
class VersionUpdater
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -86,9 +83,40 @@ AbstractSettings::AbstractSettings(const QString &name, const QString &ending)
|
|||||||
, m_styleDir(Core::ICore::userResourcePath(Beautifier::Constants::SETTINGS_DIRNAME)
|
, m_styleDir(Core::ICore::userResourcePath(Beautifier::Constants::SETTINGS_DIRNAME)
|
||||||
.pathAppended(name)
|
.pathAppended(name)
|
||||||
.toString())
|
.toString())
|
||||||
, m_name(name)
|
|
||||||
, m_versionUpdater(new VersionUpdater)
|
, m_versionUpdater(new VersionUpdater)
|
||||||
{
|
{
|
||||||
|
setSettingsGroups(Utils::Constants::BEAUTIFIER_SETTINGS_GROUP, name);
|
||||||
|
|
||||||
|
registerAspect(&command);
|
||||||
|
command.setSettingsKey("command");
|
||||||
|
command.setExpectedKind(Utils::PathChooser::ExistingCommand);
|
||||||
|
command.setCommandVersionArguments({"--version"});
|
||||||
|
command.setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle("Clang Format"));
|
||||||
|
|
||||||
|
registerAspect(&supportedMimeTypes);
|
||||||
|
supportedMimeTypes.setDisplayStyle(StringAspect::LineEditDisplay);
|
||||||
|
supportedMimeTypes.setSettingsKey("supportedMime");
|
||||||
|
supportedMimeTypes.setLabelText(Tr::tr("Restrict to MIME types:"));
|
||||||
|
supportedMimeTypes.setDefaultValue("text/x-c++src; text/x-c++hdr; text/x-csrc;text/x-chdr; "
|
||||||
|
"text/x-objcsrc; text/x-objc++src");
|
||||||
|
|
||||||
|
supportedMimeTypes.setValueAcceptor([](const QString &, const QString &value) -> std::optional<QString> {
|
||||||
|
const QStringList stringTypes = value.split(';');
|
||||||
|
QStringList types;
|
||||||
|
for (const QString &type : stringTypes) {
|
||||||
|
const MimeType mime = mimeTypeForName(type.trimmed());
|
||||||
|
if (!mime.isValid())
|
||||||
|
continue;
|
||||||
|
const QString canonicalName = mime.name();
|
||||||
|
if (!types.contains(canonicalName))
|
||||||
|
types << canonicalName;
|
||||||
|
}
|
||||||
|
return types.join("; ");
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(&command, &BaseAspect::changed, this, [this] {
|
||||||
|
m_versionUpdater->update(command());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractSettings::~AbstractSettings() = default;
|
AbstractSettings::~AbstractSettings() = default;
|
||||||
@@ -157,20 +185,6 @@ QString AbstractSettings::styleFileName(const QString &key) const
|
|||||||
return m_styleDir.absoluteFilePath(key + m_ending);
|
return m_styleDir.absoluteFilePath(key + m_ending);
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath AbstractSettings::command() const
|
|
||||||
{
|
|
||||||
return m_command;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AbstractSettings::setCommand(const FilePath &cmd)
|
|
||||||
{
|
|
||||||
if (cmd == m_command)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_command = cmd;
|
|
||||||
m_versionUpdater->update(command());
|
|
||||||
}
|
|
||||||
|
|
||||||
QVersionNumber AbstractSettings::version() const
|
QVersionNumber AbstractSettings::version() const
|
||||||
{
|
{
|
||||||
return m_versionUpdater->version();
|
return m_versionUpdater->version();
|
||||||
@@ -181,30 +195,6 @@ void AbstractSettings::setVersionRegExp(const QRegularExpression &versionRegExp)
|
|||||||
m_versionUpdater->setVersionRegExp(versionRegExp);
|
m_versionUpdater->setVersionRegExp(versionRegExp);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AbstractSettings::supportedMimeTypesAsString() const
|
|
||||||
{
|
|
||||||
return m_supportedMimeTypes.join("; ");
|
|
||||||
}
|
|
||||||
|
|
||||||
void AbstractSettings::setSupportedMimeTypes(const QString &mimes)
|
|
||||||
{
|
|
||||||
const QStringList stringTypes = mimes.split(';');
|
|
||||||
QStringList types;
|
|
||||||
for (const QString &type : stringTypes) {
|
|
||||||
const MimeType mime = mimeTypeForName(type.trimmed());
|
|
||||||
if (!mime.isValid())
|
|
||||||
continue;
|
|
||||||
const QString canonicalName = mime.name();
|
|
||||||
if (!types.contains(canonicalName))
|
|
||||||
types << canonicalName;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_supportedMimeTypes != types) {
|
|
||||||
m_supportedMimeTypes = types;
|
|
||||||
emit supportedMimeTypesChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AbstractSettings::isApplicable(const Core::IDocument *document) const
|
bool AbstractSettings::isApplicable(const Core::IDocument *document) const
|
||||||
{
|
{
|
||||||
if (!document)
|
if (!document)
|
||||||
@@ -240,17 +230,8 @@ void AbstractSettings::save()
|
|||||||
{
|
{
|
||||||
// Save settings, except styles
|
// Save settings, except styles
|
||||||
QSettings *s = Core::ICore::settings();
|
QSettings *s = Core::ICore::settings();
|
||||||
s->beginGroup(Utils::Constants::BEAUTIFIER_SETTINGS_GROUP);
|
|
||||||
s->beginGroup(m_name);
|
AspectContainer::writeSettings(s);
|
||||||
QMap<QString, QVariant>::const_iterator iSettings = m_settings.constBegin();
|
|
||||||
while (iSettings != m_settings.constEnd()) {
|
|
||||||
s->setValue(iSettings.key(), iSettings.value());
|
|
||||||
++iSettings;
|
|
||||||
}
|
|
||||||
s->setValue(COMMAND, m_command.toSettings());
|
|
||||||
s->setValue(SUPPORTED_MIME, supportedMimeTypesAsString());
|
|
||||||
s->endGroup();
|
|
||||||
s->endGroup();
|
|
||||||
|
|
||||||
// Save styles
|
// Save styles
|
||||||
if (m_stylesToRemove.isEmpty() && m_styles.isEmpty())
|
if (m_stylesToRemove.isEmpty() && m_styles.isEmpty())
|
||||||
@@ -306,27 +287,9 @@ void AbstractSettings::createDocumentationFile() const
|
|||||||
|
|
||||||
void AbstractSettings::read()
|
void AbstractSettings::read()
|
||||||
{
|
{
|
||||||
// Set default values
|
|
||||||
setSupportedMimeTypes("text/x-c++src;text/x-c++hdr;text/x-csrc;text/x-chdr;text/x-objcsrc;"
|
|
||||||
"text/x-objc++src");
|
|
||||||
|
|
||||||
// Read settings, except styles
|
// Read settings, except styles
|
||||||
QSettings *s = Core::ICore::settings();
|
QSettings *s = Core::ICore::settings();
|
||||||
s->beginGroup(Utils::Constants::BEAUTIFIER_SETTINGS_GROUP);
|
AspectContainer::readSettings(s);
|
||||||
s->beginGroup(m_name);
|
|
||||||
const QStringList keys = s->allKeys();
|
|
||||||
for (const QString &key : keys) {
|
|
||||||
if (key == COMMAND)
|
|
||||||
setCommand(FilePath::fromSettings(s->value(key)));
|
|
||||||
else if (key == SUPPORTED_MIME)
|
|
||||||
setSupportedMimeTypes(s->value(key).toString());
|
|
||||||
else if (m_settings.contains(key))
|
|
||||||
m_settings[key] = s->value(key);
|
|
||||||
else
|
|
||||||
s->remove(key);
|
|
||||||
}
|
|
||||||
s->endGroup();
|
|
||||||
s->endGroup();
|
|
||||||
|
|
||||||
m_styles.clear();
|
m_styles.clear();
|
||||||
m_changedStyles.clear();
|
m_changedStyles.clear();
|
||||||
@@ -336,18 +299,19 @@ void AbstractSettings::read()
|
|||||||
|
|
||||||
void AbstractSettings::readDocumentation()
|
void AbstractSettings::readDocumentation()
|
||||||
{
|
{
|
||||||
const QString filename = documentationFilePath();
|
const FilePath filename = documentationFilePath();
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
BeautifierPlugin::showError(Tr::tr("No documentation file specified."));
|
BeautifierPlugin::showError(Tr::tr("No documentation file specified."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile file(filename);
|
QFile file(filename.toFSPathString());
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
createDocumentationFile();
|
createDocumentationFile();
|
||||||
|
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
BeautifierPlugin::showError(Tr::tr("Cannot open documentation file \"%1\".").arg(filename));
|
BeautifierPlugin::showError(Tr::tr("Cannot open documentation file \"%1\".")
|
||||||
|
.arg(filename.toUserOutput()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +320,7 @@ void AbstractSettings::readDocumentation()
|
|||||||
return;
|
return;
|
||||||
if (xml.name() != QLatin1String(Constants::DOCUMENTATION_XMLROOT)) {
|
if (xml.name() != QLatin1String(Constants::DOCUMENTATION_XMLROOT)) {
|
||||||
BeautifierPlugin::showError(Tr::tr("The file \"%1\" is not a valid documentation file.")
|
BeautifierPlugin::showError(Tr::tr("The file \"%1\" is not a valid documentation file.")
|
||||||
.arg(filename));
|
.arg(filename.toUserOutput()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +351,7 @@ void AbstractSettings::readDocumentation()
|
|||||||
|
|
||||||
if (xml.hasError()) {
|
if (xml.hasError()) {
|
||||||
BeautifierPlugin::showError(Tr::tr("Cannot read documentation file \"%1\": %2.")
|
BeautifierPlugin::showError(Tr::tr("Cannot read documentation file \"%1\": %2.")
|
||||||
.arg(filename).arg(xml.errorString()));
|
.arg(filename.toUserOutput()).arg(xml.errorString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
#include <utils/aspects.h>
|
#include <utils/aspects.h>
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
@@ -40,7 +42,6 @@ public:
|
|||||||
void read();
|
void read();
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
virtual QString documentationFilePath() const = 0;
|
|
||||||
virtual void createDocumentationFile() const;
|
virtual void createDocumentationFile() const;
|
||||||
virtual QStringList completerWords();
|
virtual QStringList completerWords();
|
||||||
|
|
||||||
@@ -53,25 +54,21 @@ public:
|
|||||||
void replaceStyle(const QString &oldKey, const QString &newKey, const QString &value);
|
void replaceStyle(const QString &oldKey, const QString &newKey, const QString &value);
|
||||||
virtual QString styleFileName(const QString &key) const;
|
virtual QString styleFileName(const QString &key) const;
|
||||||
|
|
||||||
Utils::FilePath command() const;
|
Utils::FilePathAspect command;
|
||||||
void setCommand(const Utils::FilePath &cmd);
|
Utils::StringAspect supportedMimeTypes;
|
||||||
|
Utils::FilePathAspect documentationFilePath;
|
||||||
|
|
||||||
QVersionNumber version() const;
|
QVersionNumber version() const;
|
||||||
|
|
||||||
QString supportedMimeTypesAsString() const;
|
|
||||||
void setSupportedMimeTypes(const QString &mimes);
|
|
||||||
bool isApplicable(const Core::IDocument *document) const;
|
bool isApplicable(const Core::IDocument *document) const;
|
||||||
|
|
||||||
QStringList options();
|
QStringList options();
|
||||||
QString documentation(const QString &option) const;
|
QString documentation(const QString &option) const;
|
||||||
|
|
||||||
signals:
|
|
||||||
void supportedMimeTypesChanged();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setVersionRegExp(const QRegularExpression &versionRegExp);
|
void setVersionRegExp(const QRegularExpression &versionRegExp);
|
||||||
|
|
||||||
QMap<QString, QString> m_styles;
|
QMap<QString, QString> m_styles;
|
||||||
QMap<QString, QVariant> m_settings;
|
|
||||||
QString m_ending;
|
QString m_ending;
|
||||||
QDir m_styleDir;
|
QDir m_styleDir;
|
||||||
|
|
||||||
@@ -79,11 +76,9 @@ protected:
|
|||||||
virtual void readStyles();
|
virtual void readStyles();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_name;
|
|
||||||
std::unique_ptr<VersionUpdater> m_versionUpdater;
|
std::unique_ptr<VersionUpdater> m_versionUpdater;
|
||||||
QStringList m_stylesToRemove;
|
QStringList m_stylesToRemove;
|
||||||
QSet<QString> m_changedStyles;
|
QSet<QString> m_changedStyles;
|
||||||
Utils::FilePath m_command;
|
|
||||||
QHash<QString, int> m_options;
|
QHash<QString, int> m_options;
|
||||||
QStringList m_docu;
|
QStringList m_docu;
|
||||||
QStringList m_supportedMimeTypes;
|
QStringList m_supportedMimeTypes;
|
||||||
|
@@ -48,7 +48,7 @@ ArtisticStyle::ArtisticStyle()
|
|||||||
|
|
||||||
Core::ActionManager::actionContainer(Constants::MENU_ID)->addMenu(menu);
|
Core::ActionManager::actionContainer(Constants::MENU_ID)->addMenu(menu);
|
||||||
|
|
||||||
connect(&m_settings, &ArtisticStyleSettings::supportedMimeTypesChanged,
|
connect(&m_settings.supportedMimeTypes, &Utils::BaseAspect::changed,
|
||||||
this, [this] { updateActions(Core::EditorManager::currentEditor()); });
|
this, [this] { updateActions(Core::EditorManager::currentEditor()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "../beautifierabstracttool.h"
|
#include "../beautifierabstracttool.h"
|
||||||
|
|
||||||
#include "artisticstyleoptionspage.h"
|
|
||||||
#include "artisticstylesettings.h"
|
#include "artisticstylesettings.h"
|
||||||
|
|
||||||
namespace Beautifier::Internal {
|
namespace Beautifier::Internal {
|
||||||
|
@@ -1,134 +0,0 @@
|
|||||||
// Copyright (C) 2016 Lorenz Haas
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#include "artisticstyleoptionspage.h"
|
|
||||||
|
|
||||||
#include "artisticstyleconstants.h"
|
|
||||||
#include "artisticstylesettings.h"
|
|
||||||
|
|
||||||
#include "../beautifierconstants.h"
|
|
||||||
#include "../beautifierplugin.h"
|
|
||||||
#include "../beautifiertr.h"
|
|
||||||
#include "../configurationpanel.h"
|
|
||||||
|
|
||||||
#include <utils/layoutbuilder.h>
|
|
||||||
#include <utils/pathchooser.h>
|
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QGroupBox>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
|
|
||||||
namespace Beautifier::Internal {
|
|
||||||
|
|
||||||
class ArtisticStyleOptionsPageWidget : public Core::IOptionsPageWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ArtisticStyleOptionsPageWidget(ArtisticStyleSettings *settings);
|
|
||||||
|
|
||||||
void apply() final;
|
|
||||||
|
|
||||||
private:
|
|
||||||
ArtisticStyleSettings *m_settings;
|
|
||||||
|
|
||||||
Utils::PathChooser *m_command;
|
|
||||||
QLineEdit *m_mime;
|
|
||||||
QCheckBox *m_useOtherFiles;
|
|
||||||
QCheckBox *m_useSpecificConfigFile;
|
|
||||||
Utils::PathChooser *m_specificConfigFile;
|
|
||||||
QCheckBox *m_useHomeFile;
|
|
||||||
QCheckBox *m_useCustomStyle;
|
|
||||||
Beautifier::Internal::ConfigurationPanel *m_configurations;
|
|
||||||
};
|
|
||||||
|
|
||||||
ArtisticStyleOptionsPageWidget::ArtisticStyleOptionsPageWidget(ArtisticStyleSettings *settings)
|
|
||||||
: m_settings(settings)
|
|
||||||
{
|
|
||||||
m_command = new Utils::PathChooser;
|
|
||||||
|
|
||||||
m_mime = new QLineEdit(m_settings->supportedMimeTypesAsString());
|
|
||||||
|
|
||||||
auto options = new QGroupBox(Tr::tr("Options"));
|
|
||||||
|
|
||||||
m_useOtherFiles = new QCheckBox(Tr::tr("Use file *.astylerc defined in project files"));
|
|
||||||
m_useOtherFiles->setChecked(m_settings->useOtherFiles());
|
|
||||||
|
|
||||||
m_useSpecificConfigFile = new QCheckBox(Tr::tr("Use specific config file:"));
|
|
||||||
m_useSpecificConfigFile->setChecked(m_settings->useSpecificConfigFile());
|
|
||||||
|
|
||||||
m_specificConfigFile = new Utils::PathChooser;
|
|
||||||
m_specificConfigFile->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
||||||
m_specificConfigFile->setExpectedKind(Utils::PathChooser::File);
|
|
||||||
m_specificConfigFile->setPromptDialogFilter(Tr::tr("AStyle (*.astylerc)"));
|
|
||||||
m_specificConfigFile->setFilePath(m_settings->specificConfigFile());
|
|
||||||
|
|
||||||
m_useHomeFile = new QCheckBox(
|
|
||||||
Tr::tr("Use file .astylerc or astylerc in HOME").
|
|
||||||
replace("HOME", QDir::toNativeSeparators(QDir::home().absolutePath())));
|
|
||||||
m_useHomeFile->setChecked(m_settings->useHomeFile());
|
|
||||||
|
|
||||||
m_useCustomStyle = new QCheckBox(Tr::tr("Use customized style:"));
|
|
||||||
m_useCustomStyle->setChecked(m_settings->useCustomStyle());
|
|
||||||
|
|
||||||
m_configurations = new ConfigurationPanel(options);
|
|
||||||
m_configurations->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
||||||
m_configurations->setSettings(m_settings);
|
|
||||||
m_configurations->setCurrentConfiguration(m_settings->customStyle());
|
|
||||||
|
|
||||||
m_command->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
|
||||||
m_command->setCommandVersionArguments({"--version"});
|
|
||||||
m_command->setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(
|
|
||||||
Tr::tr(Constants::ARTISTICSTYLE_DISPLAY_NAME)));
|
|
||||||
m_command->setFilePath(m_settings->command());
|
|
||||||
|
|
||||||
using namespace Layouting;
|
|
||||||
|
|
||||||
Column {
|
|
||||||
m_useOtherFiles,
|
|
||||||
Row { m_useSpecificConfigFile, m_specificConfigFile },
|
|
||||||
m_useHomeFile,
|
|
||||||
Row { m_useCustomStyle, m_configurations },
|
|
||||||
noMargin,
|
|
||||||
}.attachTo(options);
|
|
||||||
|
|
||||||
Column {
|
|
||||||
Group {
|
|
||||||
title(Tr::tr("Configuration")),
|
|
||||||
Form {
|
|
||||||
Tr::tr("Artistic Style command:"), m_command, br,
|
|
||||||
Tr::tr("Restrict to MIME types:"), m_mime
|
|
||||||
}
|
|
||||||
},
|
|
||||||
options,
|
|
||||||
st
|
|
||||||
}.attachTo(this);
|
|
||||||
|
|
||||||
connect(m_command, &Utils::PathChooser::validChanged, options, &QWidget::setEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArtisticStyleOptionsPageWidget::apply()
|
|
||||||
{
|
|
||||||
m_settings->setCommand(m_command->filePath());
|
|
||||||
m_settings->setSupportedMimeTypes(m_mime->text());
|
|
||||||
m_settings->setUseOtherFiles(m_useOtherFiles->isChecked());
|
|
||||||
m_settings->setUseSpecificConfigFile(m_useSpecificConfigFile->isChecked());
|
|
||||||
m_settings->setSpecificConfigFile(m_specificConfigFile->filePath());
|
|
||||||
m_settings->setUseHomeFile(m_useHomeFile->isChecked());
|
|
||||||
m_settings->setUseCustomStyle(m_useCustomStyle->isChecked());
|
|
||||||
m_settings->setCustomStyle(m_configurations->currentConfiguration());
|
|
||||||
m_settings->save();
|
|
||||||
|
|
||||||
// update since not all MIME types are accepted (invalids or duplicates)
|
|
||||||
m_mime->setText(m_settings->supportedMimeTypesAsString());
|
|
||||||
}
|
|
||||||
|
|
||||||
ArtisticStyleOptionsPage::ArtisticStyleOptionsPage(ArtisticStyleSettings *settings)
|
|
||||||
{
|
|
||||||
setId("ArtisticStyle");
|
|
||||||
setDisplayName(Tr::tr("Artistic Style"));
|
|
||||||
setCategory(Constants::OPTION_CATEGORY);
|
|
||||||
setWidgetCreator([settings] { return new ArtisticStyleOptionsPageWidget(settings); });
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Beautifier::Internal
|
|
@@ -1,18 +0,0 @@
|
|||||||
// Copyright (C) 2016 Lorenz Haas
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
|
||||||
|
|
||||||
namespace Beautifier::Internal {
|
|
||||||
|
|
||||||
class ArtisticStyleSettings;
|
|
||||||
|
|
||||||
class ArtisticStyleOptionsPage final : public Core::IOptionsPage
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ArtisticStyleOptionsPage(ArtisticStyleSettings *settings);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // Beautifier::Internal
|
|
@@ -3,16 +3,24 @@
|
|||||||
|
|
||||||
#include "artisticstylesettings.h"
|
#include "artisticstylesettings.h"
|
||||||
|
|
||||||
|
#include "artisticstyleconstants.h"
|
||||||
#include "../beautifierconstants.h"
|
#include "../beautifierconstants.h"
|
||||||
|
#include "../beautifierplugin.h"
|
||||||
|
#include "../beautifiertr.h"
|
||||||
|
#include "../configurationpanel.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/process.h>
|
#include <utils/process.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QGroupBox>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
@@ -20,96 +28,52 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace Beautifier::Internal {
|
namespace Beautifier::Internal {
|
||||||
|
|
||||||
const char USE_OTHER_FILES[] = "useOtherFiles";
|
|
||||||
const char USE_SPECIFIC_CONFIG_FILE[] = "useSpecificConfigFile";
|
|
||||||
const char SPECIFIC_CONFIG_FILE[] = "specificConfigFile";
|
|
||||||
const char USE_HOME_FILE[] = "useHomeFile";
|
|
||||||
const char USE_CUSTOM_STYLE[] = "useCustomStyle";
|
|
||||||
const char CUSTOM_STYLE[] = "customStyle";
|
|
||||||
const char SETTINGS_NAME[] = "artisticstyle";
|
const char SETTINGS_NAME[] = "artisticstyle";
|
||||||
|
|
||||||
ArtisticStyleSettings::ArtisticStyleSettings() :
|
ArtisticStyleSettings::ArtisticStyleSettings()
|
||||||
AbstractSettings(SETTINGS_NAME, ".astyle")
|
: AbstractSettings(SETTINGS_NAME, ".astyle")
|
||||||
{
|
{
|
||||||
setVersionRegExp(QRegularExpression("([2-9]{1})\\.([0-9]{1,2})(\\.[1-9]{1})?$"));
|
setVersionRegExp(QRegularExpression("([2-9]{1})\\.([0-9]{1,2})(\\.[1-9]{1})?$"));
|
||||||
setCommand("astyle");
|
command.setLabelText(Tr::tr("Artistic Style command:"));
|
||||||
m_settings.insert(USE_OTHER_FILES, QVariant(true));
|
command.setDefaultValue("astyle");
|
||||||
m_settings.insert(USE_SPECIFIC_CONFIG_FILE, QVariant(false));
|
command.setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(
|
||||||
m_settings.insert(SPECIFIC_CONFIG_FILE, QVariant());
|
Tr::tr(Constants::ARTISTICSTYLE_DISPLAY_NAME)));
|
||||||
m_settings.insert(USE_HOME_FILE, QVariant(false));
|
|
||||||
m_settings.insert(USE_CUSTOM_STYLE, QVariant(false));
|
registerAspect(&useOtherFiles);
|
||||||
m_settings.insert(CUSTOM_STYLE, QVariant());
|
useOtherFiles.setSettingsKey("useOtherFiles");
|
||||||
|
useOtherFiles.setLabelText(Tr::tr("Use file *.astylerc defined in project files"));
|
||||||
|
useOtherFiles.setDefaultValue(true);
|
||||||
|
|
||||||
|
registerAspect(&useSpecificConfigFile);
|
||||||
|
useSpecificConfigFile.setSettingsKey("useSpecificConfigFile");
|
||||||
|
useSpecificConfigFile.setLabelText(Tr::tr("Use specific config file:"));
|
||||||
|
|
||||||
|
registerAspect(&specificConfigFile);
|
||||||
|
specificConfigFile.setSettingsKey("specificConfigFile");
|
||||||
|
specificConfigFile.setExpectedKind(PathChooser::File);
|
||||||
|
specificConfigFile.setPromptDialogFilter(Tr::tr("AStyle (*.astylerc)"));
|
||||||
|
|
||||||
|
registerAspect(&useHomeFile);
|
||||||
|
useHomeFile.setSettingsKey("useHomeFile");
|
||||||
|
useHomeFile.setLabelText(Tr::tr("Use file .astylerc or astylerc in HOME").
|
||||||
|
replace("HOME", QDir::toNativeSeparators(QDir::home().absolutePath())));
|
||||||
|
|
||||||
|
registerAspect(&useCustomStyle);
|
||||||
|
useCustomStyle.setSettingsKey("useCustomStyle");
|
||||||
|
useCustomStyle.setLabelText(Tr::tr("Use customized style:"));
|
||||||
|
|
||||||
|
registerAspect(&customStyle);
|
||||||
|
customStyle.setSettingsKey("customStyle");
|
||||||
|
|
||||||
|
documentationFilePath.setFilePath(
|
||||||
|
Core::ICore::userResourcePath(Beautifier::Constants::SETTINGS_DIRNAME)
|
||||||
|
.pathAppended(Beautifier::Constants::DOCUMENTATION_DIRNAME)
|
||||||
|
.pathAppended(SETTINGS_NAME)
|
||||||
|
.stringAppended(".xml"));
|
||||||
|
|
||||||
read();
|
read();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArtisticStyleSettings::useOtherFiles() const
|
|
||||||
{
|
|
||||||
return m_settings.value(USE_OTHER_FILES).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArtisticStyleSettings::setUseOtherFiles(bool useOtherFiles)
|
|
||||||
{
|
|
||||||
m_settings.insert(USE_OTHER_FILES, QVariant(useOtherFiles));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ArtisticStyleSettings::useSpecificConfigFile() const
|
|
||||||
{
|
|
||||||
return m_settings.value(USE_SPECIFIC_CONFIG_FILE).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArtisticStyleSettings::setUseSpecificConfigFile(bool useSpecificConfigFile)
|
|
||||||
{
|
|
||||||
m_settings.insert(USE_SPECIFIC_CONFIG_FILE, QVariant(useSpecificConfigFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
FilePath ArtisticStyleSettings::specificConfigFile() const
|
|
||||||
{
|
|
||||||
return FilePath::fromString(m_settings.value(SPECIFIC_CONFIG_FILE).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArtisticStyleSettings::setSpecificConfigFile(const FilePath &specificConfigFile)
|
|
||||||
{
|
|
||||||
m_settings.insert(SPECIFIC_CONFIG_FILE, QVariant(specificConfigFile.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ArtisticStyleSettings::useHomeFile() const
|
|
||||||
{
|
|
||||||
return m_settings.value(USE_HOME_FILE).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArtisticStyleSettings::setUseHomeFile(bool useHomeFile)
|
|
||||||
{
|
|
||||||
m_settings.insert(USE_HOME_FILE, QVariant(useHomeFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ArtisticStyleSettings::useCustomStyle() const
|
|
||||||
{
|
|
||||||
return m_settings.value(USE_CUSTOM_STYLE).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArtisticStyleSettings::setUseCustomStyle(bool useCustomStyle)
|
|
||||||
{
|
|
||||||
m_settings.insert(USE_CUSTOM_STYLE, QVariant(useCustomStyle));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ArtisticStyleSettings::customStyle() const
|
|
||||||
{
|
|
||||||
return m_settings.value(CUSTOM_STYLE).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArtisticStyleSettings::setCustomStyle(const QString &customStyle)
|
|
||||||
{
|
|
||||||
m_settings.insert(CUSTOM_STYLE, QVariant(customStyle));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ArtisticStyleSettings::documentationFilePath() const
|
|
||||||
{
|
|
||||||
return (Core::ICore::userResourcePath(Beautifier::Constants::SETTINGS_DIRNAME)
|
|
||||||
/ Beautifier::Constants::DOCUMENTATION_DIRNAME / SETTINGS_NAME)
|
|
||||||
.stringAppended(".xml")
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArtisticStyleSettings::createDocumentationFile() const
|
void ArtisticStyleSettings::createDocumentationFile() const
|
||||||
{
|
{
|
||||||
Process process;
|
Process process;
|
||||||
@@ -119,7 +83,7 @@ void ArtisticStyleSettings::createDocumentationFile() const
|
|||||||
if (process.result() != ProcessResult::FinishedWithSuccess)
|
if (process.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QFile file(documentationFilePath());
|
QFile file(documentationFilePath().toFSPathString());
|
||||||
const QFileInfo fi(file);
|
const QFileInfo fi(file);
|
||||||
if (!fi.exists())
|
if (!fi.exists())
|
||||||
fi.dir().mkpath(fi.absolutePath());
|
fi.dir().mkpath(fi.absolutePath());
|
||||||
@@ -183,4 +147,61 @@ void ArtisticStyleSettings::createDocumentationFile() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ArtisticStyleOptionsPageWidget : public Core::IOptionsPageWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ArtisticStyleOptionsPageWidget(ArtisticStyleSettings *settings)
|
||||||
|
{
|
||||||
|
QGroupBox *options = nullptr;
|
||||||
|
|
||||||
|
auto configurations = new ConfigurationPanel(this);
|
||||||
|
configurations->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
configurations->setSettings(settings);
|
||||||
|
configurations->setCurrentConfiguration(settings->customStyle());
|
||||||
|
|
||||||
|
using namespace Layouting;
|
||||||
|
|
||||||
|
ArtisticStyleSettings &s = *settings;
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Group {
|
||||||
|
title(Tr::tr("Configuration")),
|
||||||
|
Form {
|
||||||
|
s.command, br,
|
||||||
|
s.supportedMimeTypes
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Group {
|
||||||
|
title(Tr::tr("Options")),
|
||||||
|
bindTo(&options),
|
||||||
|
Column {
|
||||||
|
s.useOtherFiles,
|
||||||
|
Row { s.useSpecificConfigFile, s.specificConfigFile },
|
||||||
|
s.useHomeFile,
|
||||||
|
Row { s.useCustomStyle, configurations },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
st
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
setOnApply([&s, configurations] {
|
||||||
|
s.customStyle.setValue(configurations->currentConfiguration());
|
||||||
|
s.save();
|
||||||
|
});
|
||||||
|
|
||||||
|
s.read();
|
||||||
|
|
||||||
|
connect(s.command.pathChooser(), &PathChooser::validChanged, options, &QWidget::setEnabled);
|
||||||
|
options->setEnabled(s.command.pathChooser()->isValid());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ArtisticStyleOptionsPage::ArtisticStyleOptionsPage(ArtisticStyleSettings *settings)
|
||||||
|
{
|
||||||
|
setId("ArtisticStyle");
|
||||||
|
setDisplayName(Tr::tr("Artistic Style"));
|
||||||
|
setCategory(Constants::OPTION_CATEGORY);
|
||||||
|
setWidgetCreator([settings] { return new ArtisticStyleOptionsPageWidget(settings); });
|
||||||
|
}
|
||||||
|
|
||||||
} // Beautifier::Internal
|
} // Beautifier::Internal
|
||||||
|
@@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
#include "../abstractsettings.h"
|
#include "../abstractsettings.h"
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
|
||||||
|
|
||||||
namespace Beautifier::Internal {
|
namespace Beautifier::Internal {
|
||||||
|
|
||||||
class ArtisticStyleSettings : public AbstractSettings
|
class ArtisticStyleSettings : public AbstractSettings
|
||||||
@@ -14,26 +12,20 @@ class ArtisticStyleSettings : public AbstractSettings
|
|||||||
public:
|
public:
|
||||||
ArtisticStyleSettings();
|
ArtisticStyleSettings();
|
||||||
|
|
||||||
bool useOtherFiles() const;
|
Utils::BoolAspect useOtherFiles;
|
||||||
void setUseOtherFiles(bool useOtherFiles);
|
Utils::BoolAspect useSpecificConfigFile;
|
||||||
|
Utils::FilePathAspect specificConfigFile;
|
||||||
|
Utils::BoolAspect useHomeFile;
|
||||||
|
Utils::BoolAspect useCustomStyle;
|
||||||
|
Utils::StringAspect customStyle;
|
||||||
|
|
||||||
bool useSpecificConfigFile() const;
|
|
||||||
void setUseSpecificConfigFile(bool useSpecificConfigFile);
|
|
||||||
|
|
||||||
Utils::FilePath specificConfigFile() const;
|
|
||||||
void setSpecificConfigFile(const Utils::FilePath &specificConfigFile);
|
|
||||||
|
|
||||||
bool useHomeFile() const;
|
|
||||||
void setUseHomeFile(bool useHomeFile);
|
|
||||||
|
|
||||||
bool useCustomStyle() const;
|
|
||||||
void setUseCustomStyle(bool useCustomStyle);
|
|
||||||
|
|
||||||
QString customStyle() const;
|
|
||||||
void setCustomStyle(const QString &customStyle);
|
|
||||||
|
|
||||||
QString documentationFilePath() const override;
|
|
||||||
void createDocumentationFile() const override;
|
void createDocumentationFile() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ArtisticStyleOptionsPage final : public Core::IOptionsPage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ArtisticStyleOptionsPage(ArtisticStyleSettings *settings);
|
||||||
|
};
|
||||||
|
|
||||||
} // Beautifier::Internal
|
} // Beautifier::Internal
|
||||||
|
@@ -36,8 +36,6 @@ QtcPlugin {
|
|||||||
"artisticstyle.cpp",
|
"artisticstyle.cpp",
|
||||||
"artisticstyle.h",
|
"artisticstyle.h",
|
||||||
"artisticstyleconstants.h",
|
"artisticstyleconstants.h",
|
||||||
"artisticstyleoptionspage.cpp",
|
|
||||||
"artisticstyleoptionspage.h",
|
|
||||||
"artisticstylesettings.cpp",
|
"artisticstylesettings.cpp",
|
||||||
"artisticstylesettings.h"
|
"artisticstylesettings.h"
|
||||||
]
|
]
|
||||||
@@ -50,8 +48,6 @@ QtcPlugin {
|
|||||||
"clangformat.cpp",
|
"clangformat.cpp",
|
||||||
"clangformat.h",
|
"clangformat.h",
|
||||||
"clangformatconstants.h",
|
"clangformatconstants.h",
|
||||||
"clangformatoptionspage.cpp",
|
|
||||||
"clangformatoptionspage.h",
|
|
||||||
"clangformatsettings.cpp",
|
"clangformatsettings.cpp",
|
||||||
"clangformatsettings.h"
|
"clangformatsettings.h"
|
||||||
]
|
]
|
||||||
@@ -64,8 +60,6 @@ QtcPlugin {
|
|||||||
"uncrustify.cpp",
|
"uncrustify.cpp",
|
||||||
"uncrustify.h",
|
"uncrustify.h",
|
||||||
"uncrustifyconstants.h",
|
"uncrustifyconstants.h",
|
||||||
"uncrustifyoptionspage.cpp",
|
|
||||||
"uncrustifyoptionspage.h",
|
|
||||||
"uncrustifysettings.cpp",
|
"uncrustifysettings.cpp",
|
||||||
"uncrustifysettings.h"
|
"uncrustifysettings.h"
|
||||||
]
|
]
|
||||||
|
@@ -64,7 +64,7 @@ ClangFormat::ClangFormat()
|
|||||||
|
|
||||||
Core::ActionManager::actionContainer(Constants::MENU_ID)->addMenu(menu);
|
Core::ActionManager::actionContainer(Constants::MENU_ID)->addMenu(menu);
|
||||||
|
|
||||||
connect(&m_settings, &ClangFormatSettings::supportedMimeTypesChanged,
|
connect(&m_settings.supportedMimeTypes, &Utils::BaseAspect::changed,
|
||||||
this, [this] { updateActions(Core::EditorManager::currentEditor()); });
|
this, [this] { updateActions(Core::EditorManager::currentEditor()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,10 +191,10 @@ Command ClangFormat::command() const
|
|||||||
command.setProcessing(Command::PipeProcessing);
|
command.setProcessing(Command::PipeProcessing);
|
||||||
|
|
||||||
if (m_settings.usePredefinedStyle()) {
|
if (m_settings.usePredefinedStyle()) {
|
||||||
const QString predefinedStyle = m_settings.predefinedStyle();
|
const QString predefinedStyle = m_settings.predefinedStyle.stringValue();
|
||||||
command.addOption("-style=" + predefinedStyle);
|
command.addOption("-style=" + predefinedStyle);
|
||||||
if (predefinedStyle == "File") {
|
if (predefinedStyle == "File") {
|
||||||
const QString fallbackStyle = m_settings.fallbackStyle();
|
const QString fallbackStyle = m_settings.fallbackStyle.stringValue();
|
||||||
if (fallbackStyle != "Default")
|
if (fallbackStyle != "Default")
|
||||||
command.addOption("-fallback-style=" + fallbackStyle);
|
command.addOption("-fallback-style=" + fallbackStyle);
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "../beautifierabstracttool.h"
|
#include "../beautifierabstracttool.h"
|
||||||
|
|
||||||
#include "clangformatoptionspage.h"
|
|
||||||
#include "clangformatsettings.h"
|
#include "clangformatsettings.h"
|
||||||
|
|
||||||
namespace Beautifier::Internal {
|
namespace Beautifier::Internal {
|
||||||
|
@@ -1,144 +0,0 @@
|
|||||||
// Copyright (C) 2016 Lorenz Haas
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#include "clangformatoptionspage.h"
|
|
||||||
|
|
||||||
#include "clangformatsettings.h"
|
|
||||||
|
|
||||||
#include "../beautifierconstants.h"
|
|
||||||
#include "../beautifierplugin.h"
|
|
||||||
#include "../beautifiertr.h"
|
|
||||||
#include "../configurationpanel.h"
|
|
||||||
|
|
||||||
#include <utils/layoutbuilder.h>
|
|
||||||
#include <utils/pathchooser.h>
|
|
||||||
|
|
||||||
#include <QButtonGroup>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QGroupBox>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QRadioButton>
|
|
||||||
#include <QSpacerItem>
|
|
||||||
|
|
||||||
namespace Beautifier::Internal {
|
|
||||||
|
|
||||||
class ClangFormatOptionsPageWidget : public Core::IOptionsPageWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ClangFormatOptionsPageWidget(ClangFormatSettings *settings);
|
|
||||||
|
|
||||||
void apply() final;
|
|
||||||
|
|
||||||
private:
|
|
||||||
ClangFormatSettings *m_settings;
|
|
||||||
ConfigurationPanel *m_configurations;
|
|
||||||
QRadioButton *m_usePredefinedStyle;
|
|
||||||
QComboBox *m_predefinedStyle;
|
|
||||||
QComboBox *m_fallbackStyle;
|
|
||||||
Utils::PathChooser *m_command;
|
|
||||||
QLineEdit *m_mime;
|
|
||||||
};
|
|
||||||
|
|
||||||
ClangFormatOptionsPageWidget::ClangFormatOptionsPageWidget(ClangFormatSettings *settings)
|
|
||||||
: m_settings(settings)
|
|
||||||
{
|
|
||||||
auto options = new QGroupBox(Tr::tr("Options"));
|
|
||||||
options->setEnabled(false);
|
|
||||||
|
|
||||||
auto styleButtonGroup = new QButtonGroup(this);
|
|
||||||
|
|
||||||
auto useCustomizedStyle = new QRadioButton(Tr::tr("Use customized style:"));
|
|
||||||
styleButtonGroup->addButton(useCustomizedStyle);
|
|
||||||
|
|
||||||
m_configurations = new ConfigurationPanel;
|
|
||||||
m_configurations->setSettings(m_settings);
|
|
||||||
m_configurations->setCurrentConfiguration(m_settings->customStyle());
|
|
||||||
|
|
||||||
m_usePredefinedStyle = new QRadioButton(Tr::tr("Use predefined style:"));
|
|
||||||
|
|
||||||
m_usePredefinedStyle->setChecked(true);
|
|
||||||
styleButtonGroup->addButton(m_usePredefinedStyle);
|
|
||||||
|
|
||||||
m_predefinedStyle = new QComboBox;
|
|
||||||
m_predefinedStyle->addItems(m_settings->predefinedStyles());
|
|
||||||
const int predefinedStyleIndex = m_predefinedStyle->findText(m_settings->predefinedStyle());
|
|
||||||
if (predefinedStyleIndex != -1)
|
|
||||||
m_predefinedStyle->setCurrentIndex(predefinedStyleIndex);
|
|
||||||
|
|
||||||
m_fallbackStyle = new QComboBox;
|
|
||||||
m_fallbackStyle->addItems(m_settings->fallbackStyles());
|
|
||||||
m_fallbackStyle->setEnabled(false);
|
|
||||||
const int fallbackStyleIndex = m_fallbackStyle->findText(m_settings->fallbackStyle());
|
|
||||||
if (fallbackStyleIndex != -1)
|
|
||||||
m_fallbackStyle->setCurrentIndex(fallbackStyleIndex);
|
|
||||||
|
|
||||||
m_mime = new QLineEdit(m_settings->supportedMimeTypesAsString());
|
|
||||||
|
|
||||||
m_command = new Utils::PathChooser;
|
|
||||||
m_command->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
|
||||||
m_command->setCommandVersionArguments({"--version"});
|
|
||||||
m_command->setPromptDialogTitle(
|
|
||||||
BeautifierPlugin::msgCommandPromptDialogTitle("Clang Format"));
|
|
||||||
|
|
||||||
if (m_settings->usePredefinedStyle())
|
|
||||||
m_usePredefinedStyle->setChecked(true);
|
|
||||||
else
|
|
||||||
useCustomizedStyle->setChecked(true);
|
|
||||||
|
|
||||||
using namespace Layouting;
|
|
||||||
|
|
||||||
Form {
|
|
||||||
m_usePredefinedStyle, m_predefinedStyle, br,
|
|
||||||
empty, Row { Tr::tr("Fallback style:"), m_fallbackStyle }, br,
|
|
||||||
useCustomizedStyle, m_configurations, br,
|
|
||||||
}.attachTo(options);
|
|
||||||
|
|
||||||
Column {
|
|
||||||
Group {
|
|
||||||
title(Tr::tr("Configuration")),
|
|
||||||
Form {
|
|
||||||
Tr::tr("Clang Format command:"), m_command, br,
|
|
||||||
Tr::tr("Restrict to MIME types:"), m_mime
|
|
||||||
}
|
|
||||||
},
|
|
||||||
options,
|
|
||||||
st
|
|
||||||
}.attachTo(this);
|
|
||||||
|
|
||||||
connect(m_command, &Utils::PathChooser::validChanged, options, &QWidget::setEnabled);
|
|
||||||
connect(m_predefinedStyle, &QComboBox::currentTextChanged, this, [this](const QString &item) {
|
|
||||||
m_fallbackStyle->setEnabled(item == "File");
|
|
||||||
});
|
|
||||||
connect(m_usePredefinedStyle, &QRadioButton::toggled, this, [this](bool checked) {
|
|
||||||
m_fallbackStyle->setEnabled(checked && m_predefinedStyle->currentText() == "File");
|
|
||||||
m_predefinedStyle->setEnabled(checked);
|
|
||||||
});
|
|
||||||
|
|
||||||
// might trigger PathChooser::validChanged, so so after the connect above
|
|
||||||
m_command->setFilePath(m_settings->command());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClangFormatOptionsPageWidget::apply()
|
|
||||||
{
|
|
||||||
m_settings->setCommand(m_command->filePath());
|
|
||||||
m_settings->setSupportedMimeTypes(m_mime->text());
|
|
||||||
m_settings->setUsePredefinedStyle(m_usePredefinedStyle->isChecked());
|
|
||||||
m_settings->setPredefinedStyle(m_predefinedStyle->currentText());
|
|
||||||
m_settings->setFallbackStyle(m_fallbackStyle->currentText());
|
|
||||||
m_settings->setCustomStyle(m_configurations->currentConfiguration());
|
|
||||||
m_settings->save();
|
|
||||||
|
|
||||||
// update since not all MIME types are accepted (invalids or duplicates)
|
|
||||||
m_mime->setText(m_settings->supportedMimeTypesAsString());
|
|
||||||
}
|
|
||||||
|
|
||||||
ClangFormatOptionsPage::ClangFormatOptionsPage(ClangFormatSettings *settings)
|
|
||||||
{
|
|
||||||
setId("ClangFormat");
|
|
||||||
setDisplayName(Tr::tr("Clang Format"));
|
|
||||||
setCategory(Constants::OPTION_CATEGORY);
|
|
||||||
setWidgetCreator([settings] { return new ClangFormatOptionsPageWidget(settings); });
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Beautifier::Internal
|
|
@@ -1,18 +0,0 @@
|
|||||||
// Copyright (C) 2016 Lorenz Haas
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
|
||||||
|
|
||||||
namespace Beautifier::Internal {
|
|
||||||
|
|
||||||
class ClangFormatSettings;
|
|
||||||
|
|
||||||
class ClangFormatOptionsPage final : public Core::IOptionsPage
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ClangFormatOptionsPage(ClangFormatSettings *settings);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // Beautifier::Internal
|
|
@@ -4,43 +4,80 @@
|
|||||||
#include "clangformatsettings.h"
|
#include "clangformatsettings.h"
|
||||||
|
|
||||||
#include "../beautifierconstants.h"
|
#include "../beautifierconstants.h"
|
||||||
|
#include "../beautifierplugin.h"
|
||||||
#include "../beautifiertr.h"
|
#include "../beautifiertr.h"
|
||||||
|
#include "../configurationpanel.h"
|
||||||
#include <QDateTime>
|
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
#include <utils/pathchooser.h>
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QButtonGroup>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QRadioButton>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Beautifier::Internal {
|
namespace Beautifier::Internal {
|
||||||
|
|
||||||
const char USE_PREDEFINED_STYLE[] = "usePredefinedStyle";
|
|
||||||
const char PREDEFINED_STYLE[] = "predefinedStyle";
|
|
||||||
const char FALLBACK_STYLE[] = "fallbackStyle";
|
|
||||||
const char CUSTOM_STYLE[] = "customStyle";
|
|
||||||
const char SETTINGS_NAME[] = "clangformat";
|
const char SETTINGS_NAME[] = "clangformat";
|
||||||
|
|
||||||
ClangFormatSettings::ClangFormatSettings() :
|
ClangFormatSettings::ClangFormatSettings()
|
||||||
AbstractSettings(SETTINGS_NAME, ".clang-format")
|
: AbstractSettings(SETTINGS_NAME, ".clang-format")
|
||||||
{
|
{
|
||||||
setCommand("clang-format");
|
command.setDefaultValue("clang-format");
|
||||||
m_settings.insert(USE_PREDEFINED_STYLE, QVariant(true));
|
command.setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle("Clang Format"));
|
||||||
m_settings.insert(PREDEFINED_STYLE, "LLVM");
|
command.setLabelText(Tr::tr("Clang Format command:"));
|
||||||
m_settings.insert(FALLBACK_STYLE, "Default");
|
|
||||||
m_settings.insert(CUSTOM_STYLE, QVariant());
|
|
||||||
read();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ClangFormatSettings::documentationFilePath() const
|
registerAspect(&usePredefinedStyle);
|
||||||
{
|
usePredefinedStyle.setSettingsKey("usePredefinedStyle");
|
||||||
return (Core::ICore::userResourcePath() / Beautifier::Constants::SETTINGS_DIRNAME
|
usePredefinedStyle.setLabelText(Tr::tr("Use predefined style:"));
|
||||||
/ Beautifier::Constants::DOCUMENTATION_DIRNAME / SETTINGS_NAME)
|
usePredefinedStyle.setDefaultValue(true);
|
||||||
.stringAppended(".xml")
|
|
||||||
.toString();
|
registerAspect(&predefinedStyle);
|
||||||
|
predefinedStyle.setSettingsKey("predefinedStyle");
|
||||||
|
predefinedStyle.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
|
||||||
|
predefinedStyle.addOption("LLVM");
|
||||||
|
predefinedStyle.addOption("Google");
|
||||||
|
predefinedStyle.addOption("Chromium");
|
||||||
|
predefinedStyle.addOption("Mozilla");
|
||||||
|
predefinedStyle.addOption("WebKit");
|
||||||
|
predefinedStyle.addOption("File");
|
||||||
|
predefinedStyle.setDefaultValue("LLVM");
|
||||||
|
|
||||||
|
registerAspect(&fallbackStyle);
|
||||||
|
fallbackStyle.setSettingsKey("fallbackStyle");
|
||||||
|
fallbackStyle.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
|
||||||
|
fallbackStyle.addOption("Default");
|
||||||
|
fallbackStyle.addOption("None");
|
||||||
|
fallbackStyle.addOption("LLVM");
|
||||||
|
fallbackStyle.addOption("Google");
|
||||||
|
fallbackStyle.addOption("Chromium");
|
||||||
|
fallbackStyle.addOption("Mozilla");
|
||||||
|
fallbackStyle.addOption("WebKit");
|
||||||
|
fallbackStyle.setDefaultValue("Default");
|
||||||
|
|
||||||
|
registerAspect(&predefinedStyle);
|
||||||
|
predefinedStyle.setSettingsKey("predefinedStyle");
|
||||||
|
predefinedStyle.setDefaultValue("LLVM");
|
||||||
|
|
||||||
|
registerAspect(&customStyle);
|
||||||
|
customStyle.setSettingsKey("customStyle");
|
||||||
|
|
||||||
|
documentationFilePath.setFilePath(Core::ICore::userResourcePath(Constants::SETTINGS_DIRNAME)
|
||||||
|
.pathAppended(Constants::DOCUMENTATION_DIRNAME)
|
||||||
|
.pathAppended(SETTINGS_NAME).stringAppended(".xml"));
|
||||||
|
|
||||||
|
read();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangFormatSettings::createDocumentationFile() const
|
void ClangFormatSettings::createDocumentationFile() const
|
||||||
{
|
{
|
||||||
QFile file(documentationFilePath());
|
QFile file(documentationFilePath().toFSPathString());
|
||||||
const QFileInfo fi(file);
|
const QFileInfo fi(file);
|
||||||
if (!fi.exists())
|
if (!fi.exists())
|
||||||
fi.dir().mkpath(fi.absolutePath());
|
fi.dir().mkpath(fi.absolutePath());
|
||||||
@@ -144,60 +181,6 @@ QStringList ClangFormatSettings::completerWords()
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClangFormatSettings::usePredefinedStyle() const
|
|
||||||
{
|
|
||||||
return m_settings.value(USE_PREDEFINED_STYLE).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClangFormatSettings::setUsePredefinedStyle(bool usePredefinedStyle)
|
|
||||||
{
|
|
||||||
m_settings.insert(USE_PREDEFINED_STYLE, QVariant(usePredefinedStyle));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ClangFormatSettings::predefinedStyle() const
|
|
||||||
{
|
|
||||||
return m_settings.value(PREDEFINED_STYLE).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClangFormatSettings::setPredefinedStyle(const QString &predefinedStyle)
|
|
||||||
{
|
|
||||||
const QStringList test = predefinedStyles();
|
|
||||||
if (test.contains(predefinedStyle))
|
|
||||||
m_settings.insert(PREDEFINED_STYLE, QVariant(predefinedStyle));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ClangFormatSettings::fallbackStyle() const
|
|
||||||
{
|
|
||||||
return m_settings.value(FALLBACK_STYLE).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClangFormatSettings::setFallbackStyle(const QString &fallbackStyle)
|
|
||||||
{
|
|
||||||
const QStringList test = fallbackStyles();
|
|
||||||
if (test.contains(fallbackStyle))
|
|
||||||
m_settings.insert(FALLBACK_STYLE, QVariant(fallbackStyle));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ClangFormatSettings::customStyle() const
|
|
||||||
{
|
|
||||||
return m_settings.value(CUSTOM_STYLE).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClangFormatSettings::setCustomStyle(const QString &customStyle)
|
|
||||||
{
|
|
||||||
m_settings.insert(CUSTOM_STYLE, QVariant(customStyle));
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList ClangFormatSettings::predefinedStyles() const
|
|
||||||
{
|
|
||||||
return {"LLVM", "Google", "Chromium", "Mozilla", "WebKit", "File"};
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList ClangFormatSettings::fallbackStyles() const
|
|
||||||
{
|
|
||||||
return {"Default", "None", "LLVM", "Google", "Chromium", "Mozilla", "WebKit"};
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ClangFormatSettings::styleFileName(const QString &key) const
|
QString ClangFormatSettings::styleFileName(const QString &key) const
|
||||||
{
|
{
|
||||||
return m_styleDir.absolutePath() + '/' + key + '/' + m_ending;
|
return m_styleDir.absolutePath() + '/' + key + '/' + m_ending;
|
||||||
@@ -213,4 +196,86 @@ void ClangFormatSettings::readStyles()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ClangFormatOptionsPageWidget : public Core::IOptionsPageWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ClangFormatOptionsPageWidget(ClangFormatSettings *settings)
|
||||||
|
{
|
||||||
|
ClangFormatSettings &s = *settings;
|
||||||
|
QGroupBox *options = nullptr;
|
||||||
|
|
||||||
|
auto predefinedStyleButton = new QRadioButton;
|
||||||
|
s.usePredefinedStyle.adoptButton(predefinedStyleButton);
|
||||||
|
|
||||||
|
auto customizedStyleButton = new QRadioButton(Tr::tr("Use customized style:"));
|
||||||
|
|
||||||
|
auto styleButtonGroup = new QButtonGroup;
|
||||||
|
styleButtonGroup->addButton(predefinedStyleButton);
|
||||||
|
styleButtonGroup->addButton(customizedStyleButton);
|
||||||
|
|
||||||
|
auto configurations = new ConfigurationPanel(this);
|
||||||
|
configurations->setSettings(&s);
|
||||||
|
configurations->setCurrentConfiguration(s.customStyle());
|
||||||
|
|
||||||
|
using namespace Layouting;
|
||||||
|
|
||||||
|
auto fallbackBlob = Row { noMargin, Tr::tr("Fallback style:"), s.fallbackStyle }.emerge();
|
||||||
|
|
||||||
|
auto predefinedBlob = Column { noMargin, s.predefinedStyle, fallbackBlob }.emerge();
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Group {
|
||||||
|
title(Tr::tr("Configuration")),
|
||||||
|
Form {
|
||||||
|
s.command, br,
|
||||||
|
s.supportedMimeTypes
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Group {
|
||||||
|
title(Tr::tr("Options")),
|
||||||
|
bindTo(&options),
|
||||||
|
Form {
|
||||||
|
s.usePredefinedStyle, predefinedBlob, br,
|
||||||
|
customizedStyleButton, configurations,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
st
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
if (s.usePredefinedStyle.value())
|
||||||
|
predefinedStyleButton->click();
|
||||||
|
else
|
||||||
|
customizedStyleButton->click();
|
||||||
|
|
||||||
|
const auto updateEnabled = [&s, styleButtonGroup, predefinedBlob, fallbackBlob,
|
||||||
|
configurations, predefinedStyleButton] {
|
||||||
|
const bool predefSelected = styleButtonGroup->checkedButton() == predefinedStyleButton;
|
||||||
|
predefinedBlob->setEnabled(predefSelected);
|
||||||
|
fallbackBlob->setEnabled(predefSelected && s.predefinedStyle.volatileValue().toInt() == 5); // File
|
||||||
|
configurations->setEnabled(!predefSelected);
|
||||||
|
};
|
||||||
|
updateEnabled();
|
||||||
|
connect(styleButtonGroup, &QButtonGroup::buttonClicked, this, updateEnabled);
|
||||||
|
connect(&s.predefinedStyle, &SelectionAspect::volatileValueChanged, this, updateEnabled);
|
||||||
|
|
||||||
|
setOnApply([settings, configurations] {
|
||||||
|
settings->customStyle.setValue(configurations->currentConfiguration());
|
||||||
|
settings->save();
|
||||||
|
});
|
||||||
|
|
||||||
|
s.read();
|
||||||
|
|
||||||
|
connect(s.command.pathChooser(), &PathChooser::validChanged, options, &QWidget::setEnabled);
|
||||||
|
options->setEnabled(s.command.pathChooser()->isValid());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ClangFormatOptionsPage::ClangFormatOptionsPage(ClangFormatSettings *settings)
|
||||||
|
{
|
||||||
|
setId("ClangFormat");
|
||||||
|
setDisplayName(Tr::tr("Clang Format"));
|
||||||
|
setCategory(Constants::OPTION_CATEGORY);
|
||||||
|
setWidgetCreator([settings] { return new ClangFormatOptionsPageWidget(settings); });
|
||||||
|
}
|
||||||
|
|
||||||
} // Beautifier::Internal
|
} // Beautifier::Internal
|
||||||
|
@@ -12,24 +12,14 @@ class ClangFormatSettings : public AbstractSettings
|
|||||||
public:
|
public:
|
||||||
explicit ClangFormatSettings();
|
explicit ClangFormatSettings();
|
||||||
|
|
||||||
QString documentationFilePath() const override;
|
|
||||||
void createDocumentationFile() const override;
|
void createDocumentationFile() const override;
|
||||||
|
|
||||||
QStringList completerWords() override;
|
QStringList completerWords() override;
|
||||||
|
|
||||||
bool usePredefinedStyle() const;
|
Utils::BoolAspect usePredefinedStyle;
|
||||||
void setUsePredefinedStyle(bool usePredefinedStyle);
|
Utils::SelectionAspect predefinedStyle;
|
||||||
|
Utils::SelectionAspect fallbackStyle;
|
||||||
QString predefinedStyle() const;
|
Utils::StringAspect customStyle;
|
||||||
void setPredefinedStyle(const QString &predefinedStyle);
|
|
||||||
|
|
||||||
QString fallbackStyle() const;
|
|
||||||
void setFallbackStyle(const QString &fallbackStyle);
|
|
||||||
|
|
||||||
QString customStyle() const;
|
|
||||||
void setCustomStyle(const QString &customStyle);
|
|
||||||
|
|
||||||
QStringList predefinedStyles() const;
|
|
||||||
QStringList fallbackStyles() const;
|
|
||||||
|
|
||||||
QString styleFileName(const QString &key) const override;
|
QString styleFileName(const QString &key) const override;
|
||||||
|
|
||||||
@@ -37,4 +27,10 @@ private:
|
|||||||
void readStyles() override;
|
void readStyles() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ClangFormatOptionsPage final : public Core::IOptionsPage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ClangFormatOptionsPage(ClangFormatSettings *settings);
|
||||||
|
};
|
||||||
|
|
||||||
} // Beautifier::Internal
|
} // Beautifier::Internal
|
||||||
|
@@ -54,7 +54,7 @@ Uncrustify::Uncrustify()
|
|||||||
|
|
||||||
Core::ActionManager::actionContainer(Constants::MENU_ID)->addMenu(menu);
|
Core::ActionManager::actionContainer(Constants::MENU_ID)->addMenu(menu);
|
||||||
|
|
||||||
connect(&m_settings, &UncrustifySettings::supportedMimeTypesChanged,
|
connect(&m_settings.supportedMimeTypes, &Utils::BaseAspect::changed,
|
||||||
this, [this] { updateActions(Core::EditorManager::currentEditor()); });
|
this, [this] { updateActions(Core::EditorManager::currentEditor()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "../beautifierabstracttool.h"
|
#include "../beautifierabstracttool.h"
|
||||||
|
|
||||||
#include "uncrustifyoptionspage.h"
|
|
||||||
#include "uncrustifysettings.h"
|
#include "uncrustifysettings.h"
|
||||||
|
|
||||||
namespace Beautifier::Internal {
|
namespace Beautifier::Internal {
|
||||||
|
@@ -1,137 +0,0 @@
|
|||||||
// Copyright (C) 2016 Lorenz Haas
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#include "uncrustifyoptionspage.h"
|
|
||||||
|
|
||||||
#include "uncrustifyconstants.h"
|
|
||||||
#include "uncrustifysettings.h"
|
|
||||||
|
|
||||||
#include "../beautifierconstants.h"
|
|
||||||
#include "../beautifierplugin.h"
|
|
||||||
#include "../beautifiertr.h"
|
|
||||||
#include "../configurationpanel.h"
|
|
||||||
|
|
||||||
#include <utils/layoutbuilder.h>
|
|
||||||
#include <utils/pathchooser.h>
|
|
||||||
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QGroupBox>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
|
|
||||||
namespace Beautifier::Internal {
|
|
||||||
|
|
||||||
class UncrustifyOptionsPageWidget : public Core::IOptionsPageWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit UncrustifyOptionsPageWidget(UncrustifySettings *settings);
|
|
||||||
|
|
||||||
void apply() final;
|
|
||||||
|
|
||||||
private:
|
|
||||||
UncrustifySettings *m_settings;
|
|
||||||
|
|
||||||
Utils::PathChooser *m_command;
|
|
||||||
QLineEdit *m_mime;
|
|
||||||
QCheckBox *m_useOtherFiles;
|
|
||||||
QCheckBox *m_useSpecificFile;
|
|
||||||
Utils::PathChooser *m_uncrusifyFilePath;
|
|
||||||
QCheckBox *m_useHomeFile;
|
|
||||||
QCheckBox *m_useCustomStyle;
|
|
||||||
ConfigurationPanel *m_configurations;
|
|
||||||
QCheckBox *m_formatEntireFileFallback;
|
|
||||||
};
|
|
||||||
|
|
||||||
UncrustifyOptionsPageWidget::UncrustifyOptionsPageWidget(UncrustifySettings *settings)
|
|
||||||
: m_settings(settings)
|
|
||||||
{
|
|
||||||
m_command = new Utils::PathChooser;
|
|
||||||
|
|
||||||
m_mime = new QLineEdit(m_settings->supportedMimeTypesAsString());
|
|
||||||
|
|
||||||
m_useOtherFiles = new QCheckBox(Tr::tr("Use file uncrustify.cfg defined in project files"));
|
|
||||||
m_useOtherFiles->setChecked(m_settings->useOtherFiles());
|
|
||||||
|
|
||||||
m_useSpecificFile = new QCheckBox(Tr::tr("Use file specific uncrustify.cfg"));
|
|
||||||
m_useSpecificFile->setChecked(m_settings->useSpecificConfigFile());
|
|
||||||
|
|
||||||
m_uncrusifyFilePath = new Utils::PathChooser;
|
|
||||||
m_uncrusifyFilePath->setExpectedKind(Utils::PathChooser::File);
|
|
||||||
m_uncrusifyFilePath->setPromptDialogFilter(Tr::tr("Uncrustify file (*.cfg)"));
|
|
||||||
m_uncrusifyFilePath->setFilePath(m_settings->specificConfigFile());
|
|
||||||
|
|
||||||
m_useHomeFile = new QCheckBox(Tr::tr("Use file uncrustify.cfg in HOME")
|
|
||||||
.replace( "HOME", QDir::toNativeSeparators(QDir::home().absolutePath())));
|
|
||||||
m_useHomeFile->setChecked(m_settings->useHomeFile());
|
|
||||||
|
|
||||||
m_useCustomStyle = new QCheckBox(Tr::tr("Use customized style:"));
|
|
||||||
m_useCustomStyle->setChecked(m_settings->useCustomStyle());
|
|
||||||
|
|
||||||
m_configurations = new ConfigurationPanel;
|
|
||||||
m_configurations->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
||||||
m_configurations->setSettings(m_settings);
|
|
||||||
m_configurations->setCurrentConfiguration(m_settings->customStyle());
|
|
||||||
|
|
||||||
m_formatEntireFileFallback = new QCheckBox(Tr::tr("Format entire file if no text was selected"));
|
|
||||||
m_formatEntireFileFallback->setToolTip(Tr::tr("For action Format Selected Text"));
|
|
||||||
m_formatEntireFileFallback->setChecked(m_settings->formatEntireFileFallback());
|
|
||||||
|
|
||||||
m_command->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
|
||||||
m_command->setCommandVersionArguments({"--version"});
|
|
||||||
m_command->setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(
|
|
||||||
Tr::tr(Constants::UNCRUSTIFY_DISPLAY_NAME)));
|
|
||||||
m_command->setFilePath(m_settings->command());
|
|
||||||
|
|
||||||
auto options = new QGroupBox(Tr::tr("Options"));
|
|
||||||
|
|
||||||
using namespace Layouting;
|
|
||||||
|
|
||||||
Column {
|
|
||||||
m_useOtherFiles,
|
|
||||||
Row { m_useSpecificFile, m_uncrusifyFilePath },
|
|
||||||
m_useHomeFile,
|
|
||||||
Row { m_useCustomStyle, m_configurations },
|
|
||||||
m_formatEntireFileFallback
|
|
||||||
}.attachTo(options);
|
|
||||||
|
|
||||||
Column {
|
|
||||||
Group {
|
|
||||||
title(Tr::tr("Configuration")),
|
|
||||||
Form {
|
|
||||||
Tr::tr("Uncrustify command:"), m_command, br,
|
|
||||||
Tr::tr("Restrict to MIME types:"), m_mime
|
|
||||||
}
|
|
||||||
},
|
|
||||||
options,
|
|
||||||
st
|
|
||||||
}.attachTo(this);
|
|
||||||
|
|
||||||
connect(m_command, &Utils::PathChooser::validChanged, options, &QWidget::setEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UncrustifyOptionsPageWidget::apply()
|
|
||||||
{
|
|
||||||
m_settings->setCommand(m_command->filePath());
|
|
||||||
m_settings->setSupportedMimeTypes(m_mime->text());
|
|
||||||
m_settings->setUseOtherFiles(m_useOtherFiles->isChecked());
|
|
||||||
m_settings->setUseHomeFile(m_useHomeFile->isChecked());
|
|
||||||
m_settings->setUseSpecificConfigFile(m_useSpecificFile->isChecked());
|
|
||||||
m_settings->setSpecificConfigFile(m_uncrusifyFilePath->filePath());
|
|
||||||
m_settings->setUseCustomStyle(m_useCustomStyle->isChecked());
|
|
||||||
m_settings->setCustomStyle(m_configurations->currentConfiguration());
|
|
||||||
m_settings->setFormatEntireFileFallback(m_formatEntireFileFallback->isChecked());
|
|
||||||
m_settings->save();
|
|
||||||
|
|
||||||
// update since not all MIME types are accepted (invalids or duplicates)
|
|
||||||
m_mime->setText(m_settings->supportedMimeTypesAsString());
|
|
||||||
}
|
|
||||||
|
|
||||||
UncrustifyOptionsPage::UncrustifyOptionsPage(UncrustifySettings *settings)
|
|
||||||
{
|
|
||||||
setId("Uncrustify");
|
|
||||||
setDisplayName(Tr::tr("Uncrustify"));
|
|
||||||
setCategory(Constants::OPTION_CATEGORY);
|
|
||||||
setWidgetCreator([settings] { return new UncrustifyOptionsPageWidget(settings); });
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Beautifier::Internal
|
|
@@ -1,18 +0,0 @@
|
|||||||
// Copyright (C) 2016 Lorenz Haas
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
|
||||||
|
|
||||||
namespace Beautifier::Internal {
|
|
||||||
|
|
||||||
class UncrustifySettings;
|
|
||||||
|
|
||||||
class UncrustifyOptionsPage final : public Core::IOptionsPage
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit UncrustifyOptionsPage(UncrustifySettings *settings);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // Beautifier::Internal
|
|
@@ -3,14 +3,25 @@
|
|||||||
|
|
||||||
#include "uncrustifysettings.h"
|
#include "uncrustifysettings.h"
|
||||||
|
|
||||||
|
#include "uncrustifyconstants.h"
|
||||||
#include "../beautifierconstants.h"
|
#include "../beautifierconstants.h"
|
||||||
|
#include "../beautifierplugin.h"
|
||||||
|
#include "../beautifiertr.h"
|
||||||
|
#include "../configurationpanel.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/process.h>
|
#include <utils/process.h>
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
@@ -18,110 +29,57 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace Beautifier::Internal {
|
namespace Beautifier::Internal {
|
||||||
|
|
||||||
const char USE_OTHER_FILES[] = "useOtherFiles";
|
const char SETTINGS_NAME[] = "uncrustify";
|
||||||
const char USE_HOME_FILE[] = "useHomeFile";
|
|
||||||
const char USE_SPECIFIC_CONFIG_FILE_PATH[] = "useSpecificConfigFile";
|
|
||||||
const char SPECIFIC_CONFIG_FILE_PATH[] = "specificConfigFile";
|
|
||||||
const char USE_CUSTOM_STYLE[] = "useCustomStyle";
|
|
||||||
const char CUSTOM_STYLE[] = "customStyle";
|
|
||||||
const char FORMAT_ENTIRE_FILE_FALLBACK[] = "formatEntireFileFallback";
|
|
||||||
const char SETTINGS_NAME[] = "uncrustify";
|
|
||||||
|
|
||||||
UncrustifySettings::UncrustifySettings() :
|
UncrustifySettings::UncrustifySettings()
|
||||||
AbstractSettings(SETTINGS_NAME, ".cfg")
|
: AbstractSettings(SETTINGS_NAME, ".cfg")
|
||||||
{
|
{
|
||||||
setVersionRegExp(QRegularExpression("([0-9]{1})\\.([0-9]{2})"));
|
setVersionRegExp(QRegularExpression("([0-9]{1})\\.([0-9]{2})"));
|
||||||
setCommand("uncrustify");
|
|
||||||
m_settings.insert(USE_OTHER_FILES, QVariant(true));
|
command.setDefaultValue("uncrustify");
|
||||||
m_settings.insert(USE_HOME_FILE, QVariant(false));
|
command.setLabelText(Tr::tr("Uncrustify command:"));
|
||||||
m_settings.insert(USE_CUSTOM_STYLE, QVariant(false));
|
command.setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(
|
||||||
m_settings.insert(USE_SPECIFIC_CONFIG_FILE_PATH, QVariant(false));
|
Tr::tr(Constants::UNCRUSTIFY_DISPLAY_NAME)));
|
||||||
m_settings.insert(CUSTOM_STYLE, QVariant());
|
|
||||||
m_settings.insert(FORMAT_ENTIRE_FILE_FALLBACK, QVariant(true));
|
registerAspect(&useOtherFiles);
|
||||||
m_settings.insert(SPECIFIC_CONFIG_FILE_PATH, QVariant());
|
useOtherFiles.setSettingsKey("useOtherFiles");
|
||||||
|
useOtherFiles.setDefaultValue(true);
|
||||||
|
useOtherFiles.setLabelText(Tr::tr("Use file uncrustify.cfg defined in project files"));
|
||||||
|
|
||||||
|
registerAspect(&useHomeFile);
|
||||||
|
useHomeFile.setSettingsKey("useHomeFile");
|
||||||
|
useHomeFile.setLabelText(Tr::tr("Use file uncrustify.cfg in HOME")
|
||||||
|
.replace( "HOME", QDir::toNativeSeparators(QDir::home().absolutePath())));
|
||||||
|
|
||||||
|
registerAspect(&useCustomStyle);
|
||||||
|
useCustomStyle.setSettingsKey("useCustomStyle");
|
||||||
|
useCustomStyle.setLabelText(Tr::tr("Use customized style:"));
|
||||||
|
|
||||||
|
registerAspect(&useSpecificConfigFile);
|
||||||
|
useSpecificConfigFile.setSettingsKey("useSpecificConfigFile");
|
||||||
|
useSpecificConfigFile.setLabelText(Tr::tr("Use file specific uncrustify.cfg"));
|
||||||
|
|
||||||
|
registerAspect(&customStyle);
|
||||||
|
customStyle.setSettingsKey("customStyle");
|
||||||
|
|
||||||
|
registerAspect(&formatEntireFileFallback);
|
||||||
|
formatEntireFileFallback.setSettingsKey("formatEntireFileFallback");
|
||||||
|
formatEntireFileFallback.setDefaultValue(true);
|
||||||
|
formatEntireFileFallback.setLabelText(Tr::tr("Format entire file if no text was selected"));
|
||||||
|
formatEntireFileFallback.setToolTip(Tr::tr("For action Format Selected Text"));
|
||||||
|
|
||||||
|
registerAspect(&specificConfigFile);
|
||||||
|
specificConfigFile.setSettingsKey("specificConfigFile");
|
||||||
|
specificConfigFile.setExpectedKind(Utils::PathChooser::File);
|
||||||
|
specificConfigFile.setPromptDialogFilter(Tr::tr("Uncrustify file (*.cfg)"));
|
||||||
|
|
||||||
|
documentationFilePath.setFilePath(Core::ICore::userResourcePath(Constants::SETTINGS_DIRNAME)
|
||||||
|
.pathAppended(Constants::DOCUMENTATION_DIRNAME)
|
||||||
|
.pathAppended(SETTINGS_NAME).stringAppended(".xml"));
|
||||||
|
|
||||||
read();
|
read();
|
||||||
}
|
}
|
||||||
|
|
||||||
UncrustifySettings::~UncrustifySettings() = default;
|
|
||||||
|
|
||||||
bool UncrustifySettings::useOtherFiles() const
|
|
||||||
{
|
|
||||||
return m_settings.value(USE_OTHER_FILES).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UncrustifySettings::setUseOtherFiles(bool useOtherFiles)
|
|
||||||
{
|
|
||||||
m_settings.insert(USE_OTHER_FILES, QVariant(useOtherFiles));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UncrustifySettings::useHomeFile() const
|
|
||||||
{
|
|
||||||
return m_settings.value(USE_HOME_FILE).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UncrustifySettings::setUseHomeFile(bool useHomeFile)
|
|
||||||
{
|
|
||||||
m_settings.insert(USE_HOME_FILE, QVariant(useHomeFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
FilePath UncrustifySettings::specificConfigFile() const
|
|
||||||
{
|
|
||||||
return FilePath::fromString(m_settings.value(SPECIFIC_CONFIG_FILE_PATH).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void UncrustifySettings::setSpecificConfigFile(const FilePath &filePath)
|
|
||||||
{
|
|
||||||
m_settings.insert(SPECIFIC_CONFIG_FILE_PATH, QVariant(filePath.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UncrustifySettings::useSpecificConfigFile() const
|
|
||||||
{
|
|
||||||
return m_settings.value(USE_SPECIFIC_CONFIG_FILE_PATH).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UncrustifySettings::setUseSpecificConfigFile(bool useConfigFile)
|
|
||||||
{
|
|
||||||
m_settings.insert(USE_SPECIFIC_CONFIG_FILE_PATH, QVariant(useConfigFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UncrustifySettings::useCustomStyle() const
|
|
||||||
{
|
|
||||||
return m_settings.value(USE_CUSTOM_STYLE).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UncrustifySettings::setUseCustomStyle(bool useCustomStyle)
|
|
||||||
{
|
|
||||||
m_settings.insert(USE_CUSTOM_STYLE, QVariant(useCustomStyle));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString UncrustifySettings::customStyle() const
|
|
||||||
{
|
|
||||||
return m_settings.value(CUSTOM_STYLE).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UncrustifySettings::setCustomStyle(const QString &customStyle)
|
|
||||||
{
|
|
||||||
m_settings.insert(CUSTOM_STYLE, QVariant(customStyle));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UncrustifySettings::formatEntireFileFallback() const
|
|
||||||
{
|
|
||||||
return m_settings.value(FORMAT_ENTIRE_FILE_FALLBACK).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UncrustifySettings::setFormatEntireFileFallback(bool formatEntireFileFallback)
|
|
||||||
{
|
|
||||||
m_settings.insert(FORMAT_ENTIRE_FILE_FALLBACK, QVariant(formatEntireFileFallback));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString UncrustifySettings::documentationFilePath() const
|
|
||||||
{
|
|
||||||
return (Core::ICore::userResourcePath() / Beautifier::Constants::SETTINGS_DIRNAME
|
|
||||||
/ Beautifier::Constants::DOCUMENTATION_DIRNAME / SETTINGS_NAME)
|
|
||||||
.stringAppended(".xml")
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UncrustifySettings::createDocumentationFile() const
|
void UncrustifySettings::createDocumentationFile() const
|
||||||
{
|
{
|
||||||
Process process;
|
Process process;
|
||||||
@@ -131,7 +89,7 @@ void UncrustifySettings::createDocumentationFile() const
|
|||||||
if (process.result() != ProcessResult::FinishedWithSuccess)
|
if (process.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QFile file(documentationFilePath());
|
QFile file(documentationFilePath().toFSPathString());
|
||||||
const QFileInfo fi(file);
|
const QFileInfo fi(file);
|
||||||
if (!fi.exists())
|
if (!fi.exists())
|
||||||
fi.dir().mkpath(fi.absolutePath());
|
fi.dir().mkpath(fi.absolutePath());
|
||||||
@@ -185,4 +143,62 @@ void UncrustifySettings::createDocumentationFile() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class UncrustifyOptionsPageWidget : public Core::IOptionsPageWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit UncrustifyOptionsPageWidget(UncrustifySettings *settings)
|
||||||
|
{
|
||||||
|
UncrustifySettings &s = *settings;
|
||||||
|
|
||||||
|
auto configurations = new ConfigurationPanel(this);
|
||||||
|
configurations->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
configurations->setSettings(settings);
|
||||||
|
configurations->setCurrentConfiguration(settings->customStyle());
|
||||||
|
|
||||||
|
QGroupBox *options = nullptr;
|
||||||
|
|
||||||
|
using namespace Layouting;
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Group {
|
||||||
|
title(Tr::tr("Configuration")),
|
||||||
|
Form {
|
||||||
|
s.command, br,
|
||||||
|
s.supportedMimeTypes,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Group {
|
||||||
|
title(Tr::tr("Options")),
|
||||||
|
bindTo(&options),
|
||||||
|
Column {
|
||||||
|
s.useOtherFiles,
|
||||||
|
Row { s.useSpecificConfigFile, s.specificConfigFile },
|
||||||
|
s.useHomeFile,
|
||||||
|
Row { s.useCustomStyle, configurations },
|
||||||
|
s.formatEntireFileFallback
|
||||||
|
},
|
||||||
|
},
|
||||||
|
st
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
s.read();
|
||||||
|
|
||||||
|
connect(s.command.pathChooser(), &PathChooser::validChanged, options, &QWidget::setEnabled);
|
||||||
|
options->setEnabled(s.command.pathChooser()->isValid());
|
||||||
|
|
||||||
|
setOnApply([&s, configurations] {
|
||||||
|
s.customStyle.setValue(configurations->currentConfiguration());
|
||||||
|
s.save();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
UncrustifyOptionsPage::UncrustifyOptionsPage(UncrustifySettings *settings)
|
||||||
|
{
|
||||||
|
setId("Uncrustify");
|
||||||
|
setDisplayName(Tr::tr("Uncrustify"));
|
||||||
|
setCategory(Constants::OPTION_CATEGORY);
|
||||||
|
setWidgetCreator([settings] { return new UncrustifyOptionsPageWidget(settings); });
|
||||||
|
}
|
||||||
|
|
||||||
} // Beautifier::Internal
|
} // Beautifier::Internal
|
||||||
|
@@ -5,41 +5,30 @@
|
|||||||
|
|
||||||
#include "../abstractsettings.h"
|
#include "../abstractsettings.h"
|
||||||
|
|
||||||
namespace Beautifier {
|
namespace Beautifier::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class UncrustifySettings : public AbstractSettings
|
class UncrustifySettings : public AbstractSettings
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UncrustifySettings();
|
UncrustifySettings();
|
||||||
~UncrustifySettings() override;
|
|
||||||
|
|
||||||
bool useOtherFiles() const;
|
|
||||||
void setUseOtherFiles(bool useOtherFiles);
|
|
||||||
|
|
||||||
bool useHomeFile() const;
|
|
||||||
void setUseHomeFile(bool useHomeFile);
|
|
||||||
|
|
||||||
bool useCustomStyle() const;
|
|
||||||
void setUseCustomStyle(bool useCustomStyle);
|
|
||||||
|
|
||||||
QString customStyle() const;
|
|
||||||
void setCustomStyle(const QString &customStyle);
|
|
||||||
|
|
||||||
bool formatEntireFileFallback() const;
|
|
||||||
void setFormatEntireFileFallback(bool formatEntireFileFallback);
|
|
||||||
|
|
||||||
QString documentationFilePath() const override;
|
|
||||||
void createDocumentationFile() const override;
|
void createDocumentationFile() const override;
|
||||||
|
|
||||||
Utils::FilePath specificConfigFile() const;
|
Utils::BoolAspect useOtherFiles;
|
||||||
void setSpecificConfigFile(const Utils::FilePath &filePath);
|
Utils::BoolAspect useHomeFile;
|
||||||
|
Utils::BoolAspect useCustomStyle;
|
||||||
|
|
||||||
bool useSpecificConfigFile() const;
|
Utils::StringAspect customStyle;
|
||||||
void setUseSpecificConfigFile(bool useConfigFile);
|
Utils::BoolAspect formatEntireFileFallback;
|
||||||
|
|
||||||
|
Utils::FilePathAspect specificConfigFile;
|
||||||
|
Utils::BoolAspect useSpecificConfigFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
class UncrustifyOptionsPage final : public Core::IOptionsPage
|
||||||
} // namespace Beautifier
|
{
|
||||||
|
public:
|
||||||
|
explicit UncrustifyOptionsPage(UncrustifySettings *settings);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Beautifier::Internal
|
||||||
|
Reference in New Issue
Block a user