aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/tracing/qml/RowLabel.qml
blob: 53ca5c6eaf2cc395a719aa6cb704239eac534c04 (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
// 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

import QtQuick
import QtQuick.Controls
import QtCreator.Tracing

Button {
    id: button
    property var label

    readonly property int dragHeight: 5

    signal selectBySelectionId()
    signal setRowHeight(int newHeight)

    property string labelText: label.description ? label.description : qsTr("[unknown]")

    onPressed: selectBySelectionId();
    ToolTip.text: labelText + (label.displayName ? (" (" + label.displayName + ")") : "")
    ToolTip.visible: hovered
    ToolTip.delay: 1000

    background: Rectangle {
        border.width: 1
        border.color: Theme.color(Theme.Timeline_DividerColor)
        color: Theme.color(Theme.PanelStatusBarBackgroundColor)
    }

    contentItem: TimelineText {
        text: button.labelText
        verticalAlignment: Text.AlignVCenter
        horizontalAlignment: Text.AlignLeft
        elide: Text.ElideRight
        color: Theme.color(Theme.PanelTextColorLight)
    }

    MouseArea {
        hoverEnabled: true
        property bool resizing: false
        onPressed: resizing = true
        onReleased: resizing = false

        height: dragHeight
        anchors.bottom: parent.bottom
        anchors.left: parent.left
        anchors.right: parent.right
        cursorShape: Qt.SizeVerCursor

        onMouseYChanged: {
            if (resizing)
                button.setRowHeight(y + mouseY)
        }
    }
}