forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -73,7 +73,7 @@ public:
|
||||
{ProjectExplorer::Constants::PERFPROFILER_RUN_MODE}
|
||||
};
|
||||
|
||||
PerfOptionsPage optionsPage;
|
||||
PerfOptionsPage optionsPage{perfGlobalSettings()};
|
||||
PerfProfilerTool profilerTool;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user