forked from qt-creator/qt-creator
QmlProfiler: Move to new settings setup also for project settings
Change-Id: I204f052ddbc2956ff3bca8e6faaf2f758e4fee17 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -86,11 +86,13 @@ GlobalOrProjectAspect::~GlobalOrProjectAspect()
|
||||
void GlobalOrProjectAspect::setProjectSettings(ISettingsAspect *settings)
|
||||
{
|
||||
m_projectSettings = settings;
|
||||
m_projectSettings->setAutoApply(true);
|
||||
}
|
||||
|
||||
void GlobalOrProjectAspect::setGlobalSettings(ISettingsAspect *settings)
|
||||
{
|
||||
m_globalSettings = settings;
|
||||
m_projectSettings->setAutoApply(false);
|
||||
}
|
||||
|
||||
void GlobalOrProjectAspect::setUsingGlobalSettings(bool value)
|
||||
|
@@ -53,13 +53,10 @@ using namespace ProjectExplorer;
|
||||
|
||||
namespace QmlProfiler::Internal {
|
||||
|
||||
Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings)
|
||||
|
||||
class QmlProfilerPluginPrivate
|
||||
{
|
||||
public:
|
||||
QmlProfilerTool m_profilerTool;
|
||||
QmlProfilerOptionsPage m_profilerOptionsPage;
|
||||
QmlProfilerActions m_actions;
|
||||
|
||||
// The full local profiler.
|
||||
@@ -119,9 +116,4 @@ ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown()
|
||||
return SynchronousShutdown;
|
||||
}
|
||||
|
||||
QmlProfilerSettings *QmlProfilerPlugin::globalSettings()
|
||||
{
|
||||
return qmlProfilerGlobalSettings();
|
||||
}
|
||||
|
||||
} // QmlProfiler::Internal
|
||||
|
@@ -7,16 +7,11 @@
|
||||
|
||||
namespace QmlProfiler::Internal {
|
||||
|
||||
class QmlProfilerSettings;
|
||||
|
||||
class QmlProfilerPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlProfiler.json")
|
||||
|
||||
public:
|
||||
static QmlProfilerSettings *globalSettings();
|
||||
|
||||
private:
|
||||
bool initialize(const QStringList &arguments, QString *errorString) final;
|
||||
void extensionsInitialized() final;
|
||||
|
@@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qmlprofilerconstants.h"
|
||||
#include "qmlprofilerplugin.h"
|
||||
#include "qmlprofilerrunconfigurationaspect.h"
|
||||
|
||||
#include "qmlprofilerconstants.h"
|
||||
#include "qmlprofilersettings.h"
|
||||
#include "qmlprofilertr.h"
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace QmlProfiler::Internal {
|
||||
QmlProfilerRunConfigurationAspect::QmlProfilerRunConfigurationAspect(ProjectExplorer::Target *)
|
||||
{
|
||||
setProjectSettings(new QmlProfilerSettings);
|
||||
setGlobalSettings(QmlProfilerPlugin::globalSettings());
|
||||
setGlobalSettings(&Internal::globalSettings());
|
||||
setId(Constants::SETTINGS);
|
||||
setDisplayName(Tr::tr("QML Profiler Settings"));
|
||||
setUsingGlobalSettings(true);
|
||||
|
@@ -1,50 +1,33 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qmlprofilerconstants.h"
|
||||
#include "qmlprofilerplugin.h"
|
||||
#include "qmlprofilersettings.h"
|
||||
|
||||
#include "qmlprofilerconstants.h"
|
||||
#include "qmlprofilertr.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <debugger/analyzer/analyzericons.h>
|
||||
#include <debugger/debuggertr.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace QmlProfiler::Internal {
|
||||
|
||||
class QmlProfilerOptionsPageWidget : public Core::IOptionsPageWidget
|
||||
QmlProfilerSettings &globalSettings()
|
||||
{
|
||||
public:
|
||||
explicit QmlProfilerOptionsPageWidget(QmlProfilerSettings *settings)
|
||||
{
|
||||
QmlProfilerSettings &s = *settings;
|
||||
|
||||
using namespace Layouting;
|
||||
Form {
|
||||
s.flushEnabled, br,
|
||||
s.flushInterval, br,
|
||||
s.aggregateTraces, br,
|
||||
}.attachTo(this);
|
||||
}
|
||||
|
||||
void apply() final
|
||||
{
|
||||
QmlProfilerPlugin::globalSettings()->writeGlobalSettings();
|
||||
}
|
||||
};
|
||||
static QmlProfilerSettings theSettings;
|
||||
return theSettings;
|
||||
}
|
||||
|
||||
QmlProfilerSettings::QmlProfilerSettings()
|
||||
{
|
||||
setConfigWidgetCreator([this] { return new QmlProfilerOptionsPageWidget(this); });
|
||||
|
||||
setAutoApply(false);
|
||||
setSettingsGroup(Constants::ANALYZER);
|
||||
|
||||
registerAspect(&flushEnabled);
|
||||
flushEnabled.setSettingsKey("Analyzer.QmlProfiler.FlushEnabled");
|
||||
flushEnabled.setLabelPlacement(BoolAspect::LabelPlacement::InExtraLabel);
|
||||
flushEnabled.setLabelText(Tr::tr("Flush data while profiling:"));
|
||||
@@ -53,17 +36,14 @@ QmlProfilerSettings::QmlProfilerSettings()
|
||||
"data and the memory usage in the application. It distorts the profile as the flushing\n"
|
||||
"itself takes time."));
|
||||
|
||||
registerAspect(&flushInterval);
|
||||
flushInterval.setSettingsKey("Analyzer.QmlProfiler.FlushInterval");
|
||||
flushInterval.setRange(1, 10000000);
|
||||
flushInterval.setDefaultValue(1000);
|
||||
flushInterval.setLabelText(Tr::tr("Flush interval (ms):"));
|
||||
flushInterval.setEnabler(&flushEnabled);
|
||||
|
||||
registerAspect(&lastTraceFile);
|
||||
lastTraceFile.setSettingsKey("Analyzer.QmlProfiler.LastTraceFile");
|
||||
|
||||
registerAspect(&aggregateTraces);
|
||||
aggregateTraces.setSettingsKey("Analyzer.QmlProfiler.AggregateTraces");
|
||||
aggregateTraces.setLabelPlacement(BoolAspect::LabelPlacement::InExtraLabel);
|
||||
aggregateTraces.setLabelText(Tr::tr("Process data only when process ends:"));
|
||||
@@ -73,27 +53,36 @@ QmlProfilerSettings::QmlProfilerSettings()
|
||||
"for example if multiple QML engines start and stop sequentially during a single run of\n"
|
||||
"the program."));
|
||||
|
||||
// Read stored values
|
||||
setLayouter([this] {
|
||||
using namespace Layouting;
|
||||
return Form {
|
||||
flushEnabled, br,
|
||||
flushInterval, br,
|
||||
aggregateTraces, br,
|
||||
};
|
||||
});
|
||||
|
||||
setConfigWidgetCreator([this] { return layouter()().emerge(); });
|
||||
|
||||
readSettings();
|
||||
}
|
||||
|
||||
void QmlProfilerSettings::writeGlobalSettings() const
|
||||
{
|
||||
writeSettings();
|
||||
}
|
||||
// QmlProfilerSettingsPage
|
||||
|
||||
// QmlProfilerOptionsPage
|
||||
|
||||
QmlProfilerOptionsPage::QmlProfilerOptionsPage()
|
||||
class QmlProfilerSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
QmlProfilerSettingsPage()
|
||||
{
|
||||
setId(Constants::SETTINGS);
|
||||
setDisplayName(Tr::tr("QML Profiler"));
|
||||
setCategory("T.Analyzer");
|
||||
setDisplayCategory(::Debugger::Tr::tr("Analyzer"));
|
||||
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
|
||||
setWidgetCreator([] {
|
||||
return new QmlProfilerOptionsPageWidget(QmlProfilerPlugin::globalSettings());
|
||||
});
|
||||
}
|
||||
setSettingsProvider([] { return &globalSettings(); });
|
||||
}
|
||||
};
|
||||
|
||||
const QmlProfilerSettingsPage settingsPage;
|
||||
|
||||
} // QmlProfiler::Internal
|
||||
|
@@ -3,8 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
namespace QmlProfiler::Internal {
|
||||
@@ -14,18 +12,12 @@ class QmlProfilerSettings : public ProjectExplorer::ISettingsAspect
|
||||
public:
|
||||
QmlProfilerSettings();
|
||||
|
||||
void writeGlobalSettings() const;
|
||||
|
||||
Utils::BoolAspect flushEnabled;
|
||||
Utils::IntegerAspect flushInterval;
|
||||
Utils::FilePathAspect lastTraceFile;
|
||||
Utils::BoolAspect aggregateTraces;
|
||||
Utils::BoolAspect flushEnabled{this};
|
||||
Utils::IntegerAspect flushInterval{this};
|
||||
Utils::FilePathAspect lastTraceFile{this};
|
||||
Utils::BoolAspect aggregateTraces{this};
|
||||
};
|
||||
|
||||
class QmlProfilerOptionsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
QmlProfilerOptionsPage();
|
||||
};
|
||||
QmlProfilerSettings &globalSettings();
|
||||
|
||||
} // QmlProfiler::Internal
|
||||
|
@@ -566,10 +566,10 @@ void QmlProfilerTool::showErrorDialog(const QString &error)
|
||||
|
||||
static void saveLastTraceFile(const FilePath &filePath)
|
||||
{
|
||||
QmlProfilerSettings *settings = QmlProfilerPlugin::globalSettings();
|
||||
if (filePath != settings->lastTraceFile()) {
|
||||
settings->lastTraceFile.setValue(filePath);
|
||||
settings->writeGlobalSettings();
|
||||
QmlProfilerSettings &s = globalSettings();
|
||||
if (filePath != s.lastTraceFile()) {
|
||||
s.lastTraceFile.setValue(filePath);
|
||||
s.writeSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ void QmlProfilerTool::showSaveDialog()
|
||||
QLatin1String zFile(QztFileExtension);
|
||||
FilePath filePath = FileUtils::getSaveFilePath(
|
||||
nullptr, Tr::tr("Save QML Trace"),
|
||||
QmlProfilerPlugin::globalSettings()->lastTraceFile(),
|
||||
globalSettings().lastTraceFile(),
|
||||
Tr::tr("QML traces (*%1 *%2)").arg(zFile).arg(tFile));
|
||||
if (!filePath.isEmpty()) {
|
||||
if (!filePath.endsWith(zFile) && !filePath.endsWith(tFile))
|
||||
@@ -603,7 +603,7 @@ void QmlProfilerTool::showLoadDialog()
|
||||
QLatin1String zFile(QztFileExtension);
|
||||
FilePath filePath = FileUtils::getOpenFilePath(
|
||||
nullptr, Tr::tr("Load QML Trace"),
|
||||
QmlProfilerPlugin::globalSettings()->lastTraceFile(),
|
||||
globalSettings().lastTraceFile(),
|
||||
Tr::tr("QML traces (*%1 *%2)").arg(zFile).arg(tFile));
|
||||
|
||||
if (!filePath.isEmpty()) {
|
||||
|
Reference in New Issue
Block a user