Commit a5574bc8 authored by Lorenz Haas's avatar Lorenz Haas

Beautifier: Allow to define specific config file for AStyle

Change-Id: I3ea1a0bfb0f39d99606204a5699b01128138259e
Reviewed-by: Riitta-Leena Miettinen's avatarLeena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent 016767b2
......@@ -117,6 +117,11 @@
selected tool. This option is available for Artistic Style
and Uncrustify.
\li Select the \uicontrol {Use specific config file} option to
use the specified file as the configuration file for the
selected tool. This option is available for Artistic Style
and Uncrustify.
\li Select the \uicontrol {Use file in $HOME} option to use the
specified file in the user's home directory as the
configuration file for the selected tool. This option is
......
......@@ -129,6 +129,12 @@ QString ArtisticStyle::configurationFile() const
}
}
if (m_settings->useSpecificConfigFile()) {
const Utils::FileName file = m_settings->specificConfigFile();
if (file.exists())
return file.toUserOutput();
}
if (m_settings->useHomeFile()) {
const QDir homeDirectory = QDir::home();
QString file = homeDirectory.filePath(".astylerc");
......
......@@ -48,6 +48,8 @@ ArtisticStyleOptionsPageWidget::ArtisticStyleOptionsPageWidget(ArtisticStyleSett
ui->setupUi(this);
ui->useHomeFile->setText(ui->useHomeFile->text().replace(
"HOME", QDir::toNativeSeparators(QDir::home().absolutePath())));
ui->specificConfigFile->setExpectedKind(Utils::PathChooser::File);
ui->specificConfigFile->setPromptDialogFilter(tr("AStyle (*.astylerc)"));
ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand);
ui->command->setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(
ArtisticStyle::tr(Constants::ArtisticStyle::DISPLAY_NAME)));
......@@ -65,6 +67,8 @@ void ArtisticStyleOptionsPageWidget::restore()
ui->command->setPath(m_settings->command());
ui->mime->setText(m_settings->supportedMimeTypesAsString());
ui->useOtherFiles->setChecked(m_settings->useOtherFiles());
ui->useSpecificConfigFile->setChecked(m_settings->useSpecificConfigFile());
ui->specificConfigFile->setFileName(m_settings->specificConfigFile());
ui->useHomeFile->setChecked(m_settings->useHomeFile());
ui->useCustomStyle->setChecked(m_settings->useCustomStyle());
ui->configurations->setCurrentConfiguration(m_settings->customStyle());
......@@ -75,6 +79,8 @@ void ArtisticStyleOptionsPageWidget::apply()
m_settings->setCommand(ui->command->path());
m_settings->setSupportedMimeTypes(ui->mime->text());
m_settings->setUseOtherFiles(ui->useOtherFiles->isChecked());
m_settings->setUseSpecificConfigFile(ui->useSpecificConfigFile->isChecked());
m_settings->setSpecificConfigFile(ui->specificConfigFile->fileName());
m_settings->setUseHomeFile(ui->useHomeFile->isChecked());
m_settings->setUseCustomStyle(ui->useCustomStyle->isChecked());
m_settings->setCustomStyle(ui->configurations->currentConfiguration());
......
......@@ -56,6 +56,20 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
<item>
<widget class="QCheckBox" name="useSpecificConfigFile">
<property name="text">
<string>Use specific config file:</string>
</property>
</widget>
</item>
<item>
<widget class="Utils::PathChooser" name="specificConfigFile" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="useHomeFile">
<property name="text">
......
......@@ -45,10 +45,12 @@ namespace Internal {
namespace ArtisticStyle {
namespace {
const char USE_OTHER_FILES[] = "useOtherFiles";
const char USE_HOME_FILE[] = "useHomeFile";
const char USE_CUSTOM_STYLE[] = "useCustomStyle";
const char CUSTOM_STYLE[] = "customStyle";
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";
}
ArtisticStyleSettings::ArtisticStyleSettings() :
......@@ -59,6 +61,8 @@ ArtisticStyleSettings::ArtisticStyleSettings() :
setCommand("astyle");
m_settings.insert(USE_OTHER_FILES, QVariant(true));
m_settings.insert(USE_SPECIFIC_CONFIG_FILE, QVariant(false));
m_settings.insert(SPECIFIC_CONFIG_FILE, QVariant());
m_settings.insert(USE_HOME_FILE, QVariant(false));
m_settings.insert(USE_CUSTOM_STYLE, QVariant(false));
m_settings.insert(CUSTOM_STYLE, QVariant());
......@@ -117,6 +121,26 @@ 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));
}
Utils::FileName ArtisticStyleSettings::specificConfigFile() const
{
return Utils::FileName::fromString(m_settings.value(SPECIFIC_CONFIG_FILE).toString());
}
void ArtisticStyleSettings::setSpecificConfigFile(const Utils::FileName &specificConfigFile)
{
m_settings.insert(SPECIFIC_CONFIG_FILE, QVariant(specificConfigFile.toString()));
}
bool ArtisticStyleSettings::useHomeFile() const
{
return m_settings.value(USE_HOME_FILE).toBool();
......
......@@ -27,6 +27,8 @@
#include "../abstractsettings.h"
#include <utils/fileutils.h>
#include <QFuture>
#include <QFutureWatcher>
......@@ -51,6 +53,12 @@ public:
bool useOtherFiles() const;
void setUseOtherFiles(bool useOtherFiles);
bool useSpecificConfigFile() const;
void setUseSpecificConfigFile(bool useSpecificConfigFile);
Utils::FileName specificConfigFile() const;
void setSpecificConfigFile(const Utils::FileName &specificConfigFile);
bool useHomeFile() const;
void setUseHomeFile(bool useHomeFile);
......
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