Remove audio tests from main page

This commit is contained in:
Matti Viljanen 2020-03-20 16:16:30 +02:00
parent a4b709c476
commit 21a4b9e0e8
No known key found for this signature in database
GPG key ID: CF32A1495158F888
2 changed files with 58 additions and 102 deletions

View file

@ -16,11 +16,69 @@
* Author: Matti Viljanen * Author: Matti Viljanen
*/ */
import QtQuick 2.0 import QtQuick 2.0
import QtMultimedia 5.6
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
import Nemo.Notifications 1.0
import "pages" import "pages"
ApplicationWindow ApplicationWindow
{ {
SoundEffect {
id: alertLow
volume: 0.6
source: settings.lowAlertFile
}
SoundEffect {
id: alertHigh
volume: 0.6
source: settings.highAlertFile
}
Notification {
id: notification
property bool test: false
appName: qsTr("Battery Buddy")
appIcon: "/usr/share/icons/hicolor/128x128/apps/harbour-batterybuddy.png"
summary: qsTr("Battery charge", "Battery charge 20%") +" "+ battery.charge + "%"
body: test ? qsTr("This is a test.") : battery.charging ? qsTr("Please disconnect the charger.") : qsTr("Please connect the charger.")
previewSummary: summary
previewBody: body
urgency: Notification.Critical
function republish() {
if(replacesId > 0)
close()
publish()
}
function republishTest() {
test = true
republish()
test = false
}
}
Timer {
id: alertTimer
interval: settings.interval * 1000 // sec -> msec
running: true
repeat: true
onTriggered: {
if(battery.charge <= settings.lowerLimit && battery.state === "discharging") {
alertLow.play()
notification.republish()
}
else if(battery.charge >= settings.upperLimit &&
(battery.state === "charging" && battery.charging === true) || (battery.state === "idle" && battery.charging === false)) {
alertHigh.play()
notification.republish()
}
else if(notification.replacesId > 0) {
notification.close()
}
}
}
initialPage: Component { MainPage { } } initialPage: Component { MainPage { } }
cover: Qt.resolvedUrl("cover/CoverPage.qml") cover: Qt.resolvedUrl("cover/CoverPage.qml")
allowedOrientations: defaultAllowedOrientations allowedOrientations: defaultAllowedOrientations

View file

@ -16,9 +16,7 @@
* Author: Matti Viljanen * Author: Matti Viljanen
*/ */
import QtQuick 2.0 import QtQuick 2.0
import QtMultimedia 5.6
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
import Nemo.Notifications 1.0
import "../components" import "../components"
Page { Page {
@ -36,62 +34,6 @@ Page {
} }
} }
SoundEffect {
id: alertLow
volume: 0.6
source: settings.lowAlertFile
}
SoundEffect {
id: alertHigh
volume: 0.6
source: settings.highAlertFile
}
Notification {
id: notification
property bool test: false
appName: qsTr("Battery Buddy")
appIcon: "/usr/share/icons/hicolor/128x128/apps/harbour-batterybuddy.png"
summary: qsTr("Battery charge", "Battery charge 20%") +" "+ battery.charge + "%"
body: test ? qsTr("This is a test.") : battery.charging ? qsTr("Please disconnect the charger.") : qsTr("Please connect the charger.")
previewSummary: summary
previewBody: body
urgency: Notification.Critical
function republish() {
if(replacesId > 0)
close()
publish()
}
function republishTest() {
test = true
republish()
test = false
}
}
Timer {
id: alertTimer
interval: settings.interval * 1000 // sec -> msec
running: true
repeat: true
onTriggered: {
if(battery.charge <= settings.lowerLimit && battery.state === "discharging") {
alertLow.play()
notification.republish()
}
else if(battery.charge >= settings.upperLimit &&
(battery.state === "charging" && battery.charging === true) || (battery.state === "idle" && battery.charging === false)) {
alertHigh.play()
notification.republish()
}
else if(notification.replacesId > 0) {
notification.close()
}
}
}
// To enable PullDownMenu, place our content in a SilicaFlickable // To enable PullDownMenu, place our content in a SilicaFlickable
SilicaFlickable { SilicaFlickable {
id: mainFlickable id: mainFlickable
@ -168,50 +110,6 @@ Page {
color: Theme.primaryColor color: Theme.primaryColor
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
} }
Label {
x: Theme.paddingLarge
text: qsTr("Alert tests")
color: Theme.highlightColor
}
Label {
x: Theme.paddingLarge*2
width: parent.width - x*2;
wrapMode: Text.Wrap
text: qsTr("Click the buttons to test the sound and notification.")
color: Theme.primaryColor
font.pixelSize: Theme.fontSizeSmall
}
Item {
width: parent.width
height: lowButton.height
anchors.left: parent.left
Item {
width: parent.width / 2
height: lowButton.height
Button {
id: lowButton
anchors.centerIn: parent
text: qsTr("Discharged")
onClicked: {
alertLow.play()
notification.republishTest()
}
}
}
Item {
anchors.right: parent.right
width: parent.width / 2
height: lowButton.height
Button {
text: qsTr("Charged")
anchors.centerIn: parent
onClicked: {
alertHigh.play()
notification.republishTest()
}
}
}
}
Item { Item {
width: parent.width width: parent.width
height: Theme.paddingLarge height: Theme.paddingLarge