Some checks are pending
ci / test (push) Waiting to run
- Streamline installer to direct 6-step flow, eliminating Step 0 duplicate welcome - Parse friendly layout names from evdev.lst and sort top 30 world layouts first - Enable dynamic live keymap switching via localectl on layout selection - Auto-detect timezone and close sibling combos on dropdown expansion - Remove redundant keyboard test modal from welcome application - Default-enable single-password disk encryption and accept passwords under 8 chars - Replace ERASE typing confirmation with direct 'Install now' action - Enforce Mango desktop, Btrfs filesystem, and Flatpak/Nix invariants against AI mutation - Add loopback OpenCode/Ollama auto-detection and humanized failure screen with Retry
319 lines
11 KiB
Bash
319 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)
|
|
signal opened
|
|
|
|
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;
|
|
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;
|
|
combo.opened();
|
|
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) {
|
|
combo.opened();
|
|
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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|