2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2015-08-28 12:50:46 +02:00
|
|
|
|
|
|
|
|
#include "qmlprofilersettings.h"
|
2021-04-06 16:44:18 +02:00
|
|
|
|
2015-08-28 12:50:46 +02:00
|
|
|
#include "qmlprofilerconstants.h"
|
2021-04-06 16:44:18 +02:00
|
|
|
#include "qmlprofilerplugin.h"
|
2015-08-28 12:50:46 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
2021-04-06 16:44:18 +02:00
|
|
|
#include <debugger/analyzer/analyzericons.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
|
2015-08-28 12:50:46 +02:00
|
|
|
#include <QSettings>
|
|
|
|
|
|
2021-04-06 16:44:18 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2015-08-28 12:50:46 +02:00
|
|
|
namespace QmlProfiler {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2021-04-06 16:44:18 +02:00
|
|
|
static QWidget *createQmlConfigWidget(QmlProfilerSettings *settings)
|
2015-08-28 12:50:46 +02:00
|
|
|
{
|
2021-04-06 16:44:18 +02:00
|
|
|
QmlProfilerSettings &s = *settings;
|
|
|
|
|
using namespace Layouting;
|
|
|
|
|
|
|
|
|
|
return Form {
|
|
|
|
|
s.flushEnabled,
|
|
|
|
|
s.flushInterval,
|
|
|
|
|
s.aggregateTraces
|
|
|
|
|
}.emerge();
|
2015-08-28 12:50:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-06 16:44:18 +02:00
|
|
|
QmlProfilerSettings::QmlProfilerSettings()
|
2015-08-28 12:50:46 +02:00
|
|
|
{
|
2021-04-06 16:44:18 +02:00
|
|
|
setConfigWidgetCreator([this] { return createQmlConfigWidget(this); });
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
setSettingsGroup(Constants::ANALYZER);
|
2021-04-06 16:44:18 +02:00
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&flushEnabled);
|
2021-04-06 16:44:18 +02:00
|
|
|
flushEnabled.setSettingsKey("Analyzer.QmlProfiler.FlushEnabled");
|
|
|
|
|
flushEnabled.setLabelPlacement(BoolAspect::LabelPlacement::InExtraLabel);
|
|
|
|
|
flushEnabled.setLabelText(tr("Flush data while profiling:"));
|
|
|
|
|
flushEnabled.setToolTip(tr(
|
|
|
|
|
"Periodically flush pending data to the profiler. This reduces the delay when loading the\n"
|
|
|
|
|
"data and the memory usage in the application. It distorts the profile as the flushing\n"
|
|
|
|
|
"itself takes time."));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&flushInterval);
|
2021-04-06 16:44:18 +02:00
|
|
|
flushInterval.setSettingsKey("Analyzer.QmlProfiler.FlushInterval");
|
|
|
|
|
flushInterval.setRange(1, 10000000);
|
|
|
|
|
flushInterval.setDefaultValue(1000);
|
2021-04-12 13:43:24 +02:00
|
|
|
flushInterval.setLabelText(tr("Flush interval (ms):"));
|
|
|
|
|
flushInterval.setEnabler(&flushEnabled);
|
2021-04-06 16:44:18 +02:00
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&lastTraceFile);
|
2021-04-06 16:44:18 +02:00
|
|
|
lastTraceFile.setSettingsKey("Analyzer.QmlProfiler.LastTraceFile");
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&aggregateTraces);
|
2021-04-06 16:44:18 +02:00
|
|
|
aggregateTraces.setSettingsKey("Analyzer.QmlProfiler.AggregateTraces");
|
|
|
|
|
aggregateTraces.setLabelPlacement(BoolAspect::LabelPlacement::InExtraLabel);
|
|
|
|
|
aggregateTraces.setLabelText(tr("Process data only when process ends:"));
|
|
|
|
|
aggregateTraces.setToolTip(tr(
|
|
|
|
|
"Only process data when the process being profiled ends, not when the current recording\n"
|
|
|
|
|
"session ends. This way multiple recording sessions can be aggregated in a single trace,\n"
|
|
|
|
|
"for example if multiple QML engines start and stop sequentially during a single run of\n"
|
|
|
|
|
"the program."));
|
|
|
|
|
|
|
|
|
|
// Read stored values
|
2021-04-06 18:35:27 +02:00
|
|
|
readSettings(Core::ICore::settings());
|
2015-08-28 12:50:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-06 16:44:18 +02:00
|
|
|
void QmlProfilerSettings::writeGlobalSettings() const
|
2015-08-28 12:50:46 +02:00
|
|
|
{
|
2021-04-06 18:35:27 +02:00
|
|
|
writeSettings(Core::ICore::settings());
|
2015-08-28 12:50:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-06 16:44:18 +02:00
|
|
|
// QmlProfilerOptionsPage
|
2015-11-18 12:34:52 +01:00
|
|
|
|
2021-04-06 16:44:18 +02:00
|
|
|
QmlProfilerOptionsPage::QmlProfilerOptionsPage()
|
2015-11-18 12:34:52 +01:00
|
|
|
{
|
2021-04-06 16:44:18 +02:00
|
|
|
setId(Constants::SETTINGS);
|
|
|
|
|
setDisplayName(QmlProfilerSettings::tr("QML Profiler"));
|
|
|
|
|
setCategory("T.Analyzer");
|
|
|
|
|
setDisplayCategory(QmlProfilerSettings::tr("Analyzer"));
|
|
|
|
|
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
|
2015-11-18 12:34:52 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-06 16:44:18 +02:00
|
|
|
QWidget *QmlProfilerOptionsPage::widget()
|
2015-08-28 12:50:46 +02:00
|
|
|
{
|
2021-04-06 16:44:18 +02:00
|
|
|
// We cannot parent the widget to the options page as it expects a QWidget as parent
|
|
|
|
|
if (!m_widget)
|
|
|
|
|
m_widget = createQmlConfigWidget(QmlProfilerPlugin::globalSettings());
|
|
|
|
|
return m_widget;
|
2015-08-28 12:50:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-06 16:44:18 +02:00
|
|
|
void QmlProfilerOptionsPage::apply()
|
2015-08-28 12:50:46 +02:00
|
|
|
{
|
2021-04-06 16:44:18 +02:00
|
|
|
QmlProfilerPlugin::globalSettings()->writeGlobalSettings();
|
2015-08-28 12:50:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-06 16:44:18 +02:00
|
|
|
void QmlProfilerOptionsPage::finish()
|
2015-08-28 12:50:46 +02:00
|
|
|
{
|
2021-04-06 16:44:18 +02:00
|
|
|
delete m_widget;
|
2015-08-28 12:50:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // QmlProfiler
|