forked from qt-creator/qt-creator
Tracing: Add context menu option to reset the flame graph
The double-clicking-on-blank-space method is really hard to discover. Task-number: QTCREATORBUG-20732 Change-Id: I09e3189292c236fea0698e7cb68ea8340f9033fe Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -45,6 +45,7 @@ class TRACING_EXPORT FlameGraph : public QQuickItem
|
||||
NOTIFY maximumDepthChanged)
|
||||
Q_PROPERTY(int depth READ depth NOTIFY depthChanged)
|
||||
Q_PROPERTY(QPersistentModelIndex root READ root WRITE setRoot NOTIFY rootChanged)
|
||||
Q_PROPERTY(bool zoomed READ isZoomed NOTIFY rootChanged)
|
||||
Q_PROPERTY(int selectedTypeId READ selectedTypeId WRITE setSelectedTypeId
|
||||
NOTIFY selectedTypeIdChanged)
|
||||
|
||||
@@ -83,6 +84,11 @@ public:
|
||||
return m_root;
|
||||
}
|
||||
|
||||
bool isZoomed() const
|
||||
{
|
||||
return m_root.isValid();
|
||||
}
|
||||
|
||||
void setRoot(const QPersistentModelIndex &root)
|
||||
{
|
||||
if (root != m_root) {
|
||||
|
@@ -42,6 +42,9 @@ ScrollView {
|
||||
flamegraph.selectedTypeId = selectedTypeId;
|
||||
}
|
||||
|
||||
function resetRoot() { flamegraph.resetRoot(); }
|
||||
property bool zoomed: flamegraph.zoomed
|
||||
|
||||
property int sizeRole: -1
|
||||
property var model: null
|
||||
|
||||
|
@@ -74,5 +74,15 @@ void PerfProfilerFlameGraphView::selectByTypeId(int typeId)
|
||||
rootObject()->setProperty("selectedTypeId", typeId);
|
||||
}
|
||||
|
||||
void PerfProfilerFlameGraphView::resetRoot()
|
||||
{
|
||||
QMetaObject::invokeMethod(rootObject(), "resetRoot");
|
||||
}
|
||||
|
||||
bool PerfProfilerFlameGraphView::isZoomed() const
|
||||
{
|
||||
return rootObject()->property("zoomed").toBool();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace PerfProfiler
|
||||
|
@@ -41,6 +41,8 @@ public:
|
||||
~PerfProfilerFlameGraphView();
|
||||
|
||||
void selectByTypeId(int typeId);
|
||||
void resetRoot();
|
||||
bool isZoomed() const;
|
||||
|
||||
signals:
|
||||
void gotoSourceLocation(QString file, int line, int column);
|
||||
|
@@ -305,9 +305,13 @@ PerfProfilerTool::PerfProfilerTool(QObject *parent) :
|
||||
m_limitToRange, &QAction::trigger);
|
||||
connect(menu1->addAction(tr("Show Full Range")), &QAction::triggered,
|
||||
m_showFullRange, &QAction::trigger);
|
||||
QAction *resetAction = menu1->addAction(tr("Reset Flame Graph"));
|
||||
connect(resetAction, &QAction::triggered,
|
||||
m_flameGraphView, &PerfProfilerFlameGraphView::resetRoot);
|
||||
m_flameGraphView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_flameGraphView, &QWidget::customContextMenuRequested,
|
||||
menu1, [menu1, this](const QPoint &pos) {
|
||||
menu1, [this, menu1, resetAction](const QPoint &pos) {
|
||||
resetAction->setEnabled(m_flameGraphView->isZoomed());
|
||||
menu1->exec(m_flameGraphView->mapToGlobal(pos));
|
||||
});
|
||||
|
||||
|
@@ -93,9 +93,14 @@ void FlameGraphView::contextMenuEvent(QContextMenuEvent *ev)
|
||||
QAction *getGlobalStatsAction = menu.addAction(tr("Show Full Range"));
|
||||
if (!m_model->modelManager()->isRestrictedToRange())
|
||||
getGlobalStatsAction->setEnabled(false);
|
||||
QAction *resetAction = menu.addAction(tr("Reset Flame Graph"));
|
||||
resetAction->setEnabled(m_content->rootObject()->property("zoomed").toBool());
|
||||
|
||||
if (menu.exec(position) == getGlobalStatsAction)
|
||||
const QAction *selected = menu.exec(position);
|
||||
if (selected == getGlobalStatsAction)
|
||||
emit showFullRange();
|
||||
else if (selected == resetAction)
|
||||
QMetaObject::invokeMethod(m_content->rootObject(), "resetRoot");
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user