2020-08-03 13:27:42 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019-2020 by Savoir-faire Linux
|
|
|
|
* Author: Yang Wang <yang.wang@savoirfairelinux.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-10-06 13:58:44 +02:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Controls.Universal 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
2020-08-03 13:27:42 -04:00
|
|
|
import QtGraphicalEffects 1.14
|
|
|
|
import QtQuick.Controls.Styles 1.4
|
2020-12-05 14:05:57 +01:00
|
|
|
import net.jami.Constants 1.0
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
ComboBox {
|
2020-09-03 21:19:10 -04:00
|
|
|
id: root
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-07 11:24:18 -04:00
|
|
|
property string tooltipText:""
|
|
|
|
|
|
|
|
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
|
|
|
|
ToolTip.visible: hovered && (tooltipText.length > 0)
|
|
|
|
ToolTip.text: tooltipText
|
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
delegate: ItemDelegate {
|
2020-09-03 21:19:10 -04:00
|
|
|
width: root.width
|
2020-08-03 13:27:42 -04:00
|
|
|
contentItem: Text {
|
|
|
|
text: {
|
2020-09-03 21:19:10 -04:00
|
|
|
if (index < 0)
|
|
|
|
return qsTr("")
|
|
|
|
var currentItem = root.delegateModel.items.get(index)
|
|
|
|
return currentItem.model[root.textRole].toString()
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
2020-11-28 16:14:25 -05:00
|
|
|
color: JamiTheme.textColor
|
2020-09-03 21:19:10 -04:00
|
|
|
font: root.font
|
2020-08-03 13:27:42 -04:00
|
|
|
elide: Text.ElideRight
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
}
|
2020-09-03 21:19:10 -04:00
|
|
|
highlighted: root.highlightedIndex === index
|
2020-11-28 16:14:25 -05:00
|
|
|
background: Rectangle {
|
|
|
|
color: highlighted? JamiTheme.selectedColor : JamiTheme.editBackgroundColor
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
indicator: Canvas {
|
|
|
|
id: canvas
|
2020-09-03 21:19:10 -04:00
|
|
|
x: root.width - width - root.rightPadding
|
|
|
|
y: root.topPadding + (root.availableHeight - height) / 2
|
2020-08-03 13:27:42 -04:00
|
|
|
width: 12
|
|
|
|
height: 8
|
|
|
|
contextType: "2d"
|
|
|
|
|
|
|
|
Connections {
|
2020-09-03 21:19:10 -04:00
|
|
|
target: root
|
2020-08-03 13:27:42 -04:00
|
|
|
function onPressedChanged(){
|
|
|
|
canvas.requestPaint()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onPaint: {
|
|
|
|
context.reset();
|
|
|
|
context.moveTo(0, 0);
|
|
|
|
context.lineTo(width, 0);
|
|
|
|
context.lineTo(width / 2, height);
|
|
|
|
context.closePath();
|
2020-11-28 16:14:25 -05:00
|
|
|
context.fillStyle = root.pressed ? JamiTheme.pressColor : JamiTheme.textColor;
|
2020-08-03 13:27:42 -04:00
|
|
|
context.fill();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Text {
|
|
|
|
leftPadding: 0
|
2020-09-03 21:19:10 -04:00
|
|
|
rightPadding: root.indicator.width + root.spacing
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
text: root.displayText
|
|
|
|
font: root.font
|
2020-11-28 16:14:25 -05:00
|
|
|
color: JamiTheme.textColor
|
2020-08-03 13:27:42 -04:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
2020-11-28 16:14:25 -05:00
|
|
|
color: JamiTheme.editBackgroundColor
|
2020-08-03 13:27:42 -04:00
|
|
|
implicitWidth: 120
|
|
|
|
implicitHeight: 40
|
2020-11-28 16:14:25 -05:00
|
|
|
border.color: JamiTheme.editBackgroundColor
|
2020-09-03 21:19:10 -04:00
|
|
|
border.width: root.visualFocus ? 2 : 1
|
2020-08-03 13:27:42 -04:00
|
|
|
radius: 2
|
|
|
|
}
|
|
|
|
|
|
|
|
popup: Popup {
|
2020-09-03 21:19:10 -04:00
|
|
|
y: root.height - 1
|
|
|
|
width: root.width
|
2020-08-03 13:27:42 -04:00
|
|
|
implicitHeight: contentItem.implicitHeight
|
|
|
|
padding: 1
|
|
|
|
|
|
|
|
contentItem: ListView {
|
|
|
|
clip: true
|
|
|
|
implicitHeight: contentHeight
|
2020-09-03 21:19:10 -04:00
|
|
|
model: root.delegateModel
|
|
|
|
currentIndex: root.highlightedIndex
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
ScrollIndicator.vertical: ScrollIndicator { }
|
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
2020-11-28 16:14:25 -05:00
|
|
|
color: JamiTheme.editBackgroundColor
|
2020-08-03 13:27:42 -04:00
|
|
|
border.color: "gray"
|
|
|
|
radius: 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|