From 220e5547db4e73ff22765b390e67251f9e0f9dd1 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Wed, 31 May 2023 19:55:16 -0400 Subject: [PATCH] Draw the indicator for combobox to ensure it looks the same on all platforms. --- gpt4all-chat/qml/MyComboBox.qml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gpt4all-chat/qml/MyComboBox.qml b/gpt4all-chat/qml/MyComboBox.qml index 213154d1..11e7f0ae 100644 --- a/gpt4all-chat/qml/MyComboBox.qml +++ b/gpt4all-chat/qml/MyComboBox.qml @@ -3,6 +3,7 @@ import QtQuick.Controls import QtQuick.Controls.Basic ComboBox { + id: comboBox font.pixelSize: theme.fontSizeLarge spacing: 0 padding: 10 @@ -50,6 +51,33 @@ ComboBox { color: theme.backgroundDark } } + 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: { + 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); + context.strokeStyle = comboBox.pressed ? theme.textAccent : theme.mutedTextColor; + context.stroke(); + + } + } background: Rectangle { color: theme.backgroundDark radius: 10