aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlprofiler/qmlprofilersettings.cpp
blob: a4beb6e6a3e9ecf6b811f5a0de61793aafcf0fff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// 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 "qmlprofilersettings.h"

#include "qmlprofilerconstants.h"
#include "qmlprofilertr.h"

#include <coreplugin/dialogs/ioptionspage.h>

#include <utils/layoutbuilder.h>

using namespace Utils;

namespace QmlProfiler::Internal {

QmlProfilerSettings &globalSettings()
{
    static QmlProfilerSettings theSettings;
    return theSettings;
}

QmlProfilerSettings::QmlProfilerSettings()
{
    setAutoApply(false);
    setSettingsGroup(Constants::ANALYZER);

    flushEnabled.setSettingsKey("Analyzer.QmlProfiler.FlushEnabled");
    flushEnabled.setLabelPlacement(BoolAspect::LabelPlacement::InExtraLabel);
    flushEnabled.setLabelText(Tr::tr("Flush data while profiling:"));
    flushEnabled.setToolTip(Tr::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."));

    flushInterval.setSettingsKey("Analyzer.QmlProfiler.FlushInterval");
    flushInterval.setRange(1, 10000000);
    flushInterval.setDefaultValue(1000);
    flushInterval.setLabelText(Tr::tr("Flush interval (ms):"));

    lastTraceFile.setSettingsKey("Analyzer.QmlProfiler.LastTraceFile");

    aggregateTraces.setSettingsKey("Analyzer.QmlProfiler.AggregateTraces");
    aggregateTraces.setLabelPlacement(BoolAspect::LabelPlacement::InExtraLabel);
    aggregateTraces.setLabelText(Tr::tr("Process data only when process ends:"));
    aggregateTraces.setToolTip(Tr::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."));

    setLayouter([this] {
        using namespace Layouting;
        return Form {
            flushEnabled, br,
            flushInterval, br,
            aggregateTraces, br,
        };
    });

    readSettings();

    flushInterval.setEnabler(&flushEnabled);
}

// QmlProfilerSettingsPage

class QmlProfilerSettingsPage final : public Core::IOptionsPage
{
public:
    QmlProfilerSettingsPage()
    {
        setId(Constants::SETTINGS);
        setDisplayName(Tr::tr("QML Profiler"));
        setCategory("T.Analyzer");
        setSettingsProvider([] { return &globalSettings(); });
    }
};

const QmlProfilerSettingsPage settingsPage;

} // QmlProfiler::Internal