• 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
Sheet.qml
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Marco Martin <mart@kde.org>
4 **
5 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 ** All rights reserved.
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** This file is part of the Qt Components project.
10 **
11 ** $QT_BEGIN_LICENSE:BSD$
12 ** You may use this file under the terms of the BSD license as follows:
13 **
14 ** "Redistribution and use in source and binary forms, with or without
15 ** modification, are permitted provided that the following conditions are
16 ** met:
17 ** * Redistributions of source code must retain the above copyright
18 ** notice, this list of conditions and the following disclaimer.
19 ** * Redistributions in binary form must reproduce the above copyright
20 ** notice, this list of conditions and the following disclaimer in
21 ** the documentation and/or other materials provided with the
22 ** distribution.
23 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
24 ** the names of its contributors may be used to endorse or promote
25 ** products derived from this software without specific prior written
26 ** permission.
27 **
28 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42 
43 import QtQuick 1.0
44 import org.kde.plasma.core 0.1 as PlasmaCore
45 import "private/AppManager.js" as Utils
46 import "." 0.1
47 
57 Item {
58  id: root
59 
64  property alias title: titleLabel.text
65 
72  property alias content: contentItem.children
73 // property alias visualParent: dialog.visualParent
74 
85  property int status: DialogStatus.Closed
86  property alias acceptButtonText: acceptButton.text
87  property alias rejectButtonText: rejectButton.text
93  property alias acceptButton: acceptButton
94 
99  property alias rejectButton: rejectButton
100 
101  property alias privateTitleHeight: titleBar.height
102  property alias privateButtonsHeight: buttonsRow.height
103 
108  signal accepted
109 
116  signal rejected
117 
124  signal clickedOutside
125 
129  function open()
130  {
131  var pos = dialog.popupPosition(null, Qt.AlignCenter)
132  dialog.x = pos.x
133  dialog.y = pos.y
134 
135  dialog.visible = true
136  dialog.activateWindow()
137  }
138 
145  function accept()
146  {
147  if (status == DialogStatus.Open) {
148  dialog.visible = false
149  accepted()
150  }
151  }
152 
159  function reject() {
160  if (status == DialogStatus.Open) {
161  dialog.visible = false
162  rejected()
163  }
164  }
165 
169  function close() {
170  dialog.visible = false
171  }
172 
173  visible: false
174 
175  PlasmaCore.Dialog {
176  id: dialog
177  windowFlags: Qt.Dialog
178  location: 4 //FIXME: replace with BottomEdge when we have an enum reachable from everywhere in core
179 
180 
181  //onFaderClicked: root.clickedOutside()
182  property Item rootItem
183 
184  //state: "Hidden"
185  visible: false
186  onVisibleChanged: {
187  if (visible) {
188  status = DialogStatus.Open
189  } else {
190  status = DialogStatus.Closed
191  }
192  }
193 
194  mainItem: Item {
195  id: mainItem
196  width: theme.defaultFont.mSize.width * 40
197  height: Math.max(titleBar.childrenRect.height + contentItem.childrenRect.height + buttonsRow.childrenRect.height + 8, theme.defaultFont.mSize.height * 25)
198 
199  // Consume all key events that are not processed by children
200  Keys.onPressed: event.accepted = true
201  Keys.onReleased: event.accepted = true
202 
203  PlasmaCore.FrameSvgItem {
204  id: titleBar
205  imagePath: "widgets/extender-dragger"
206  prefix: "root"
207  anchors.left: parent.left
208  anchors.right: parent.right
209  //FIXME: +5 because of Plasma::Dialog margins
210  height: titleLabel.paintedHeight + margins.top + margins.bottom
211 
212  Column {
213  id: titleLayoutHelper // needed to make the text mirror correctly
214 
215  anchors {
216  right: parent.right
217  left: parent.left
218  top: parent.top
219  bottom: parent.bottom
220  leftMargin: parent.margins.left
221  rightMargin: parent.margins.right
222  topMargin: parent.margins.top
223  bottomMargin: parent.margins.bottom
224  }
225 
226  Label {
227  id: titleLabel
228  elide: Text.ElideRight
229  height: paintedHeight
230  font.pointSize: theme.defaultFont.pointSize * 1.1
231  font.weight: Font.Bold
232  style: Text.Raised
233  styleColor: Qt.rgba(1,1,1,0.8)
234  anchors {
235  left: parent.left
236  right: parent.right
237  }
238  horizontalAlignment: Text.AlignHCenter
239  verticalAlignment: Text.AlignVCenter
240  }
241  }
242  }
243 
244  Item {
245  id: contentItem
246 
247  onChildrenRectChanged: mainItem.width = Math.max(childrenRect.width, buttonsRow.childrenRect.width)
248 
249  clip: true
250  anchors {
251  top: titleBar.bottom
252  left: parent.left
253  right: parent.right
254  bottom: buttonsRow.top
255  bottomMargin: 8
256  }
257  }
258 
259  Row {
260  id: buttonsRow
261  spacing: 8
262  anchors {
263  bottom: parent.bottom
264  horizontalCenter: parent.horizontalCenter
265  //the bottom margin is disabled but we want it anyways
266  bottomMargin: theme.defaultFont.mSize.height*0.6
267  }
268 
269  Button {
270  id: acceptButton
271  onClicked: accept()
272  }
273 
274  Button {
275  id: rejectButton
276  onClicked: reject()
277  }
278  }
279  }
280 
281  Component.onCompleted: {
282  rootItem = Utils.rootObject()
283  }
284  }
285 }
Button
A button with optional label and icon which uses the plasma theme.
Definition: Button.qml:32
DialogStatus::Closed
Definition: enums.h:37
DialogStatus::Open
Definition: enums.h:35
Label
This is a label which uses the plasma theme.
Definition: Label.qml:32
Item
Column
DialogStatus
Definition: enums.h:27
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