import QtQuick
import qs.config
import qs.services

SettingsPage {
    title: "Sound"
    lede: "Live PipeWire output, input, and device selection."

    SettingsCard {
        title: "Output"
        subtitle: AudioDevices.current(true)?.description ?? "No output device"

        SoundDeviceList {
            width: parent.width
            output: true
        }

        AudioBalance {
            width: parent.width
            node: AudioDevices.current(true)
        }
    }

    SettingsCard {
        title: "Input"
        subtitle: AudioDevices.current(false)?.description ?? "No input device"

        SoundDeviceList {
            width: parent.width
            output: false
        }
    }

    SettingsCard {
        title: "Sound feedback"
        subtitle: "Use the same event preferences as GTK and GNOME applications."

        SettingRow {
            label: "Event sounds"
            detail: "Play alerts and interface event sounds"
            controlWidth: 42

            SettingsToggle {
                anchors.fill: parent
                checked: SoundFeedback.eventSounds
                enabled: !SoundFeedback.busy
                onToggled: checked => SoundFeedback.setEventSounds(checked)
            }
        }

        SettingRow {
            label: "Input feedback"
            detail: "Play sounds for supported typing and input events"
            controlWidth: 42
            divider: false

            SettingsToggle {
                anchors.fill: parent
                checked: SoundFeedback.inputFeedback
                enabled: !SoundFeedback.busy
                onToggled: checked => SoundFeedback.setInputFeedback(checked)
            }
        }
    }

    SettingsCard {
        title: "Advanced sound"

        ActionRow {
            label: "Application volumes and profiles"
            detail: "Open Fedora's complete sound panel"
            divider: false
            action: "Open panel"
            onTriggered: SystemSettings.openGnomePanel("sound")
        }
    }
}
