• 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
  • templates
controls/templates/AbstractApplicationHeader.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.Layouts 1.2
22 import "private"
23 import org.kde.kirigami 1.0
24 
25 
37 Item {
38  id: root
39  z: 90
40  property int minimumHeight: 0
41  property int preferredHeight: Units.gridUnit * 2
42  property int maximumHeight: Units.gridUnit * 3
43  default property alias contentItem: mainItem.data
44 
45  parent: __appWindow.contentItem.parent
46  //FIXME: remove
47  property QtObject __appWindow: applicationWindow();
48 
49  anchors {
50  top: parent.top
51  left: parent.left
52  right: parent.right
53  }
54  height: preferredHeight
55 
61  property Item background
62 
63  onBackgroundChanged: {
64  background.z = -1;
65  background.parent = root;
66  background.anchors.fill = root;
67  }
68 
69  Behavior on height {
70  enabled: __appWindow.pageStack.currentItem && __appWindow.pageStack.currentItem.flickable && !__appWindow.pageStack.currentItem.flickable.moving
71  NumberAnimation {
72  duration: Units.longDuration
73  easing.type: Easing.InOutQuad
74  }
75  }
76 
77  opacity: height > 0 && -translateTransform.y <= height ? 1 : 0
78  Behavior on opacity {
79  OpacityAnimator {
80  duration: Units.longDuration
81  easing.type: Easing.InOutQuad
82  }
83  }
84 
85  Connections {
86  target: __appWindow
87  onWideScreenChanged: {
88  if (wideScreen) {
89  height = preferredHeight;
90  } else {
91  height = preferredHeight;
92  }
93  }
94  onHeightChanged: root.height = preferredHeight;
95  onReachableModeChanged: root.height = __appWindow.reachableMode && !__appWindow.wideScreen ? maximumHeight : preferredHeight;
96  }
97 
98  transform: Translate {
99  id: translateTransform
100  y: {
101  if (__appWindow === undefined) {
102  return 0;
103  }
104  if (__appWindow.reachableMode && !__appWindow.wideScreen) {
105  return __appWindow.height/2;
106  } else if (!__appWindow.controlsVisible) {
107  return -headerItem.height - Units.smallSpacing;
108  } else {
109  return 0;
110  }
111  }
112  Behavior on y {
113  NumberAnimation {
114  duration: Units.longDuration
115  easing.type: translateTransform.y < 0 ? Easing.OutQuad : Easing.InQuad
116  }
117  }
118  }
119 
120  Item {
121  id: headerItem
122  anchors {
123  left: parent.left
124  right: parent.right
125  bottom: parent.bottom
126  }
127 
128  height: parent.preferredHeight
129 
130  Connections {
131  id: headerSlideConnection
132  target: __appWindow.pageStack.currentItem ? __appWindow.pageStack.currentItem.flickable : null
133  property int oldContentY
134  onContentYChanged: {
135  if (!__appWindow.pageStack.currentItem) {
136  return;
137  }
138  if (__appWindow.pageStack.currentItem.flickable.atYBeginning ||
139  __appWindow.pageStack.currentItem.flickable.atYEnd) {
140  return;
141  }
142 
143  if (__appWindow.wideScreen) {
144  root.height = root.preferredHeight;
145  } else if (__appWindow.reachableMode && !__appWindow.wideScreen) {
146  root.height = root.maximumHeight;
147  } else {
148  root.height = Math.min(root.preferredHeight,
149  Math.max(root.minimumHeight,
150  root.height + oldContentY - __appWindow.pageStack.currentItem.flickable.contentY));
151  oldContentY = __appWindow.pageStack.currentItem.flickable.contentY;
152  }
153  }
154  onMovementEnded: {
155  if (root.height > root.preferredHeight) {
156  //if don't change the position if more then preferredSize is shown
157  } else if (root.height > root.preferredHeight/2 ) {
158  root.height = root.preferredHeight;
159  } else {
160  root.height = 0;
161  }
162  }
163  }
164  Connections {
165  target: __appWindow.pageStack
166  onCurrentItemChanged: {
167  if (!__appWindow.pageStack.currentItem) {
168  return;
169  }
170  if (__appWindow.pageStack.currentItem.flickable) {
171  headerSlideConnection.oldContentY = __appWindow.pageStack.currentItem.flickable.contentY;
172  } else {
173  headerSlideConnection.oldContentY = 0;
174  }
175  root.height = root.preferredHeight;
176  }
177  }
178 
179  Item {
180  id: mainItem
181  anchors {
182  fill: parent
183  topMargin: applicationWindow().reachable ? 0 : Math.min(headerItem.height - root.height, headerItem.height - root.preferredHeight)
184  }
185  }
186  }
187 }
188 
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::longDuration
int longDuration
units.longDuration should be used for longer, screen-covering animations, for opening and closing of ...
Definition: controls/Units.qml:75
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