/*!
 *
 * Copyright (c) 2023-2024 Diality Inc. - All Rights Reserved.
 * \copyright
 * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN
 * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER.
 *
 * \file    SettingsROInput.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      18-Jul-2023
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  18-Jul-2023
 *
 */

// Qt
import QtQuick                  2.12

//  Qml imports
import "qrc:/globals"
import "qrc:/components"
import "qrc:/compounds"

/*!
 * \brief   SettingsROInput is the screen
 *          which enables the Ro Water Input
 */
SettingsBase    { id: _root
    itemIndex           : SettingsStack.RoInput
    confirmVisible      : false
    onVisibleChanged    : _roInputComboBox.currentIndex = vSettings.roWaterMode

    contentItem: Item {
        LabelUnitContainer { id: _settingsRoInputItem
            text                        : qsTr("RO Water Mode")
            width                       : parent.width / 2
            anchors.horizontalCenter    : parent.horizontalCenter

            contentItem : BaseComboBox { id: _roInputComboBox
                anchors.rightMargin : Variables.defaultMargin
                anchors.leftMargin  : anchors.rightMargin
                anchors.topMargin   : Variables.defaultMargin / 2
                anchors.bottomMargin: anchors.topMargin
                centerHorizontally  : true

                currentIndex        : vSettings.roWaterMode
                model               : vTreatmentRanges.roWaterModeOptions

                onActivated: {
                    vSettings.roWaterMode           = _roInputComboBox.currentIndex
                    vAdjustRoWaterMode.doAdjustment ( _roInputComboBox.currentIndex )
                }
            }
        }
    }

    Connections { target: vAdjustRoWaterMode
        function onAdjustmentTriggered(vValue) {
            if ( vAdjustRoWaterMode.adjustment_Accepted ) {
                _settingsRoInput.notificationText = ""
            }
            else {
                _settingsRoInput.notificationText = vAdjustRoWaterMode.adjustment_ReasonText
            }
        }
    }
}

