Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MikeTrahearn/1563 Show Popup for "Detect generator at AC input" setting #1814

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion components/listitems/core/ListSwitch.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ ListItem {

anchors.fill: parent.backgroundRect
radius: backgroundRect.radius
onClicked: root._setChecked(!switchItem.checked)
onClicked: if(content.enabled) {
root._setChecked(!switchItem.checked)
} else {
root.clicked()
}
}

VeQuickItem {
Expand Down
25 changes: 18 additions & 7 deletions pages/settings/PageSettingsGenerator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,33 @@ Page {
}

ListSwitch {
id: generatorACInputSwitch

property bool generatorIsSet: acIn1Source.value === 2 || acIn2Source.value === 2
property ToastNotification toast: null
//% "Detect generator at AC input"
text: qsTrId("page_settings_generator_detect_generator_at_ac_input")
dataItem.uid: settingsBindPrefix + "/Alarms/NoGeneratorAtAcIn"
enabled: dataItem.isValid && (generatorIsSet || checked)
content.enabled: dataItem.isValid && (generatorIsSet || checked)

Connections {
target: generatorACInputSwitch.toast
function onDismissed() {
generatorACInputSwitch.toast = null
}
}

onClicked: {
if (!checked) {
generatorACInputSwitch.toast?.close(true)
if (!generatorIsSet) {
//% "None of the AC inputs is set to generator. Go to the system setup page and set the correct AC input to generator in order to enable this functionality."
Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_detect_generator_not_set"),
Theme.animation_generator_detectGeneratorNotSet_toastNotification_autoClose_duration)
generatorACInputSwitch.toast = Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_detect_generator_not_set"),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add generatorACInputSwitch?.close() to close any existing toast immediately (because we can't recycle yet)

Theme.animation_generator_detectGeneratorNotSet_toastNotification_autoClose_duration)
} else {
//% "An alarm will be triggered when no power from the generator is detected at the inverter AC input. Make sure that the correct AC input is set to generator on the system setup page."
Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_detect_generator_set"),
Theme.animation_generator_detectGeneratorSet_toastNotification_autoClose_duration)
generatorACInputSwitch.toast = Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_detect_generator_set"),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add generatorACInputSwitch?.close() to close any existing toast immediately (because we can't recycle yet)

Theme.animation_generator_detectGeneratorSet_toastNotification_autoClose_duration)
}
}
}
Expand All @@ -124,7 +136,7 @@ Page {
if (!checked) {
//% "An alarm will be triggered when autostart function is left disabled for more than 10 minutes"
Global.notificationLayer.showToastNotification(VenusOS.Notification_Info,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review if we need to close any existing ToastNotification immediately (because we can't recycle yet)

qsTrId("page_settings_generator_alarm_info"), 12000)
qsTrId("page_settings_generator_alarm_info"), 12000)
}
}
}
Expand Down Expand Up @@ -155,4 +167,3 @@ Page {
}
}
}

Loading