aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/tracing/qml/SelectionRangeDetails.qml
blob: 458e5cf7ad4ea7845c326b57bd4ad96b7e1e5f78 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/****************************************************************************
**
** 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.
**
****************************************************************************/

import QtQuick 2.1
import TimelineTheme 1.0
import TimelineTimeFormatter 1.0

Item {
    id: selectionRangeDetails

    signal recenter
    signal close

    property double startTime
    property double endTime
    property double duration
    property double referenceDuration
    property bool showDuration
    property bool hasContents

    width: Math.max(150, col.width + 25)
    height: hasContents ? col.height + 30 : 0

    // keep inside view
    Connections {
        target: selectionRangeDetails.parent
        onWidthChanged: fitInView();
        onHeightChanged: fitInView();
    }

    function fitInView() {
        // don't reposition if it does not fit
        if (parent.width < width || parent.height < height)
            return;

        if (x + width > parent.width)
            x = parent.width - width;
        if (x < 0)
            x = 0;
        if (y + height > parent.height)
            y = parent.height - height;
        if (y < 0)
            y = 0;
    }

    // title bar
    Rectangle {
        width: parent.width
        height: 20
        color: Theme.color(Theme.Timeline_PanelHeaderColor)
    }

    //title
    TimelineText {
        id: typeTitle
        text: "  "+qsTr("Selection")
        font.bold: true
        height: 20
        verticalAlignment: Text.AlignVCenter
        width: parent.width
        color: Theme.color(Theme.PanelTextColorLight)
    }

    // Details area
    Rectangle {
        color: Theme.color(Theme.Timeline_PanelBackgroundColor)
        width: parent.width
        height: col.height + 10
        y: 20
        Grid {
            id: col
            x: 10
            y: 5
            spacing: 5
            columns: 2

            Repeater {
                id: details
                property var contents: [
                    qsTr("Start") + ":",
                    TimeFormatter.format(startTime, referenceDuration),
                    (qsTr("End") + ":"),
                    TimeFormatter.format(endTime, referenceDuration),
                    (qsTr("Duration") + ":"),
                    TimeFormatter.format(duration, referenceDuration)
                ]

                model: showDuration ? 6 : 2
                Detail {
                    isLabel: index % 2 === 0
                    text: details.contents[index]
                }
            }
        }
    }

    MouseArea {
        anchors.fill: parent
        drag.target: parent
        drag.minimumX: 0
        drag.maximumX: selectionRangeDetails.parent.width - width
        drag.minimumY: 0
        drag.maximumY: selectionRangeDetails.parent.height - height
        onClicked: selectionRangeDetails.recenter()
    }

    ImageToolButton {
        id: closeIcon
        imageSource: "image://icons/close_window"
        anchors.right: selectionRangeDetails.right
        anchors.top: selectionRangeDetails.top
        implicitHeight: typeTitle.height
        onClicked: selectionRangeDetails.close()
    }
}