forked from qt-creator/qt-creator
CppEditor: Move CppFileSettingsForProjectWidget to .cpp
... and de-pimpl/re-order there. Change-Id: I01b8e3d56ae28b0206dcd56a6cc04acf8c7b1942 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -537,55 +537,57 @@ void CppFileSettingsForProject::saveSettings()
|
|||||||
m_project->setNamedSettings(projectSettingsKeyC, data);
|
m_project->setNamedSettings(projectSettingsKeyC, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
class CppFileSettingsForProjectWidget::Private
|
class CppFileSettingsForProjectWidget : public ProjectExplorer::ProjectSettingsWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private(const CppFileSettingsForProject &s) : settings(s) {}
|
CppFileSettingsForProjectWidget(const CppFileSettingsForProject &settings)
|
||||||
|
: m_settings(settings),
|
||||||
|
m_initialSettings(settings.settings()),
|
||||||
|
m_widget(&m_initialSettings),
|
||||||
|
m_wasGlobal(settings.useGlobalSettings())
|
||||||
|
{
|
||||||
|
setGlobalSettingsId(Constants::CPP_FILE_SETTINGS_ID);
|
||||||
|
const auto layout = new QVBoxLayout(this);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->addWidget(&m_widget);
|
||||||
|
|
||||||
void maybeClearHeaderSourceCache();
|
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged, this, [this](bool checked) {
|
||||||
void updateSubWidgetState() { widget.setEnabled(!settings.useGlobalSettings()); }
|
m_settings.setUseGlobalSettings(checked);
|
||||||
|
if (!checked)
|
||||||
|
m_settings.setSettings(m_widget.currentSettings());
|
||||||
|
maybeClearHeaderSourceCache();
|
||||||
|
updateSubWidgetState();
|
||||||
|
});
|
||||||
|
|
||||||
CppFileSettingsForProject settings;
|
connect(&m_widget, &CppFileSettingsWidget::userChange, this, [this] {
|
||||||
CppFileSettings initialSettings = settings.settings();
|
m_settings.setSettings(m_widget.currentSettings());
|
||||||
CppFileSettingsWidget widget{&initialSettings};
|
maybeClearHeaderSourceCache();
|
||||||
QCheckBox useGlobalSettingsCheckBox;
|
});
|
||||||
const bool wasGlobal = settings.useGlobalSettings();
|
|
||||||
};
|
|
||||||
|
|
||||||
CppFileSettingsForProjectWidget::CppFileSettingsForProjectWidget(
|
updateSubWidgetState();
|
||||||
const CppFileSettingsForProject &settings) : d(new Private(settings))
|
|
||||||
{
|
|
||||||
setGlobalSettingsId(Constants::CPP_FILE_SETTINGS_ID);
|
|
||||||
const auto layout = new QVBoxLayout(this);
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
layout->addWidget(&d->widget);
|
|
||||||
|
|
||||||
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged, this,
|
|
||||||
[this](bool checked) {
|
|
||||||
d->settings.setUseGlobalSettings(checked);
|
|
||||||
if (!checked)
|
|
||||||
d->settings.setSettings(d->widget.currentSettings());
|
|
||||||
d->maybeClearHeaderSourceCache();
|
|
||||||
d->updateSubWidgetState();
|
|
||||||
});
|
|
||||||
connect(&d->widget, &CppFileSettingsWidget::userChange, this, [this] {
|
|
||||||
d->settings.setSettings(d->widget.currentSettings());
|
|
||||||
d->maybeClearHeaderSourceCache();
|
|
||||||
});
|
|
||||||
d->updateSubWidgetState();
|
|
||||||
}
|
|
||||||
|
|
||||||
CppFileSettingsForProjectWidget::~CppFileSettingsForProjectWidget() { delete d; }
|
|
||||||
|
|
||||||
void CppFileSettingsForProjectWidget::Private::maybeClearHeaderSourceCache()
|
|
||||||
{
|
|
||||||
const CppFileSettings &s = settings.settings();
|
|
||||||
if (settings.useGlobalSettings() != wasGlobal
|
|
||||||
|| s.headerSearchPaths != initialSettings.headerSearchPaths
|
|
||||||
|| s.sourceSearchPaths != initialSettings.sourceSearchPaths) {
|
|
||||||
CppEditorPlugin::clearHeaderSourceCache();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
void maybeClearHeaderSourceCache()
|
||||||
|
{
|
||||||
|
const CppFileSettings &s = m_settings.settings();
|
||||||
|
if (m_settings.useGlobalSettings() != m_wasGlobal
|
||||||
|
|| s.headerSearchPaths != m_initialSettings.headerSearchPaths
|
||||||
|
|| s.sourceSearchPaths != m_initialSettings.sourceSearchPaths) {
|
||||||
|
CppEditorPlugin::clearHeaderSourceCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateSubWidgetState()
|
||||||
|
{
|
||||||
|
m_widget.setEnabled(!m_settings.useGlobalSettings());
|
||||||
|
}
|
||||||
|
|
||||||
|
CppFileSettingsForProject m_settings;
|
||||||
|
CppFileSettings m_initialSettings;
|
||||||
|
CppFileSettingsWidget m_widget;
|
||||||
|
QCheckBox m_useGlobalSettingsCheckBox;
|
||||||
|
const bool m_wasGlobal;
|
||||||
|
};
|
||||||
|
|
||||||
class CppFileSettingsProjectPanelFactory final : public ProjectPanelFactory
|
class CppFileSettingsProjectPanelFactory final : public ProjectPanelFactory
|
||||||
{
|
{
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
#include "cppeditorconstants.h"
|
#include "cppeditorconstants.h"
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
#include <projectexplorer/projectsettingswidget.h>
|
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
@@ -74,17 +73,6 @@ public:
|
|||||||
CppFileSettingsPage();
|
CppFileSettingsPage();
|
||||||
};
|
};
|
||||||
|
|
||||||
class CppFileSettingsForProjectWidget : public ProjectExplorer::ProjectSettingsWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CppFileSettingsForProjectWidget(const CppFileSettingsForProject &settings);
|
|
||||||
~CppFileSettingsForProjectWidget();
|
|
||||||
|
|
||||||
private:
|
|
||||||
class Private;
|
|
||||||
Private * const d;
|
|
||||||
};
|
|
||||||
|
|
||||||
CppFileSettings &globalCppFileSettings();
|
CppFileSettings &globalCppFileSettings();
|
||||||
|
|
||||||
void setupCppFileSettings();
|
void setupCppFileSettings();
|
||||||
|
Reference in New Issue
Block a user