forked from qt-creator/qt-creator
ProjectExplorer: Aspectify Compile output settings page
Change-Id: Icc7b1917a57a96e482db7b4f0ba5c0a203f4958c Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -442,16 +442,6 @@ int BuildManager::getErrorTaskCount()
|
|||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildManager::setCompileOutputSettings(const CompileOutputSettings &settings)
|
|
||||||
{
|
|
||||||
d->m_outputWindow->setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
const CompileOutputSettings &BuildManager::compileOutputSettings()
|
|
||||||
{
|
|
||||||
return d->m_outputWindow->settings();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString BuildManager::displayNameForStepId(Id stepId)
|
QString BuildManager::displayNameForStepId(Id stepId)
|
||||||
{
|
{
|
||||||
if (stepId == Constants::BUILDSTEPS_CLEAN) {
|
if (stepId == Constants::BUILDSTEPS_CLEAN) {
|
||||||
@@ -853,7 +843,7 @@ bool BuildManager::buildLists(const QList<BuildStepList *> bsls, const QStringLi
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->m_outputWindow->settings().popUp)
|
if (CompileOutputSettings::instance().popUp())
|
||||||
d->m_outputWindow->popup(IOutputPane::NoModeSwitch);
|
d->m_outputWindow->popup(IOutputPane::NoModeSwitch);
|
||||||
startBuildQueue();
|
startBuildQueue();
|
||||||
return true;
|
return true;
|
||||||
@@ -866,7 +856,7 @@ void BuildManager::appendStep(BuildStep *step, const QString &name)
|
|||||||
d->m_outputWindow->popup(IOutputPane::NoModeSwitch);
|
d->m_outputWindow->popup(IOutputPane::NoModeSwitch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (d->m_outputWindow->settings().popUp)
|
if (CompileOutputSettings::instance().popUp())
|
||||||
d->m_outputWindow->popup(IOutputPane::NoModeSwitch);
|
d->m_outputWindow->popup(IOutputPane::NoModeSwitch);
|
||||||
startBuildQueue();
|
startBuildQueue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,10 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class RunConfiguration;
|
|
||||||
|
|
||||||
namespace Internal { class CompileOutputSettings; }
|
|
||||||
|
|
||||||
class Task;
|
|
||||||
class Project;
|
class Project;
|
||||||
|
class RunConfiguration;
|
||||||
|
class Task;
|
||||||
|
|
||||||
enum class BuildForRunConfigStatus { Building, NotBuilding, BuildFailed };
|
enum class BuildForRunConfigStatus { Building, NotBuilding, BuildFailed };
|
||||||
enum class ConfigSelection { All, Active };
|
enum class ConfigSelection { All, Active };
|
||||||
@@ -66,9 +64,6 @@ public:
|
|||||||
|
|
||||||
static int getErrorTaskCount();
|
static int getErrorTaskCount();
|
||||||
|
|
||||||
static void setCompileOutputSettings(const Internal::CompileOutputSettings &settings);
|
|
||||||
static const Internal::CompileOutputSettings &compileOutputSettings();
|
|
||||||
|
|
||||||
static QString displayNameForStepId(Utils::Id stepId);
|
static QString displayNameForStepId(Utils::Id stepId);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
@@ -17,7 +17,9 @@
|
|||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
#include <texteditor/fontsettings.h>
|
#include <texteditor/fontsettings.h>
|
||||||
#include <texteditor/behaviorsettings.h>
|
#include <texteditor/behaviorsettings.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/outputformatter.h>
|
#include <utils/outputformatter.h>
|
||||||
#include <utils/proxyaction.h>
|
#include <utils/proxyaction.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
@@ -43,9 +45,6 @@ namespace Internal {
|
|||||||
|
|
||||||
const char SETTINGS_KEY[] = "ProjectExplorer/CompileOutput/Zoom";
|
const char SETTINGS_KEY[] = "ProjectExplorer/CompileOutput/Zoom";
|
||||||
const char C_COMPILE_OUTPUT[] = "ProjectExplorer.CompileOutput";
|
const char C_COMPILE_OUTPUT[] = "ProjectExplorer.CompileOutput";
|
||||||
const char POP_UP_KEY[] = "ProjectExplorer/Settings/ShowCompilerOutput";
|
|
||||||
const char WRAP_OUTPUT_KEY[] = "ProjectExplorer/Settings/WrapBuildOutput";
|
|
||||||
const char MAX_LINES_KEY[] = "ProjectExplorer/Settings/MaxBuildOutputLines";
|
|
||||||
const char OPTIONS_PAGE_ID[] = "C.ProjectExplorer.CompileOutputOptions";
|
const char OPTIONS_PAGE_ID[] = "C.ProjectExplorer.CompileOutputOptions";
|
||||||
|
|
||||||
CompileOutputWindow::CompileOutputWindow(QAction *cancelBuildAction) :
|
CompileOutputWindow::CompileOutputWindow(QAction *cancelBuildAction) :
|
||||||
@@ -101,8 +100,17 @@ CompileOutputWindow::CompileOutputWindow(QAction *cancelBuildAction) :
|
|||||||
Tr::tr("O"));
|
Tr::tr("O"));
|
||||||
ExtensionSystem::PluginManager::addObject(m_handler);
|
ExtensionSystem::PluginManager::addObject(m_handler);
|
||||||
setupContext(C_COMPILE_OUTPUT, m_outputWindow);
|
setupContext(C_COMPILE_OUTPUT, m_outputWindow);
|
||||||
loadSettings();
|
|
||||||
updateFromSettings();
|
updateFromSettings();
|
||||||
|
|
||||||
|
m_outputWindow->setWordWrapEnabled(m_settings.wrapOutput());
|
||||||
|
m_outputWindow->setMaxCharCount(m_settings.maxCharCount());
|
||||||
|
|
||||||
|
connect(&m_settings.wrapOutput, &Utils::BaseAspect::changed, m_outputWindow, [this] {
|
||||||
|
m_outputWindow->setWordWrapEnabled(m_settings.wrapOutput());
|
||||||
|
});
|
||||||
|
connect(&m_settings.maxCharCount, &Utils::BaseAspect::changed, m_outputWindow, [this] {
|
||||||
|
m_outputWindow->setMaxCharCount(m_settings.maxCharCount());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CompileOutputWindow::~CompileOutputWindow()
|
CompileOutputWindow::~CompileOutputWindow()
|
||||||
@@ -115,10 +123,7 @@ CompileOutputWindow::~CompileOutputWindow()
|
|||||||
|
|
||||||
void CompileOutputWindow::updateFromSettings()
|
void CompileOutputWindow::updateFromSettings()
|
||||||
{
|
{
|
||||||
m_outputWindow->setWordWrapEnabled(m_settings.wrapOutput);
|
|
||||||
m_outputWindow->setMaxCharCount(m_settings.maxCharCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompileOutputWindow::hasFocus() const
|
bool CompileOutputWindow::hasFocus() const
|
||||||
{
|
{
|
||||||
return m_outputWindow->window()->focusWidget() == m_outputWindow;
|
return m_outputWindow->window()->focusWidget() == m_outputWindow;
|
||||||
@@ -213,13 +218,6 @@ void CompileOutputWindow::reset()
|
|||||||
m_outputWindow->reset();
|
m_outputWindow->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompileOutputWindow::setSettings(const CompileOutputSettings &settings)
|
|
||||||
{
|
|
||||||
m_settings = settings;
|
|
||||||
storeSettings();
|
|
||||||
updateFromSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils::OutputFormatter *CompileOutputWindow::outputFormatter() const
|
Utils::OutputFormatter *CompileOutputWindow::outputFormatter() const
|
||||||
{
|
{
|
||||||
return m_outputWindow->outputFormatter();
|
return m_outputWindow->outputFormatter();
|
||||||
@@ -231,75 +229,49 @@ void CompileOutputWindow::updateFilter()
|
|||||||
filterUsesRegexp(), filterIsInverted());
|
filterUsesRegexp(), filterIsInverted());
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool kPopUpDefault = false;
|
// CompileOutputSettings
|
||||||
const bool kWrapOutputDefault = true;
|
|
||||||
|
|
||||||
void CompileOutputWindow::loadSettings()
|
static CompileOutputSettings *s_compileOutputSettings;
|
||||||
|
|
||||||
|
CompileOutputSettings &CompileOutputSettings::instance()
|
||||||
{
|
{
|
||||||
QSettings * const s = Core::ICore::settings();
|
return *s_compileOutputSettings;
|
||||||
m_settings.popUp = s->value(POP_UP_KEY, kPopUpDefault).toBool();
|
|
||||||
m_settings.wrapOutput = s->value(WRAP_OUTPUT_KEY, kWrapOutputDefault).toBool();
|
|
||||||
m_settings.maxCharCount = s->value(MAX_LINES_KEY,
|
|
||||||
Core::Constants::DEFAULT_MAX_CHAR_COUNT).toInt() * 100;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompileOutputWindow::storeSettings() const
|
CompileOutputSettings::CompileOutputSettings()
|
||||||
{
|
{
|
||||||
Utils::QtcSettings *const s = Core::ICore::settings();
|
s_compileOutputSettings = this;
|
||||||
s->setValueWithDefault(POP_UP_KEY, m_settings.popUp, kPopUpDefault);
|
|
||||||
s->setValueWithDefault(WRAP_OUTPUT_KEY, m_settings.wrapOutput, kWrapOutputDefault);
|
|
||||||
s->setValueWithDefault(MAX_LINES_KEY,
|
|
||||||
m_settings.maxCharCount / 100,
|
|
||||||
Core::Constants::DEFAULT_MAX_CHAR_COUNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
class CompileOutputSettingsWidget : public Core::IOptionsPageWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CompileOutputSettingsWidget()
|
|
||||||
{
|
|
||||||
const CompileOutputSettings &settings = BuildManager::compileOutputSettings();
|
|
||||||
m_wrapOutputCheckBox.setText(Tr::tr("Word-wrap output"));
|
|
||||||
m_wrapOutputCheckBox.setChecked(settings.wrapOutput);
|
|
||||||
m_popUpCheckBox.setText(Tr::tr("Open Compile Output when building"));
|
|
||||||
m_popUpCheckBox.setChecked(settings.popUp);
|
|
||||||
m_maxCharsBox.setMaximum(100000000);
|
|
||||||
m_maxCharsBox.setValue(settings.maxCharCount);
|
|
||||||
const auto layout = new QVBoxLayout(this);
|
|
||||||
layout->addWidget(&m_wrapOutputCheckBox);
|
|
||||||
layout->addWidget(&m_popUpCheckBox);
|
|
||||||
const auto maxCharsLayout = new QHBoxLayout;
|
|
||||||
const QString msg = Tr::tr("Limit output to %1 characters");
|
|
||||||
const QStringList parts = msg.split("%1") << QString() << QString();
|
|
||||||
maxCharsLayout->addWidget(new QLabel(parts.at(0).trimmed()));
|
|
||||||
maxCharsLayout->addWidget(&m_maxCharsBox);
|
|
||||||
maxCharsLayout->addWidget(new QLabel(parts.at(1).trimmed()));
|
|
||||||
maxCharsLayout->addStretch(1);
|
|
||||||
layout->addLayout(maxCharsLayout);
|
|
||||||
layout->addStretch(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void apply() final
|
|
||||||
{
|
|
||||||
CompileOutputSettings s;
|
|
||||||
s.wrapOutput = m_wrapOutputCheckBox.isChecked();
|
|
||||||
s.popUp = m_popUpCheckBox.isChecked();
|
|
||||||
s.maxCharCount = m_maxCharsBox.value();
|
|
||||||
BuildManager::setCompileOutputSettings(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QCheckBox m_wrapOutputCheckBox;
|
|
||||||
QCheckBox m_popUpCheckBox;
|
|
||||||
QSpinBox m_maxCharsBox;
|
|
||||||
};
|
|
||||||
|
|
||||||
CompileOutputSettingsPage::CompileOutputSettingsPage()
|
|
||||||
{
|
|
||||||
setId(OPTIONS_PAGE_ID);
|
setId(OPTIONS_PAGE_ID);
|
||||||
setDisplayName(Tr::tr("Compile Output"));
|
setDisplayName(Tr::tr("Compile Output"));
|
||||||
setCategory(Constants::BUILD_AND_RUN_SETTINGS_CATEGORY);
|
setCategory(Constants::BUILD_AND_RUN_SETTINGS_CATEGORY);
|
||||||
setWidgetCreator([] { return new CompileOutputSettingsWidget; });
|
|
||||||
|
wrapOutput.setSettingsKey("ProjectExplorer/Settings/WrapBuildOutput");
|
||||||
|
wrapOutput.setDefaultValue(true);
|
||||||
|
wrapOutput.setLabelText(Tr::tr("Word-wrap output"));
|
||||||
|
|
||||||
|
popUp.setSettingsKey("ProjectExplorer/Settings/ShowCompilerOutput");
|
||||||
|
popUp.setLabelText(Tr::tr("Open Compile Output when building"));
|
||||||
|
|
||||||
|
maxCharCount.setSettingsKey("ProjectExplorer/Settings/MaxBuildOutputLines");
|
||||||
|
maxCharCount.setRange(1, Core::Constants::DEFAULT_MAX_CHAR_COUNT);
|
||||||
|
maxCharCount.setDefaultValue(Core::Constants::DEFAULT_MAX_CHAR_COUNT);
|
||||||
|
maxCharCount.setToSettingsTransformation([](const QVariant &v) { return v.toInt() / 100; });
|
||||||
|
maxCharCount.setFromSettingsTransformation([](const QVariant &v) { return v.toInt() * 100; });
|
||||||
|
|
||||||
|
setLayouter([this] {
|
||||||
|
using namespace Layouting;
|
||||||
|
const QString msg = Tr::tr("Limit output to %1 characters");
|
||||||
|
const QStringList parts = msg.split("%1") << QString() << QString();
|
||||||
|
return Column {
|
||||||
|
wrapOutput,
|
||||||
|
popUp,
|
||||||
|
Row { parts.at(0), maxCharCount, parts.at(1), st },
|
||||||
|
st
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
readSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
|
|||||||
@@ -26,6 +26,18 @@ namespace Internal {
|
|||||||
class ShowOutputTaskHandler;
|
class ShowOutputTaskHandler;
|
||||||
class CompileOutputTextEdit;
|
class CompileOutputTextEdit;
|
||||||
|
|
||||||
|
class CompileOutputSettings final : public Core::PagedSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CompileOutputSettings();
|
||||||
|
|
||||||
|
static CompileOutputSettings &instance();
|
||||||
|
|
||||||
|
Utils::BoolAspect popUp{this};
|
||||||
|
Utils::BoolAspect wrapOutput{this};
|
||||||
|
Utils::IntegerAspect maxCharCount{this};
|
||||||
|
};
|
||||||
|
|
||||||
class CompileOutputWindow final : public Core::IOutputPane
|
class CompileOutputWindow final : public Core::IOutputPane
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -57,19 +69,13 @@ public:
|
|||||||
void flush();
|
void flush();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
const CompileOutputSettings &settings() const { return m_settings; }
|
|
||||||
void setSettings(const CompileOutputSettings &settings);
|
|
||||||
|
|
||||||
Utils::OutputFormatter *outputFormatter() const;
|
Utils::OutputFormatter *outputFormatter() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateFilter() override;
|
void updateFilter() override;
|
||||||
const QList<Core::OutputWindow *> outputWindows() const override { return {m_outputWindow}; }
|
const QList<Core::OutputWindow *> outputWindows() const override { return {m_outputWindow}; }
|
||||||
|
|
||||||
void loadSettings();
|
|
||||||
void storeSettings() const;
|
|
||||||
void updateFromSettings();
|
void updateFromSettings();
|
||||||
|
|
||||||
Core::OutputWindow *m_outputWindow;
|
Core::OutputWindow *m_outputWindow;
|
||||||
ShowOutputTaskHandler *m_handler;
|
ShowOutputTaskHandler *m_handler;
|
||||||
QToolButton *m_cancelBuildButton;
|
QToolButton *m_cancelBuildButton;
|
||||||
@@ -77,11 +83,5 @@ private:
|
|||||||
CompileOutputSettings m_settings;
|
CompileOutputSettings m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CompileOutputSettingsPage final : public Core::IOptionsPage
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CompileOutputSettingsPage();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
|||||||
@@ -666,7 +666,6 @@ public:
|
|||||||
// Settings pages
|
// Settings pages
|
||||||
ProjectExplorerSettingsPage m_projectExplorerSettingsPage;
|
ProjectExplorerSettingsPage m_projectExplorerSettingsPage;
|
||||||
AppOutputSettingsPage m_appOutputSettingsPage;
|
AppOutputSettingsPage m_appOutputSettingsPage;
|
||||||
CompileOutputSettingsPage m_compileOutputSettingsPage;
|
|
||||||
DeviceSettingsPage m_deviceSettingsPage;
|
DeviceSettingsPage m_deviceSettingsPage;
|
||||||
SshSettingsPage m_sshSettingsPage;
|
SshSettingsPage m_sshSettingsPage;
|
||||||
CustomParsersSettingsPage m_customParsersSettingsPage;
|
CustomParsersSettingsPage m_customParsersSettingsPage;
|
||||||
|
|||||||
@@ -74,14 +74,6 @@ public:
|
|||||||
int maxCharCount = Core::Constants::DEFAULT_MAX_CHAR_COUNT;
|
int maxCharCount = Core::Constants::DEFAULT_MAX_CHAR_COUNT;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CompileOutputSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool popUp = false;
|
|
||||||
bool wrapOutput = false;
|
|
||||||
int maxCharCount = Core::Constants::DEFAULT_MAX_CHAR_COUNT;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ProjectExplorerSettingsPage : public Core::IOptionsPage
|
class ProjectExplorerSettingsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user