aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/perfprofiler
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2020-01-27 11:39:22 +0100
committerhjk <hjk@qt.io>2020-01-28 08:50:59 +0000
commit218b6ac4910fe0ec8676063cf555e1ae20122509 (patch)
tree28be169c89a5145946b5cd5d88d5bf4ac3c42d0c /src/plugins/perfprofiler
parent56febd062c6fec20e01d9514925c6cc2ce08f246 (diff)
Perf: Move closer to now-standard option page setup
The aspect widgets need to serve two purposes (global settings, and in run configurations), but that's still possible with an IOptionPageWidget base, the in-project use simply never triggers the apply(). Change-Id: I1344a37b6dba558b950904378443682b5a068214 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/perfprofiler')
-rw-r--r--src/plugins/perfprofiler/perfconfigwidget.cpp11
-rw-r--r--src/plugins/perfprofiler/perfconfigwidget.h7
-rw-r--r--src/plugins/perfprofiler/perfoptionspage.cpp24
-rw-r--r--src/plugins/perfprofiler/perfoptionspage.h14
-rw-r--r--src/plugins/perfprofiler/perfprofilerplugin.cpp2
5 files changed, 23 insertions, 35 deletions
diff --git a/src/plugins/perfprofiler/perfconfigwidget.cpp b/src/plugins/perfprofiler/perfconfigwidget.cpp
index bdf2a0540e..6473d19d2e 100644
--- a/src/plugins/perfprofiler/perfconfigwidget.cpp
+++ b/src/plugins/perfprofiler/perfconfigwidget.cpp
@@ -62,9 +62,11 @@ public:
const QModelIndex &index) const override;
};
-PerfConfigWidget::PerfConfigWidget(PerfSettings *settings, QWidget *parent) :
- QWidget(parent), m_settings(settings), m_ui(new Ui::PerfConfigWidget)
+PerfConfigWidget::PerfConfigWidget(PerfSettings *settings, QWidget *parent)
+ : m_settings(settings), m_ui(new Ui::PerfConfigWidget)
{
+ setParent(parent);
+
m_ui->setupUi(this);
m_ui->useTracePointsButton->setVisible(false);
@@ -178,6 +180,11 @@ void PerfConfigWidget::setTracePointsButtonVisible(bool visible)
m_ui->useTracePointsButton->setVisible(visible);
}
+void PerfConfigWidget::apply()
+{
+ m_settings->writeGlobalSettings();
+}
+
void PerfConfigWidget::readTracePoints()
{
QMessageBox messageBox;
diff --git a/src/plugins/perfprofiler/perfconfigwidget.h b/src/plugins/perfprofiler/perfconfigwidget.h
index 12cb5eefe7..4ff5064db9 100644
--- a/src/plugins/perfprofiler/perfconfigwidget.h
+++ b/src/plugins/perfprofiler/perfconfigwidget.h
@@ -27,24 +27,27 @@
#include "perfsettings.h"
-#include <QWidget>
+#include <coreplugin/dialogs/ioptionspage.h>
namespace PerfProfiler {
namespace Internal {
namespace Ui { class PerfConfigWidget; }
-class PerfConfigWidget : public QWidget
+class PerfConfigWidget : public Core::IOptionsPageWidget
{
Q_OBJECT
public:
explicit PerfConfigWidget(PerfSettings *settings, QWidget *parent = nullptr);
~PerfConfigWidget();
+
void updateUi();
void setTarget(ProjectExplorer::Target *target);
void setTracePointsButtonVisible(bool visible);
private:
+ void apply() final;
+
void readTracePoints();
void handleProcessFinished();
void handleProcessError(QProcess::ProcessError error);
diff --git a/src/plugins/perfprofiler/perfoptionspage.cpp b/src/plugins/perfprofiler/perfoptionspage.cpp
index d445ecc560..4cb6e167a8 100644
--- a/src/plugins/perfprofiler/perfoptionspage.cpp
+++ b/src/plugins/perfprofiler/perfoptionspage.cpp
@@ -23,40 +23,24 @@
**
****************************************************************************/
-#include "perfconfigwidget.h"
#include "perfoptionspage.h"
+
+#include "perfconfigwidget.h"
#include "perfprofilerconstants.h"
-#include "perfprofilerplugin.h"
#include <debugger/analyzer/analyzericons.h>
namespace PerfProfiler {
namespace Internal {
-PerfOptionsPage::PerfOptionsPage()
+PerfOptionsPage::PerfOptionsPage(PerfSettings *settings)
{
setId(Constants::PerfSettingsId);
setDisplayName(QCoreApplication::translate("PerfProfiler::PerfOptionsPage", "CPU Usage"));
setCategory("T.Analyzer");
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer"));
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
-}
-
-QWidget *PerfOptionsPage::widget()
-{
- if (!m_widget)
- m_widget = new PerfConfigWidget(PerfProfilerPlugin::globalSettings());
- return m_widget;
-}
-
-void PerfOptionsPage::apply()
-{
- PerfProfilerPlugin::globalSettings()->writeGlobalSettings();
-}
-
-void PerfOptionsPage::finish()
-{
- delete m_widget;
+ setWidgetCreator([settings] { return new PerfConfigWidget(settings); });
}
} // namespace Internal
diff --git a/src/plugins/perfprofiler/perfoptionspage.h b/src/plugins/perfprofiler/perfoptionspage.h
index febde556e0..c873fc8f7e 100644
--- a/src/plugins/perfprofiler/perfoptionspage.h
+++ b/src/plugins/perfprofiler/perfoptionspage.h
@@ -27,23 +27,17 @@
#include <coreplugin/dialogs/ioptionspage.h>
-#include <QPointer>
-
namespace PerfProfiler {
+
+class PerfSettings;
+
namespace Internal {
class PerfOptionsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
- PerfOptionsPage();
-
- QWidget *widget();
- void apply();
- void finish();
-
-private:
- QPointer<QWidget> m_widget;
+ explicit PerfOptionsPage(PerfSettings *settings);
};
} // namespace Internal
diff --git a/src/plugins/perfprofiler/perfprofilerplugin.cpp b/src/plugins/perfprofiler/perfprofilerplugin.cpp
index 03d1de8eaf..d66a12a500 100644
--- a/src/plugins/perfprofiler/perfprofilerplugin.cpp
+++ b/src/plugins/perfprofiler/perfprofilerplugin.cpp
@@ -73,7 +73,7 @@ public:
{ProjectExplorer::Constants::PERFPROFILER_RUN_MODE}
};
- PerfOptionsPage optionsPage;
+ PerfOptionsPage optionsPage{perfGlobalSettings()};
PerfProfilerTool profilerTool;
};