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