// Tiling.
//
// How windows share the space. The window-layout card keeps its handoff row
// because the adjustable parts of window *appearance* -- gaps, corners,
// borders, effects -- live on the Appearance page next to the preview that
// explains them. Splitting them would put two halves of one idea on two pages;
// pointing at the other half keeps one.

import QtQuick
import qs.config
import qs.services

SettingsPage {
    id: root

    title: "Tiling"
    lede: "How windows share the space, and where their edges are."

    SettingsCard {
        title: "Window layout"
        subtitle: "Follows the Forge mental model, with native Hyprland tiling."

        // These were two read-only rows reporting "Tiling" and "Dynamic", which
        // described settings rather than facts -- both are ordinary Hyprland
        // options that simply had no controls. TextRow's own documentation says
        // a setting the user could reasonably change does not belong in it.
        ChoiceRow { setting: "windowLayout" }
        ToggleRow { setting: "preserveSplit" }
        ChoiceRow { setting: "forceSplit" }
        ToggleRow { setting: "windowSnapping" }
        ActionRow {
            label: "Gaps, corners, and effects"
            detail: "Adjusted on the Appearance page, beside a live preview"
            action: "Open Appearance"
            divider: false
            onTriggered: ShellState.openSettingsSection("appearance", "windows")
        }
    }

    // GNOME's Multitasking panel, in Hyprland's terms.
    // Only meaningful when the layout above is Master and stack. Hidden
    // otherwise, because a card of settings that do nothing under the layout
    // you are actually running is worse than not offering the layout at all.
    SettingsCard {
        visible: DesktopPreferences.get("windowLayout") === "master"
        title: "Master and stack"
        subtitle: "How the master area behaves. These apply only while the tiling layout above is Master and stack."

        SliderRow { setting: "masterFactor" }
        ChoiceRow { setting: "masterOrientation" }
        ChoiceRow { setting: "masterNewStatus" }
        ToggleRow { setting: "masterNewOnTop"; divider: false }
    }

    SettingsCard {
        title: "Window edges"
        subtitle: "How the pointer grabs a window's border, and how floating windows behave near each other and the screen edge."

        ToggleRow { setting: "resizeOnBorder" }
        SliderRow { setting: "borderGrabArea"; zeroLabel: "Border only" }
        ToggleRow { setting: "hoverIconOnBorder" }
        SliderRow { setting: "snapWindowGap"; zeroLabel: "Touching" }
        SliderRow { setting: "snapMonitorGap"; zeroLabel: "Touching" }
        ToggleRow { setting: "snapRespectGaps"; divider: false }
    }

    // Hyprland's own interruptions. Panama turns all four off, which is a
    // defensible default and was not previously a decision anyone could
    // reverse without editing looks.lua.
    SettingsCard {
        title: "Hyprland notices"
        subtitle: "Panama hides all of these by default. They are the compositor's own, not Panama's."

        ToggleRow { setting: "hyprlandLogo" }
        ToggleRow { setting: "hyprlandSplash" }
        ToggleRow { setting: "hyprlandUpdateNews" }
        ToggleRow { setting: "hyprlandDonationNag"; divider: false }
    }
}
