From c5a820964992c47ab4fb5fc43ad2160a0366ae00 Mon Sep 17 00:00:00 2001 From: Mike Trahearn Date: Thu, 9 Jan 2025 14:13:09 +1000 Subject: [PATCH] Commonise GeneratorDisableAutoStartDialog to reduce duplication Fixes #1239 --- CMakeLists.txt | 1 + components/PageGensetModel.qml | 14 ++------------ .../dialogs/GeneratorDisableAutoStartDialog.qml | 17 +++++++++++++++++ pages/controlcards/GeneratorCard.qml | 14 ++------------ 4 files changed, 22 insertions(+), 24 deletions(-) create mode 100644 components/dialogs/GeneratorDisableAutoStartDialog.qml diff --git a/CMakeLists.txt b/CMakeLists.txt index ea028136e..80f1f4d6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -303,6 +303,7 @@ set (VENUS_QML_MODULE_SOURCES components/dialogs/GeneratorDialog.qml components/dialogs/GeneratorStartDialog.qml components/dialogs/GeneratorStopDialog.qml + components/dialogs/GeneratorDisableAutoStartDialog.qml components/dialogs/InverterChargerModeDialog.qml components/dialogs/InverterChargerEssModeDialog.qml components/dialogs/ModalDialog.qml diff --git a/components/PageGensetModel.qml b/components/PageGensetModel.qml index ff2c98c78..501e4ac0e 100644 --- a/components/PageGensetModel.qml +++ b/components/PageGensetModel.qml @@ -73,18 +73,8 @@ ObjectModel { Component { id: confirmationDialogComponent - ModalWarningDialog { - dialogDoneOptions: VenusOS.ModalDialog_DoneOptions_OkAndCancel - - //% "Disable autostart?" - title: qsTrId("ac-in-genset_disableautostartdialog_title") - - //% "Autostart will be disabled and the generator won't automatically start based on the configured conditions.\nIf the generator is currently running due to a autostart condition, disabling autostart will also stop it immediately." - description: qsTrId("ac-in-genset_disableautostartdialog_description") - - onAccepted: { - autostartSwitch.dataItem.setValue(false) - } + GeneratorDisableAutoStartDialog { + onAccepted: autostartSwitch.dataItem.setValue(false) } } } diff --git a/components/dialogs/GeneratorDisableAutoStartDialog.qml b/components/dialogs/GeneratorDisableAutoStartDialog.qml new file mode 100644 index 000000000..5eaa62f29 --- /dev/null +++ b/components/dialogs/GeneratorDisableAutoStartDialog.qml @@ -0,0 +1,17 @@ +/* +** Copyright (C) 2023 Victron Energy B.V. +** See LICENSE.txt for license information. +*/ + +import QtQuick +import Victron.VenusOS + +ModalWarningDialog { + dialogDoneOptions: VenusOS.ModalDialog_DoneOptions_OkAndCancel + + //% "Disable autostart?" + title: qsTrId("ac-in-genset_disableautostartdialog_title") + + //% "Autostart will be disabled and the generator won't automatically start based on the configured conditions.\nIf the generator is currently running due to a autostart condition, disabling autostart will also stop it immediately." + description: qsTrId("ac-in-genset_disableautostartdialog_description") +} diff --git a/pages/controlcards/GeneratorCard.qml b/pages/controlcards/GeneratorCard.qml index 5750cafa3..990ea5132 100644 --- a/pages/controlcards/GeneratorCard.qml +++ b/pages/controlcards/GeneratorCard.qml @@ -85,18 +85,8 @@ ControlCard { Component { id: confirmationDialogComponent - ModalWarningDialog { - dialogDoneOptions: VenusOS.ModalDialog_DoneOptions_OkAndCancel - - //% "Disable autostart?" - title: qsTrId("controlcard_generator_disableautostartdialog_title") - - //% "Autostart will be disabled and the generator won't automatically start based on the configured conditions.\nIf the generator is currently running due to a autostart condition, disabling autostart will also stop it immediately." - description: qsTrId("controlcard_generator_disableautostartdialog_description") - - onAccepted: { - root.generator.setAutoStart(false) - } + GeneratorDisableAutoStartDialog { + onAccepted: root.generator.setAutoStart(false) } } }