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
+50
View File
@@ -0,0 +1,50 @@
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import ovras.advsettings 1.0
MyComboBox {
textRole: "text"
valueRole: "value"
model: [
{ value: 0, text: "00" },
{ value: 1, text: "01" },
{ value: 2, text: "02" },
{ value: 3, text: "03" },
{ value: 4, text: "04" },
{ value: 5, text: "05" },
{ value: 6, text: "06" },
{ value: 7, text: "07" },
{ value: 8, text: "08" },
{ value: 9, text: "09" },
{ value: 10, text: "10" },
{ value: 11, text: "11" },
{ value: 12, text: "12" },
{ value: 13, text: "13" },
{ value: 14, text: "14" },
{ value: 15, text: "15" },
{ value: 16, text: "16" },
{ value: 17, text: "17" },
{ value: 18, text: "18" },
{ value: 19, text: "19" },
{ value: 20, text: "20" },
{ value: 21, text: "21" },
{ value: 22, text: "22" },
{ value: 23, text: "23" },
]
delegate: ItemDelegate {
width: parent.width
text: modelData.text
hoverEnabled: true
contentItem: MyText {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
text: parent.text
color: parent.enabled ? "#ffffff" : "#909090"
}
background: Rectangle {
color: parent.pressed ? "#406288" : (parent.hovered ? "#365473" : "#2c435d")
}
}
}
@@ -0,0 +1,86 @@
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import ovras.advsettings 1.0
MyComboBox {
textRole: "text"
valueRole: "value"
model: [
{ value: 0, text: "00" },
{ value: 1, text: "01" },
{ value: 2, text: "02" },
{ value: 3, text: "03" },
{ value: 4, text: "04" },
{ value: 5, text: "05" },
{ value: 6, text: "06" },
{ value: 7, text: "07" },
{ value: 8, text: "08" },
{ value: 9, text: "09" },
{ value: 10, text: "10" },
{ value: 11, text: "11" },
{ value: 12, text: "12" },
{ value: 13, text: "13" },
{ value: 14, text: "14" },
{ value: 15, text: "15" },
{ value: 16, text: "16" },
{ value: 17, text: "17" },
{ value: 18, text: "18" },
{ value: 19, text: "19" },
{ value: 20, text: "20" },
{ value: 21, text: "21" },
{ value: 22, text: "22" },
{ value: 23, text: "23" },
{ value: 24, text: "24" },
{ value: 25, text: "25" },
{ value: 26, text: "26" },
{ value: 27, text: "27" },
{ value: 28, text: "28" },
{ value: 29, text: "29" },
{ value: 30, text: "30" },
{ value: 31, text: "31" },
{ value: 32, text: "32" },
{ value: 33, text: "33" },
{ value: 34, text: "34" },
{ value: 35, text: "35" },
{ value: 36, text: "36" },
{ value: 37, text: "37" },
{ value: 38, text: "38" },
{ value: 39, text: "39" },
{ value: 40, text: "40" },
{ value: 41, text: "41" },
{ value: 42, text: "42" },
{ value: 43, text: "43" },
{ value: 44, text: "44" },
{ value: 45, text: "45" },
{ value: 46, text: "46" },
{ value: 47, text: "47" },
{ value: 48, text: "48" },
{ value: 49, text: "49" },
{ value: 50, text: "50" },
{ value: 51, text: "51" },
{ value: 52, text: "52" },
{ value: 53, text: "53" },
{ value: 54, text: "54" },
{ value: 55, text: "55" },
{ value: 56, text: "56" },
{ value: 57, text: "57" },
{ value: 58, text: "58" },
{ value: 59, text: "59" }
]
delegate: ItemDelegate {
width: parent.width
text: modelData.text
hoverEnabled: true
contentItem: MyText {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
text: parent.text
color: parent.enabled ? "#ffffff" : "#909090"
}
background: Rectangle {
color: parent.pressed ? "#406288" : (parent.hovered ? "#365473" : "#2c435d")
}
}
}
+49
View File
@@ -0,0 +1,49 @@
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import ovras.advsettings 1.0
RowLayout {
signal timeChanged(int hour, int minute, int second)
HourComboBox {
id: hourBox
onActivated: {
parent.timeChanged(hourBox.currentIndex,
minuteBox.currentIndex,
secondBox.currentIndex)
}
}
MyText {
text: "h"
}
MinuteSecondComboBox {
id: minuteBox
onActivated: {
parent.timeChanged(hourBox.currentIndex,
minuteBox.currentIndex,
secondBox.currentIndex)
}
}
MyText {
text: "m"
}
MinuteSecondComboBox {
id: secondBox
onActivated: {
parent.timeChanged(hourBox.currentIndex,
minuteBox.currentIndex,
secondBox.currentIndex)
}
}
MyText {
text: "s"
}
function changeTimer(hour, minute, second) {
hourBox.currentIndex = hour
minuteBox.currentIndex = minute
secondBox.currentIndex = second
}
}
@@ -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())
}
}
}