phoebus_os/installer/live/desktop/common/PhoebusCombo.qml
Phoebus 3515f1cf12
Some checks are pending
ci / test (push) Waiting to run
feat(desktop): streamline installer UX and add DWM keybindings
- Add canonical DWM / DWL keybindings to MANGO_CONFIG_DEFAULT (Mod+Shift+Return
  terminal, Mod+Return zoom, Mod+j/k focusstack, Mod+Shift+j/k movestack, Mod+h/l
  setmfact, Mod+i/d incnmaster, Mod+Shift+c/q killclient, Mod+t/m/f layouts,
  Mod+Shift+Space float toggle, Mod+Tab view previous, Mod+1..9 tags,
  Mod+Shift+1..9 movetotag, mouse window drag/resize)
- Close Welcome window on installer launch to allow full-screen tiling
- Rewrite PhoebusCombo into a scrollable dropdown with search and vertical scrollbar
- Parse XKB rules (evdev.lst / base.lst) for standard desktop keyboard layouts
- Streamline installer defaults: lock to Mango + DankMaterialShell, Btrfs with
  snapshots, and Nix + Flatpak enabled (removing confusing manual choices)
- Simplify Account step: username only, single password with disk encryption toggle,
  and remove artificial 8-character password length limit
- Direct installation confirmation without typing ERASE or ticking confirmation box
- Fix live progress log details view with a dedicated scrollable log box and 1.5s timer
2026-09-22 18:17:31 -07:00

317 lines
11 KiB
Bash

import QtQuick
import QtQuick.Controls
// A styled dropdown selection menu with built-in search and scrolling.
//
// Shows a dropdown toggle button with the current selection. Clicking it opens
// a scrollable menu of all available options (with instant search filtering).
// `options` may be plain strings or `{value, label}` pairs.
Column {
id: combo
property string label: ""
property string placeholder: "Select an option..."
property string error: ""
property var options: []
property bool popupOpen: false
property string currentValue: ""
property string currentLabel: ""
property int highlightIndex: -1
property var filteredOptions: []
// Compatibility aliases for existing bridge and harness code
property alias text: combo.currentValue
property var inputItem: QtObject {
property alias text: combo.currentValue
property bool activeFocus: combo.popupOpen || searchField.activeFocus
function forceActiveFocus() {
combo.popupOpen = true;
searchField.forceActiveFocus();
}
}
signal edited(string value)
signal selected(string value)
width: parent ? parent.width : implicitWidth
spacing: 4
function optionValue(option) {
return (option !== null && typeof option === "object") ? ("" + option.value) : ("" + option);
}
function optionLabel(option) {
return (option !== null && typeof option === "object" && option.label !== undefined)
? ("" + option.label) : ("" + option);
}
function updateCurrentLabel() {
const all = combo.options || [];
for (let i = 0; i < all.length; i++) {
if (combo.optionValue(all[i]) === combo.currentValue) {
combo.currentLabel = combo.optionLabel(all[i]);
return;
}
}
combo.currentLabel = combo.currentValue;
}
function refreshFilter() {
const query = (searchField.text || "").trim().toLowerCase();
const all = combo.options || [];
const out = [];
for (let i = 0; i < all.length; i++) {
const val = combo.optionValue(all[i]);
const lbl = combo.optionLabel(all[i]);
if (query.length === 0
|| val.toLowerCase().indexOf(query) !== -1
|| lbl.toLowerCase().indexOf(query) !== -1) {
out.push({ value: val, label: lbl });
}
}
combo.filteredOptions = out;
if (combo.highlightIndex >= out.length)
combo.highlightIndex = out.length > 0 ? 0 : -1;
}
function choose(val, lbl) {
combo.currentValue = val;
combo.currentLabel = lbl;
combo.popupOpen = false;
searchField.text = "";
combo.edited(val);
combo.selected(val);
}
function forceFocus() {
combo.popupOpen = true;
searchField.forceActiveFocus();
}
onCurrentValueChanged: updateCurrentLabel()
onOptionsChanged: {
updateCurrentLabel();
refreshFilter();
}
Component.onCompleted: {
updateCurrentLabel();
refreshFilter();
}
// Label
Text {
width: parent.width
text: combo.label
color: Theme.warmWhite
font.family: Theme.family
font.pixelSize: Theme.fontSmall
font.weight: Font.DemiBold
visible: combo.label.length > 0
}
// Main Selection Box (Clickable)
Rectangle {
id: selectorBox
width: parent.width
height: Theme.controlHeight
radius: Theme.radiusSmall
color: Theme.charcoal
border.width: combo.popupOpen ? 2 : 1
border.color: combo.error.length > 0 ? Theme.danger
: combo.popupOpen ? Theme.focusRing
: Theme.border
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.right: chevron.left
anchors.leftMargin: 12
anchors.rightMargin: 8
text: combo.currentLabel.length > 0 ? combo.currentLabel : combo.placeholder
color: combo.currentLabel.length > 0 ? Theme.warmWhite : Theme.muted
font.family: Theme.family
font.pixelSize: Theme.fontBody
elide: Text.ElideRight
}
Text {
id: chevron
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 14
text: combo.popupOpen ? "\u25B4" : "\u25BE"
color: Theme.muted
font.pixelSize: Theme.fontHeading
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
combo.popupOpen = !combo.popupOpen;
if (combo.popupOpen) {
searchField.text = "";
combo.refreshFilter();
searchField.forceActiveFocus();
}
}
}
}
// Inline Error
Text {
width: parent.width
visible: combo.error.length > 0
text: combo.error
color: Theme.danger
font.family: Theme.family
font.pixelSize: Theme.fontSmall
}
// Dropdown Menu Panel
Rectangle {
id: dropdownMenu
width: parent.width
visible: combo.popupOpen
height: visible ? (searchBoxRect.height + listContainer.height + 16) : 0
radius: Theme.radiusSmall
color: Theme.surfaceRaised
border.width: 1
border.color: Theme.border
Column {
anchors.fill: parent
anchors.margins: 8
spacing: 6
// Search filter box inside dropdown
Rectangle {
id: searchBoxRect
width: parent.width
height: 34
radius: 4
color: Theme.surface
border.width: 1
border.color: searchField.activeFocus ? Theme.focusRing : Theme.border
TextInput {
id: searchField
anchors.fill: parent
anchors.leftMargin: 8
anchors.rightMargin: 8
verticalAlignment: TextInput.AlignVCenter
color: Theme.warmWhite
font.family: Theme.family
font.pixelSize: Theme.fontSmall
selectionColor: Theme.amberDeep
selectedTextColor: Theme.warmWhite
clip: true
Text {
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
text: "Type to filter options..."
color: Theme.muted
font.family: Theme.family
font.pixelSize: Theme.fontSmall
visible: searchField.text.length === 0
}
onTextChanged: combo.refreshFilter()
Keys.onUpPressed: event => {
event.accepted = true;
if (combo.filteredOptions.length === 0) return;
combo.highlightIndex = combo.highlightIndex <= 0 ? combo.filteredOptions.length - 1 : combo.highlightIndex - 1;
listView.positionViewAtIndex(combo.highlightIndex, ListView.Contain);
}
Keys.onDownPressed: event => {
event.accepted = true;
if (combo.filteredOptions.length === 0) return;
combo.highlightIndex = combo.highlightIndex >= combo.filteredOptions.length - 1 ? 0 : combo.highlightIndex + 1;
listView.positionViewAtIndex(combo.highlightIndex, ListView.Contain);
}
Keys.onReturnPressed: event => {
event.accepted = true;
if (combo.highlightIndex >= 0 && combo.highlightIndex < combo.filteredOptions.length) {
const chosen = combo.filteredOptions[combo.highlightIndex];
combo.choose(chosen.value, chosen.label);
}
}
Keys.onEnterPressed: event => {
event.accepted = true;
if (combo.highlightIndex >= 0 && combo.highlightIndex < combo.filteredOptions.length) {
const chosen = combo.filteredOptions[combo.highlightIndex];
combo.choose(chosen.value, chosen.label);
}
}
Keys.onEscapePressed: event => {
event.accepted = true;
combo.popupOpen = false;
}
}
}
// Scrollable list of options
Item {
id: listContainer
width: parent.width
height: Math.min(220, listView.contentHeight > 0 ? listView.contentHeight : 40)
clip: true
ListView {
id: listView
anchors.fill: parent
model: combo.filteredOptions
boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical: ScrollBar {
active: true
policy: listView.contentHeight > listView.height ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded
}
delegate: Rectangle {
id: optionRow
required property var modelData
required property int index
width: listView.width
height: 32
radius: 4
color: index === combo.highlightIndex ? Theme.amberDeep
: (rowHover.containsMouse ? Theme.surface : "transparent")
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 10
anchors.rightMargin: 10
text: optionRow.modelData.label
color: index === combo.highlightIndex ? Theme.charcoal : Theme.warmWhite
font.family: Theme.family
font.pixelSize: Theme.fontSmall
elide: Text.ElideRight
}
MouseArea {
id: rowHover
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: combo.choose(optionRow.modelData.value, optionRow.modelData.label)
}
}
}
Text {
anchors.centerIn: parent
text: "No matching options found"
color: Theme.muted
font.family: Theme.family
font.pixelSize: Theme.fontSmall
visible: combo.filteredOptions.length === 0
}
}
}
}
}