From e9d36fe9efdbc5a0743db33cf87f82ac5a530525 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 28 Jun 2019 15:33:55 +0200 Subject: Tracing: Use Combobox for the modes menu This is a better fit than a custom Button + Menu combination. Fixes: QTCREATORBUG-22579 Change-Id: Ie6f8a7ef2ce0da67a16bc365d6f619a11bc56221 Reviewed-by: Milian Wolff --- src/libs/tracing/qml/FlameGraphView.qml | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'src/libs') diff --git a/src/libs/tracing/qml/FlameGraphView.qml b/src/libs/tracing/qml/FlameGraphView.qml index 621569e8bb..f98bcb3134 100644 --- a/src/libs/tracing/qml/FlameGraphView.qml +++ b/src/libs/tracing/qml/FlameGraphView.qml @@ -45,7 +45,7 @@ ScrollView { function resetRoot() { flamegraph.resetRoot(); } property bool zoomed: flamegraph.zoomed - property int sizeRole: -1 + property var sizeRole: modes[Math.max(0, modesMenu.currentIndex)] property var model: null property int typeIdRole: -1 @@ -56,7 +56,7 @@ ScrollView { property int summaryRole: -1 property int noteRole: -1 - property var trRoleNames: [] + property var trRoleNames: ({}) property var modes: [] @@ -314,29 +314,11 @@ ScrollView { } } - Button { + ComboBox { + id: modesMenu x: flickable.width - width y: flickable.contentY - - // It won't listen to anchors.margins and by default it doesn't add any margin. Great. - width: implicitWidth + 20 - - text: qsTr("Visualize %1").arg(trRoleNames[root.sizeRole]) - onClicked: modesMenu.open() - - Menu { - id: modesMenu - y: parent.height - Instantiator { - model: root.modes - MenuItem { - text: root.trRoleNames[modelData] - onTriggered: root.sizeRole = modelData - } - onObjectAdded: modesMenu.insertItem(index, object) - onObjectRemoved: modesMenu.removeItem(object) - } - } + model: root.modes.map(function(role) { return root.trRoleNames[role] }); } } } -- cgit v1.2.3