2
* Copyright 2012 Marco Martin <mart@kde.org>
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.
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
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.
21
import org.kde.plasma.core 0.1 as PlasmaCore
22
import org.kde.plasma.extras 0.1 as PlasmaExtras
23
import org.kde.plasma.components 0.1 as PlasmaComponents
27
property Item visualParent
29
property int status: PlasmaComponents.DialogStatus.Closed
30
default property alias data: contentItem.data
34
if (root.visualParent) {
35
internal.parentPos = root.visualParent.mapToItem(dismissArea.parent, 0, 0)
37
root.status = PlasmaComponents.DialogStatus.Opening
38
appearAnimation.running = true
43
root.status = PlasmaComponents.DialogStatus.Closing
44
appearAnimation.running = true
51
easing.type: Easing.InOutQuad
54
to: root.status == PlasmaComponents.DialogStatus.Opening ? 1 : 0
57
script: root.status == PlasmaComponents.DialogStatus.Opening ? root.status = PlasmaComponents.DialogStatus.Open : PlasmaComponents.DialogStatus.Closed
66
//to not pass hover events to the background
69
//FIXME: this is an hack: it's taking the dialog background making sure no opaque or transparent are selected
70
//in Plasma2 we need to have the backingstore blur there as well
71
PlasmaExtras.FallbackComponent {
73
basePath: "desktoptheme"
74
candidates: [theme.themeName, "default"]
75
property string svgPath: fallbackComponent.filePath("/dialogs/background.svgz")
79
//fallback if inline-background doesn't work
81
fallbackComponent.svgPath = fallbackComponent.filePath("/dialogs/background.svgz")
82
shadowFrame.visible = backgroundSvg.hasElement("shadow-top")
85
PlasmaCore.FrameSvgItem {
87
imagePath: fallbackComponent.svgPath
91
leftMargin: -margins.left
92
topMargin: -margins.top
93
rightMargin: -margins.right
94
bottomMargin: -margins.bottom
96
Component.onCompleted: shadowFrame.visible = backgroundSvg.hasElement("shadow-top")
98
PlasmaCore.FrameSvgItem {
100
property variant parentPos
101
imagePath: fallbackComponent.svgPath
102
property bool under: root.visualParent ? internal.parentPos.y + root.visualParent.height + height < dismissArea.height : true
103
//bindings won't work inside anchers definition
106
tipSvg.anchors.top = undefined
107
tipSvg.anchors.bottom = tipSvg.parent.top
109
tipSvg.anchors.bottom = undefined
110
tipSvg.anchors.top = tipSvg.parent.bottom
115
if (root.visualParent) {
116
internal.parentPos.x - internal.width/2 + root.visualParent.width/2
118
dismissArea.width/2 - internal.width/2
122
if (root.visualParent) {
124
internal.parentPos.y + root.visualParent.height
126
internal.parentPos.y - internal.height
129
dismissArea.height/2 - internal.height/2
132
width: contentItem.width + margins.left + margins.right
133
height: contentItem.height + margins.top + margins.bottom
137
visible: root.visualParent != null
138
svg: PlasmaCore.Svg {
140
imagePath: fallbackComponent.svgPath
142
elementId: internal.under ? "baloon-tip-top" : "baloon-tip-bottom"
144
horizontalCenter: parent.horizontalCenter
147
topMargin: -backgroundSvg.elementSize("hint-bottom-shadow").height - 1
148
bottomMargin: -backgroundSvg.elementSize("hint-top-shadow").height - 1
150
width: naturalSize.width
151
height: naturalSize.height
155
x: parent.margins.left
156
y: parent.margins.top
157
width: childrenRect.width
158
height: childrenRect.height
159
onClicked: mouse.accepted = true
165
Component.onCompleted: {
167
while (candidate.parent) {
168
candidate = candidate.parent
171
dismissArea.parent = candidate
173
dismissArea.visible = false
175
internal.parentPos = root.mapToItem(dismissArea.parent, 0, 0)