• 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
CommonDialog.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.1
44 import org.kde.plasma.core 0.1 as PlasmaCore
45 import "." 0.1
46 
55 Dialog {
56  id: root
57 
59  property alias titleText: titleAreaText.text
60 
62  property string titleIcon
63 
65  property variant buttonTexts: []
66 
71  signal buttonClicked(int index)
72 
73  onButtonTextsChanged: {
74  for (var i = buttonRow.children.length; i > 0; --i) {
75  buttonRow.children[i - 1].destroy()
76  }
77  for (var j = 0; j < buttonTexts.length; ++j) {
78  var button = buttonComponent.createObject(buttonRow)
79  button.text = buttonTexts[j]
80  button.index = j
81  }
82  }
83 
84  Component {
85  id: buttonComponent
86  Button {
87  property int index
88 
89  onClicked: {
90  if (root.status == DialogStatus.Open) {
91  root.buttonClicked(index)
92  root.close()
93  }
94  }
95  }
96  }
97 
98  QtObject {
99  id: internal
100 
101  /*function buttonWidth() {
102  switch (buttonTexts.length) {
103  case 0: return 0
104  case 1: return Math.round((800 - 3 * 4) / 2)
105  default: return (buttonContainer.width - (buttonTexts.length + 1) *
106  4) / buttonTexts.length
107  }
108  }*/
109 
110  function iconSource() {
111  return root.titleIcon
112  }
113  }
114 
115  title: PlasmaCore.FrameSvgItem {
116  imagePath: "widgets/extender-dragger"
117  prefix: "root"
118  visible: titleAreaText.text != ""
119  anchors.left: parent.left
120  anchors.right: parent.right
121  //FIXME: +5 because of Plasma::Dialog margins
122  height: titleAreaText.paintedHeight + margins.top + margins.bottom
123 
124  LayoutMirroring.childrenInherit: true
125 
126  Column {
127  id: titleLayoutHelper // needed to make the text mirror correctly
128 
129  anchors {
130  right: parent.right
131  left: titleAreaIcon.source == "" ? parent.left : titleAreaIcon.right
132  top: parent.top
133  bottom: parent.bottom
134  leftMargin: parent.margins.left
135  rightMargin: parent.margins.right
136  topMargin: parent.margins.top
137  bottomMargin: parent.margins.bottom
138  }
139 
140  Label {
141  id: titleAreaText
142  LayoutMirroring.enabled: root.LayoutMirroring.enabled
143  elide: Text.ElideRight
144  height: paintedHeight
145  anchors {
146  left: parent.left
147  right: parent.right
148  }
149  horizontalAlignment: Text.AlignHCenter
150  verticalAlignment: Text.AlignVCenter
151  }
152  }
153 
154  PlasmaCore.IconItem {
155  id: titleAreaIcon
156  width: theme.iconSizeSmall
157  height: theme.iconSizeSmall
158  source: titleIcon
159  anchors.left: parent.left
160  anchors.rightMargin: 4
161  anchors.verticalCenter: parent.verticalCenter
162  }
163  }
164 
165  buttons: Row {
166  id: buttonRow
167 
168  LayoutMirroring.enabled: false
169  LayoutMirroring.childrenInherit: true
170  objectName: "buttonRow"
171  anchors.centerIn: parent
172  spacing: 4
173  }
174 }
Button
A button with optional label and icon which uses the plasma theme.
Definition: Button.qml:32
DialogStatus::Open
Definition: enums.h:35
Button::text
string text
This property holds the text label for the button.
Definition: Button.qml:62
Label
This is a label which uses the plasma theme.
Definition: Label.qml:32
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