Refactor alarm system and replace notification method

The old OpenVR overlays did not function for unknown reasons, and it was
not possible to get them to work.

With this a white overlay with ALARM ACTIVATED will be shown for 3 seconds.
It's not pretty, but it effectively communicates that an alarm has been
activated.

This fixes
https://github.com/OpenVR-Advanced-Settings/OpenVR-AdvancedSettings/issues/417
This commit is contained in:
Vasily
2020-06-05 20:52:13 +02:00
committed by username223
parent 8c2af7477c
commit 4757756d32
16 changed files with 531 additions and 457 deletions
@@ -10,7 +10,7 @@ GroupBox {
label: MyText {
leftPadding: 10
text: "Alarm Clock"
text: "Clock"
bottomPadding: -10
}
background: Rectangle {
@@ -19,164 +19,97 @@ GroupBox {
radius: 8
}
ColumnLayout {
anchors.fill: parent
Rectangle {
color: "#ffffff"
height: 1
Layout.fillWidth: true
Layout.bottomMargin: 5
}
RowLayout {
MyToggleButton {
id: alarmClockToggle
text: ""
onCheckedChanged: {
UtilitiesTabController.setAlarmEnabled(checked, false)
}
property int activationButtonWidth: 170;
property int startStopPauseResetButtonWidth: 220
ColumnLayout {
LineSeparator {
}
Item {
Layout.fillWidth: true
}
MyTextField {
id: alarmClockHourText
text: "00"
keyBoardUID: 602
Layout.preferredWidth: 50
horizontalAlignment: Text.AlignHCenter
function onInputEvent(input) {
var val = parseInt(input)
if (!isNaN(val)) {
if (val < 0) {
val = 0
} else if (val > 23) {
val = 23
}
UtilitiesTabController.setAlarmTimeHour(val, false)
RowLayout {
MyToggleButton {
id: alarmClockToggle
text: "Alarm"
Layout.preferredWidth: parent.parent.parent.activationButtonWidth
onCheckedChanged: {
VrAlarm.alarmEnabled = checked
}
parent.parent.parent.setAlarmHourText(UtilitiesTabController.alarmTimeHour)
}
}
MyText {
text: ":"
}
MyTextField {
id: alarmClockMinuteText
text: "00"
keyBoardUID: 603
Layout.preferredWidth: 50
horizontalAlignment: Text.AlignHCenter
function onInputEvent(input) {
var val = parseInt(input)
if (!isNaN(val)) {
if (val < 0) {
val = 0
} else if (val > 59) {
val = 59
}
UtilitiesTabController.setAlarmTimeMinute(val, false)
TimeAssembly {
id: alarmClockTimeAssembly
onTimeChanged: {
VrAlarm.setAlarmTime(hour, minute, second)
}
parent.parent.parent.setAlarmMinuteText(UtilitiesTabController.alarmTimeMinute)
}
}
Item {
Layout.fillWidth: true
}
MyPushButton2 {
Layout.preferredWidth: 200
text: "Current Time"
onClicked: {
UtilitiesTabController.setAlarmTimeToCurrentTime()
Item {
Layout.fillWidth: true
}
}
MyPushButton2 {
Layout.leftMargin: 50
Layout.preferredWidth: 120
text: "+1 Hour"
onClicked: {
UtilitiesTabController.modAlarmTimeHour(1)
MyPushButton2 {
Layout.preferredWidth: 170
text: "Current Time"
onClicked: {
VrAlarm.setAlarmTimeToCurrentTime()
alarmClockTimeAssembly.changeTimer(VrAlarm.getAlarmHour(),
VrAlarm.getAlarmMinute(),
VrAlarm.getAlarmSecond())
}
}
}
MyPushButton2 {
Layout.preferredWidth: 120
text: "-1 Hour"
onClicked: {
UtilitiesTabController.modAlarmTimeHour(-1)
MyPushButton2 {
Layout.preferredWidth: 120
text: "+1 Hour"
onClicked: {
VrAlarm.modAlarmTime(1, 0, 0)
}
}
}
MyPushButton2 {
text: "+5 Min"
Layout.leftMargin: 50
Layout.preferredWidth: 120
onClicked: {
UtilitiesTabController.modAlarmTimeMinute(5)
MyPushButton2 {
Layout.preferredWidth: 120
text: "-1 Hour"
onClicked: {
VrAlarm.modAlarmTime(-1, 0, 0)
}
}
}
MyPushButton2 {
Layout.preferredWidth: 120
text: "-5 Min"
onClicked: {
UtilitiesTabController.modAlarmTimeMinute(-5)
MyPushButton2 {
text: "+5 Min"
Layout.preferredWidth: 120
onClicked: {
VrAlarm.modAlarmTime(0, 5, 0)
}
}
}
}
RowLayout {
MyToggleButton {
id: alarmDontAnnoyToggle
text: "Don't Annoy me"
onCheckedChanged: {
UtilitiesTabController.setAlarmIsModal(!checked, false)
MyPushButton2 {
Layout.preferredWidth: 120
text: "-5 Min"
onClicked: {
VrAlarm.modAlarmTime(0, -5, 0)
}
}
}
}
}
Component.onCompleted: {
alarmClockToggle.checked = UtilitiesTabController.alarmEnabled
alarmDontAnnoyToggle.checked = !UtilitiesTabController.alarmIsModal
setAlarmHourText(UtilitiesTabController.alarmTimeHour)
setAlarmMinuteText(UtilitiesTabController.alarmTimeMinute)
alarmGroupBox.visible = !OverlayController.desktopMode
alarmClockToggle.checked = VrAlarm.alarmEnabled
alarmClockTimeAssembly.changeTimer(VrAlarm.getAlarmHour(),
VrAlarm.getAlarmMinute(),
VrAlarm.getAlarmSecond())
}
Connections {
target: UtilitiesTabController
target: VrAlarm
onAlarmEnabledChanged: {
alarmClockToggle.checked = UtilitiesTabController.alarmEnabled
alarmClockToggle.checked = VrAlarm.alarmEnabled
}
onAlarmIsModalChanged: {
alarmDontAnnoyToggle.checked = !UtilitiesTabController.alarmIsModal
}
onAlarmTimeHourChanged: {
setAlarmHourText(UtilitiesTabController.alarmTimeHour)
}
onAlarmTimeMinuteChanged: {
setAlarmMinuteText(UtilitiesTabController.alarmTimeMinute)
}
}
function setAlarmHourText(value) {
if (value < 9) {
alarmClockHourText.text = "0" + value
} else {
alarmClockHourText.text = value
}
}
function setAlarmMinuteText(value) {
if (value < 9) {
alarmClockMinuteText.text = "0" + value
} else {
alarmClockMinuteText.text = value
onAlarmTimeChanged: {
alarmClockTimeAssembly.changeTimer(VrAlarm.getAlarmHour(),
VrAlarm.getAlarmMinute(),
VrAlarm.getAlarmSecond())
}
}
}