SelectionRangeDetails.qml 5.06 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
hjk's avatar
hjk committed
3
4
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** 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 Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29
30
31
32

import QtQuick 1.0
import Monitor 1.0

33
Item {
34
35
36
37
38
39
40
41
    id: selectionRangeDetails

    property string startTime
    property string endTime
    property string duration
    property bool showDuration

    width: 170
42
    height: col.height + 30
43
44
45
46
47
    z: 1
    visible: false
    x: 200
    y: 125

48
49
50
51
52
    property int yoffset: root.scrollY
    onYoffsetChanged: y = relativey + yoffset
    property int relativey : y - yoffset
    onYChanged: relativey = y - yoffset

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    // keep inside view
    Connections {
        target: root
        onWidthChanged: fitInView();
        onCandidateHeightChanged: fitInView();
    }

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

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

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
    // shadow
    BorderImage {
        property int px: 4
        source: "dialog_shadow.png"

        border {
            left: px; top: px
            right: px; bottom: px
        }
        width: parent.width + 2*px - 1
        height: parent.height
        x: -px + 1
        y: px + 1
    }

    // title bar
    Rectangle {
        width: parent.width
        height: 20
        color: "#4a64b8"
        radius: 5
        border.width: 1
        border.color: "#a0a0a0"
    }
    Item {
        width: parent.width+1
        height: 11
        y: 10
        clip: true
        Rectangle {
            width: parent.width-1
            height: 15
            y: -5
            color: "#4a64b8"
            border.width: 1
            border.color: "#a0a0a0"
        }
    }

114
115
116
    //title
    Text {
        id: typeTitle
117
        text: "  "+qsTr("Selection")
118
        font.bold: true
119
120
121
122
123
        height: 18
        y: 2
        verticalAlignment: Text.AlignVCenter
        width: parent.width
        color: "white"
124
125
    }

126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
    // Details area
    Rectangle {
        color: "white"
        width: parent.width
        height: col.height + 10
        y: 20
        border.width: 1
        border.color: "#a0a0a0"
        Column {
            id: col
            x: 10
            y: 5
            Detail {
                label: qsTr("Start")
                content:  selectionRangeDetails.startTime
            }
            Detail {
                label: qsTr("End")
                visible: selectionRangeDetails.showDuration
                content:  selectionRangeDetails.endTime
            }
            Detail {
                label: qsTr("Duration")
                visible: selectionRangeDetails.showDuration
                content: selectionRangeDetails.duration
            }
152
        }
153
154
155
156
157
158
    }

    MouseArea {
        width: col.width + 45
        height: col.height + 30
        drag.target: parent
159
160
161
162
        drag.minimumX: 0
        drag.maximumX: root.width - parent.width
        drag.minimumY: 0
        drag.maximumY: root.candidateHeight - parent.height
163
164
165
166
        onClicked: {
            if ((selectionRange.x < flick.contentX) ^ (selectionRange.x+selectionRange.width > flick.contentX + flick.width)) {
                root.recenter(selectionRange.startTime + selectionRange.duration/2);
            }
167
168
169
170
171
        }
    }

    Text {
        id: closeIcon
172
173
        x: selectionRangeDetails.width - 14
        y: 4
174
        text:"X"
175
        color: "white"
176
177
178
179
180
181
182
183
184
185
186
        MouseArea {
            anchors.fill: parent
            anchors.leftMargin: -8
            onClicked: {
                root.selectionRangeMode = false;
                root.updateRangeButton();
            }
        }
    }

}