• Skip to content
  • Skip to link menu
Brand

API Documentation

  1. KDE API Reference
  2. Kirigami
  • KDE Home
  • Contact Us

Quick Links

Skip menu "Kirigami"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List
  • Related Pages

Class Picker

About

QtQuick plugins to build user interfaces based on the KDE UX guidelines

Maintainer
Marco Martin
Supported platforms
Android, Linux
Community
IRC: #plasma on Freenode
Mailing list: plasma-devel
Use with CMake
find_package(KF5Kirigami)
target_link_libraries(yourapp KF5::Kirigami)
Clone
git clone git://anongit.kde.org/kirigami1.git
Browse source
Kirigami on cgit.kde.org

Kirigami

  • src
  • controls
ToolBarApplicationHeader.qml
1 /*
2  * Copyright 2015 Marco Martin <mart@kde.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2 or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Library General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 import QtQuick 2.5
21 import QtQuick.Controls 1.3 as Controls
22 import QtQuick.Layouts 1.2
23 import QtQuick.Controls.Private 1.0
24 import "private"
25 import org.kde.kirigami 1.0
26 
27 
31 ApplicationHeader {
32  id: header
33 
34  preferredHeight: 34//spacer.height
35  maximumHeight: preferredHeight
36 
37  Controls.ToolButton {
38  id: spacer
39  iconName: "go-previous"
40  visible: false
41  }
42 
43  //FIXME: needs a property difinition to have its own type in qml
44  property string _internal: ""
45 
46  pageDelegate: Item {
47  id: delegateItem
48  readonly property Page page: applicationWindow().pageStack.get(modelData)
49  property ListView view: ListView.view
50  readonly property bool current: __appWindow.pageStack.currentIndex == index
51  property Row layout
52 
53  width: {
54  //more columns shown?
55  if (__appWindow.wideScreen) {
56  if (modelData == 0 && view.x > 0) {
57  return page.width - Math.max(0, view.x - __appWindow.contentItem.x);
58  } else {
59  return page.width;
60  }
61  } else {
62  return Math.min(view.width, delegateRoot.implicitWidth + Units.smallSpacing);
63  }
64  }
65  height: view.height
66 
67  Component.onCompleted: {
68  layout = toolbarComponent.createObject(delegateItem)
69  }
70  Component {
71  id: toolbarComponent
72  Row {
73  id: layout
74  x: __appWindow.wideScreen ? (Math.min(delegateItem.width - width, Math.max(0, delegateItem.view.contentX - delegateItem.x))) : 0
75 
76  Rectangle {
77  anchors.verticalCenter: parent.verticalCenter
78  color: Theme.textColor
79  opacity: 0.3
80  width: Units.devicePixelRatio
81  height: parent.height * 0.6
82  }
83  Controls.ToolButton {
84  anchors.verticalCenter: parent.verticalCenter
85  iconName: page && page.actions && page.actions.main ? page.actions.main.iconName : ""
86  text: page && page.actions && page.actions.main ? page.actions.main.text : ""
87  tooltip: page && page.actions && page.actions.main ? page.actions.main.text : ""
88  checkable: page && page.actions && page.actions.main && page.actions.main.checkable
89  checked: page && page.actions && page.actions.main && page.actions.main.checked
90  enabled: page && page.actions && page.actions.main && page.actions.main.enabled
91  opacity: enabled ? 1 : 0.4
92  visible: page && page.actions && page.actions.main && page.actions.main.visible
93  onClicked: page.actions.main.trigger();
94  }
95  Controls.ToolButton {
96  anchors.verticalCenter: parent.verticalCenter
97  iconName: page && page.actions && page.actions.left ? page.actions.left.iconName : ""
98  text: page && page.actions && page.actions.left ? page.actions.left.text : ""
99  tooltip: page && page.actions && page.actions.left ? page.actions.left.text : ""
100  checkable: page && page.actions && page.actions.left && page.actions.left.checkable
101  checked: page && page.actions && page.actions.left && page.actions.left.checked
102  enabled: page && page.actions && page.actions.left && page.actions.left.enabled
103  opacity: enabled ? 1 : 0.4
104  visible: page && page.actions && page.actions.left && page.actions.left && page.actions.left.visible
105  onClicked: page.actions.left.trigger();
106  }
107  Controls.ToolButton {
108  anchors.verticalCenter: parent.verticalCenter
109  iconName: page && page.actions && page.actions.right ? page.actions.right.iconName : ""
110  text: page && page.actions && page.actions.right ? page.actions.right.text : ""
111  tooltip: page && page.actions && page.actions.right ? page.actions.right.text : ""
112  checkable: page && page.actions && page.actions.right && page.actions.right.checkable
113  checked: page && page.actions && page.actions.right && page.actions.right.checked
114  enabled: page && page.actions && page.actions.right && page.actions.right.enabled
115  opacity: enabled ? 1 : 0.4
116  visible: page && page.actions && page.actions.right && page.actions.right && page.actions.right.visible
117  onClicked: page.actions.right.trigger();
118  }
119  Rectangle {
120  anchors.verticalCenter: parent.verticalCenter
121  color: Theme.textColor
122  opacity: 0.3
123  width: Units.devicePixelRatio
124  height: parent.height * 0.6
125  }
126  Repeater {
127  id: repeater
128  model: page && page.actions.contextualActions ? page.actions.contextualActions : null
129  delegate: Controls.ToolButton {
130  anchors.verticalCenter: parent.verticalCenter
131  iconName: modelData.iconName
132  text: modelData.text
133  tooltip: modelData.text
134  checkable: modelData.checkable
135  checked: modelData.checked
136  enabled: modelData.enabled
137  opacity: enabled ? 1 : 0.4
138  visible: modelData.visible && x+layout.x+width*2 < delegateItem.width
139  onClicked: modelData.trigger();
140  }
141  }
142  }
143  }
144  Heading {
145  x: __appWindow.wideScreen ? (Math.min(delegateItem.width - width, Math.max(0, delegateItem.view.contentX - delegateItem.x))) : 0
146  anchors.verticalCenter: parent.verticalCenter
147  visible: layout.width <= 0
148  opacity: delegateItem.current ? 1 : 0.4
149  color: Theme.textColor
150  elide: Text.ElideRight
151  text: page ? page.title : ""
152  font.pixelSize: parent.height / 1.6
153  }
154  Controls.ToolButton {
155  id: moreButton
156  anchors {
157  right: parent.right
158  verticalCenter: parent.verticalCenter
159  }
160 
161  //TODO: we need a kebab icon
162  iconName: "application-menu"
163  visible: menu.visibleChildren > 0
164  onClicked: page.actions.main
165 
166  menu: Controls.Menu {
167  id: menu
168 
169  property int visibleChildren: 0
170  Instantiator {
171  model: page && page.actions.contextualActions ? page.actions.contextualActions : null
172  delegate: Controls.MenuItem {
173  text: modelData ? modelData.text : ""
174  iconName: modelData.iconName
175  shortcut: modelData.shortcut
176  onTriggered: modelData.trigger();
177  //skip the 3 buttons and 2 separators
178  visible: !layout.children[index+5].visible && modelData.visible
179  enabled: modelData.enabled
180  onVisibleChanged: {
181  if (visible) {
182  menu.visibleChildren++;
183  } else {
184  menu.visibleChildren = Math.max(0, menu.visibleChildren-1);
185  }
186  }
187  }
188  onObjectAdded: {
189  menu.insertItem(index, object);
190  if (object.visible) {
191  menu.visibleChildren++;
192  }
193  }
194  onObjectRemoved: {
195  menu.removeItem(object);
196  if (object.visible) {
197  menu.visibleChildren = Math.max(0, menu.visibleChildren-1);
198  }
199  }
200  }
201  }
202  }
203  }
204 }
org::kde::kirigami::Heading
A heading label used for subsections of texts.
Definition: Heading.qml:47
org::kde::kirigami::Units::smallSpacing
int smallSpacing
units.smallSpacing is the amount of spacing that should be used around smaller UI elements...
Definition: controls/Units.qml:56
org::kde::kirigami::Units::devicePixelRatio
real devicePixelRatio
The ratio between physical and device-independent pixels.
Definition: controls/Units.qml:70
org::kde::kirigami::Theme
Definition: controls/Theme.qml:22
org::kde::kirigami::Page
Page is a container for all the app pages: everything pushed to the ApplicationWindow stackView shoul...
Definition: Page.qml:29
org::kde::kirigami::Units
Definition: controls/Units.qml:24
This file is part of the KDE documentation.
Documentation copyright © 1996-2017 The KDE developers.
Generated on Fri Feb 17 2017 11:09:23 by doxygen 1.8.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal