From ee991234d5884863e91fa1463f29f43536d0dddc Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Mon, 20 Mar 2017 09:09:35 +0100 Subject: make Notification.qml follow coding style --- components/package/contents/ui/Notification.qml | 65 +++++++++++++++---------- 1 file changed, 38 insertions(+), 27 deletions(-) (limited to 'components/package') diff --git a/components/package/contents/ui/Notification.qml b/components/package/contents/ui/Notification.qml index 2e01eabb..81275b02 100644 --- a/components/package/contents/ui/Notification.qml +++ b/components/package/contents/ui/Notification.qml @@ -4,13 +4,37 @@ import org.kde.kirigami 1.0 as Kirigami MouseArea { id: popup - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter - width: Math.max(300, message.contentWidth + (Kirigami.Units.largeSpacing * 2)) - height: Math.max(50, message.contentHeight + (Kirigami.Units.largeSpacing * 2)) + property alias title: message.text property alias timeout: hideTimer.interval property alias background: bg.color + + function hide() { + if (hideTimer.running) + hideTimer.stop() + popup.opacity = 0.0 + } + + function show() { + console.warn("Trying to show the notification", title); + popup.opacity = 1.0 + hideTimer.restart() + } + + function notify(text) { + popup.title = text + bg.color = Kirigami.Theme.highlightColor + show() + } + + anchors { + top: parent.top + horizontalCenter: parent.horizontalCenter + } + + width: Math.max(300, message.contentWidth + (Kirigami.Units.largeSpacing * 2)) + height: Math.max(50, message.contentHeight + (Kirigami.Units.largeSpacing * 2)) + visible: opacity > 0 opacity: 0.0 @@ -35,33 +59,20 @@ MouseArea { onTriggered: popup.hide() } - function hide() { - if (hideTimer.running) - hideTimer.stop() - popup.opacity = 0.0 - } - - function show() { - console.warn("Trying to show the notification", title); - popup.opacity = 1.0 - hideTimer.restart() - } - - function notify(text) { - popup.title = text - bg.color = Kirigami.Theme.highlightColor - show() - } - Label { id: message - anchors.verticalCenter: popup.verticalCenter + + anchors { + verticalCenter: popup.verticalCenter + left: parent.left + leftMargin: Kirigami.Units.largeSpacing + right: parent.right + rightMargin: Kirigami.Units.largeSpacing + } + font.pixelSize: 16 + color: Kirigami.Theme.highlightedTextColor - anchors.left: parent.left - anchors.leftMargin: Kirigami.Units.largeSpacing - anchors.right: parent.right - anchors.rightMargin: Kirigami.Units.largeSpacing horizontalAlignment: Text.AlignHCenter elide: Text.ElideRight wrapMode: Text.Wrap -- cgit v1.2.3