• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

PlasmaComponents

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • plasmacomponents
  • qml
ToolBar.qml
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2011 by 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 1.1
21 import org.kde.plasma.core 0.1 as PlasmaCore
22 
26 Item{
27  id: toolBar
28  width: parent.width
29  height: (tools && enabled) ? tools.height + frameSvg.margins.top + frameSvg.margins.bottom : 0
30  visible: height > 0
31 
37  property alias margins: frameSvg.margins
38 
39  Behavior on height {
40  PropertyAnimation {
41  id: heightAnimation
42  duration: 250
43  }
44  }
45  z: 1000
46 
53  property Item tools
54 
66  property string transition: "set"
67 
68  //This invisible item keeps all the old dismissed tools:
69  //note that the outside application still has to keep references to them (or explicitly delete them) or they will just accumulate wasting memory
70  Item {
71  id: oldToolsItem
72  visible: false
73  }
74 
82  function setTools(tools, transition)
83  {
84  if (toolBar.tools == tools) {
85  return
86  }
87 
88  if (connection.oldTools) {
89  connection.oldTools.parent = oldToolsItem
90  }
91  connection.oldTools = toolBar.tools
92  toolBar.transition = transition
93  toolBar.tools = tools
94  }
95  Connections {
96  id: connection
97  target: toolBar
98  property Item oldTools
99 
100  function internalToolsChanged()
101  {
102  var newContainer
103  var oldContainer
104  if (containerA.current) {
105  newContainer = containerB
106  oldContainer = containerA
107  } else {
108  newContainer = containerA
109  oldContainer = containerB
110  }
111  containerA.current = !containerA.current
112 
113  if (tools) {
114  tools.parent = newContainer
115  tools.visible = true
116  tools.anchors.left = newContainer.left
117  tools.anchors.right = newContainer.right
118  }
119 
120  switch (transition) {
121  case "push":
122  containerA.animationsEnabled = true
123  oldContainer.x = -oldContainer.width/2
124 
125  containerA.animationsEnabled = false
126  newContainer.x = newContainer.width/2
127  newContainer.y = 0
128  containerA.animationsEnabled = true
129  newContainer.x = 0
130  break
131  case "pop":
132  containerA.animationsEnabled = true
133  oldContainer.x = oldContainer.width/2
134 
135  containerA.animationsEnabled = false
136  newContainer.x = -newContainer.width/2
137  newContainer.y = 0
138  containerA.animationsEnabled = true
139  newContainer.x = 0
140  break
141  case "replace":
142  containerA.animationsEnabled = true
143  oldContainer.y = oldContainer.height
144 
145  containerA.animationsEnabled = false
146  newContainer.x = 0
147  newContainer.y = -newContainer.height
148  containerA.animationsEnabled = true
149  newContainer.y = 0
150  break
151  case "set":
152  default:
153  containerA.animationsEnabled = false
154  containerA.animationsEnabled = false
155  oldContainer.x = -oldContainer.width/2
156  newContainer.x = 0
157  break
158  }
159 
160  newContainer.opacity = 1
161  oldContainer.opacity = 0
162  }
163  onToolsChanged: connection.internalToolsChanged()
164  Component.onCompleted: connection.internalToolsChanged()
165  }
166 
167  PlasmaCore.FrameSvgItem {
168  id: frameSvg
169  imagePath: "widgets/toolbar"
170  anchors {
171  fill: parent
172  leftMargin: -margins.left
173  rightMargin: -margins.right
174  //FIXME: difference between actial border and shadow
175  topMargin: toolBar.y <= 0 ? -margins.top : -margins.top/2
176  bottomMargin: toolBar.y >= toolBar.parent.height - toolBar.height ? -margins.bottom : -margins.bottom/2
177  }
178  }
179 
180  Item {
181  clip: containerAOpacityAnimation.running || heightAnimation.running
182  anchors {
183  fill: parent
184  leftMargin: frameSvg.margins.left
185  topMargin: frameSvg.margins.top
186  rightMargin: frameSvg.margins.right
187  bottomMargin: frameSvg.margins.bottom
188  }
189 
190  // We have two containers here so that when we transition from one set of tools to another
191  // we can have a nice transition animation with the old tools in one container and the
192  // new tools in the other
193  Item {
194  id: containerA
195  width: parent.width
196  height: parent.height
197  property bool animationsEnabled: false
198  opacity: 0
199  //this asymmetry just to not export a property
200  property bool current: false
201  Behavior on opacity {
202  PropertyAnimation {
203  id: containerAOpacityAnimation
204  duration: 250
205  }
206  }
207  Behavior on x {
208  enabled: containerA.animationsEnabled
209  PropertyAnimation {
210  duration: 250
211  }
212  }
213  Behavior on y {
214  enabled: containerA.animationsEnabled
215  PropertyAnimation {
216  duration: 250
217  }
218  }
219  }
220  Item {
221  id: containerB
222  width: parent.width
223  height: parent.height
224  opacity: 0
225  Behavior on opacity {
226  PropertyAnimation { duration: 250 }
227  }
228  Behavior on x {
229  enabled: containerA.animationsEnabled
230  PropertyAnimation {
231  duration: 250
232  }
233  }
234  Behavior on y {
235  enabled: containerA.animationsEnabled
236  PropertyAnimation {
237  duration: 250
238  }
239  }
240  }
241  }
242 }
Item
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PlasmaComponents

Skip menu "PlasmaComponents"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

Search



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