/*!
 *
 * Copyright (c) 2022-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    KeyboardItem.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      22-Feb-2022
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  22-Feb-2022
 *
 */

// Qt
import QtQuick                          2.12
import QtQuick.VirtualKeyboard          2.4
import QtQuick.VirtualKeyboard.Settings 2.2

// Project
//  C++ imports

//  Qml imports
import "qrc:/globals"


/*!
 * \brief   Keyboard is the single keyboard in the entire applicaiton.
 */
InputPanel { id : _root
    function setVisible(vVisible) {
        Qt.inputMethod.show()
        visible = vVisible
    }

    externalLanguageSwitchEnabled: true
    active          : false // if active set to true then in the TextInput section handlers will show up, which is not nice.
    y               : Qt.inputMethod.visible ? parent.height - _root.height  - _bottomFiller.height : parent.height
    anchors.left    : parent.left
    anchors.right   : parent.right

    Behavior on y { NumberAnimation { duration: Variables.keybardAnimationDuration } }
    // when an alarm is active then alarm covers the keyboard
    // to avoid that keyboard moved a little higher
    // because the keyboard height is calculated by InputPanel itself and can not be set,
    // a gap beetween the bottom of the keyboard and the screen.
    // the rectangle _bottomFiller is to fill that gap
    Rectangle { id: _bottomFiller
        height: Variables.minVGap
        color: "black" // InputPanel background color.
        anchors.left: _root.left
        anchors.right: _root.right
        anchors.top: _root.bottom
    }
    Component.onCompleted: {
        VirtualKeyboardSettings.locale = vLocalization.keyboardLocale;
        console.log("Default keyboard locale set to : " + VirtualKeyboardSettings.locale)
    }
}
