Plasma

Sheet.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Marco Martin <[email protected]>
4 **
5 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 ** All rights reserved.
7 ** Contact: Nokia Corporation ([email protected])
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 2.1
44 import org.kde.plasma.core 2.0 as PlasmaCore
45 import "private/AppManager.js" as Utils
46 import "." 2.0 as PlasmaComponents
47 
59 Item {
60  id: root
61 
66  property alias title: titleLabel.text
67 
74  property alias content: contentItem.children
75 // property alias visualParent: dialog.visualParent
76 
87  property int status: PlasmaComponents.DialogStatus.Closed
88  property alias acceptButtonText: acceptButton.text
89  property alias rejectButtonText: rejectButton.text
95  property alias acceptButton: acceptButton
96 
101  property alias rejectButton: rejectButton
102 
103  property alias privateTitleHeight: titleBar.height
104  property alias privateButtonsHeight: buttonsRow.height
105 
110  signal accepted
111 
118  signal rejected
119 
126  signal clickedOutside
127 
131  function open()
132  {
133  dialog.visible = true
134  dialog.requestActivate()
135  }
136 
143  function accept()
144  {
145  if (status == DialogStatus.Open) {
146  dialog.visible = false
147  accepted()
148  }
149  }
150 
157  function reject() {
158  if (status == DialogStatus.Open) {
159  dialog.visible = false
160  rejected()
161  }
162  }
163 
167  function close() {
168  dialog.visible = false
169  }
170 
171  visible: false
172 
173  PlasmaCore.Dialog {
174  id: dialog
175  flags: Qt.Dialog
176  location: PlasmaCore.Types.BottomEdge
177 
178 
179  //onFaderClicked: root.clickedOutside()
180  property Item rootItem
181 
182  //state: "Hidden"
183  visible: false
184  onVisibleChanged: {
185  if (visible) {
186  status = PlasmaComponents.DialogStatus.Open
187  } else {
188  status = PlasmaComponents.DialogStatus.Closed
189  }
190  }
191 
192  mainItem: Item {
193  id: mainItem
194  width: PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).width * 40
195  height: Math.max(titleBar.childrenRect.height + contentItem.childrenRect.height + buttonsRow.childrenRect.height + 8, PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height * 25)
196 
197  // Consume all key events that are not processed by children
198  Keys.onPressed: event.accepted = true
199  Keys.onReleased: event.accepted = true
200 
201  PlasmaCore.FrameSvgItem {
202  id: titleBar
203  imagePath: "widgets/extender-dragger"
204  prefix: "root"
205  anchors.left: parent.left
206  anchors.right: parent.right
207  //FIXME: +5 because of Plasma::Dialog margins
208  height: titleLabel.paintedHeight + margins.top + margins.bottom
209 
210  Column {
211  id: titleLayoutHelper // needed to make the text mirror correctly
212 
213  anchors {
214  right: parent.right
215  left: parent.left
216  top: parent.top
217  bottom: parent.bottom
218  leftMargin: parent.margins.left
219  rightMargin: parent.margins.right
220  topMargin: parent.margins.top
221  bottomMargin: parent.margins.bottom
222  }
223 
224  PlasmaComponents.Label {
225  id: titleLabel
226  elide: Text.ElideRight
227  height: paintedHeight
228  font.pointSize: PlasmaCore.Theme.defaultFont.pointSize * 1.1
229  font.weight: Font.Bold
230  style: Text.Raised
231  styleColor: Qt.rgba(1,1,1,0.8)
232  anchors {
233  left: parent.left
234  right: parent.right
235  }
236  horizontalAlignment: Text.AlignHCenter
237  verticalAlignment: Text.AlignVCenter
238  }
239  }
240  }
241 
242  Item {
243  id: contentItem
244 
245  onChildrenRectChanged: mainItem.width = Math.max(childrenRect.width, buttonsRow.childrenRect.width)
246 
247  clip: true
248  anchors {
249  top: titleBar.bottom
250  left: parent.left
251  right: parent.right
252  bottom: buttonsRow.top
253  bottomMargin: 8
254  }
255  }
256 
257  Row {
258  id: buttonsRow
259  spacing: 8
260  anchors {
261  bottom: parent.bottom
262  horizontalCenter: parent.horizontalCenter
263  //the bottom margin is disabled but we want it anyways
264  bottomMargin: PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height*0.6
265  }
266 
267  PlasmaComponents.Button {
268  id: acceptButton
269  onClicked: accept()
270  }
271 
272  PlasmaComponents.Button {
273  id: rejectButton
274  onClicked: reject()
275  }
276  }
277  }
278 
279  Component.onCompleted: {
280  rootItem = Utils.rootObject(this)
281  }
282  }
283 }
QTextStream & right(QTextStream &stream)
QVariant location(const QVariant &res)
const QList< QKeySequence > & close()
QTextStream & left(QTextStream &stream)
QTextStream & left(QTextStream &s)
QTextStream & right(QTextStream &s)
KIOCORE_EXPORT FileJob * open(const QUrl &url, QIODevice::OpenMode mode)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 7 2020 22:39:25 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.