• Skip to content
  • Skip to link menu
Brand

API Documentation

  1. KDE API Reference
  2. Kirigami
  • KDE Home
  • Contact Us

Quick Links

Skip menu "Kirigami"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List
  • Related Pages

Class Picker

About

QtQuick plugins to build user interfaces based on the KDE UX guidelines

Maintainer
Marco Martin
Supported platforms
Android, Linux
Community
IRC: #plasma on Freenode
Mailing list: plasma-devel
Use with CMake
find_package(KF5Kirigami)
target_link_libraries(yourapp KF5::Kirigami)
Clone
git clone git://anongit.kde.org/kirigami1.git
Browse source
Kirigami on cgit.kde.org

Kirigami

  • src
  • controls
  • templates
  • private
PassiveNotification.qml
1 /*
2  * Copyright 2015 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 2.5
21 import QtQuick.Controls 1.3 as Controls
22 import QtQuick.Layouts 1.2
23 import QtGraphicalEffects 1.0
24 import org.kde.kirigami 1.0
25 
26 MouseArea {
27  id: root
28  z: 9999
29  width: background.width
30  height: background.height
31  opacity: 0
32  enabled: appearAnimation.appear
33 
34  anchors {
35  horizontalCenter: parent.horizontalCenter
36  bottom: parent.bottom
37  bottomMargin: Units.gridUnit * 4
38  }
39  function showNotification(message, timeout, actionText, callBack) {
40  if (!message) {
41  return;
42  }
43  appearAnimation.running = false;
44  appearAnimation.appear = true;
45  appearAnimation.running = true;
46  if (timeout == "short") {
47  timer.interval = 1000;
48  } else if (timeout == "long") {
49  timer.interval = 4500;
50  } else if (timeout > 0) {
51  timer.interval = timeout;
52  } else {
53  timer.interval = 4500;
54  }
55  messageLabel.text = message ? message : "";
56  actionButton.text = actionText ? actionText : "";
57  actionButton.callBack = callBack ? callBack : "";
58 
59  timer.restart();
60  }
61 
62  function hideNotification() {
63  appearAnimation.running = false;
64  appearAnimation.appear = false;
65  appearAnimation.running = true;
66  }
67 
68 
69  onClicked: {
70  appearAnimation.appear = false;
71  appearAnimation.running = true;
72  }
73 
74  transform: Translate {
75  id: transform
76  y: root.height
77  }
78 
79  Timer {
80  id: timer
81  interval: 4000
82  onTriggered: {
83  appearAnimation.appear = false;
84  appearAnimation.running = true;
85  }
86  }
87  ParallelAnimation {
88  id: appearAnimation
89  property bool appear: true
90  NumberAnimation {
91  target: root
92  properties: "opacity"
93  to: appearAnimation.appear ? 1 : 0
94  duration: Units.longDuration
95  easing.type: Easing.InOutQuad
96  }
97  NumberAnimation {
98  target: transform
99  properties: "y"
100  to: appearAnimation.appear ? 0 : background.height
101  duration: Units.longDuration
102  easing.type: appearAnimation.appear ? Easing.OutQuad : Easing.InQuad
103  }
104  }
105 
106  Item {
107  id: background
108  width: backgroundRect.width + Units.gridUnit
109  height: backgroundRect.height + Units.gridUnit
110  Rectangle {
111  id: backgroundRect
112  anchors.centerIn: parent
113  radius: Units.smallSpacing
114  color: Theme.textColor
115  opacity: 0.6
116  width: mainLayout.width + Math.round((height - mainLayout.height))
117  height: Math.max(mainLayout.height + Units.smallSpacing*2, Units.gridUnit*2)
118  }
119  RowLayout {
120  id: mainLayout
121  anchors.centerIn: parent
122  Label {
123  id: messageLabel
124  width: Math.min(root.parent.width - Units.largeSpacing*2, implicitWidth)
125  elide: Text.ElideRight
126  color: Theme.backgroundColor
127  }
128  Controls.Button {
129  id: actionButton
130  property var callBack
131  visible: text != ""
132  onClicked: {
133  appearAnimation.appear = false;
134  appearAnimation.running = true;
135  if (callBack) {
136  callBack();
137  }
138  }
139  }
140  }
141  layer.enabled: true
142  layer.effect: DropShadow {
143  horizontalOffset: 0
144  verticalOffset: 0
145  radius: Units.gridUnit
146  samples: 32
147  color: Qt.rgba(0, 0, 0, 0.5)
148  }
149  }
150 }
151 
org::kde::kirigami::Units::smallSpacing
int smallSpacing
units.smallSpacing is the amount of spacing that should be used around smaller UI elements...
Definition: controls/Units.qml:56
org::kde::kirigami::Units::longDuration
int longDuration
units.longDuration should be used for longer, screen-covering animations, for opening and closing of ...
Definition: controls/Units.qml:75
org::kde::kirigami::Units::largeSpacing
int largeSpacing
units.largeSpacing is the amount of spacing that should be used inside bigger UI elements, for example between an icon and the corresponding text.
Definition: controls/Units.qml:63
org::kde::kirigami::Label
This is a label which uses the plasma Theme.
Definition: Label.qml:36
org::kde::kirigami::Theme
Definition: controls/Theme.qml:22
org::kde::kirigami::Units::gridUnit
int gridUnit
The fundamental unit of space that should be used for sizes, expressed in pixels. ...
Definition: controls/Units.qml:31
org::kde::kirigami::Units
Definition: controls/Units.qml:24
This file is part of the KDE documentation.
Documentation copyright © 1996-2017 The KDE developers.
Generated on Fri Feb 17 2017 11:09:23 by doxygen 1.8.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

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