]> rtime.felk.cvut.cz Git - coffee/qtwebbrowser.git/blob - src/app/qml/assets/UIToolBar.qml
Use qml extension plugin
[coffee/qtwebbrowser.git] / src / app / qml / assets / UIToolBar.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtBrowser project.
7 **
8 ** $QT_BEGIN_LICENSE:GPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 2 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.GPLv2 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU General Public License version 2 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 3.0 as published by the Free Software
28 ** Foundation and appearing in the file LICENSE.GPL included in the
29 ** packaging of this file. Please review the following information to
30 ** ensure the GNU General Public License version 3.0 requirements will be
31 ** met: http://www.gnu.org/copyleft/gpl.html.
32 **
33 **
34 ** $QT_END_LICENSE$
35 **
36 ****************************************************************************/
37
38 import QtQuick 2.5
39 import QtQuick.Controls 1.0
40 import QtQuick.Controls.Styles 1.0
41 import QtQuick.Layouts 1.0
42
43 ToolBar {
44     id: root
45
46     property alias title: titleBox.text
47     property alias source: toolBarButton.source
48     property alias indicator: indicatorText.text
49
50     property int indicatorWidth: 40
51     property int indicatorHeight: 32
52
53     signal optionClicked()
54     signal doneClicked()
55
56     height: navigation.height
57
58     style: ToolBarStyle {
59         background: Rectangle {
60             color: toolBarFillColor
61         }
62         padding {
63             left: 0
64             right: 0
65             top: 0
66             bottom: 0
67         }
68     }
69
70     RowLayout {
71         spacing: 0
72         height: toolBarSize
73         anchors.fill: parent
74         Rectangle {
75             width: childrenRect.width
76             anchors {
77                 left: parent.left
78                 top: parent.top
79                 bottom: parent.bottom
80             }
81             color: toolBarFillColor
82             Text {
83                 id: titleBox
84                 visible: root.title !== ""
85                 anchors {
86                     leftMargin: visible ? 30 : 0
87                     left: parent.left
88                     verticalCenter: parent.verticalCenter
89                 }
90                 color: "white"
91                 font.pixelSize: 28
92                 font.family: defaultFontFamily
93             }
94             Rectangle {
95                 visible: toolBarButton.visible && titleBox.visible
96                 width: 1
97                 anchors {
98                     top: parent.top
99                     bottom: parent.bottom
100                 }
101                 color: toolBarSeparatorColor
102             }
103             UIButton {
104                 id: toolBarButton
105                 visible: root.source !== ""
106                 color: toolBarFillColor
107                 Component.onCompleted: toolBarButton.clicked.connect(root.optionClicked)
108                 anchors.left: titleBox.right
109             }
110         }
111         Rectangle {
112             visible: toolBarButton.visible
113             width: 1
114             anchors {
115                 top: parent.top
116                 bottom: parent.bottom
117             }
118             color: toolBarSeparatorColor
119         }
120         Rectangle {
121             width: indicatorWidth
122             anchors {
123                 top: parent.top
124                 bottom: parent.bottom
125             }
126             color: toolBarFillColor
127         }
128         Rectangle {
129             color: toolBarFillColor
130             Layout.fillWidth: true
131             anchors {
132                 top: parent.top
133                 bottom: parent.bottom
134             }
135             Rectangle {
136                 visible: root.indicator !== ""
137                 color: "transparent"
138                 border.color: "white"
139                 border.width: 2
140                 width: indicatorWidth
141                 height: indicatorHeight
142                 anchors.centerIn: parent
143                 Text {
144                     id: indicatorText
145                     anchors.centerIn: parent
146                     color: "white"
147                     font.family: defaultFontFamily
148                     font.pixelSize: 20
149                 }
150             }
151         }
152         Rectangle {
153             width: 1
154             anchors {
155                 top: parent.top
156                 bottom: parent.bottom
157             }
158             color: toolBarSeparatorColor
159         }
160         UIButton {
161             id: doneButton
162             color: toolBarFillColor
163             buttonText: "Done"
164             implicitWidth: 120
165             Component.onCompleted: doneButton.clicked.connect(root.doneClicked)
166         }
167     }
168 }