import QtQuick
import Quickshell
import qs.Common
import qs.Services
import qs.Widgets
import qs.Modules.Plugins

PluginComponent {
    id: root

    function toggleKeyboard() {
        Quickshell.execDetached(["sh", "-c", "pkill -SIGRTMIN -x wvkbd-mobintl"]);
    }

    pillClickAction: () => root.toggleKeyboard()

    horizontalBarPill: Component {
        MouseArea {
            implicitWidth: icon.implicitWidth
            implicitHeight: icon.implicitHeight
            hoverEnabled: true
            cursorShape: Qt.PointingHandCursor
            onClicked: root.toggleKeyboard()

            DankIcon {
                id: icon
                name: "keyboard"
                size: Theme.iconSize
                color: parent.containsMouse ? Theme.primary : Theme.surfaceText
            }
        }
    }

    verticalBarPill: Component {
        MouseArea {
            implicitWidth: iconV.implicitWidth
            implicitHeight: iconV.implicitHeight
            hoverEnabled: true
            cursorShape: Qt.PointingHandCursor
            onClicked: root.toggleKeyboard()

            DankIcon {
                id: iconV
                name: "keyboard"
                size: Theme.iconSize
                color: parent.containsMouse ? Theme.primary : Theme.surfaceText
                anchors.horizontalCenter: parent.horizontalCenter
            }
        }
    }
}
