• 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
GlobalDrawer.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.1
21 import QtQuick.Controls 1.4 as Controls
22 import QtQuick.Layouts 1.2
23 import QtGraphicalEffects 1.0
24 import org.kde.kirigami 1.0
25 
26 import "private"
27 
66 OverlayDrawer {
67  id: root
68  edge: Qt.LeftEdge
69 
74  property alias title: heading.text
75 
81  property alias titleIcon: headingIcon.source
82 
89  property alias bannerImageSource: bannerImage.source
90 
127  property list<QtObject> actions
128 
129 
152  default property alias content: mainContent.data
153 
176  property alias topContent: topContent.data
177 
184  property bool resetMenuOnTriggered: true
185 
191  readonly property Action currentSubMenu: stackView.currentItem ? stackView.currentItem.current: null
192 
196  signal bannerClicked()
197 
198 
201  function resetMenu() {
202  stackView.pop(stackView.initialItem);
203  if (root.modal) {
204  root.opened = false;
205  }
206  }
207 
208  contentItem: Controls.ScrollView {
209  id: scrollView
210  anchors.fill: parent
211  implicitWidth: Math.min (Units.gridUnit * 20, root.parent.width * 0.8)
212  horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
213  Flickable {
214  id: mainFlickable
215  contentWidth: width
216  contentHeight: mainColumn.Layout.minimumHeight
217  ColumnLayout {
218  id: mainColumn
219  width: mainFlickable.width
220  spacing: 0
221  height: Math.max(root.height, Layout.minimumHeight)
222 
223  Image {
224  id: bannerImage
225 
226  Layout.fillWidth: true
227 
228  Layout.preferredWidth: title.implicitWidth
229  Layout.preferredHeight: bannerImageSource != "" ? Math.max(title.implicitHeight, Math.floor(width / (sourceSize.width/sourceSize.height))) : title.implicitHeight
230  Layout.minimumHeight: Math.max(headingIcon.height, heading.height) + Units.smallSpacing * 2
231 
232  MouseArea {
233  anchors.fill: parent
234  onClicked: root.bannerClicked()
235  }
236 
237  fillMode: Image.PreserveAspectCrop
238  asynchronous: true
239 
240  anchors {
241  left: parent.left
242  right: parent.right
243  top: parent.top
244  }
245 
246  EdgeShadow {
247  edge: Qt.BottomEdge
248  visible: bannerImageSource != ""
249  anchors {
250  left: parent.left
251  right: parent.right
252  bottom: parent.top
253  }
254  }
255  LinearGradient {
256  anchors {
257  left: parent.left
258  right: parent.right
259  top: parent.top
260  }
261  visible: bannerImageSource != ""
262  height: title.height * 1.3
263  start: Qt.point(0, 0)
264  end: Qt.point(0, height)
265  gradient: Gradient {
266  GradientStop {
267  position: 0.0
268  color: Qt.rgba(0, 0, 0, 0.8)
269  }
270  GradientStop {
271  position: 1.0
272  color: "transparent"
273  }
274  }
275  }
276 
277  RowLayout {
278  id: title
279  anchors {
280  left: parent.left
281  top: parent.top
282  margins: Units.smallSpacing * 2
283  }
284  Icon {
285  id: headingIcon
286  Layout.minimumWidth: Units.iconSizes.large
287  Layout.minimumHeight: width
288  }
289  Heading {
290  id: heading
291  Layout.fillWidth: true
292  Layout.rightMargin: heading.height
293  level: 1
294  color: bannerImageSource != "" ? "white" : Theme.textColor
295  elide: Text.ElideRight
296  }
297  }
298  }
299 
300  ColumnLayout {
301  id: topContent
302  spacing: 0
303  Layout.alignment: Qt.AlignHCenter
304  Layout.leftMargin: root.leftPadding
305  Layout.rightMargin: root.rightPadding
306  Layout.bottomMargin: Units.smallSpacing
307  Layout.topMargin: root.topPadding
308  Layout.fillWidth: true
309  Layout.fillHeight: true
310  //NOTE: why this? just Layout.fillWidth: true doesn't seem sufficient
311  //as items are added only after this column creation
312  Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding
313  visible: children.length > 0 && childrenRect.height > 0
314  }
315 
316  Controls.StackView {
317  id: stackView
318  Layout.fillWidth: true
319  Layout.minimumHeight: currentItem ? currentItem.implicitHeight : 0
320  Layout.maximumHeight: Layout.minimumHeight
321  initialItem: menuComponent
322  }
323  Item {
324  Layout.fillWidth: true
325  Layout.fillHeight: true
326  Layout.minimumHeight: Units.smallSpacing
327  }
328 
329  ColumnLayout {
330  id: mainContent
331  Layout.alignment: Qt.AlignHCenter
332  Layout.leftMargin: root.leftPadding
333  Layout.rightMargin: root.rightPadding
334  Layout.fillWidth: true
335  Layout.fillHeight: true
336  //NOTE: why this? just Layout.fillWidth: true doesn't seem sufficient
337  //as items are added only after this column creation
338  Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding
339  visible: children.length > 0
340  }
341  Item {
342  Layout.minimumWidth: Units.smallSpacing
343  Layout.minimumHeight: root.bottomPadding
344  }
345 
346  Component {
347  id: menuComponent
348  ColumnLayout {
349  spacing: 0
350  property alias model: actionsRepeater.model
351  property Action current
352 
353  property int level: 0
354  Layout.maximumHeight: Layout.minimumHeight
355 
356 
357  BasicListItem {
358  visible: level > 0
359  supportsMouseEvents: true
360  icon: "go-previous"
361  label: qsTr("Back")
362  separatorVisible: false
363  onClicked: stackView.pop()
364  }
365 
366  Repeater {
367  id: actionsRepeater
368  model: actions
369  delegate: BasicListItem {
370  id: listItem
371  supportsMouseEvents: true
372  checked: modelData.checked
373  icon: modelData.iconName
374  label: modelData.text
375  separatorVisible: false
376  visible: model ? model.visible || model.visible===undefined : modelData.visible
377  enabled: model ? model.enabled : modelData.enabled
378  opacity: enabled ? 1.0 : 0.3
379  Icon {
380  anchors {
381  verticalCenter: parent.verticalCenter
382  right: parent.right
383  }
384  height: Units.iconSizes.smallMedium
385  selected: listItem.checked || listItem.pressed
386  width: height
387  source: "go-next"
388  visible: modelData.children!==undefined && modelData.children.length > 0
389  }
390 
391  onClicked: {
392  modelData.trigger();
393 
394  if (modelData.children!==undefined && modelData.children.length > 0) {
395  stackView.push(menuComponent, {model: modelData.children, level: level + 1, current: modelData });
396  } else if (root.resetMenuOnTriggered) {
397  root.resetMenu();
398  }
399  }
400  }
401  }
402  }
403  }
404  }
405  }
406  }
407 }
408 
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::Action
An item that represents an abstract Action.
Definition: Action.qml:27
org::kde::kirigami::BasicListItem
An item delegate for the primitive ListView component.
Definition: BasicListItem.qml:31
org::kde::kirigami::OverlayDrawer
Overlay Drawers are used to expose additional UI elements needed for small secondary tasks for which ...
Definition: controls/OverlayDrawer.qml:31
org::kde::kirigami::AbstractListItem::checked
bool checked
checked: bool If true makes the list item look as checked or pressed.
Definition: controls/templates/AbstractListItem.qml:72
org::kde::kirigami::Theme
Definition: controls/Theme.qml:22
org::kde::kirigami::Units::gridUnit
int gridUnit
The fundamental unit of space that should be used for sizes, expressed in pixels. ...
Definition: controls/Units.qml:31
org::kde::kirigami::Units
Definition: controls/Units.qml:24
org::kde::kirigami::Units::iconSizes
QtObject iconSizes
units.iconSizes provides access to platform-dependent icon sizing
Definition: controls/Units.qml:49
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