QmlProfiler: Aspectify settings

Only four simple values.

Adapting qmlprofilerconfigwidget_test did not seem desirable,
as in the aspectified state this is hidden in the base aspects
implementations.

Change-Id: I933a8ca065169c61b7f25f109e0b7a0e6d21cb33
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-04-06 16:44:18 +02:00
parent b88b73d9c1
commit 8eb74080ab
17 changed files with 120 additions and 714 deletions

View File

@@ -17,17 +17,15 @@ add_qtc_plugin(QmlProfiler
qmlprofiler_global.h
qmlprofileractions.cpp qmlprofileractions.h
qmlprofileranimationsmodel.cpp qmlprofileranimationsmodel.h
qmlprofilerattachdialog.cpp qmlprofilerattachdialog.h qmlprofilerattachdialog.ui
qmlprofilerattachdialog.cpp qmlprofilerattachdialog.h
qmlprofilerbindingloopsrenderpass.cpp qmlprofilerbindingloopsrenderpass.h
qmlprofilerclientmanager.cpp qmlprofilerclientmanager.h
qmlprofilerconfigwidget.cpp qmlprofilerconfigwidget.h qmlprofilerconfigwidget.ui
qmlprofilerconstants.h
qmlprofilerdetailsrewriter.cpp qmlprofilerdetailsrewriter.h
qmlprofilereventsview.h
qmlprofilereventtypes.h
qmlprofilermodelmanager.cpp qmlprofilermodelmanager.h
qmlprofilernotesmodel.cpp qmlprofilernotesmodel.h
qmlprofileroptionspage.cpp qmlprofileroptionspage.h
qmlprofilerplugin.cpp qmlprofilerplugin.h
qmlprofilerrangemodel.cpp qmlprofilerrangemodel.h
qmlprofilerrunconfigurationaspect.cpp qmlprofilerrunconfigurationaspect.h
@@ -67,7 +65,6 @@ extend_qtc_plugin(QmlProfiler
tests/qmlprofilerattachdialog_test.cpp tests/qmlprofilerattachdialog_test.h
tests/qmlprofilerbindingloopsrenderpass_test.cpp tests/qmlprofilerbindingloopsrenderpass_test.h
tests/qmlprofilerclientmanager_test.cpp tests/qmlprofilerclientmanager_test.h
tests/qmlprofilerconfigwidget_test.cpp tests/qmlprofilerconfigwidget_test.h
tests/qmlprofilerdetailsrewriter_test.cpp tests/qmlprofilerdetailsrewriter_test.h
tests/qmlprofilertool_test.cpp tests/qmlprofilertool_test.h
tests/qmlprofilertraceclient_test.cpp tests/qmlprofilertraceclient_test.h

View File

@@ -20,11 +20,9 @@ SOURCES += \
qmlprofilerattachdialog.cpp \
qmlprofilerbindingloopsrenderpass.cpp \
qmlprofilerclientmanager.cpp \
qmlprofilerconfigwidget.cpp \
qmlprofilerdetailsrewriter.cpp \
qmlprofilermodelmanager.cpp \
qmlprofilernotesmodel.cpp \
qmlprofileroptionspage.cpp \
qmlprofilerplugin.cpp \
qmlprofilerrangemodel.cpp \
qmlprofilerrunconfigurationaspect.cpp \
@@ -61,14 +59,12 @@ HEADERS += \
qmlprofilerattachdialog.h \
qmlprofilerbindingloopsrenderpass.h \
qmlprofilerclientmanager.h \
qmlprofilerconfigwidget.h \
qmlprofilerconstants.h \
qmlprofilerdetailsrewriter.h \
qmlprofilereventsview.h \
qmlprofilereventtypes.h \
qmlprofilermodelmanager.h \
qmlprofilernotesmodel.h \
qmlprofileroptionspage.h \
qmlprofilerplugin.h \
qmlprofilerrangemodel.h \
qmlprofilerrunconfigurationaspect.h \
@@ -91,9 +87,6 @@ HEADERS += \
RESOURCES += \
qml/qmlprofiler.qrc
FORMS += \
qmlprofilerconfigwidget.ui
equals(TEST, 1) {
include(tests/tests.pri)
}

View File

@@ -36,14 +36,12 @@ QtcPlugin {
"qmlprofilerattachdialog.cpp", "qmlprofilerattachdialog.h",
"qmlprofilerbindingloopsrenderpass.cpp","qmlprofilerbindingloopsrenderpass.h",
"qmlprofilerclientmanager.cpp", "qmlprofilerclientmanager.h",
"qmlprofilerconfigwidget.cpp", "qmlprofilerconfigwidget.h",
"qmlprofilerconfigwidget.ui", "qmlprofilerconstants.h",
"qmlprofilerconstants.h",
"qmlprofilerdetailsrewriter.cpp", "qmlprofilerdetailsrewriter.h",
"qmlprofilereventsview.h",
"qmlprofilereventtypes.h",
"qmlprofilermodelmanager.cpp", "qmlprofilermodelmanager.h",
"qmlprofilernotesmodel.cpp", "qmlprofilernotesmodel.h",
"qmlprofileroptionspage.cpp", "qmlprofileroptionspage.h",
"qmlprofilerplugin.cpp", "qmlprofilerplugin.h",
"qmlprofilerrunconfigurationaspect.cpp", "qmlprofilerrunconfigurationaspect.h",
"qmlprofilerrangemodel.cpp", "qmlprofilerrangemodel.h",
@@ -93,7 +91,6 @@ QtcPlugin {
"qmlprofilerbindingloopsrenderpass_test.cpp",
"qmlprofilerbindingloopsrenderpass_test.h",
"qmlprofilerclientmanager_test.cpp", "qmlprofilerclientmanager_test.h",
"qmlprofilerconfigwidget_test.cpp", "qmlprofilerconfigwidget_test.h",
"qmlprofilerdetailsrewriter_test.cpp", "qmlprofilerdetailsrewriter_test.h",
"qmlprofilertool_test.cpp", "qmlprofilertool_test.h",
"qmlprofilertraceclient_test.cpp", "qmlprofilertraceclient_test.h",

View File

@@ -1,129 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QmlProfiler::Internal::QmlProfilerAttachDialog</class>
<widget class="QDialog" name="QmlProfiler::Internal::QmlProfilerAttachDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>203</width>
<height>136</height>
</rect>
</property>
<property name="windowTitle">
<string>QML Profiler</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="addressLabel">
<property name="text">
<string>&amp;Host:</string>
</property>
<property name="buddy">
<cstring>addressLineEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="addressLineEdit">
<property name="text">
<string>localhost</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="portLabel">
<property name="text">
<string>&amp;Port:</string>
</property>
<property name="buddy">
<cstring>portSpinBox</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="portSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>3768</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Sys&amp;root:</string>
</property>
<property name="buddy">
<cstring>sysrootChooser</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Utils::PathChooser" name="sysrootChooser" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QmlProfiler::Internal::QmlProfilerAttachDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QmlProfiler::Internal::QmlProfilerAttachDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -1,64 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "qmlprofilerconfigwidget.h"
#include "ui_qmlprofilerconfigwidget.h"
namespace QmlProfiler {
namespace Internal {
QmlProfilerConfigWidget::QmlProfilerConfigWidget(QmlProfilerSettings *settings) :
m_ui(new Ui::QmlProfilerConfigWidget), m_settings(settings)
{
m_ui->setupUi(this);
updateUi();
connect(m_ui->flushEnabled, &QCheckBox::toggled,
m_settings, &QmlProfilerSettings::setFlushEnabled);
connect(m_ui->flushInterval, QOverload<int>::of(&QSpinBox::valueChanged),
m_settings, &QmlProfilerSettings::setFlushInterval);
connect(m_ui->aggregateTraces, &QCheckBox::toggled,
m_settings, &QmlProfilerSettings::setAggregateTraces);
connect(m_settings, &QmlProfilerSettings::changed, this, &QmlProfilerConfigWidget::updateUi);
}
QmlProfilerConfigWidget::~QmlProfilerConfigWidget()
{
delete m_ui;
}
void QmlProfilerConfigWidget::updateUi()
{
m_ui->flushEnabled->setChecked(m_settings->flushEnabled());
m_ui->flushInterval->setEnabled(m_settings->flushEnabled());
m_ui->flushInterval->setValue(m_settings->flushInterval());
m_ui->aggregateTraces->setChecked(m_settings->aggregateTraces());
}
} // Internal
} // QmlProfiler

View File

@@ -1,55 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "qmlprofilersettings.h"
#include <QWidget>
namespace QmlProfiler {
namespace Internal {
namespace Ui {
class QmlProfilerConfigWidget;
}
class QmlProfilerConfigWidget : public QWidget
{
Q_OBJECT
public:
explicit QmlProfilerConfigWidget(QmlProfilerSettings *settings);
~QmlProfilerConfigWidget() override;
private:
void updateUi();
Ui::QmlProfilerConfigWidget *m_ui;
QmlProfilerSettings *m_settings;
};
} // Internal
} // QmlProfiler

View File

@@ -1,71 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QmlProfiler::Internal::QmlProfilerConfigWidget</class>
<widget class="QWidget" name="QmlProfiler::Internal::QmlProfilerConfigWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>320</width>
<height>100</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="flushEnabledLabel">
<property name="text">
<string>Flush data while profiling:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="flushEnabled">
<property name="toolTip">
<string>Periodically flush pending data to the profiler. This reduces the delay when loading the
data and the memory usage in the application. It distorts the profile as the flushing
itself takes time.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="flushIntervalLabel">
<property name="text">
<string>Flush interval (ms):</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="flushInterval">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000000</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="aggregateTracesLabel">
<property name="text">
<string>Process data only when process ends:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="aggregateTraces">
<property name="toolTip">
<string>Only process data when the process being profiled ends, not when the current recording
session ends. This way multiple recording sessions can be aggregated in a single trace,
for example if multiple QML engines start and stop sequentially during a single run of
the program.</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -30,10 +30,6 @@ namespace Constants {
const char TASK_LOAD[] = "QmlProfiler.TaskLoad";
const char TASK_SAVE[] = "QmlProfiler.TaskSave";
const char FLUSH_ENABLED[] = "Analyzer.QmlProfiler.FlushEnabled";
const char FLUSH_INTERVAL[] = "Analyzer.QmlProfiler.FlushInterval";
const char LAST_TRACE_FILE[] = "Analyzer.QmlProfiler.LastTraceFile";
const char AGGREGATE_TRACES[] = "Analyzer.QmlProfiler.AggregateTraces";
const char SETTINGS[] = "Analyzer.QmlProfiler.Settings";
const char ANALYZER[] = "Analyzer";
const char TEXT_MARK_CATEGORY[] = "Analyzer.QmlProfiler.TextMark";

View File

@@ -1,64 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "qmlprofileroptionspage.h"
#include "qmlprofilerconfigwidget.h"
#include "qmlprofilerplugin.h"
#include "qmlprofilerconstants.h"
#include <debugger/analyzer/analyzericons.h>
namespace QmlProfiler {
namespace Internal {
QmlProfilerOptionsPage::QmlProfilerOptionsPage()
{
setId(Constants::SETTINGS);
setDisplayName(QmlProfilerConfigWidget::tr("QML Profiler"));
setCategory("T.Analyzer");
setDisplayCategory(QmlProfilerConfigWidget::tr("Analyzer"));
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
}
QWidget *QmlProfilerOptionsPage::widget()
{
// We cannot parent the widget to the options page as it expects a QWidget as parent
if (!m_widget)
m_widget = new QmlProfilerConfigWidget(QmlProfilerPlugin::globalSettings());
return m_widget;
}
void QmlProfilerOptionsPage::apply()
{
QmlProfilerPlugin::globalSettings()->writeGlobalSettings();
}
void QmlProfilerOptionsPage::finish()
{
delete m_widget;
}
} // Internal
} // QmlProfiler

View File

@@ -1,48 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <coreplugin/dialogs/ioptionspage.h>
#include <QPointer>
namespace QmlProfiler {
namespace Internal {
class QmlProfilerOptionsPage final : public Core::IOptionsPage
{
public:
QmlProfilerOptionsPage();
QWidget *widget() override;
void apply() override;
void finish() override;
private:
QPointer<QWidget> m_widget;
};
} // Internal
} // QmlProfiler

View File

@@ -25,7 +25,6 @@
#include "qmlprofilerplugin.h"
#include "qmlprofilerrunconfigurationaspect.h"
#include "qmlprofileroptionspage.h"
#include "qmlprofilerruncontrol.h"
#include "qmlprofilersettings.h"
#include "qmlprofilertool.h"
@@ -49,7 +48,6 @@
#include "tests/qmlprofilerattachdialog_test.h"
#include "tests/qmlprofilerbindingloopsrenderpass_test.h"
#include "tests/qmlprofilerclientmanager_test.h"
#include "tests/qmlprofilerconfigwidget_test.h"
#include "tests/qmlprofilerdetailsrewriter_test.h"
#include "tests/qmlprofilertool_test.h"
#include "tests/qmlprofilertraceclient_test.h"
@@ -154,7 +152,6 @@ QVector<QObject *> QmlProfiler::Internal::QmlProfilerPlugin::createTestObjects()
tests << new QmlProfilerAttachDialogTest;
tests << new QmlProfilerBindingLoopsRenderPassTest;
tests << new QmlProfilerClientManagerTest;
tests << new QmlProfilerConfigWidgetTest;
tests << new QmlProfilerDetailsRewriterTest;
tests << new QmlProfilerToolTest;
tests << new QmlProfilerTraceClientTest;

View File

@@ -24,115 +24,122 @@
****************************************************************************/
#include "qmlprofilersettings.h"
#include "qmlprofilerconstants.h"
#include "qmlprofilerconfigwidget.h"
#include "qmlprofilerplugin.h"
#include <coreplugin/icore.h>
#include <debugger/analyzer/analyzericons.h>
#include <utils/layoutbuilder.h>
#include <QSettings>
using namespace Utils;
namespace QmlProfiler {
namespace Internal {
static QWidget *createQmlConfigWidget(QmlProfilerSettings *settings)
{
QmlProfilerSettings &s = *settings;
using namespace Layouting;
return Form {
s.flushEnabled,
s.flushInterval,
s.aggregateTraces
}.emerge();
}
QmlProfilerSettings::QmlProfilerSettings()
{
setConfigWidgetCreator([this] { return new QmlProfilerConfigWidget(this); });
setConfigWidgetCreator([this] { return createQmlConfigWidget(this); });
QVariantMap defaults;
defaults.insert(QLatin1String(Constants::FLUSH_INTERVAL), 1000);
defaults.insert(QLatin1String(Constants::FLUSH_ENABLED), false);
defaults.insert(QLatin1String(Constants::LAST_TRACE_FILE), QString());
defaults.insert(QLatin1String(Constants::AGGREGATE_TRACES), false);
group.setSettingsGroup(Constants::ANALYZER);
group.registerAspect(&flushEnabled);
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."));
group.registerAspect(&flushInterval);
flushInterval.setSettingsKey("Analyzer.QmlProfiler.FlushInterval");
flushInterval.setRange(1, 10000000);
flushInterval.setDefaultValue(1000);
flushInterval.setLabelText(tr("Flush interval (ms):", nullptr));
flushInterval.setEnabled(false); // Controled by flushEnabled.
group.registerAspect(&lastTraceFile);
lastTraceFile.setSettingsKey("Analyzer.QmlProfiler.LastTraceFile");
group.registerAspect(&aggregateTraces);
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."));
connect(&flushEnabled, &BoolAspect::volatileValueChanged,
&flushInterval, &BaseAspect::setEnabled);
connect(&flushEnabled, &BoolAspect::valueChanged,
&flushInterval, &BaseAspect::setEnabled);
// Read stored values
QSettings *settings = Core::ICore::settings();
settings->beginGroup(QLatin1String(Constants::ANALYZER));
QVariantMap map = defaults;
for (QVariantMap::ConstIterator it = defaults.constBegin(); it != defaults.constEnd(); ++it)
map.insert(it.key(), settings->value(it.key(), it.value()));
settings->endGroup();
fromMap(map);
}
bool QmlProfilerSettings::flushEnabled() const
{
return m_flushEnabled;
}
void QmlProfilerSettings::setFlushEnabled(bool flushEnabled)
{
if (m_flushEnabled != flushEnabled) {
m_flushEnabled = flushEnabled;
emit changed();
}
}
quint32 QmlProfilerSettings::flushInterval() const
{
return m_flushInterval;
}
void QmlProfilerSettings::setFlushInterval(quint32 flushInterval)
{
if (m_flushInterval != flushInterval) {
m_flushInterval = flushInterval;
emit changed();
}
}
QString QmlProfilerSettings::lastTraceFile() const
{
return m_lastTraceFile;
}
void QmlProfilerSettings::setLastTraceFile(const QString &lastTracePath)
{
if (m_lastTraceFile != lastTracePath) {
m_lastTraceFile = lastTracePath;
emit changed();
}
}
bool QmlProfilerSettings::aggregateTraces() const
{
return m_aggregateTraces;
}
void QmlProfilerSettings::setAggregateTraces(bool aggregateTraces)
{
if (m_aggregateTraces != aggregateTraces) {
m_aggregateTraces = aggregateTraces;
emit changed();
}
group.readSettings(Core::ICore::settings());
}
void QmlProfilerSettings::writeGlobalSettings() const
{
QSettings *settings = Core::ICore::settings();
settings->beginGroup(QLatin1String(Constants::ANALYZER));
QVariantMap map;
toMap(map);
for (QVariantMap::ConstIterator it = map.constBegin(); it != map.constEnd(); ++it)
settings->setValue(it.key(), it.value());
settings->endGroup();
group.writeSettings(Core::ICore::settings());
}
void QmlProfilerSettings::toMap(QVariantMap &map) const
{
map[QLatin1String(Constants::FLUSH_INTERVAL)] = m_flushInterval;
map[QLatin1String(Constants::FLUSH_ENABLED)] = m_flushEnabled;
map[QLatin1String(Constants::LAST_TRACE_FILE)] = m_lastTraceFile;
map[QLatin1String(Constants::AGGREGATE_TRACES)] = m_aggregateTraces;
group.toMap(map);
}
void QmlProfilerSettings::fromMap(const QVariantMap &map)
{
m_flushEnabled = map.value(QLatin1String(Constants::FLUSH_ENABLED)).toBool();
m_flushInterval = map.value(QLatin1String(Constants::FLUSH_INTERVAL)).toUInt();
m_lastTraceFile = map.value(QLatin1String(Constants::LAST_TRACE_FILE)).toString();
m_aggregateTraces = map.value(QLatin1String(Constants::AGGREGATE_TRACES)).toBool();
emit changed();
group.fromMap(map);
}
// QmlProfilerOptionsPage
QmlProfilerOptionsPage::QmlProfilerOptionsPage()
{
setId(Constants::SETTINGS);
setDisplayName(QmlProfilerSettings::tr("QML Profiler"));
setCategory("T.Analyzer");
setDisplayCategory(QmlProfilerSettings::tr("Analyzer"));
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
}
QWidget *QmlProfilerOptionsPage::widget()
{
// 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;
}
void QmlProfilerOptionsPage::apply()
{
QmlProfilerPlugin::globalSettings()->writeGlobalSettings();
}
void QmlProfilerOptionsPage::finish()
{
delete m_widget;
}
} // Internal

View File

@@ -25,8 +25,12 @@
#pragma once
#include <coreplugin/dialogs/ioptionspage.h>
#include <projectexplorer/runconfiguration.h>
#include <QPointer>
namespace QmlProfiler {
namespace Internal {
@@ -36,32 +40,31 @@ class QmlProfilerSettings : public ProjectExplorer::ISettingsAspect
public:
QmlProfilerSettings();
bool flushEnabled() const;
void setFlushEnabled(bool flushEnabled);
quint32 flushInterval() const;
void setFlushInterval(quint32 flushInterval);
QString lastTraceFile() const;
void setLastTraceFile(const QString &lastTraceFile);
bool aggregateTraces() const;
void setAggregateTraces(bool aggregateTraces);
void writeGlobalSettings() const;
signals:
void changed();
Utils::BoolAspect flushEnabled;
Utils::IntegerAspect flushInterval;
Utils::StringAspect lastTraceFile;
Utils::BoolAspect aggregateTraces;
Utils::AspectContainer group;
protected:
void toMap(QVariantMap &map) const override;
void fromMap(const QVariantMap &map) override;
};
class QmlProfilerOptionsPage final : public Core::IOptionsPage
{
public:
QmlProfilerOptionsPage();
QWidget *widget() override;
void apply() override;
void finish() override;
private:
bool m_flushEnabled;
quint32 m_flushInterval;
QString m_lastTraceFile;
bool m_aggregateTraces;
QPointer<QWidget> m_widget;
};
} // Internal

View File

@@ -314,9 +314,9 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker)
if (auto aspect = static_cast<QmlProfilerRunConfigurationAspect *>(
runControl->aspect(Constants::SETTINGS))) {
if (auto settings = static_cast<const QmlProfilerSettings *>(aspect->currentSettings())) {
d->m_profilerConnections->setFlushInterval(settings->flushEnabled() ?
settings->flushInterval() : 0);
d->m_profilerModelManager->setAggregateTraces(settings->aggregateTraces());
d->m_profilerConnections->setFlushInterval(settings->flushEnabled.value() ?
settings->flushInterval.value() : 0);
d->m_profilerModelManager->setAggregateTraces(settings->aggregateTraces.value());
}
}
@@ -589,8 +589,8 @@ void QmlProfilerTool::showErrorDialog(const QString &error)
void saveLastTraceFile(const QString &filename)
{
QmlProfilerSettings *settings = QmlProfilerPlugin::globalSettings();
if (filename != settings->lastTraceFile()) {
settings->setLastTraceFile(filename);
if (filename != settings->lastTraceFile.value()) {
settings->lastTraceFile.setValue(filename);
settings->writeGlobalSettings();
}
}
@@ -601,7 +601,7 @@ void QmlProfilerTool::showSaveDialog()
QLatin1String zFile(QztFileExtension);
QString filename = QFileDialog::getSaveFileName(
ICore::dialogParent(), tr("Save QML Trace"),
QmlProfilerPlugin::globalSettings()->lastTraceFile(),
QmlProfilerPlugin::globalSettings()->lastTraceFile.value(),
tr("QML traces (*%1 *%2)").arg(zFile).arg(tFile));
if (!filename.isEmpty()) {
if (!filename.endsWith(zFile) && !filename.endsWith(tFile))
@@ -625,7 +625,7 @@ void QmlProfilerTool::showLoadDialog()
QLatin1String zFile(QztFileExtension);
QString filename = QFileDialog::getOpenFileName(
ICore::dialogParent(), tr("Load QML Trace"),
QmlProfilerPlugin::globalSettings()->lastTraceFile(),
QmlProfilerPlugin::globalSettings()->lastTraceFile.value(),
tr("QML traces (*%1 *%2)").arg(zFile).arg(tFile));
if (!filename.isEmpty()) {

View File

@@ -1,96 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "qmlprofilerconfigwidget_test.h"
#include <QtTest>
namespace QmlProfiler {
namespace Internal {
QmlProfilerConfigWidgetTest::QmlProfilerConfigWidgetTest(QObject *parent) :
QObject(parent), widget(&settings)
{
widget.show();
flushEnabled = widget.findChild<QCheckBox*>("flushEnabled");
QVERIFY(flushEnabled);
flushInterval = widget.findChild<QSpinBox*>("flushInterval");
QVERIFY(flushInterval);
aggregateTraces = widget.findChild<QCheckBox*>("aggregateTraces");
QVERIFY(aggregateTraces);
}
void QmlProfilerConfigWidgetTest::testUpdateFromSettings()
{
QSignalSpy flushes(flushEnabled, SIGNAL(stateChanged(int)));
QCOMPARE(flushEnabled->checkState(), Qt::Unchecked);
settings.setFlushEnabled(true);
QCOMPARE(flushEnabled->checkState(), Qt::Checked);
settings.setFlushEnabled(false);
QCOMPARE(flushEnabled->checkState(), Qt::Unchecked);
QCOMPARE(flushes.count(), 2);
QSignalSpy intervals(flushInterval, SIGNAL(valueChanged(int)));
QCOMPARE(flushInterval->value(), 1000);
settings.setFlushInterval(200);
QCOMPARE(flushInterval->value(), 200);
settings.setFlushInterval(1000);
QCOMPARE(flushInterval->value(), 1000);
QCOMPARE(intervals.count(), 2);
QSignalSpy aggregates(aggregateTraces, SIGNAL(stateChanged(int)));
QCOMPARE(aggregateTraces->checkState(), Qt::Unchecked);
settings.setAggregateTraces(true);
QCOMPARE(aggregateTraces->checkState(), Qt::Checked);
settings.setAggregateTraces(false);
QCOMPARE(aggregateTraces->checkState(), Qt::Unchecked);
QCOMPARE(aggregates.count(), 2);
}
void QmlProfilerConfigWidgetTest::testChangeWidget()
{
QCOMPARE(flushEnabled->checkState(), Qt::Unchecked);
QVERIFY(!settings.flushEnabled());
flushEnabled->setCheckState(Qt::Checked);
QVERIFY(settings.flushEnabled());
flushEnabled->setCheckState(Qt::Unchecked);
QVERIFY(!settings.flushEnabled());
QCOMPARE(flushInterval->value(), 1000);
QCOMPARE(settings.flushInterval(), 1000u);
flushInterval->setValue(200);
QCOMPARE(settings.flushInterval(), 200u);
flushInterval->setValue(1000);
QCOMPARE(settings.flushInterval(), 1000u);
QCOMPARE(aggregateTraces->checkState(), Qt::Unchecked);
QVERIFY(!settings.aggregateTraces());
aggregateTraces->setCheckState(Qt::Checked);
QVERIFY(settings.aggregateTraces());
aggregateTraces->setCheckState(Qt::Unchecked);
QVERIFY(!settings.aggregateTraces());
}
} // namespace Internal
} // namespace QmlProfiler

View File

@@ -1,55 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <qmlprofiler/qmlprofilerconfigwidget.h>
#include <QObject>
#include <QCheckBox>
#include <QSpinBox>
namespace QmlProfiler {
namespace Internal {
class QmlProfilerConfigWidgetTest : public QObject
{
Q_OBJECT
public:
explicit QmlProfilerConfigWidgetTest(QObject *parent = nullptr);
private slots:
void testUpdateFromSettings();
void testChangeWidget();
private:
QmlProfilerSettings settings;
QmlProfilerConfigWidget widget;
QCheckBox *flushEnabled;
QSpinBox *flushInterval;
QCheckBox *aggregateTraces;
};
} // namespace Internal
} // namespace QmlProfiler

View File

@@ -15,7 +15,6 @@ SOURCES += \
$$PWD/qmlprofilerattachdialog_test.cpp \
$$PWD/qmlprofilerbindingloopsrenderpass_test.cpp \
$$PWD/qmlprofilerclientmanager_test.cpp \
$$PWD/qmlprofilerconfigwidget_test.cpp \
$$PWD/qmlprofilerdetailsrewriter_test.cpp \
$$PWD/qmlprofilertool_test.cpp \
$$PWD/qmlprofilertraceclient_test.cpp \
@@ -38,7 +37,6 @@ HEADERS += \
$$PWD/qmlprofilerattachdialog_test.h \
$$PWD/qmlprofilerbindingloopsrenderpass_test.h \
$$PWD/qmlprofilerclientmanager_test.h \
$$PWD/qmlprofilerconfigwidget_test.h \
$$PWD/qmlprofilerdetailsrewriter_test.h \
$$PWD/qmlprofilertool_test.h \
$$PWD/qmlprofilertraceclient_test.h \