2023-05-22 09:01:46 -04:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Controls.Basic
|
2024-06-29 18:00:52 -04:00
|
|
|
import QtQuick.Layouts
|
|
|
|
import Qt5Compat.GraphicalEffects
|
2023-05-22 09:01:46 -04:00
|
|
|
|
|
|
|
ComboBox {
|
2023-05-31 19:55:16 -04:00
|
|
|
id: comboBox
|
2023-05-22 09:01:46 -04:00
|
|
|
font.pixelSize: theme.fontSizeLarge
|
|
|
|
spacing: 0
|
|
|
|
padding: 10
|
|
|
|
Accessible.role: Accessible.ComboBox
|
2024-06-29 18:00:52 -04:00
|
|
|
contentItem: RowLayout {
|
|
|
|
id: contentRow
|
|
|
|
spacing: 0
|
|
|
|
Text {
|
|
|
|
id: text
|
|
|
|
Layout.fillWidth: true
|
|
|
|
leftPadding: 10
|
|
|
|
rightPadding: 20
|
|
|
|
text: comboBox.displayText
|
|
|
|
font: comboBox.font
|
|
|
|
color: theme.textColor
|
|
|
|
verticalAlignment: Text.AlignLeft
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
|
|
|
Item {
|
|
|
|
Layout.preferredWidth: updown.width
|
|
|
|
Layout.preferredHeight: updown.height
|
|
|
|
Image {
|
|
|
|
id: updown
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
sourceSize.width: comboBox.font.pixelSize
|
|
|
|
sourceSize.height: comboBox.font.pixelSize
|
|
|
|
mipmap: true
|
|
|
|
visible: false
|
|
|
|
source: "qrc:/gpt4all/icons/up_down.svg"
|
|
|
|
}
|
|
|
|
|
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: updown
|
|
|
|
source: updown
|
|
|
|
color: theme.textColor
|
|
|
|
}
|
|
|
|
}
|
2023-05-22 09:01:46 -04:00
|
|
|
}
|
|
|
|
delegate: ItemDelegate {
|
2024-07-10 10:36:20 -04:00
|
|
|
width: comboBox.width -20
|
2023-05-22 09:01:46 -04:00
|
|
|
contentItem: Text {
|
|
|
|
text: modelData
|
|
|
|
color: theme.textColor
|
|
|
|
font: comboBox.font
|
|
|
|
elide: Text.ElideRight
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
}
|
|
|
|
background: Rectangle {
|
2024-07-10 10:36:20 -04:00
|
|
|
radius: 10
|
|
|
|
color: highlighted ? theme.menuHighlightColor : theme.menuBackgroundColor
|
2023-05-22 09:01:46 -04:00
|
|
|
}
|
|
|
|
highlighted: comboBox.highlightedIndex === index
|
|
|
|
}
|
|
|
|
popup: Popup {
|
2024-06-26 14:53:44 -04: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 09:01:46 -04:00
|
|
|
y: comboBox.height - 1
|
|
|
|
width: comboBox.width
|
2024-07-03 11:43:59 -04:00
|
|
|
implicitHeight: contentItem.implicitHeight + 20
|
2023-05-22 09:01:46 -04:00
|
|
|
padding: 0
|
|
|
|
|
2024-07-03 11:43:59 -04:00
|
|
|
contentItem: Rectangle {
|
|
|
|
implicitWidth: myListView.contentWidth
|
|
|
|
implicitHeight: myListView.contentHeight
|
|
|
|
color: "transparent"
|
|
|
|
ListView {
|
|
|
|
id: myListView
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 10
|
|
|
|
clip: true
|
|
|
|
implicitHeight: contentHeight
|
|
|
|
model: comboBox.popup.visible ? comboBox.delegateModel : null
|
|
|
|
currentIndex: comboBox.highlightedIndex
|
|
|
|
ScrollIndicator.vertical: ScrollIndicator { }
|
|
|
|
}
|
2023-05-22 09:01:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
2024-07-10 10:36:20 -04:00
|
|
|
color: theme.menuBackgroundColor//theme.controlBorder
|
|
|
|
border.color: theme.menuBorderColor //theme.controlBorder
|
|
|
|
border.width: 1
|
2024-07-03 11:43:59 -04:00
|
|
|
radius: 10
|
2023-05-22 09:01:46 -04:00
|
|
|
}
|
|
|
|
}
|
2024-06-29 18:00:52 -04:00
|
|
|
indicator: Item {
|
2023-05-31 19:55:16 -04:00
|
|
|
}
|
2023-05-22 09:01:46 -04:00
|
|
|
background: Rectangle {
|
2024-01-22 14:41:47 -05:00
|
|
|
color: theme.controlBackground
|
|
|
|
border.width: 1
|
|
|
|
border.color: theme.controlBorder
|
2023-05-22 09:01:46 -04:00
|
|
|
radius: 10
|
|
|
|
}
|
2024-01-22 14:41:47 -05:00
|
|
|
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
|
2023-05-22 09:01:46 -04:00
|
|
|
}
|