// Mouse & Touchpad.
//
// GNOME splits pointing devices out of Keyboard, and so does this: the settings
// are unrelated, and burying pointer speed under a page called "Shortcuts" is
// where it was before. These all reach Hyprland's input section, which until now
// could only be changed by editing hypr/input.lua by hand.
//
// The touchpad card renders only when a touchpad is attached. On a desktop it
// would be worse than useless -- every switch on it appears to work, because the
// preference is stored and the compositor accepts an option for a device class
// with no members, so the user would be toggling settings that can never affect
// anything with nothing to say so.

import QtQuick
import qs.config
import qs.services

SettingsPage {
    id: root

    title: "Mouse & Touchpad"
    lede: InputDevices.hasTouchpad
        ? "Pointer behavior for your mouse and touchpad."
        : "Pointer behavior. Touchpad settings appear when a touchpad is attached."

    SettingsCard {
        title: "Mouse"
        subtitle: "Applied to every pointing device that is not a touchpad."

        SliderRow { setting: "pointerSensitivity" }
        ChoiceRow { setting: "accelProfile" }
        ToggleRow { setting: "naturalScroll" }
        SliderRow { setting: "scrollFactor" }
        ToggleRow { setting: "leftHanded" }
        ToggleRow {
            setting: "middleClickPaste"
            detail: "Paste the primary selection in GTK and native Wayland applications; individual apps may choose not to support it"
            divider: false
        }
    }

    SettingsCard {
        visible: InputDevices.hasTouchpad
        title: "Touchpad"
        subtitle: "Separate from the mouse on purpose: libinput keeps them apart, and a touchpad and a mouse usually want to scroll in opposite directions."

        ToggleRow { setting: "touchpadTapToClick" }
        ToggleRow { setting: "touchpadNaturalScroll" }
        ToggleRow { setting: "touchpadDisableWhileTyping" }
        SliderRow { setting: "touchpadScrollFactor" }
        ChoiceRow { setting: "touchpadDragLock" }
        ToggleRow { setting: "touchpadMiddleButtonEmulation"; divider: false }
    }

    SettingsCard {
        visible: InputDevices.hasTouchpad
        title: "Gestures"
        subtitle: "Three fingers sideways moves between workspaces, up opens the overview, and down closes it — the same gestures GNOME used. Which gestures exist is fixed by the compositor at startup; what they feel like is here."

        SliderRow { setting: "swipeDistance" }
        ToggleRow { setting: "swipeInvert"; divider: false }
    }

    SettingsCard {
        title: "Pointer"

        ChoiceRow { setting: "followMouse" }
        SliderRow { setting: "cursorInactiveTimeout"; zeroLabel: "Never" }
        SliderRow { setting: "cursorSize"; divider: false }
    }
}
