phoebus_os/installer/live/desktop/common/PhoebusCombo.qml
Phoebus 39c69d59cf feat(gui): pick timezone/locale/keymap and AI model from lists
The region and keyboard fields were free-text, so users had to know zone
names and layout names from memory, and the AI model had to be typed.
Add an 'options' bridge op (live timezones/locales/keymaps) and an
'ai_catalog' op (the OpenCode provider/model catalog, or an
OpenAI-compatible /models list), and a searchable PhoebusCombo picker.
Also name provider/model in OpenCode errors instead of an opaque HTTP
code. Record the user-trial findings U1-U5.
2026-09-22 03:57:01 -07:00

108 lines
3.5 KiB
Bash

import QtQuick
// A labelled input with an inline, filtered suggestion list. The user can type
// to narrow the list or click an entry to choose it, and a custom value is
// still allowed. Used for timezone, locale, keymap, provider and model so the
// user picks from what the system actually offers instead of typing from
// memory.
Column {
id: combo
property string label: ""
property string placeholder: ""
property string error: ""
property var options: []
property int maxVisible: 8
property string hint: "Type to filter, click to choose"
property alias text: field.text
property alias inputItem: field.inputItem
property var suggestions: []
signal edited(string value)
signal selected(string value)
width: parent ? parent.width : implicitWidth
spacing: 4
function refresh() {
const query = (field.text || "").toLowerCase();
const all = combo.options || [];
const out = [];
for (let i = 0; i < all.length && out.length < combo.maxVisible; i++) {
const option = "" + all[i];
if (query.length === 0 || option.toLowerCase().indexOf(query) !== -1)
out.push(option);
}
combo.suggestions = out;
}
onOptionsChanged: combo.refresh()
Component.onCompleted: combo.refresh()
PhoebusField {
id: field
width: parent.width
label: combo.label
placeholder: combo.placeholder
error: combo.error
onEdited: value => { combo.edited(value); combo.refresh(); }
}
// Show the first suggestions as soon as the field takes focus.
Connections {
target: field.inputItem
function onActiveFocusChanged() {
if (field.inputItem.activeFocus)
combo.refresh();
}
}
Column {
width: parent.width
spacing: 0
visible: field.inputItem.activeFocus && combo.suggestions.length > 0
Repeater {
model: field.inputItem.activeFocus ? combo.suggestions : []
delegate: Rectangle {
required property var modelData
width: parent.width
height: 30
color: hover.containsMouse ? Theme.surfaceRaised : Theme.surface
border.width: 1
border.color: Theme.border
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 12
anchors.rightMargin: 12
text: modelData
elide: Text.ElideRight
color: Theme.warmWhite
font.family: Theme.family
font.pixelSize: Theme.fontSmall
}
MouseArea {
id: hover
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
field.inputItem.text = modelData;
combo.selected(modelData);
combo.suggestions = [];
}
}
}
}
}
Text {
width: parent.width
visible: field.inputItem.activeFocus && combo.options.length > 0
text: combo.hint
color: Theme.muted
font.family: Theme.family
font.pixelSize: Theme.fontSmall
}
}