[Sailfish] Notifications with nemomobile plugin

This commit is contained in:
Muki 2016-11-19 13:57:28 +01:00
parent 895473dbe7
commit e005aaadfa
2 changed files with 47 additions and 64 deletions

View file

@ -0,0 +1,47 @@
/*
Copyright (C) 2016 Michal Kosciesza <michal@mkiol.net>
This file is part of Kaktus.
Kaktus is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Kaktus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Kaktus. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.0
import Sailfish.Silica 1.0
import org.nemomobile.notifications 1.0
Notification {
id: root
expireTimeout: 4000
maxContentLines: 10
function show(bodyText, summaryText, clickedHandler) {
if (!bodyText || bodyText === "")
return
if (bodyText === root.body)
close()
if (clickedHandler)
root.connect.clicked = clickedHandler
summaryText = summaryText ? summaryText : ""
replacesId = 0
body = bodyText
previewBody = bodyText
summary = summaryText
previewSummary = summaryText
publish()
}
}

View file

@ -1,64 +0,0 @@
/*
Copyright (C) 2014 Michal Kosciesza <michal@mkiol.net>
This file is part of Kaktus.
Kaktus is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Kaktus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Kaktus. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.0
import Sailfish.Silica 1.0
Rectangle {
id: root
rotation: app.orientation==Orientation.Portrait ? 0 : 90
transformOrigin: Item.TopLeft
height: app.orientation==Orientation.Portrait ? label.height + 2*Theme.paddingSmall : label.height + 1*Theme.paddingSmall
width: app.orientation==Orientation.Portrait ? app.width : app.height
y: app.orientation==Orientation.Portrait ? 0 : 0
x: app.orientation==Orientation.Portrait ? 0 : app.width
color: Theme.highlightBackgroundColor
opacity: timer.running ? 1.0 : 0.0
MouseArea {
anchors.fill: parent
onClicked: timer.stop()
}
Behavior on opacity { FadeAnimation {} }
function show(text) {
label.text = text;
timer.restart();
}
Label {
id: label
font.pixelSize: Theme.fontSizeSmall
font.family: Theme.fontFamily
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left; anchors.leftMargin: Theme.paddingMedium
anchors.right: parent.right; anchors.rightMargin: Theme.paddingMedium
opacity: 0.8
wrapMode: Text.WordWrap
color: Theme.highlightDimmerColor
}
Timer {
id: timer
interval: 4000
}
}