• 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
ContextDrawer.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.Layouts 1.2
22 import QtQuick.Controls 1.0 as QtControls
23 import org.kde.kirigami 1.0
24 
69 OverlayDrawer {
70  id: root
71 
76  property string title: qsTr("Actions")
77 
78 
83  property var actions: pageStack.currentItem ? pageStack.currentItem.contextualActions : null
84  enabled: menu.count > 0
85  edge: Qt.RightEdge
86  opened: false
87 
88  handleVisible: applicationWindow == undefined || applicationWindow().wideScreen == true ? false : applicationWindow().controlsVisible
89 
90  Connections {
91  target: pageStack
92  onCurrentItemChanged: {
93  if (pageStack.currentItem)
94  actions = pageStack.currentItem.contextualActions
95  }
96  }
97 
98  contentItem: QtControls.ScrollView {
99  implicitWidth: Units.gridUnit * 20
100  ListView {
101  id: menu
102  interactive: contentHeight > height
103  model: {
104  if (typeof root.actions == "undefined") {
105  return null;
106  }
107  if (root.actions.length == 0) {
108  return null;
109  } else {
110  return root.actions[0].text !== undefined &&
111  root.actions[0].trigger !== undefined ?
112  root.actions :
113  root.actions[0];
114  }
115  }
116  topMargin: menu.height - menu.contentHeight
117  header: Item {
118  height: heading.height
119  width: menu.width
120  Heading {
121  id: heading
122  anchors {
123  left: parent.left
124  right: parent.right
125  margins: Units.largeSpacing
126  }
127  elide: Text.ElideRight
128  level: 2
129  text: root.title
130  }
131  }
132  delegate: BasicListItem {
133  checked: modelData.checked
134  icon: modelData.iconName
135  supportsMouseEvents: true
136  separatorVisible: false
137  label: model ? model.text : modelData.text
138  enabled: model ? model.enabled : modelData.enabled
139  visible: model ? model.visible : modelData.visible
140  opacity: enabled ? 1.0 : 0.6
141  onClicked: {
142  if (modelData && modelData.trigger !== undefined) {
143  modelData.trigger();
144  // assume the model is a list of QAction or Action
145  } else if (menu.model.length > index) {
146  menu.model[index].trigger();
147  } else {
148  console.warning("Don't know how to trigger the action")
149  }
150  root.opened = false;
151  }
152  }
153  }
154  }
155 }
org::kde::kirigami::Heading
A heading label used for subsections of texts.
Definition: Heading.qml:47
org::kde::kirigami::BasicListItem
An item delegate for the primitive ListView component.
Definition: BasicListItem.qml:31
org::kde::kirigami::Units::largeSpacing
int largeSpacing
units.largeSpacing is the amount of spacing that should be used inside bigger UI elements, for example between an icon and the corresponding text.
Definition: controls/Units.qml:63
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::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
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