forked from qt-creator/qt-creator
ProjectExplorer: Add a common template for project settings
- Added base widget class for common options among project settings tabs - Added usage new template class to all pages used in project settings ToDo - Make CodeStyle tab standardized Change-Id: I8f70413b6ee764c5e43fbeae104b9389237c582f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -47,6 +47,7 @@ const char AUTOTEST_CONTEXT[] = "Auto Tests";
|
|||||||
const char TASK_INDEX[] = "AutoTest.Task.Index";
|
const char TASK_INDEX[] = "AutoTest.Task.Index";
|
||||||
const char TASK_PARSE[] = "AutoTest.Task.Parse";
|
const char TASK_PARSE[] = "AutoTest.Task.Parse";
|
||||||
const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests";
|
const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests";
|
||||||
|
const char AUTOTEST_SETTINGS_ID[] = "A.AutoTest.0.General";
|
||||||
const char AUTOTEST_SETTINGS_TR[] = QT_TRANSLATE_NOOP("AutoTest", "Testing");
|
const char AUTOTEST_SETTINGS_TR[] = QT_TRANSLATE_NOOP("AutoTest", "Testing");
|
||||||
const char FRAMEWORK_PREFIX[] = "AutoTest.Framework.";
|
const char FRAMEWORK_PREFIX[] = "AutoTest.Framework.";
|
||||||
const char SETTINGSPAGE_PREFIX[] = "A.AutoTest.";
|
const char SETTINGSPAGE_PREFIX[] = "A.AutoTest.";
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "projectsettingswidget.h"
|
#include "projectsettingswidget.h"
|
||||||
|
|
||||||
|
#include "autotestconstants.h"
|
||||||
#include "autotestplugin.h"
|
#include "autotestplugin.h"
|
||||||
#include "testframeworkmanager.h"
|
#include "testframeworkmanager.h"
|
||||||
#include "testprojectsettings.h"
|
#include "testprojectsettings.h"
|
||||||
@@ -53,14 +54,12 @@ static QSpacerItem *createSpacer(QSizePolicy::Policy horizontal, QSizePolicy::Po
|
|||||||
|
|
||||||
ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *project,
|
ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *project,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QWidget(parent)
|
: ProjectExplorer::ProjectSettingsWidget(parent)
|
||||||
, m_projectSettings(AutotestPlugin::projectSettings(project))
|
, m_projectSettings(AutotestPlugin::projectSettings(project))
|
||||||
{
|
{
|
||||||
|
setGlobalSettingsId(Constants::AUTOTEST_SETTINGS_ID);
|
||||||
auto verticalLayout = new QVBoxLayout(this);
|
auto verticalLayout = new QVBoxLayout(this);
|
||||||
verticalLayout->setContentsMargins(0, 0, 0, 0);
|
verticalLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
m_useGlobalSettings = new QComboBox;
|
|
||||||
m_useGlobalSettings->addItem(tr("Global"));
|
|
||||||
m_useGlobalSettings->addItem(tr("Custom"));
|
|
||||||
|
|
||||||
auto generalWidget = new QWidget;
|
auto generalWidget = new QWidget;
|
||||||
auto groupBoxLayout = new QVBoxLayout;
|
auto groupBoxLayout = new QVBoxLayout;
|
||||||
@@ -82,10 +81,6 @@ ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *p
|
|||||||
groupBoxLayout->addLayout(horizontalLayout);
|
groupBoxLayout->addLayout(horizontalLayout);
|
||||||
generalWidget->setLayout(groupBoxLayout);
|
generalWidget->setLayout(groupBoxLayout);
|
||||||
|
|
||||||
horizontalLayout = new QHBoxLayout;
|
|
||||||
horizontalLayout->addWidget(m_useGlobalSettings);
|
|
||||||
horizontalLayout->addItem(createSpacer(QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
||||||
verticalLayout->addLayout(horizontalLayout);
|
|
||||||
horizontalLayout = new QHBoxLayout;
|
horizontalLayout = new QHBoxLayout;
|
||||||
verticalLayout->addItem(createSpacer(QSizePolicy::Minimum, QSizePolicy::Fixed));
|
verticalLayout->addItem(createSpacer(QSizePolicy::Minimum, QSizePolicy::Fixed));
|
||||||
horizontalLayout->addWidget(generalWidget);
|
horizontalLayout->addWidget(generalWidget);
|
||||||
@@ -93,19 +88,20 @@ ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *p
|
|||||||
verticalLayout->addLayout(horizontalLayout);
|
verticalLayout->addLayout(horizontalLayout);
|
||||||
verticalLayout->addItem(createSpacer(QSizePolicy::Minimum, QSizePolicy::Expanding));
|
verticalLayout->addItem(createSpacer(QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||||
|
|
||||||
m_useGlobalSettings->setCurrentIndex(m_projectSettings->useGlobalSettings() ? 0 : 1);
|
|
||||||
generalWidget->setDisabled(m_projectSettings->useGlobalSettings());
|
generalWidget->setDisabled(m_projectSettings->useGlobalSettings());
|
||||||
|
|
||||||
populateFrameworks(m_projectSettings->activeFrameworks(),
|
populateFrameworks(m_projectSettings->activeFrameworks(),
|
||||||
m_projectSettings->activeTestTools());
|
m_projectSettings->activeTestTools());
|
||||||
|
|
||||||
connect(m_useGlobalSettings, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
setUseGlobalSettings(m_projectSettings->useGlobalSettings());
|
||||||
this, [this, generalWidget](int index) {
|
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged,
|
||||||
generalWidget->setEnabled(index != 0);
|
this, [this, generalWidget](bool useGlobalSettings) {
|
||||||
m_projectSettings->setUseGlobalSettings(index == 0);
|
generalWidget->setEnabled(!useGlobalSettings);
|
||||||
m_syncTimer.start(3000);
|
m_projectSettings->setUseGlobalSettings(useGlobalSettings);
|
||||||
m_syncType = ITestBase::Framework | ITestBase::Tool;
|
m_syncTimer.start(3000);
|
||||||
});
|
m_syncType = ITestBase::Framework | ITestBase::Tool;
|
||||||
|
});
|
||||||
|
|
||||||
connect(m_activeFrameworks, &QTreeWidget::itemChanged,
|
connect(m_activeFrameworks, &QTreeWidget::itemChanged,
|
||||||
this, &ProjectTestSettingsWidget::onActiveFrameworkChanged);
|
this, &ProjectTestSettingsWidget::onActiveFrameworkChanged);
|
||||||
connect(m_runAfterBuild, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
connect(m_runAfterBuild, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@@ -45,12 +47,13 @@ namespace Internal {
|
|||||||
|
|
||||||
class TestProjectSettings;
|
class TestProjectSettings;
|
||||||
|
|
||||||
class ProjectTestSettingsWidget : public QWidget
|
class ProjectTestSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ProjectTestSettingsWidget(ProjectExplorer::Project *project,
|
explicit ProjectTestSettingsWidget(ProjectExplorer::Project *project,
|
||||||
QWidget *parent = nullptr);
|
QWidget *parent = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void populateFrameworks(const QHash<Autotest::ITestFramework *, bool> &frameworks,
|
void populateFrameworks(const QHash<Autotest::ITestFramework *, bool> &frameworks,
|
||||||
const QHash<Autotest::ITestTool *, bool> &testTools);
|
const QHash<Autotest::ITestTool *, bool> &testTools);
|
||||||
|
@@ -203,7 +203,7 @@ void TestSettingsWidget::onFrameworkItemChanged()
|
|||||||
TestSettingsPage::TestSettingsPage(TestSettings *settings)
|
TestSettingsPage::TestSettingsPage(TestSettings *settings)
|
||||||
: m_settings(settings)
|
: m_settings(settings)
|
||||||
{
|
{
|
||||||
setId("A.AutoTest.0.General");
|
setId(Constants::AUTOTEST_SETTINGS_ID);
|
||||||
setDisplayName(tr("General"));
|
setDisplayName(tr("General"));
|
||||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||||
setDisplayCategory(QCoreApplication::translate("AutoTest", Constants::AUTOTEST_SETTINGS_TR));
|
setDisplayCategory(QCoreApplication::translate("AutoTest", Constants::AUTOTEST_SETTINGS_TR));
|
||||||
|
149
src/plugins/clangcodemodel/clangprojectsettingswidget.cpp
Normal file
149
src/plugins/clangcodemodel/clangprojectsettingswidget.cpp
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2016 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "clangprojectsettingswidget.h"
|
||||||
|
|
||||||
|
#include "clangmodelmanagersupport.h"
|
||||||
|
#include "clangprojectsettings.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <cppeditor/clangdiagnosticconfig.h>
|
||||||
|
#include <cppeditor/clangdiagnosticconfigswidget.h>
|
||||||
|
#include <cppeditor/cppeditorconstants.h>
|
||||||
|
#include <cppeditor/cppcodemodelsettings.h>
|
||||||
|
#include <cppeditor/cpptoolsreuse.h>
|
||||||
|
|
||||||
|
#include <utils/hostosinfo.h>
|
||||||
|
|
||||||
|
namespace ClangCodeModel {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
static Utils::Id configIdForProject(ClangProjectSettings &projectSettings)
|
||||||
|
{
|
||||||
|
if (projectSettings.useGlobalConfig())
|
||||||
|
return CppEditor::codeModelSettings()->clangDiagnosticConfigId();
|
||||||
|
return projectSettings.warningConfigId();
|
||||||
|
}
|
||||||
|
|
||||||
|
ClangProjectSettingsWidget::ClangProjectSettingsWidget(ProjectExplorer::Project *project)
|
||||||
|
: m_projectSettings(ClangModelManagerSupport::instance()->projectSettings(project))
|
||||||
|
{
|
||||||
|
m_ui.setupUi(this);
|
||||||
|
setGlobalSettingsId(CppEditor::Constants::CPP_CODE_MODEL_SETTINGS_ID);
|
||||||
|
|
||||||
|
using namespace CppEditor;
|
||||||
|
|
||||||
|
m_ui.delayedTemplateParseCheckBox->setVisible(Utils::HostOsInfo::isWindowsHost());
|
||||||
|
|
||||||
|
connect(m_ui.clangDiagnosticConfigsSelectionWidget,
|
||||||
|
&ClangDiagnosticConfigsSelectionWidget::changed,
|
||||||
|
this,
|
||||||
|
[this]() {
|
||||||
|
// Save project's config id
|
||||||
|
const Utils::Id currentConfigId = m_ui.clangDiagnosticConfigsSelectionWidget
|
||||||
|
->currentConfigId();
|
||||||
|
m_projectSettings.setWarningConfigId(currentConfigId);
|
||||||
|
|
||||||
|
// Save global custom configs
|
||||||
|
const ClangDiagnosticConfigs configs = m_ui.clangDiagnosticConfigsSelectionWidget
|
||||||
|
->customConfigs();
|
||||||
|
CppEditor::codeModelSettings()->setClangCustomDiagnosticConfigs(configs);
|
||||||
|
CppEditor::codeModelSettings()->toSettings(Core::ICore::settings());
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged,
|
||||||
|
this, &ClangProjectSettingsWidget::onGlobalCustomChanged);
|
||||||
|
connect(m_ui.delayedTemplateParseCheckBox, &QCheckBox::toggled,
|
||||||
|
this, &ClangProjectSettingsWidget::onDelayedTemplateParseClicked);
|
||||||
|
connect(project, &ProjectExplorer::Project::aboutToSaveSettings,
|
||||||
|
this, &ClangProjectSettingsWidget::onAboutToSaveProjectSettings);
|
||||||
|
|
||||||
|
connect(&m_projectSettings, &ClangProjectSettings::changed,
|
||||||
|
this, &ClangProjectSettingsWidget::syncWidgets);
|
||||||
|
connect(CppEditor::codeModelSettings(), &CppEditor::CppCodeModelSettings::changed,
|
||||||
|
this, &ClangProjectSettingsWidget::syncOtherWidgetsToComboBox);
|
||||||
|
|
||||||
|
syncWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClangProjectSettingsWidget::onDelayedTemplateParseClicked(bool checked)
|
||||||
|
{
|
||||||
|
// Don't save it when we reset the global config in code
|
||||||
|
if (m_projectSettings.useGlobalConfig())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QLatin1String extraFlag{checked ? ClangProjectSettings::DelayedTemplateParsing
|
||||||
|
: ClangProjectSettings::NoDelayedTemplateParsing};
|
||||||
|
QStringList options = m_projectSettings.commandLineOptions();
|
||||||
|
options.removeAll(QLatin1String{ClangProjectSettings::DelayedTemplateParsing});
|
||||||
|
options.removeAll(QLatin1String{ClangProjectSettings::NoDelayedTemplateParsing});
|
||||||
|
options.append(extraFlag);
|
||||||
|
m_projectSettings.setCommandLineOptions(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClangProjectSettingsWidget::onGlobalCustomChanged(bool useGlobalSettings)
|
||||||
|
{
|
||||||
|
m_projectSettings.setUseGlobalConfig(useGlobalSettings);
|
||||||
|
syncOtherWidgetsToComboBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClangProjectSettingsWidget::onAboutToSaveProjectSettings()
|
||||||
|
{
|
||||||
|
CppEditor::codeModelSettings()->toSettings(Core::ICore::settings());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClangProjectSettingsWidget::syncWidgets()
|
||||||
|
{
|
||||||
|
setUseGlobalSettings(m_projectSettings.useGlobalConfig());
|
||||||
|
syncOtherWidgetsToComboBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClangProjectSettingsWidget::syncOtherWidgetsToComboBox()
|
||||||
|
{
|
||||||
|
const QStringList options = m_projectSettings.commandLineOptions();
|
||||||
|
m_ui.delayedTemplateParseCheckBox->setChecked(
|
||||||
|
options.contains(QLatin1String{ClangProjectSettings::DelayedTemplateParsing}));
|
||||||
|
|
||||||
|
const bool isCustom = !m_projectSettings.useGlobalConfig();
|
||||||
|
m_ui.delayedTemplateParseCheckBox->setEnabled(isCustom);
|
||||||
|
|
||||||
|
for (int i = 0; i < m_ui.clangDiagnosticConfigsSelectionWidget->layout()->count(); ++i) {
|
||||||
|
QWidget *widget = m_ui.clangDiagnosticConfigsSelectionWidget->layout()->itemAt(i)->widget();
|
||||||
|
if (widget)
|
||||||
|
widget->setEnabled(isCustom);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ui.clangDiagnosticConfigsSelectionWidget
|
||||||
|
->refresh(CppEditor::diagnosticConfigsModel(),
|
||||||
|
configIdForProject(m_projectSettings),
|
||||||
|
[](const CppEditor::ClangDiagnosticConfigs &configs,
|
||||||
|
const Utils::Id &configToSelect) {
|
||||||
|
return new CppEditor::ClangDiagnosticConfigsWidget(configs, configToSelect);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace ClangCodeModel
|
61
src/plugins/clangcodemodel/clangprojectsettingswidget.h
Normal file
61
src/plugins/clangcodemodel/clangprojectsettingswidget.h
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2016 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ui_clangprojectsettingswidget.h"
|
||||||
|
|
||||||
|
#include "clangprojectsettings.h"
|
||||||
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
|
namespace ProjectExplorer { class Project; }
|
||||||
|
|
||||||
|
namespace ClangCodeModel {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class ClangProjectSettingsWidget: public ProjectExplorer::ProjectSettingsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ClangProjectSettingsWidget(ProjectExplorer::Project *project);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void onDelayedTemplateParseClicked(bool);
|
||||||
|
void onGlobalCustomChanged(bool useGlobalSettings);
|
||||||
|
void onAboutToSaveProjectSettings();
|
||||||
|
|
||||||
|
void syncWidgets();
|
||||||
|
void syncOtherWidgetsToComboBox();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::ClangProjectSettingsWidget m_ui;
|
||||||
|
ClangProjectSettings &m_projectSettings;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace ClangCodeModel
|
67
src/plugins/clangcodemodel/clangprojectsettingswidget.ui
Normal file
67
src/plugins/clangcodemodel/clangprojectsettingswidget.ui
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ClangCodeModel::Internal::ClangProjectSettingsWidget</class>
|
||||||
|
<widget class="QWidget" name="ClangCodeModel::Internal::ClangProjectSettingsWidget">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>814</width>
|
||||||
|
<height>330</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="delayedTemplateParseCheckBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Parse templates in a MSVC-compliant way. This helps to parse headers for example from Active Template Library (ATL) or Windows Runtime Library (WRL).
|
||||||
|
However, using the relaxed and extended rules means also that no highlighting/completion can be provided within template functions.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable MSVC-compliant template parsing</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="CppEditor::ClangDiagnosticConfigsSelectionWidget" name="clangDiagnosticConfigsSelectionWidget" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>CppEditor::ClangDiagnosticConfigsSelectionWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>cppeditor/clangdiagnosticconfigsselectionwidget.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@@ -126,7 +126,8 @@ bool ClangToolsPlugin::initialize(const QStringList &arguments, QString *errorSt
|
|||||||
panelFactory->setPriority(100);
|
panelFactory->setPriority(100);
|
||||||
panelFactory->setId(Constants::PROJECT_PANEL_ID);
|
panelFactory->setId(Constants::PROJECT_PANEL_ID);
|
||||||
panelFactory->setDisplayName(tr("Clang Tools"));
|
panelFactory->setDisplayName(tr("Clang Tools"));
|
||||||
panelFactory->setCreateWidgetFunction([](Project *project) { return new ProjectSettingsWidget(project); });
|
panelFactory->setCreateWidgetFunction(
|
||||||
|
[](Project *project) { return new ClangToolsProjectSettingsWidget(project); });
|
||||||
ProjectPanelFactory::registerFactory(panelFactory);
|
ProjectPanelFactory::registerFactory(panelFactory);
|
||||||
|
|
||||||
connect(Core::EditorManager::instance(),
|
connect(Core::EditorManager::instance(),
|
||||||
|
@@ -70,21 +70,13 @@ private:
|
|||||||
SuppressedDiagnosticsList m_diagnostics;
|
SuppressedDiagnosticsList m_diagnostics;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { UseGlobalSettings, UseCustomSettings }; // Values in sync with m_globalCustomComboBox
|
ClangToolsProjectSettingsWidget::ClangToolsProjectSettingsWidget(ProjectExplorer::Project *project, QWidget *parent) :
|
||||||
|
ProjectExplorer::ProjectSettingsWidget(parent),
|
||||||
ProjectSettingsWidget::ProjectSettingsWidget(ProjectExplorer::Project *project, QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
m_projectSettings(ClangToolsProjectSettings::getSettings(project))
|
m_projectSettings(ClangToolsProjectSettings::getSettings(project))
|
||||||
{
|
{
|
||||||
m_globalCustomComboBox = new QComboBox;
|
setGlobalSettingsId(ClangTools::Constants::SETTINGS_PAGE_ID);
|
||||||
m_globalCustomComboBox->addItem(tr("Use Global Settings"));
|
|
||||||
m_globalCustomComboBox->addItem(tr("Use Customized Settings"));
|
|
||||||
|
|
||||||
m_restoreGlobal = new QPushButton(tr("Restore Global Settings"));
|
m_restoreGlobal = new QPushButton(tr("Restore Global Settings"));
|
||||||
|
|
||||||
auto gotoGlobalSettingsLabel =
|
|
||||||
new QLabel("<a href=\"target\">" + tr("Open Global Settings") + "</a>");
|
|
||||||
|
|
||||||
auto gotoAnalyzerModeLabel =
|
auto gotoAnalyzerModeLabel =
|
||||||
new QLabel("<a href=\"target\">" + tr("Go to Analyzer") + "</a>");
|
new QLabel("<a href=\"target\">" + tr("Go to Analyzer") + "</a>");
|
||||||
|
|
||||||
@@ -100,9 +92,7 @@ ProjectSettingsWidget::ProjectSettingsWidget(ProjectExplorer::Project *project,
|
|||||||
|
|
||||||
Column {
|
Column {
|
||||||
Row {
|
Row {
|
||||||
m_globalCustomComboBox,
|
|
||||||
m_restoreGlobal,
|
m_restoreGlobal,
|
||||||
gotoGlobalSettingsLabel,
|
|
||||||
Stretch(),
|
Stretch(),
|
||||||
gotoAnalyzerModeLabel
|
gotoAnalyzerModeLabel
|
||||||
},
|
},
|
||||||
@@ -122,36 +112,26 @@ ProjectSettingsWidget::ProjectSettingsWidget(ProjectExplorer::Project *project,
|
|||||||
}
|
}
|
||||||
}.attachTo(this, false);
|
}.attachTo(this, false);
|
||||||
|
|
||||||
// Use global/custom settings combo box
|
setUseGlobalSettings(m_projectSettings->useGlobalSettings());
|
||||||
const int globalOrCustomIndex = m_projectSettings->useGlobalSettings() ? UseGlobalSettings
|
onGlobalCustomChanged();
|
||||||
: UseCustomSettings;
|
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged,
|
||||||
m_globalCustomComboBox->setCurrentIndex(globalOrCustomIndex);
|
this, QOverload<bool>::of(&ClangToolsProjectSettingsWidget::onGlobalCustomChanged));
|
||||||
onGlobalCustomChanged(globalOrCustomIndex);
|
|
||||||
connect(m_globalCustomComboBox,
|
|
||||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
||||||
this,
|
|
||||||
QOverload<int>::of(&ProjectSettingsWidget::onGlobalCustomChanged));
|
|
||||||
|
|
||||||
// Global settings
|
// Global settings
|
||||||
connect(ClangToolsSettings::instance(),
|
connect(ClangToolsSettings::instance(),
|
||||||
&ClangToolsSettings::changed,
|
&ClangToolsSettings::changed,
|
||||||
this,
|
this,
|
||||||
QOverload<>::of(&ProjectSettingsWidget::onGlobalCustomChanged));
|
QOverload<>::of(&ClangToolsProjectSettingsWidget::onGlobalCustomChanged));
|
||||||
connect(m_restoreGlobal, &QPushButton::clicked, this, [this]() {
|
connect(m_restoreGlobal, &QPushButton::clicked, this, [this]() {
|
||||||
m_runSettingsWidget->fromSettings(ClangToolsSettings::instance()->runSettings());
|
m_runSettingsWidget->fromSettings(ClangToolsSettings::instance()->runSettings());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Links
|
|
||||||
connect(gotoGlobalSettingsLabel, &QLabel::linkActivated, [](const QString &) {
|
|
||||||
Core::ICore::showOptionsDialog(ClangTools::Constants::SETTINGS_PAGE_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(gotoAnalyzerModeLabel, &QLabel::linkActivated, [](const QString &) {
|
connect(gotoAnalyzerModeLabel, &QLabel::linkActivated, [](const QString &) {
|
||||||
ClangTool::instance()->selectPerspective();
|
ClangTool::instance()->selectPerspective();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Run options
|
// Run options
|
||||||
connect(m_runSettingsWidget, &RunSettingsWidget::changed, [this]() {
|
connect(m_runSettingsWidget, &RunSettingsWidget::changed, this, [this]() {
|
||||||
// Save project run settings
|
// Save project run settings
|
||||||
m_projectSettings->setRunSettings(m_runSettingsWidget->toSettings());
|
m_projectSettings->setRunSettings(m_runSettingsWidget->toSettings());
|
||||||
|
|
||||||
@@ -165,31 +145,30 @@ ProjectSettingsWidget::ProjectSettingsWidget(ProjectExplorer::Project *project,
|
|||||||
// Suppressed diagnostics
|
// Suppressed diagnostics
|
||||||
auto * const model = new SuppressedDiagnosticsModel(this);
|
auto * const model = new SuppressedDiagnosticsModel(this);
|
||||||
model->setDiagnostics(m_projectSettings->suppressedDiagnostics());
|
model->setDiagnostics(m_projectSettings->suppressedDiagnostics());
|
||||||
connect(m_projectSettings.data(), &ClangToolsProjectSettings::suppressedDiagnosticsChanged,
|
connect(m_projectSettings.data(), &ClangToolsProjectSettings::suppressedDiagnosticsChanged, this,
|
||||||
[model, this] {
|
[model, this] {
|
||||||
model->setDiagnostics(m_projectSettings->suppressedDiagnostics());
|
model->setDiagnostics(m_projectSettings->suppressedDiagnostics());
|
||||||
updateButtonStates();
|
updateButtonStates();
|
||||||
});
|
});
|
||||||
m_diagnosticsView->setModel(model);
|
m_diagnosticsView->setModel(model);
|
||||||
updateButtonStates();
|
updateButtonStates();
|
||||||
connect(m_diagnosticsView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
connect(m_diagnosticsView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||||
[this](const QItemSelection &, const QItemSelection &) {
|
[this](const QItemSelection &, const QItemSelection &) {
|
||||||
updateButtonStateRemoveSelected();
|
updateButtonStateRemoveSelected();
|
||||||
});
|
});
|
||||||
connect(m_removeSelectedButton, &QAbstractButton::clicked,
|
connect(m_removeSelectedButton, &QAbstractButton::clicked,
|
||||||
[this](bool) { removeSelected(); });
|
this, [this](bool) { removeSelected(); });
|
||||||
connect(m_removeAllButton, &QAbstractButton::clicked,
|
connect(m_removeAllButton, &QAbstractButton::clicked,
|
||||||
[this](bool) { m_projectSettings->removeAllSuppressedDiagnostics();});
|
this, [this](bool) { m_projectSettings->removeAllSuppressedDiagnostics();});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsWidget::onGlobalCustomChanged()
|
void ClangToolsProjectSettingsWidget::onGlobalCustomChanged()
|
||||||
{
|
{
|
||||||
onGlobalCustomChanged(m_globalCustomComboBox->currentIndex());
|
onGlobalCustomChanged(useGlobalSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsWidget::onGlobalCustomChanged(int index)
|
void ClangToolsProjectSettingsWidget::onGlobalCustomChanged(bool useGlobal)
|
||||||
{
|
{
|
||||||
const bool useGlobal = index == UseGlobalSettings;
|
|
||||||
const RunSettings runSettings = useGlobal ? ClangToolsSettings::instance()->runSettings()
|
const RunSettings runSettings = useGlobal ? ClangToolsSettings::instance()->runSettings()
|
||||||
: m_projectSettings->runSettings();
|
: m_projectSettings->runSettings();
|
||||||
m_runSettingsWidget->fromSettings(runSettings);
|
m_runSettingsWidget->fromSettings(runSettings);
|
||||||
@@ -199,25 +178,25 @@ void ProjectSettingsWidget::onGlobalCustomChanged(int index)
|
|||||||
m_projectSettings->setUseGlobalSettings(useGlobal);
|
m_projectSettings->setUseGlobalSettings(useGlobal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsWidget::updateButtonStates()
|
void ClangToolsProjectSettingsWidget::updateButtonStates()
|
||||||
{
|
{
|
||||||
updateButtonStateRemoveSelected();
|
updateButtonStateRemoveSelected();
|
||||||
updateButtonStateRemoveAll();
|
updateButtonStateRemoveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsWidget::updateButtonStateRemoveSelected()
|
void ClangToolsProjectSettingsWidget::updateButtonStateRemoveSelected()
|
||||||
{
|
{
|
||||||
const auto selectedRows = m_diagnosticsView->selectionModel()->selectedRows();
|
const auto selectedRows = m_diagnosticsView->selectionModel()->selectedRows();
|
||||||
QTC_ASSERT(selectedRows.count() <= 1, return);
|
QTC_ASSERT(selectedRows.count() <= 1, return);
|
||||||
m_removeSelectedButton->setEnabled(!selectedRows.isEmpty());
|
m_removeSelectedButton->setEnabled(!selectedRows.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsWidget::updateButtonStateRemoveAll()
|
void ClangToolsProjectSettingsWidget::updateButtonStateRemoveAll()
|
||||||
{
|
{
|
||||||
m_removeAllButton->setEnabled(m_diagnosticsView->model()->rowCount() > 0);
|
m_removeAllButton->setEnabled(m_diagnosticsView->model()->rowCount() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsWidget::removeSelected()
|
void ClangToolsProjectSettingsWidget::removeSelected()
|
||||||
{
|
{
|
||||||
const auto selectedRows = m_diagnosticsView->selectionModel()->selectedRows();
|
const auto selectedRows = m_diagnosticsView->selectionModel()->selectedRows();
|
||||||
QTC_ASSERT(selectedRows.count() == 1, return);
|
QTC_ASSERT(selectedRows.count() == 1, return);
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -41,16 +43,16 @@ namespace Internal {
|
|||||||
class ClangToolsProjectSettings;
|
class ClangToolsProjectSettings;
|
||||||
class RunSettingsWidget;
|
class RunSettingsWidget;
|
||||||
|
|
||||||
class ProjectSettingsWidget : public QWidget
|
class ClangToolsProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ProjectSettingsWidget(ProjectExplorer::Project *project, QWidget *parent = nullptr);
|
explicit ClangToolsProjectSettingsWidget(ProjectExplorer::Project *project, QWidget *parent = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onGlobalCustomChanged();
|
void onGlobalCustomChanged();
|
||||||
void onGlobalCustomChanged(int index);
|
void onGlobalCustomChanged(bool useGlobal);
|
||||||
|
|
||||||
void updateButtonStates();
|
void updateButtonStates();
|
||||||
void updateButtonStateRemoveSelected();
|
void updateButtonStateRemoveSelected();
|
||||||
|
@@ -450,43 +450,35 @@ public:
|
|||||||
ClangdProjectSettingsWidget::ClangdProjectSettingsWidget(const ClangdProjectSettings &settings)
|
ClangdProjectSettingsWidget::ClangdProjectSettingsWidget(const ClangdProjectSettings &settings)
|
||||||
: d(new Private(settings))
|
: d(new Private(settings))
|
||||||
{
|
{
|
||||||
|
setGlobalSettingsId(Constants::CPP_CLANGD_SETTINGS_ID);
|
||||||
const auto layout = new QVBoxLayout(this);
|
const auto layout = new QVBoxLayout(this);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
const auto globalSettingsLayout = new QHBoxLayout;
|
|
||||||
globalSettingsLayout->addWidget(&d->useGlobalSettingsCheckBox);
|
|
||||||
const auto globalSettingsLabel = new QLabel("Use <a href=\"dummy\">global settings</a>");
|
|
||||||
connect(globalSettingsLabel, &QLabel::linkActivated,
|
|
||||||
this, [] { Core::ICore::showOptionsDialog(Constants::CPP_CLANGD_SETTINGS_ID); });
|
|
||||||
globalSettingsLayout->addWidget(globalSettingsLabel);
|
|
||||||
globalSettingsLayout->addStretch(1);
|
|
||||||
layout->addLayout(globalSettingsLayout);
|
|
||||||
|
|
||||||
const auto separator = new QFrame;
|
|
||||||
separator->setFrameShape(QFrame::HLine);
|
|
||||||
layout->addWidget(separator);
|
|
||||||
layout->addWidget(&d->widget);
|
layout->addWidget(&d->widget);
|
||||||
|
|
||||||
const auto updateGlobalSettingsCheckBox = [this] {
|
const auto updateGlobalSettingsCheckBox = [this] {
|
||||||
if (ClangdSettings::instance().granularity() == ClangdSettings::Granularity::Session) {
|
if (ClangdSettings::instance().granularity() == ClangdSettings::Granularity::Session) {
|
||||||
d->useGlobalSettingsCheckBox.setEnabled(false);
|
setUseGlobalSettingsCheckBoxEnabled(false);
|
||||||
d->useGlobalSettingsCheckBox.setChecked(true);
|
setUseGlobalSettings(true);
|
||||||
} else {
|
} else {
|
||||||
d->useGlobalSettingsCheckBox.setEnabled(true);
|
setUseGlobalSettingsCheckBoxEnabled(true);
|
||||||
d->useGlobalSettingsCheckBox.setChecked(d->settings.useGlobalSettings());
|
setUseGlobalSettings(d->settings.useGlobalSettings());
|
||||||
}
|
}
|
||||||
d->widget.setEnabled(!d->useGlobalSettingsCheckBox.isChecked());
|
d->widget.setEnabled(!useGlobalSettings());
|
||||||
};
|
};
|
||||||
|
|
||||||
updateGlobalSettingsCheckBox();
|
updateGlobalSettingsCheckBox();
|
||||||
connect(&ClangdSettings::instance(), &ClangdSettings::changed,
|
connect(&ClangdSettings::instance(), &ClangdSettings::changed,
|
||||||
this, updateGlobalSettingsCheckBox);
|
this, updateGlobalSettingsCheckBox);
|
||||||
|
|
||||||
connect(&d->useGlobalSettingsCheckBox, &QCheckBox::clicked, [this](bool checked) {
|
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged, this,
|
||||||
d->widget.setEnabled(!checked);
|
[this](bool checked) {
|
||||||
d->settings.setUseGlobalSettings(checked);
|
d->widget.setEnabled(!checked);
|
||||||
if (!checked)
|
d->settings.setUseGlobalSettings(checked);
|
||||||
d->settings.setSettings(d->widget.settingsData());
|
if (!checked)
|
||||||
});
|
d->settings.setSettings(d->widget.settingsData());
|
||||||
connect(&d->widget, &ClangdSettingsWidget::settingsDataChanged, [this] {
|
});
|
||||||
|
|
||||||
|
connect(&d->widget, &ClangdSettingsWidget::settingsDataChanged, this, [this] {
|
||||||
d->settings.setSettings(d->widget.settingsData());
|
d->settings.setSettings(d->widget.settingsData());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cppcodemodelsettings.h"
|
#include "cppcodemodelsettings.h"
|
||||||
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ private:
|
|||||||
Private * const d;
|
Private * const d;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ClangdProjectSettingsWidget : public QWidget
|
class ClangdProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "cppquickfixprojectsettingswidget.h"
|
#include "cppquickfixprojectsettingswidget.h"
|
||||||
|
#include "cppeditorconstants.h"
|
||||||
#include "cppquickfixsettingswidget.h"
|
#include "cppquickfixsettingswidget.h"
|
||||||
#include "ui_cppquickfixprojectsettingswidget.h"
|
#include "ui_cppquickfixprojectsettingswidget.h"
|
||||||
|
|
||||||
@@ -33,9 +34,10 @@ using namespace CppEditor::Internal;
|
|||||||
|
|
||||||
CppQuickFixProjectSettingsWidget::CppQuickFixProjectSettingsWidget(ProjectExplorer::Project *project,
|
CppQuickFixProjectSettingsWidget::CppQuickFixProjectSettingsWidget(ProjectExplorer::Project *project,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QWidget(parent)
|
: ProjectExplorer::ProjectSettingsWidget(parent)
|
||||||
, ui(new Ui::CppQuickFixProjectSettingsWidget)
|
, ui(new Ui::CppQuickFixProjectSettingsWidget)
|
||||||
{
|
{
|
||||||
|
setGlobalSettingsId(CppEditor::Constants::QUICK_FIX_SETTINGS_ID);
|
||||||
m_projectSettings = CppQuickFixProjectsSettings::getSettings(project);
|
m_projectSettings = CppQuickFixProjectsSettings::getSettings(project);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
m_settingsWidget = new CppEditor::Internal::CppQuickFixSettingsWidget(this);
|
m_settingsWidget = new CppEditor::Internal::CppQuickFixSettingsWidget(this);
|
||||||
@@ -43,20 +45,20 @@ CppQuickFixProjectSettingsWidget::CppQuickFixProjectSettingsWidget(ProjectExplor
|
|||||||
if (QLayout *layout = m_settingsWidget->layout())
|
if (QLayout *layout = m_settingsWidget->layout())
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
ui->layout->addWidget(m_settingsWidget);
|
ui->layout->addWidget(m_settingsWidget);
|
||||||
connect(ui->comboBox,
|
|
||||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged,
|
||||||
this,
|
this, &CppQuickFixProjectSettingsWidget::currentItemChanged);
|
||||||
&CppQuickFixProjectSettingsWidget::currentItemChanged);
|
setUseGlobalSettings(m_projectSettings->isUsingGlobalSettings());
|
||||||
connect(ui->pushButton_custom,
|
currentItemChanged(m_projectSettings->useCustomSettings());
|
||||||
&QAbstractButton::clicked,
|
|
||||||
this,
|
connect(ui->pushButton_custom, &QAbstractButton::clicked,
|
||||||
&CppQuickFixProjectSettingsWidget::buttonCustomClicked);
|
this, &CppQuickFixProjectSettingsWidget::buttonCustomClicked);
|
||||||
connect(m_settingsWidget, &CppEditor::Internal::CppQuickFixSettingsWidget::settingsChanged, [this] {
|
connect(m_settingsWidget, &CppEditor::Internal::CppQuickFixSettingsWidget::settingsChanged, this,
|
||||||
m_settingsWidget->saveSettings(m_projectSettings->getSettings());
|
[this] {
|
||||||
if (!useGlobalSettings())
|
m_settingsWidget->saveSettings(m_projectSettings->getSettings());
|
||||||
m_projectSettings->saveOwnSettings();
|
if (!useGlobalSettings())
|
||||||
});
|
m_projectSettings->saveOwnSettings();
|
||||||
ui->comboBox->setCurrentIndex(m_projectSettings->isUsingGlobalSettings() ? 0 : 1);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CppQuickFixProjectSettingsWidget::~CppQuickFixProjectSettingsWidget()
|
CppQuickFixProjectSettingsWidget::~CppQuickFixProjectSettingsWidget()
|
||||||
@@ -64,9 +66,9 @@ CppQuickFixProjectSettingsWidget::~CppQuickFixProjectSettingsWidget()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppQuickFixProjectSettingsWidget::currentItemChanged()
|
void CppQuickFixProjectSettingsWidget::currentItemChanged(bool useGlobalSettings)
|
||||||
{
|
{
|
||||||
if (useGlobalSettings()) {
|
if (useGlobalSettings) {
|
||||||
const auto &path = m_projectSettings->filePathOfSettingsFile();
|
const auto &path = m_projectSettings->filePathOfSettingsFile();
|
||||||
ui->pushButton_custom->setToolTip(tr("Custom settings are saved in a file. If you use the "
|
ui->pushButton_custom->setToolTip(tr("Custom settings are saved in a file. If you use the "
|
||||||
"global settings, you can delete that file."));
|
"global settings, you can delete that file."));
|
||||||
@@ -75,7 +77,7 @@ void CppQuickFixProjectSettingsWidget::currentItemChanged()
|
|||||||
m_projectSettings->useGlobalSettings();
|
m_projectSettings->useGlobalSettings();
|
||||||
} else /*Custom*/ {
|
} else /*Custom*/ {
|
||||||
if (!m_projectSettings->useCustomSettings()) {
|
if (!m_projectSettings->useCustomSettings()) {
|
||||||
ui->comboBox->setCurrentIndex(0);
|
setUseGlobalSettings(!m_projectSettings->useCustomSettings());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ui->pushButton_custom->setToolTip(tr("Resets all settings to the global settings."));
|
ui->pushButton_custom->setToolTip(tr("Resets all settings to the global settings."));
|
||||||
@@ -99,8 +101,3 @@ void CppQuickFixProjectSettingsWidget::buttonCustomClicked()
|
|||||||
m_settingsWidget->loadSettings(m_projectSettings->getSettings());
|
m_settingsWidget->loadSettings(m_projectSettings->getSettings());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppQuickFixProjectSettingsWidget::useGlobalSettings()
|
|
||||||
{
|
|
||||||
return ui->comboBox->currentIndex() == 0;
|
|
||||||
}
|
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cppquickfixprojectsettings.h"
|
#include "cppquickfixprojectsettings.h"
|
||||||
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ namespace ProjectExplorer { class Project; }
|
|||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class CppQuickFixSettingsWidget;
|
class CppQuickFixSettingsWidget;
|
||||||
class CppQuickFixProjectSettingsWidget : public QWidget
|
class CppQuickFixProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -48,12 +49,10 @@ public:
|
|||||||
~CppQuickFixProjectSettingsWidget();
|
~CppQuickFixProjectSettingsWidget();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void currentItemChanged();
|
void currentItemChanged(bool useGlobalSettings);
|
||||||
void buttonCustomClicked();
|
void buttonCustomClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool useGlobalSettings();
|
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(Ui)::CppQuickFixProjectSettingsWidget *ui;
|
QT_PREPEND_NAMESPACE(Ui)::CppQuickFixProjectSettingsWidget *ui;
|
||||||
CppQuickFixSettingsWidget *m_settingsWidget;
|
CppQuickFixSettingsWidget *m_settingsWidget;
|
||||||
CppQuickFixProjectsSettings::CppQuickFixProjectsSettingsPtr m_projectSettings;
|
CppQuickFixProjectsSettings::CppQuickFixProjectsSettingsPtr m_projectSettings;
|
||||||
|
@@ -23,33 +23,16 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="1">
|
<item row="2" column="0" colspan="2">
|
||||||
|
<layout class="QVBoxLayout" name="layout"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
<widget class="QPushButton" name="pushButton_custom">
|
<widget class="QPushButton" name="pushButton_custom">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="2">
|
|
||||||
<layout class="QVBoxLayout" name="layout"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QComboBox" name="comboBox">
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>-1</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Global Settings</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Custom Settings</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@@ -143,6 +143,7 @@ add_qtc_plugin(ProjectExplorer
|
|||||||
projectmodels.cpp projectmodels.h
|
projectmodels.cpp projectmodels.h
|
||||||
projectnodes.cpp projectnodes.h
|
projectnodes.cpp projectnodes.h
|
||||||
projectpanelfactory.cpp projectpanelfactory.h
|
projectpanelfactory.cpp projectpanelfactory.h
|
||||||
|
projectsettingswidget.cpp projectsettingswidget.h
|
||||||
projecttree.cpp projecttree.h
|
projecttree.cpp projecttree.h
|
||||||
projecttreewidget.cpp projecttreewidget.h
|
projecttreewidget.cpp projecttreewidget.h
|
||||||
projectwelcomepage.cpp projectwelcomepage.h
|
projectwelcomepage.cpp projectwelcomepage.h
|
||||||
|
@@ -34,9 +34,10 @@ using namespace TextEditor;
|
|||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
|
|
||||||
CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project) : QWidget(), m_project(project)
|
CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project) : ProjectSettingsWidget(), m_project(project)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
setUseGlobalSettingsCheckBoxVisible(false);
|
||||||
|
|
||||||
const EditorConfiguration *config = m_project->editorConfiguration();
|
const EditorConfiguration *config = m_project->editorConfiguration();
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui_codestylesettingspropertiespage.h"
|
#include "ui_codestylesettingspropertiespage.h"
|
||||||
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class EditorConfiguration;
|
class EditorConfiguration;
|
||||||
@@ -33,7 +34,7 @@ class Project;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class CodeStyleSettingsWidget : public QWidget
|
class CodeStyleSettingsWidget : public ProjectSettingsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@@ -210,10 +210,11 @@ void DependenciesView::updateSizeHint()
|
|||||||
// DependenciesWidget
|
// DependenciesWidget
|
||||||
//
|
//
|
||||||
|
|
||||||
DependenciesWidget::DependenciesWidget(Project *project, QWidget *parent) : QWidget(parent),
|
DependenciesWidget::DependenciesWidget(Project *project, QWidget *parent) : ProjectSettingsWidget(parent),
|
||||||
m_project(project),
|
m_project(project),
|
||||||
m_model(new DependenciesModel(project, this))
|
m_model(new DependenciesModel(project, this))
|
||||||
{
|
{
|
||||||
|
setUseGlobalSettingsCheckBoxVisible(false);
|
||||||
auto vbox = new QVBoxLayout(this);
|
auto vbox = new QVBoxLayout(this);
|
||||||
vbox->setContentsMargins(0, 0, 0, 0);
|
vbox->setContentsMargins(0, 0, 0, 0);
|
||||||
m_detailsContainer = new Utils::DetailsWidget(this);
|
m_detailsContainer = new Utils::DetailsWidget(this);
|
||||||
|
@@ -25,8 +25,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -81,7 +82,7 @@ private:
|
|||||||
QSize m_sizeHint;
|
QSize m_sizeHint;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DependenciesWidget : public QWidget
|
class DependenciesWidget : public ProjectSettingsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "editorconfiguration.h"
|
#include "editorconfiguration.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
|
|
||||||
|
#include <texteditor/texteditorconstants.h>
|
||||||
#include <texteditor/behaviorsettings.h>
|
#include <texteditor/behaviorsettings.h>
|
||||||
#include <texteditor/extraencodingsettings.h>
|
#include <texteditor/extraencodingsettings.h>
|
||||||
#include <texteditor/marginsettings.h>
|
#include <texteditor/marginsettings.h>
|
||||||
@@ -38,18 +39,20 @@
|
|||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
|
|
||||||
EditorSettingsWidget::EditorSettingsWidget(Project *project) : QWidget(), m_project(project)
|
EditorSettingsWidget::EditorSettingsWidget(Project *project) : ProjectSettingsWidget(), m_project(project)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
setGlobalSettingsId(TextEditor::Constants::TEXT_EDITOR_BEHAVIOR_SETTINGS);
|
||||||
|
|
||||||
const EditorConfiguration *config = m_project->editorConfiguration();
|
const EditorConfiguration *config = m_project->editorConfiguration();
|
||||||
settingsToUi(config);
|
settingsToUi(config);
|
||||||
|
|
||||||
globalSettingsActivated(config->useGlobalSettings() ? 0 : 1);
|
globalSettingsActivated(config->useGlobalSettings());
|
||||||
|
setUseGlobalSettings(config->useGlobalSettings());
|
||||||
|
|
||||||
|
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged,
|
||||||
connect(m_ui.globalSelector, QOverload<int>::of(&QComboBox::activated),
|
|
||||||
this, &EditorSettingsWidget::globalSettingsActivated);
|
this, &EditorSettingsWidget::globalSettingsActivated);
|
||||||
|
|
||||||
connect(m_ui.restoreButton, &QAbstractButton::clicked,
|
connect(m_ui.restoreButton, &QAbstractButton::clicked,
|
||||||
this, &EditorSettingsWidget::restoreDefaultValues);
|
this, &EditorSettingsWidget::restoreDefaultValues);
|
||||||
|
|
||||||
@@ -78,7 +81,6 @@ void EditorSettingsWidget::settingsToUi(const EditorConfiguration *config)
|
|||||||
m_ui.useIndenter->setChecked(config->marginSettings().m_useIndenter);
|
m_ui.useIndenter->setChecked(config->marginSettings().m_useIndenter);
|
||||||
m_ui.wrapColumn->setValue(config->marginSettings().m_marginColumn);
|
m_ui.wrapColumn->setValue(config->marginSettings().m_marginColumn);
|
||||||
m_ui.behaviorSettingsWidget->setCodeStyle(config->codeStyle());
|
m_ui.behaviorSettingsWidget->setCodeStyle(config->codeStyle());
|
||||||
m_ui.globalSelector->setCurrentIndex(config->useGlobalSettings() ? 0 : 1);
|
|
||||||
m_ui.behaviorSettingsWidget->setAssignedCodec(config->textCodec());
|
m_ui.behaviorSettingsWidget->setAssignedCodec(config->textCodec());
|
||||||
m_ui.behaviorSettingsWidget->setAssignedTypingSettings(config->typingSettings());
|
m_ui.behaviorSettingsWidget->setAssignedTypingSettings(config->typingSettings());
|
||||||
m_ui.behaviorSettingsWidget->setAssignedStorageSettings(config->storageSettings());
|
m_ui.behaviorSettingsWidget->setAssignedStorageSettings(config->storageSettings());
|
||||||
@@ -86,9 +88,8 @@ void EditorSettingsWidget::settingsToUi(const EditorConfiguration *config)
|
|||||||
m_ui.behaviorSettingsWidget->setAssignedExtraEncodingSettings(config->extraEncodingSettings());
|
m_ui.behaviorSettingsWidget->setAssignedExtraEncodingSettings(config->extraEncodingSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorSettingsWidget::globalSettingsActivated(int index)
|
void EditorSettingsWidget::globalSettingsActivated(bool useGlobal)
|
||||||
{
|
{
|
||||||
const bool useGlobal = !index;
|
|
||||||
m_ui.displaySettings->setEnabled(!useGlobal);
|
m_ui.displaySettings->setEnabled(!useGlobal);
|
||||||
m_ui.behaviorSettingsWidget->setActive(!useGlobal);
|
m_ui.behaviorSettingsWidget->setActive(!useGlobal);
|
||||||
m_ui.restoreButton->setEnabled(!useGlobal);
|
m_ui.restoreButton->setEnabled(!useGlobal);
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui_editorsettingspropertiespage.h"
|
#include "ui_editorsettingspropertiespage.h"
|
||||||
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class EditorConfiguration;
|
class EditorConfiguration;
|
||||||
@@ -33,14 +34,14 @@ class Project;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class EditorSettingsWidget : public QWidget
|
class EditorSettingsWidget : public ProjectSettingsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit EditorSettingsWidget(Project *project);
|
explicit EditorSettingsWidget(Project *project);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void globalSettingsActivated(int index);
|
void globalSettingsActivated(bool useGlobal);
|
||||||
void restoreDefaultValues();
|
void restoreDefaultValues();
|
||||||
|
|
||||||
void settingsToUi(const EditorConfiguration *config);
|
void settingsToUi(const EditorConfiguration *config);
|
||||||
|
@@ -6,56 +6,19 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>401</width>
|
<width>601</width>
|
||||||
<height>173</height>
|
<height>173</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Editor settings:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QComboBox" name="globalSelector">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Global</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Custom</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QPushButton" name="restoreButton">
|
<widget class="QPushButton" name="restoreButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Restore Global</string>
|
<string>Restore Global</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="1" column="0" colspan="3">
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>3</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" colspan="4">
|
|
||||||
<widget class="QGroupBox" name="displaySettings">
|
<widget class="QGroupBox" name="displaySettings">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@@ -107,9 +70,6 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="4">
|
|
||||||
<widget class="TextEditor::BehaviorSettingsWidget" name="behaviorSettingsWidget" native="true"/>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@@ -123,6 +83,22 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0" colspan="3">
|
||||||
|
<widget class="TextEditor::BehaviorSettingsWidget" name="behaviorSettingsWidget" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>3</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
NamedWidget::NamedWidget(const QString &displayName, QWidget *parent)
|
NamedWidget::NamedWidget(const QString &displayName, QWidget *parent)
|
||||||
: QWidget(parent), m_displayName(displayName)
|
: ProjectSettingsWidget(parent), m_displayName(displayName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,12 +26,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "projectexplorer_export.h"
|
#include "projectexplorer_export.h"
|
||||||
|
#include "projectsettingswidget.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT NamedWidget : public QWidget
|
class PROJECTEXPLORER_EXPORT NamedWidget : public ProjectSettingsWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit NamedWidget(const QString &displayName, QWidget *parent = nullptr);
|
explicit NamedWidget(const QString &displayName, QWidget *parent = nullptr);
|
||||||
|
@@ -25,11 +25,14 @@
|
|||||||
|
|
||||||
#include "panelswidget.h"
|
#include "panelswidget.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
@@ -41,7 +44,7 @@ namespace ProjectExplorer {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const int ABOVE_HEADING_MARGIN = 10;
|
const int ABOVE_HEADING_MARGIN = 10;
|
||||||
const int ABOVE_CONTENTS_MARGIN = 4;
|
const int CONTENTS_MARGIN = 5;
|
||||||
const int BELOW_CONTENTS_MARGIN = 16;
|
const int BELOW_CONTENTS_MARGIN = 16;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -85,7 +88,16 @@ PanelsWidget::PanelsWidget(QWidget *parent) : QWidget(parent)
|
|||||||
PanelsWidget::PanelsWidget(const QString &displayName, QWidget *widget)
|
PanelsWidget::PanelsWidget(const QString &displayName, QWidget *widget)
|
||||||
: PanelsWidget(nullptr)
|
: PanelsWidget(nullptr)
|
||||||
{
|
{
|
||||||
addPropertiesPanel(displayName, widget);
|
addPropertiesPanel(displayName);
|
||||||
|
addWidget(widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
PanelsWidget::PanelsWidget(const QString &displayName, ProjectSettingsWidget *widget)
|
||||||
|
: PanelsWidget(nullptr)
|
||||||
|
{
|
||||||
|
addPropertiesPanel(displayName);
|
||||||
|
addGlobalSettingsProperties(widget);
|
||||||
|
addWidget(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
PanelsWidget::~PanelsWidget() = default;
|
PanelsWidget::~PanelsWidget() = default;
|
||||||
@@ -102,7 +114,7 @@ PanelsWidget::~PanelsWidget() = default;
|
|||||||
* | widget |
|
* | widget |
|
||||||
* +------------+ BELOW_CONTENTS_MARGIN
|
* +------------+ BELOW_CONTENTS_MARGIN
|
||||||
*/
|
*/
|
||||||
void PanelsWidget::addPropertiesPanel(const QString &displayName, QWidget *widget)
|
void PanelsWidget::addPropertiesPanel(const QString &displayName)
|
||||||
{
|
{
|
||||||
// name:
|
// name:
|
||||||
auto nameLabel = new QLabel(m_root);
|
auto nameLabel = new QLabel(m_root);
|
||||||
@@ -120,11 +132,51 @@ void PanelsWidget::addPropertiesPanel(const QString &displayName, QWidget *widge
|
|||||||
line->setForegroundRole(QPalette::Midlight);
|
line->setForegroundRole(QPalette::Midlight);
|
||||||
line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
m_layout->addWidget(line);
|
m_layout->addWidget(line);
|
||||||
|
}
|
||||||
|
|
||||||
// add the widget:
|
void PanelsWidget::addWidget(QWidget *widget)
|
||||||
widget->setContentsMargins(0, ABOVE_CONTENTS_MARGIN, 0, BELOW_CONTENTS_MARGIN);
|
{
|
||||||
|
widget->setContentsMargins(0, CONTENTS_MARGIN, 0, BELOW_CONTENTS_MARGIN);
|
||||||
widget->setParent(m_root);
|
widget->setParent(m_root);
|
||||||
m_layout->addWidget(widget);
|
m_layout->addWidget(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PanelsWidget::addGlobalSettingsProperties(ProjectSettingsWidget *widget)
|
||||||
|
{
|
||||||
|
if (!widget->isUseGlobalSettingsCheckBoxVisible())
|
||||||
|
return;
|
||||||
|
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
const auto useGlobalSettingsCheckBox = new QCheckBox;
|
||||||
|
useGlobalSettingsCheckBox->setChecked(widget->useGlobalSettings());
|
||||||
|
useGlobalSettingsCheckBox->setEnabled(widget->isUseGlobalSettingsCheckBoxEnabled());
|
||||||
|
const auto settingsLabel = new QLabel("Use <a href=\"dummy\">global settings</a>");
|
||||||
|
settingsLabel->setContentsMargins(CONTENTS_MARGIN, 0, 0, 0);
|
||||||
|
settingsLabel->setEnabled(widget->isUseGlobalSettingsCheckBoxEnabled());
|
||||||
|
const auto horizontLayout = new QHBoxLayout;
|
||||||
|
horizontLayout->setContentsMargins(0, CONTENTS_MARGIN, 0, CONTENTS_MARGIN);
|
||||||
|
horizontLayout->addWidget(useGlobalSettingsCheckBox);
|
||||||
|
horizontLayout->addWidget(settingsLabel);
|
||||||
|
horizontLayout->addStretch(1);
|
||||||
|
m_layout->addLayout(horizontLayout);
|
||||||
|
|
||||||
|
auto separator = new QFrame(m_root);
|
||||||
|
separator->setFrameShape(QFrame::HLine);
|
||||||
|
m_layout->addWidget(separator);
|
||||||
|
|
||||||
|
connect(widget, &ProjectSettingsWidget::useGlobalSettingsCheckBoxEnabledChanged, this,
|
||||||
|
[useGlobalSettingsCheckBox, settingsLabel] (bool enabled) {
|
||||||
|
useGlobalSettingsCheckBox->setEnabled(enabled);
|
||||||
|
settingsLabel->setEnabled(enabled);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(useGlobalSettingsCheckBox, &QCheckBox::stateChanged,
|
||||||
|
widget, &ProjectSettingsWidget::setUseGlobalSettings);
|
||||||
|
connect(widget, &ProjectSettingsWidget::useGlobalSettingsChanged,
|
||||||
|
useGlobalSettingsCheckBox, &QCheckBox::setChecked);
|
||||||
|
|
||||||
|
connect(settingsLabel, &QLabel::linkActivated, this, [widget] {
|
||||||
|
Core::ICore::showOptionsDialog(widget->globalSettingsId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} // ProjectExplorer
|
} // ProjectExplorer
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "projectexplorer_export.h"
|
#include "projectexplorer_export.h"
|
||||||
|
#include "projectsettingswidget.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@@ -42,9 +43,12 @@ class PROJECTEXPLORER_EXPORT PanelsWidget : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit PanelsWidget(QWidget *parent = nullptr);
|
explicit PanelsWidget(QWidget *parent = nullptr);
|
||||||
PanelsWidget(const QString &displayName, QWidget *widget);
|
PanelsWidget(const QString &displayName, QWidget *widget);
|
||||||
|
PanelsWidget(const QString &displayName, ProjectSettingsWidget *widget);
|
||||||
~PanelsWidget() override;
|
~PanelsWidget() override;
|
||||||
|
|
||||||
void addPropertiesPanel(const QString &displayName, QWidget *widget);
|
void addPropertiesPanel(const QString &displayName);
|
||||||
|
void addGlobalSettingsProperties(ProjectSettingsWidget *widget);
|
||||||
|
void addWidget(QWidget *widget);
|
||||||
|
|
||||||
static int constexpr PanelVMargin = 14;
|
static int constexpr PanelVMargin = 14;
|
||||||
|
|
||||||
|
@@ -393,6 +393,7 @@ class ProjectEnvironmentWidget : public NamedWidget
|
|||||||
public:
|
public:
|
||||||
explicit ProjectEnvironmentWidget(Project *project) : NamedWidget(tr("Project Environment"))
|
explicit ProjectEnvironmentWidget(Project *project) : NamedWidget(tr("Project Environment"))
|
||||||
{
|
{
|
||||||
|
setUseGlobalSettingsCheckBoxVisible(false);
|
||||||
const auto vbox = new QVBoxLayout(this);
|
const auto vbox = new QVBoxLayout(this);
|
||||||
vbox->setContentsMargins(0, 0, 0, 0);
|
vbox->setContentsMargins(0, 0, 0, 0);
|
||||||
const auto envWidget = new EnvironmentWidget(this, EnvironmentWidget::TypeLocal);
|
const auto envWidget = new EnvironmentWidget(this, EnvironmentWidget::TypeLocal);
|
||||||
|
@@ -119,6 +119,7 @@ Project {
|
|||||||
"projectmodels.cpp", "projectmodels.h",
|
"projectmodels.cpp", "projectmodels.h",
|
||||||
"projectnodes.cpp", "projectnodes.h",
|
"projectnodes.cpp", "projectnodes.h",
|
||||||
"projectpanelfactory.cpp", "projectpanelfactory.h",
|
"projectpanelfactory.cpp", "projectpanelfactory.h",
|
||||||
|
"projectsettingswidget.cpp", "projectsettingswidget.h",
|
||||||
"projecttree.cpp",
|
"projecttree.cpp",
|
||||||
"projecttree.h",
|
"projecttree.h",
|
||||||
"projecttreewidget.cpp", "projecttreewidget.h",
|
"projecttreewidget.cpp", "projecttreewidget.h",
|
||||||
|
@@ -28,6 +28,8 @@
|
|||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "projectwindow.h"
|
#include "projectwindow.h"
|
||||||
|
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -90,7 +92,7 @@ void ProjectPanelFactory::setId(Utils::Id id)
|
|||||||
m_id = id;
|
m_id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *ProjectPanelFactory::createWidget(Project *project) const
|
ProjectSettingsWidget *ProjectPanelFactory::createWidget(Project *project) const
|
||||||
{
|
{
|
||||||
return m_widgetCreator(project);
|
return m_widgetCreator(project);
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "projectexplorer_export.h"
|
#include "projectexplorer_export.h"
|
||||||
|
|
||||||
|
#include "projectsettingswidget.h"
|
||||||
|
|
||||||
#include <utils/id.h>
|
#include <utils/id.h>
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
@@ -54,7 +56,7 @@ public:
|
|||||||
// interface for users of ProjectPanelFactory
|
// interface for users of ProjectPanelFactory
|
||||||
bool supports(Project *project);
|
bool supports(Project *project);
|
||||||
|
|
||||||
using WidgetCreator = std::function<QWidget *(Project *)>;
|
using WidgetCreator = std::function<ProjectSettingsWidget *(Project *)>;
|
||||||
|
|
||||||
// interface for "implementations" of ProjectPanelFactory
|
// interface for "implementations" of ProjectPanelFactory
|
||||||
// by default all projects are supported, only set a custom supports function
|
// by default all projects are supported, only set a custom supports function
|
||||||
@@ -70,7 +72,7 @@ public:
|
|||||||
Utils::TreeItem *createPanelItem(Project *project);
|
Utils::TreeItem *createPanelItem(Project *project);
|
||||||
|
|
||||||
void setCreateWidgetFunction(const WidgetCreator &createWidgetFunction);
|
void setCreateWidgetFunction(const WidgetCreator &createWidgetFunction);
|
||||||
QWidget *createWidget(Project *project) const;
|
ProjectSettingsWidget *createWidget(Project *project) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ProjectExplorerPlugin;
|
friend class ProjectExplorerPlugin;
|
||||||
|
80
src/plugins/projectexplorer/projectsettingswidget.cpp
Normal file
80
src/plugins/projectexplorer/projectsettingswidget.cpp
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2022 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "projectsettingswidget.h"
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
|
ProjectSettingsWidget::ProjectSettingsWidget(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void ProjectSettingsWidget::setUseGlobalSettings(bool useGlobalSettings)
|
||||||
|
{
|
||||||
|
if (m_useGlobalSettings == useGlobalSettings)
|
||||||
|
return;
|
||||||
|
m_useGlobalSettings = useGlobalSettings;
|
||||||
|
emit useGlobalSettingsChanged(useGlobalSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProjectSettingsWidget::useGlobalSettings() const
|
||||||
|
{
|
||||||
|
return m_useGlobalSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectSettingsWidget::setUseGlobalSettingsCheckBoxEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
if (m_useGlobalSettingsCheckBoxEnabled == enabled)
|
||||||
|
return;
|
||||||
|
m_useGlobalSettingsCheckBoxEnabled = enabled;
|
||||||
|
emit useGlobalSettingsCheckBoxEnabledChanged(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProjectSettingsWidget::isUseGlobalSettingsCheckBoxEnabled() const
|
||||||
|
{
|
||||||
|
return m_useGlobalSettingsCheckBoxEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProjectSettingsWidget::isUseGlobalSettingsCheckBoxVisible() const
|
||||||
|
{
|
||||||
|
return m_useGlobalSettingsCheckBoxVisibleVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectSettingsWidget::setUseGlobalSettingsCheckBoxVisible(bool visible)
|
||||||
|
{
|
||||||
|
m_useGlobalSettingsCheckBoxVisibleVisible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils::Id ProjectSettingsWidget::globalSettingsId() const
|
||||||
|
{
|
||||||
|
return m_globalSettingsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectSettingsWidget::setGlobalSettingsId(Utils::Id globalId)
|
||||||
|
{
|
||||||
|
m_globalSettingsId = globalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // ProjectExplorer
|
64
src/plugins/projectexplorer/projectsettingswidget.h
Normal file
64
src/plugins/projectexplorer/projectsettingswidget.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2022 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "projectexplorer_export.h"
|
||||||
|
#include "projectexplorer/project.h"
|
||||||
|
|
||||||
|
#include <utils/id.h>
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
|
class PROJECTEXPLORER_EXPORT ProjectSettingsWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ProjectSettingsWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
void setUseGlobalSettings(bool useGlobalSettings);
|
||||||
|
bool useGlobalSettings() const;
|
||||||
|
|
||||||
|
void setUseGlobalSettingsCheckBoxEnabled(bool enadled);
|
||||||
|
bool isUseGlobalSettingsCheckBoxEnabled() const;
|
||||||
|
|
||||||
|
bool isUseGlobalSettingsCheckBoxVisible() const;
|
||||||
|
Utils::Id globalSettingsId() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setUseGlobalSettingsCheckBoxVisible(bool visible);
|
||||||
|
void setGlobalSettingsId(Utils::Id globalId);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void useGlobalSettingsChanged(bool useGlobalSettings);
|
||||||
|
void useGlobalSettingsCheckBoxEnabledChanged(bool enadled);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_useGlobalSettings = true;
|
||||||
|
bool m_useGlobalSettingsCheckBoxEnabled = true;
|
||||||
|
bool m_useGlobalSettingsCheckBoxVisibleVisible = true;
|
||||||
|
Utils::Id m_globalSettingsId;
|
||||||
|
};
|
||||||
|
} // namespace ProjectExplorer
|
@@ -26,15 +26,16 @@
|
|||||||
#include "projectwindow.h"
|
#include "projectwindow.h"
|
||||||
|
|
||||||
#include "buildinfo.h"
|
#include "buildinfo.h"
|
||||||
#include "projectexplorerconstants.h"
|
|
||||||
#include "kit.h"
|
#include "kit.h"
|
||||||
#include "kitmanager.h"
|
#include "kitmanager.h"
|
||||||
#include "kitoptionspage.h"
|
#include "kitoptionspage.h"
|
||||||
#include "panelswidget.h"
|
#include "panelswidget.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "projectexplorer.h"
|
#include "projectexplorer.h"
|
||||||
|
#include "projectexplorerconstants.h"
|
||||||
#include "projectimporter.h"
|
#include "projectimporter.h"
|
||||||
#include "projectpanelfactory.h"
|
#include "projectpanelfactory.h"
|
||||||
|
#include "projectsettingswidget.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "targetsettingspanel.h"
|
#include "targetsettingspanel.h"
|
||||||
@@ -261,7 +262,7 @@ QVariant MiscSettingsPanelItem::data(int column, int role) const
|
|||||||
|
|
||||||
if (role == PanelWidgetRole) {
|
if (role == PanelWidgetRole) {
|
||||||
if (!m_widget) {
|
if (!m_widget) {
|
||||||
QWidget *widget = m_factory->createWidget(m_project);
|
ProjectSettingsWidget *widget = m_factory->createWidget(m_project);
|
||||||
m_widget = new PanelsWidget(m_factory->displayName(), widget);
|
m_widget = new PanelsWidget(m_factory->displayName(), widget);
|
||||||
m_widget->setFocusProxy(widget);
|
m_widget->setFocusProxy(widget);
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -42,7 +44,7 @@ namespace Ui {
|
|||||||
class TodoProjectSettingsWidget;
|
class TodoProjectSettingsWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TodoProjectSettingsWidget : public QWidget
|
class TodoProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user