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 "ui_valgrindconfigwidget.h"
|
||||||
|
|
||||||
|
#include <debugger/analyzer/analyzericons.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
@@ -44,7 +45,39 @@
|
|||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Internal {
|
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_settings(settings),
|
||||||
m_ui(new Ui::ValgrindConfigWidget)
|
m_ui(new Ui::ValgrindConfigWidget)
|
||||||
{
|
{
|
||||||
@@ -149,7 +182,7 @@ ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings, bool
|
|||||||
this, &ValgrindConfigWidget::slotSuppressionSelectionChanged);
|
this, &ValgrindConfigWidget::slotSuppressionSelectionChanged);
|
||||||
slotSuppressionSelectionChanged();
|
slotSuppressionSelectionChanged();
|
||||||
|
|
||||||
if (!global) {
|
if (settings != ValgrindGlobalSettings::instance()) {
|
||||||
// In project settings we want a flat vertical list.
|
// In project settings we want a flat vertical list.
|
||||||
auto l = new QVBoxLayout;
|
auto l = new QVBoxLayout;
|
||||||
while (layout()->count()) {
|
while (layout()->count()) {
|
||||||
@@ -268,5 +301,22 @@ void ValgrindConfigWidget::slotSuppressionSelectionChanged()
|
|||||||
m_ui->removeSuppression->setEnabled(m_ui->suppressionList->selectionModel()->hasSelection());
|
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 Internal
|
||||||
} // namespace Valgrind
|
} // namespace Valgrind
|
||||||
|
|||||||
@@ -26,42 +26,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QStandardItemModel;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
namespace Ui { class ValgrindConfigWidget; }
|
class ValgrindOptionsPage : public Core::IOptionsPage
|
||||||
|
|
||||||
class ValgrindBaseSettings;
|
|
||||||
|
|
||||||
class ValgrindConfigWidget : public QWidget
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ValgrindConfigWidget(ValgrindBaseSettings *settings, bool global);
|
ValgrindOptionsPage();
|
||||||
~ValgrindConfigWidget() override;
|
|
||||||
|
|
||||||
void setSuppressions(const QStringList &files);
|
static QWidget *createSettingsWidget(class ValgrindBaseSettings *settings);
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -53,40 +53,6 @@ using namespace ProjectExplorer;
|
|||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Internal {
|
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
|
class ValgrindRunConfigurationAspect : public GlobalOrProjectAspect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -109,6 +75,7 @@ public:
|
|||||||
ValgrindGlobalSettings valgrindGlobalSettings; // Needs to come before the tools.
|
ValgrindGlobalSettings valgrindGlobalSettings; // Needs to come before the tools.
|
||||||
MemcheckTool memcheckTool;
|
MemcheckTool memcheckTool;
|
||||||
CallgrindTool callgrindTool;
|
CallgrindTool callgrindTool;
|
||||||
|
ValgrindOptionsPage valgrindOptionsPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
ValgrindPlugin::~ValgrindPlugin()
|
ValgrindPlugin::~ValgrindPlugin()
|
||||||
@@ -120,8 +87,6 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
|||||||
{
|
{
|
||||||
d = new ValgrindPluginPrivate;
|
d = new ValgrindPluginPrivate;
|
||||||
|
|
||||||
new ValgrindOptionsPage(this);
|
|
||||||
|
|
||||||
RunConfiguration::registerAspect<ValgrindRunConfigurationAspect>();
|
RunConfiguration::registerAspect<ValgrindRunConfigurationAspect>();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ ValgrindGlobalSettings::ValgrindGlobalSettings()
|
|||||||
{
|
{
|
||||||
theGlobalSettings = this;
|
theGlobalSettings = this;
|
||||||
|
|
||||||
setConfigWidgetCreator([this] { return new ValgrindConfigWidget(this, true); });
|
setConfigWidgetCreator([this] { return ValgrindOptionsPage::createSettingsWidget(this); });
|
||||||
readSettings();
|
readSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,7 +494,7 @@ void ValgrindGlobalSettings::setShortenTemplates(bool on)
|
|||||||
|
|
||||||
ValgrindProjectSettings::ValgrindProjectSettings()
|
ValgrindProjectSettings::ValgrindProjectSettings()
|
||||||
{
|
{
|
||||||
setConfigWidgetCreator([this] { return new ValgrindConfigWidget(this, false); });
|
setConfigWidgetCreator([this] { return ValgrindOptionsPage::createSettingsWidget(this); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValgrindProjectSettings::fromMap(const QVariantMap &map)
|
void ValgrindProjectSettings::fromMap(const QVariantMap &map)
|
||||||
|
|||||||
Reference in New Issue
Block a user