forked from qt-creator/qt-creator
Valgrind: Apply new SettingsPage patterns
Change-Id: I7b2c7cf06ed79926fbbd00d4df479c0e0a7da249 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -30,12 +30,13 @@
|
||||
|
||||
#include "ui_valgrindconfigwidget.h"
|
||||
|
||||
#include <debugger/analyzer/analyzericons.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <QStandardItemModel>
|
||||
#include <QFileDialog>
|
||||
|
||||
@@ -44,7 +45,39 @@
|
||||
namespace Valgrind {
|
||||
namespace Internal {
|
||||
|
||||
ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings, bool global)
|
||||
class ValgrindBaseSettings;
|
||||
|
||||
class ValgrindConfigWidget : public Core::IOptionsPageWidget
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Valgrind::Internal::ValgrindConfigWidget)
|
||||
|
||||
public:
|
||||
explicit ValgrindConfigWidget(ValgrindBaseSettings *settings);
|
||||
~ValgrindConfigWidget() override;
|
||||
|
||||
void apply() final
|
||||
{
|
||||
ValgrindGlobalSettings::instance()->writeSettings();
|
||||
}
|
||||
|
||||
void setSuppressions(const QStringList &files);
|
||||
QStringList suppressions() const;
|
||||
|
||||
void slotAddSuppression();
|
||||
void slotRemoveSuppression();
|
||||
void slotSuppressionsRemoved(const QStringList &files);
|
||||
void slotSuppressionsAdded(const QStringList &files);
|
||||
void slotSuppressionSelectionChanged();
|
||||
|
||||
private:
|
||||
void updateUi();
|
||||
|
||||
ValgrindBaseSettings *m_settings;
|
||||
Ui::ValgrindConfigWidget *m_ui;
|
||||
QStandardItemModel *m_model;
|
||||
};
|
||||
|
||||
ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings)
|
||||
: m_settings(settings),
|
||||
m_ui(new Ui::ValgrindConfigWidget)
|
||||
{
|
||||
@@ -149,7 +182,7 @@ ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings, bool
|
||||
this, &ValgrindConfigWidget::slotSuppressionSelectionChanged);
|
||||
slotSuppressionSelectionChanged();
|
||||
|
||||
if (!global) {
|
||||
if (settings != ValgrindGlobalSettings::instance()) {
|
||||
// In project settings we want a flat vertical list.
|
||||
auto l = new QVBoxLayout;
|
||||
while (layout()->count()) {
|
||||
@@ -268,5 +301,22 @@ void ValgrindConfigWidget::slotSuppressionSelectionChanged()
|
||||
m_ui->removeSuppression->setEnabled(m_ui->suppressionList->selectionModel()->hasSelection());
|
||||
}
|
||||
|
||||
// ValgrindOptionsPage
|
||||
|
||||
ValgrindOptionsPage::ValgrindOptionsPage()
|
||||
{
|
||||
setId(ANALYZER_VALGRIND_SETTINGS);
|
||||
setDisplayName(ValgrindConfigWidget::tr("Valgrind"));
|
||||
setCategory("T.Analyzer");
|
||||
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer"));
|
||||
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
|
||||
setWidgetCreator([] { return new ValgrindConfigWidget(ValgrindGlobalSettings::instance()); });
|
||||
}
|
||||
|
||||
QWidget *ValgrindOptionsPage::createSettingsWidget(ValgrindBaseSettings *settings)
|
||||
{
|
||||
return new ValgrindConfigWidget(settings);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Valgrind
|
||||
|
||||
@@ -26,42 +26,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QStandardItemModel;
|
||||
QT_END_NAMESPACE
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
namespace Valgrind {
|
||||
namespace Internal {
|
||||
|
||||
namespace Ui { class ValgrindConfigWidget; }
|
||||
|
||||
class ValgrindBaseSettings;
|
||||
|
||||
class ValgrindConfigWidget : public QWidget
|
||||
class ValgrindOptionsPage : public Core::IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ValgrindConfigWidget(ValgrindBaseSettings *settings, bool global);
|
||||
~ValgrindConfigWidget() override;
|
||||
ValgrindOptionsPage();
|
||||
|
||||
void setSuppressions(const QStringList &files);
|
||||
QStringList suppressions() const;
|
||||
|
||||
void slotAddSuppression();
|
||||
void slotRemoveSuppression();
|
||||
void slotSuppressionsRemoved(const QStringList &files);
|
||||
void slotSuppressionsAdded(const QStringList &files);
|
||||
void slotSuppressionSelectionChanged();
|
||||
|
||||
private:
|
||||
void updateUi();
|
||||
|
||||
ValgrindBaseSettings *m_settings;
|
||||
Ui::ValgrindConfigWidget *m_ui;
|
||||
QStandardItemModel *m_model;
|
||||
static QWidget *createSettingsWidget(class ValgrindBaseSettings *settings);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -53,40 +53,6 @@ using namespace ProjectExplorer;
|
||||
namespace Valgrind {
|
||||
namespace Internal {
|
||||
|
||||
class ValgrindOptionsPage : public IOptionsPage
|
||||
{
|
||||
public:
|
||||
explicit ValgrindOptionsPage(QObject *parent)
|
||||
: IOptionsPage(parent)
|
||||
{
|
||||
setId(ANALYZER_VALGRIND_SETTINGS);
|
||||
setDisplayName(QCoreApplication::translate("Valgrind::Internal::ValgrindOptionsPage", "Valgrind"));
|
||||
setCategory("T.Analyzer");
|
||||
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer"));
|
||||
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
|
||||
}
|
||||
|
||||
QWidget *widget() override
|
||||
{
|
||||
if (!m_widget)
|
||||
m_widget = new ValgrindConfigWidget(ValgrindGlobalSettings::instance(), true);
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
void apply() override
|
||||
{
|
||||
ValgrindGlobalSettings::instance()->writeSettings();
|
||||
}
|
||||
|
||||
void finish() override
|
||||
{
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
private:
|
||||
QPointer<QWidget> m_widget;
|
||||
};
|
||||
|
||||
class ValgrindRunConfigurationAspect : public GlobalOrProjectAspect
|
||||
{
|
||||
public:
|
||||
@@ -109,6 +75,7 @@ public:
|
||||
ValgrindGlobalSettings valgrindGlobalSettings; // Needs to come before the tools.
|
||||
MemcheckTool memcheckTool;
|
||||
CallgrindTool callgrindTool;
|
||||
ValgrindOptionsPage valgrindOptionsPage;
|
||||
};
|
||||
|
||||
ValgrindPlugin::~ValgrindPlugin()
|
||||
@@ -120,8 +87,6 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
{
|
||||
d = new ValgrindPluginPrivate;
|
||||
|
||||
new ValgrindOptionsPage(this);
|
||||
|
||||
RunConfiguration::registerAspect<ValgrindRunConfigurationAspect>();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -305,7 +305,7 @@ ValgrindGlobalSettings::ValgrindGlobalSettings()
|
||||
{
|
||||
theGlobalSettings = this;
|
||||
|
||||
setConfigWidgetCreator([this] { return new ValgrindConfigWidget(this, true); });
|
||||
setConfigWidgetCreator([this] { return ValgrindOptionsPage::createSettingsWidget(this); });
|
||||
readSettings();
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ void ValgrindGlobalSettings::setShortenTemplates(bool on)
|
||||
|
||||
ValgrindProjectSettings::ValgrindProjectSettings()
|
||||
{
|
||||
setConfigWidgetCreator([this] { return new ValgrindConfigWidget(this, false); });
|
||||
setConfigWidgetCreator([this] { return ValgrindOptionsPage::createSettingsWidget(this); });
|
||||
}
|
||||
|
||||
void ValgrindProjectSettings::fromMap(const QVariantMap &map)
|
||||
|
||||
Reference in New Issue
Block a user