diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ab0a05b8..92911b300 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -331,6 +331,7 @@ set (VENUS_QML_MODULE_SOURCES components/listitems/ListMountStateButton.qml components/listitems/ListPvInverterPositionRadioButtonGroup.qml components/listitems/ListEvChargerPositionRadioButtonGroup.qml + components/listitems/ListRebootButton.qml components/listitems/ListRelayState.qml components/listitems/ListResetHistory.qml components/listitems/ListTemperatureRelay.qml diff --git a/components/listitems/ListRebootButton.qml b/components/listitems/ListRebootButton.qml new file mode 100644 index 000000000..f21c6c37f --- /dev/null +++ b/components/listitems/ListRebootButton.qml @@ -0,0 +1,52 @@ +/* +** Copyright (C) 2025 Victron Energy B.V. +** See LICENSE.txt for license information. +*/ + +import QtQuick +import QtQuick.Controls.impl as CP +import Victron.VenusOS +import QtQuick.Templates as T + +ListButton { + id: root + + text: CommonWords.reboot + //% "Reboot now" + button.text: qsTrId("settings_reboot_now") + writeAccessLevel: VenusOS.User_AccessType_User + onClicked: Global.dialogLayer.open(confirmRebootDialogComponent) + + Component { + id: confirmRebootDialogComponent + + ModalWarningDialog { + //% "Press 'OK' to reboot" + title: qsTrId("press_ok_to_reboot") + dialogDoneOptions: VenusOS.ModalDialog_DoneOptions_OkAndCancel + onClosed: { + if (result === T.Dialog.Accepted) { + Global.venusPlatform.reboot() + Qt.callLater(Global.dialogLayer.open, rebootingDialogComponent) + } + } + } + } + + Component { + id: rebootingDialogComponent + + ModalWarningDialog { + title: BackendConnection.type === BackendConnection.DBusSource + //% "Rebooting..." + ? qsTrId("dialoglayer_rebooting") + //% "Device has been rebooted." + : qsTrId("dialoglayer_rebooted") + + // On device, dialog cannot be dismissed; just wait until device is rebooted. + dialogDoneOptions: VenusOS.ModalDialog_DoneOptions_OkOnly + footer.enabled: BackendConnection.type !== BackendConnection.DBusSource + footer.opacity: footer.enabled ? 1 : 0 + } + } +} diff --git a/pages/settings/PageSettingsGeneral.qml b/pages/settings/PageSettingsGeneral.qml index ba7484200..1c4604d90 100644 --- a/pages/settings/PageSettingsGeneral.qml +++ b/pages/settings/PageSettingsGeneral.qml @@ -5,7 +5,6 @@ import QtQuick import Victron.VenusOS -import QtQuick.Templates as T Page { id: root @@ -136,46 +135,7 @@ Page { SettingsListHeader { } - ListButton { - text: CommonWords.reboot - //% "Reboot now" - button.text: qsTrId("settings_reboot_now") - writeAccessLevel: VenusOS.User_AccessType_User - onClicked: Global.dialogLayer.open(confirmRebootDialogComponent) - - Component { - id: confirmRebootDialogComponent - - ModalWarningDialog { - //% "Press 'OK' to reboot" - title: qsTrId("press_ok_to_reboot") - dialogDoneOptions: VenusOS.ModalDialog_DoneOptions_OkAndCancel - onClosed: { - if (result === T.Dialog.Accepted) { - Global.venusPlatform.reboot() - Qt.callLater(Global.dialogLayer.open, rebootingDialogComponent) - } - } - } - } - - Component { - id: rebootingDialogComponent - - ModalWarningDialog { - title: BackendConnection.type === BackendConnection.DBusSource - //% "Rebooting..." - ? qsTrId("dialoglayer_rebooting") - //% "Device has been rebooted." - : qsTrId("dialoglayer_rebooted") - - // On device, dialog cannot be dismissed; just wait until device is rebooted. - dialogDoneOptions: VenusOS.ModalDialog_DoneOptions_OkOnly - footer.enabled: BackendConnection.type !== BackendConnection.DBusSource - footer.opacity: footer.enabled ? 1 : 0 - } - } - } + ListRebootButton { } SettingsListHeader { } diff --git a/pages/settings/PageSettingsModificationChecks.qml b/pages/settings/PageSettingsModificationChecks.qml index f906a1fe5..d11d0c825 100644 --- a/pages/settings/PageSettingsModificationChecks.qml +++ b/pages/settings/PageSettingsModificationChecks.qml @@ -334,47 +334,13 @@ Page { } } - ListButton { + ListRebootButton { //% "Reboot now to apply changes" text: qsTrId("pagesettingsmodificationchecks_reboot_now_to_apply_changes") - //% "Reboot now" - button.text: qsTrId("settings_reboot_now") - writeAccessLevel: VenusOS.User_AccessType_User - preferredVisible: systemHooksState >= 1 && systemHooksState <= 4 - onClicked: Global.dialogLayer.open(confirmRebootDialogComponent) - - Component { - id: confirmRebootDialogComponent - - ModalWarningDialog { - //% "Press 'OK' to reboot" - title: qsTrId("press_ok_to_reboot") - dialogDoneOptions: VenusOS.ModalDialog_DoneOptions_OkAndCancel - onClosed: { - if (result === T.Dialog.Accepted) { - Global.venusPlatform.reboot() - Qt.callLater(Global.dialogLayer.open, rebootingDialogComponent) - } - } - } - } - - Component { - id: rebootingDialogComponent - - ModalWarningDialog { - title: BackendConnection.type === BackendConnection.DBusSource - //% "Rebooting..." - ? qsTrId("dialoglayer_rebooting") - //% "Device has been rebooted." - : qsTrId("dialoglayer_rebooted") - - // On device, dialog cannot be dismissed; just wait until device is rebooted. - dialogDoneOptions: VenusOS.ModalDialog_DoneOptions_OkOnly - footer.enabled: BackendConnection.type !== BackendConnection.DBusSource - footer.opacity: footer.enabled ? 1 : 0 - } - } + // Show button if + // - Switch is enabled and custom-rc is not present, but rc.local or rcS.local are present + // - Switch is disabled and custom-rc is present + preferredVisible: (enableAllModifications.checked && !(systemHooksState & 16) && ((systemHooksState & 4) || (systemHooksState & 8))) || (!enableAllModifications.checked && (systemHooksState & 16)) } SettingsListHeader {