Initial commit of WhisperVoice
This commit is contained in:
127
src/ui/qml/ModernComboBox.qml
Normal file
127
src/ui/qml/ModernComboBox.qml
Normal file
@@ -0,0 +1,127 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
ComboBox {
|
||||
id: control
|
||||
|
||||
// Custom properties
|
||||
property color accentColor: SettingsStyle.accent
|
||||
property color bgColor: "#1a1a20"
|
||||
property color popupColor: "#252530"
|
||||
|
||||
delegate: ItemDelegate {
|
||||
id: delegate
|
||||
width: control.width
|
||||
height: 40
|
||||
padding: 0
|
||||
|
||||
contentItem: RowLayout {
|
||||
spacing: 8
|
||||
width: parent.width
|
||||
anchors.leftMargin: 10
|
||||
anchors.rightMargin: 10
|
||||
|
||||
Text {
|
||||
text: control.textRole ? (modelData[control.textRole] || modelData) : modelData
|
||||
color: highlighted ? control.accentColor : "#ffffff"
|
||||
font.family: "JetBrains Mono"
|
||||
font.pixelSize: 14
|
||||
elide: Text.ElideRight
|
||||
Layout.fillWidth: true
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
scale: highlighted ? 1.05 : 1.0
|
||||
Behavior on scale { NumberAnimation { duration: 100 } }
|
||||
}
|
||||
|
||||
// Indicator for "Downloaded" or "Active"
|
||||
Rectangle {
|
||||
width: 6; height: 6; radius: 3
|
||||
color: control.accentColor
|
||||
visible: ui.isModelDownloaded(modelData)
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: highlighted ? Qt.rgba(control.accentColor.r, control.accentColor.g, control.accentColor.b, 0.1) : "transparent"
|
||||
radius: 4
|
||||
Behavior on color { ColorAnimation { duration: 100 } }
|
||||
}
|
||||
}
|
||||
|
||||
indicator: Canvas {
|
||||
x: control.width - width - control.rightPadding
|
||||
y: control.topPadding + (control.availableHeight - height) / 2
|
||||
width: 12
|
||||
height: 8
|
||||
contextType: "2d"
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
function onPressedChanged() { control.indicator.requestPaint() }
|
||||
}
|
||||
|
||||
onPaint: {
|
||||
context.reset();
|
||||
context.moveTo(0, 0);
|
||||
context.lineTo(width, 0);
|
||||
context.lineTo(width / 2, height);
|
||||
context.closePath();
|
||||
context.fillStyle = control.pressed ? control.accentColor : "#888888";
|
||||
context.fill();
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: Text {
|
||||
leftPadding: 10
|
||||
rightPadding: control.indicator.width + control.spacing
|
||||
|
||||
text: control.displayText
|
||||
font.family: "JetBrains Mono"
|
||||
font.pixelSize: 14
|
||||
color: control.pressed ? control.accentColor : "#ffffff"
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
implicitWidth: 140
|
||||
implicitHeight: 40
|
||||
color: control.bgColor
|
||||
border.color: control.pressed || control.activeFocus ? control.accentColor : "#40ffffff"
|
||||
border.width: 1
|
||||
radius: 6
|
||||
|
||||
// Glow effect on focus (Simplified to just border for stability)
|
||||
Behavior on border.color { ColorAnimation { duration: 150 } }
|
||||
}
|
||||
|
||||
popup: Popup {
|
||||
y: control.height - 1
|
||||
width: control.width
|
||||
implicitHeight: contentItem.implicitHeight
|
||||
padding: 5
|
||||
|
||||
contentItem: ListView {
|
||||
clip: true
|
||||
implicitHeight: contentHeight
|
||||
model: control.popup.visible ? control.delegateModel : null
|
||||
currentIndex: control.highlightedIndex
|
||||
|
||||
ScrollIndicator.vertical: ScrollIndicator { }
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: control.popupColor
|
||||
border.color: "#40ffffff"
|
||||
border.width: 1
|
||||
radius: 6
|
||||
}
|
||||
|
||||
enter: Transition {
|
||||
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 100 }
|
||||
NumberAnimation { property: "scale"; from: 0.95; to: 1.0; duration: 100 }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user