2023-05-22 13:01:46 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Controls.Basic
|
|
|
|
|
|
|
|
ComboBox {
|
2023-05-31 23:55:16 +00:00
|
|
|
id: comboBox
|
2023-05-22 13:01:46 +00:00
|
|
|
font.pixelSize: theme.fontSizeLarge
|
|
|
|
spacing: 0
|
|
|
|
padding: 10
|
|
|
|
Accessible.role: Accessible.ComboBox
|
|
|
|
contentItem: Text {
|
2023-07-01 15:34:21 +00:00
|
|
|
id: text
|
2023-05-22 13:01:46 +00:00
|
|
|
leftPadding: 10
|
2023-06-02 23:59:53 +00:00
|
|
|
rightPadding: 20
|
2023-05-22 13:01:46 +00:00
|
|
|
text: comboBox.displayText
|
|
|
|
font: comboBox.font
|
|
|
|
color: theme.textColor
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
|
|
|
delegate: ItemDelegate {
|
|
|
|
width: comboBox.width
|
|
|
|
contentItem: Text {
|
|
|
|
text: modelData
|
|
|
|
color: theme.textColor
|
|
|
|
font: comboBox.font
|
|
|
|
elide: Text.ElideRight
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
}
|
|
|
|
background: Rectangle {
|
2024-01-22 19:41:47 +00:00
|
|
|
color: highlighted ? theme.lightContrast : theme.darkContrast
|
2023-05-22 13:01:46 +00:00
|
|
|
}
|
|
|
|
highlighted: comboBox.highlightedIndex === index
|
|
|
|
}
|
|
|
|
popup: Popup {
|
2024-06-26 18:53:44 +00:00
|
|
|
// FIXME This should be made much nicer to take into account lists that are very long so
|
|
|
|
// that it is scrollable and also sized optimally taking into account the x,y and the content
|
|
|
|
// width and height as well as the window width and height
|
2023-05-22 13:01:46 +00:00
|
|
|
y: comboBox.height - 1
|
|
|
|
width: comboBox.width
|
|
|
|
implicitHeight: contentItem.implicitHeight
|
|
|
|
padding: 0
|
|
|
|
|
|
|
|
contentItem: ListView {
|
|
|
|
clip: true
|
|
|
|
implicitHeight: contentHeight
|
|
|
|
model: comboBox.popup.visible ? comboBox.delegateModel : null
|
|
|
|
currentIndex: comboBox.highlightedIndex
|
|
|
|
ScrollIndicator.vertical: ScrollIndicator { }
|
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
2024-01-22 19:41:47 +00:00
|
|
|
color: theme.black
|
2023-05-22 13:01:46 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-31 23:55:16 +00:00
|
|
|
indicator: Canvas {
|
|
|
|
id: canvas
|
|
|
|
x: comboBox.width - width - comboBox.rightPadding
|
|
|
|
y: comboBox.topPadding + (comboBox.availableHeight - height) / 2
|
|
|
|
width: 12
|
|
|
|
height: 18
|
|
|
|
contextType: "2d"
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: comboBox
|
|
|
|
function onPressedChanged() { canvas.requestPaint(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
onPaint: {
|
2023-06-01 00:09:05 +00:00
|
|
|
var context = getContext("2d");
|
2023-05-31 23:55:16 +00:00
|
|
|
context.reset();
|
|
|
|
context.lineWidth = 2;
|
|
|
|
context.moveTo(0, height / 2 - 2);
|
|
|
|
context.lineTo(width / 2, 0);
|
|
|
|
context.lineTo(width, height / 2 - 2);
|
|
|
|
context.moveTo(0, height / 2 + 2);
|
|
|
|
context.lineTo(width / 2, height);
|
|
|
|
context.lineTo(width, height / 2 + 2);
|
2024-06-24 22:49:23 +00:00
|
|
|
context.strokeStyle = comboBox.pressed ? theme.mutedLightTextColor : theme.mutedLighterTextColor;
|
2023-05-31 23:55:16 +00:00
|
|
|
context.stroke();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2023-05-22 13:01:46 +00:00
|
|
|
background: Rectangle {
|
2024-01-22 19:41:47 +00:00
|
|
|
color: theme.controlBackground
|
|
|
|
border.width: 1
|
|
|
|
border.color: theme.controlBorder
|
2023-05-22 13:01:46 +00:00
|
|
|
radius: 10
|
|
|
|
}
|
2024-01-22 19:41:47 +00:00
|
|
|
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
|
2023-05-22 13:01:46 +00:00
|
|
|
}
|