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

// Qt
import QtQuick 2.12

HeaderBarPopup { id: _root

    padding         : Variables.defaultMargin * 2

    QtObject { id: _private
        readonly property int   sliderWidth     : 430
        readonly property int columnWidth       : sliderWidth + padding * 2
    }

    contentItem: Column { id : _dialogColumn
        anchors.centerIn    : parent
        width               : _private.columnWidth
        spacing             : Variables.defaultMargin * 2

        SettingsSlider { id: _brightness
            width           : _private.columnWidth
            value           : vDevice.brightnesss ?? 0
            iconImage       : "qrc:/images/iBrightness"

            onValueChanged  :  vDevice.brightness = slider.value
        }

        SettingsSlider { id: _volume
            width           : _private.columnWidth
            value           : vAdjustmentAlarmVolume.hdAlarmVolume ?? 0
            iconImage       : "qrc:/images/iVolume"

            onValueChanged  : vAdjustmentAlarmVolume.doAdjustment( slider.value )
        }
    }

    Connections { target: vAdjustmentAlarmVolume
        function onAdjustmentTriggered  ( vValue ) {
            if ( vAdjustmentAlarmVolume.adjustment_Accepted ) {
                vSettings   .alarmVolume   = vAdjustmentAlarmVolume.hdAlarmVolume
            }
            else {
                // TODO do something with rejection message
                print("**** Volume Rejected Reason: " + vAdjustmentAlarmVolume.adjustment_ReasonText)
            }
        }
    }

    Connections { target: vDevice
        // TODO do something with rejection message
        function onStatusChanged        ( vValue ) { print("**** Brightness Status: " + vValue) }
    }
}
