170 lines
5.5 KiB
QML
170 lines
5.5 KiB
QML
//
|
|
// This file is part of Sugar Dark, a theme for the Simple Display Desktop Manager.
|
|
//
|
|
// Copyright 2018 Marian Arlt
|
|
//
|
|
// Sugar Dark 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.
|
|
//
|
|
// Sugar Dark 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 Sugar Dark. If not, see <https://www.gnu.org/licenses/>.
|
|
//
|
|
|
|
import QtQuick 2.11
|
|
import QtQuick.Controls 2.4
|
|
import QtGraphicalEffects 1.0
|
|
|
|
Item {
|
|
id: sessionButton
|
|
height: root.font.pointSize
|
|
width: parent.width / 2
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
property var selectedSession: selectSession.currentIndex
|
|
property string textConstantSession
|
|
|
|
ComboBox {
|
|
id: selectSession
|
|
|
|
hoverEnabled: true
|
|
anchors.left: parent.left
|
|
|
|
model: sessionModel
|
|
currentIndex: model.lastIndex
|
|
textRole: "name"
|
|
|
|
delegate: ItemDelegate {
|
|
width: parent.width
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
contentItem: Text {
|
|
text: model.name
|
|
font.pointSize: root.font.pointSize * 0.8
|
|
color: selectSession.highlightedIndex === index ? "#444" : root.palette.highlight
|
|
verticalAlignment: Text.AlignVCenter
|
|
horizontalAlignment: Text.AlignHCenter
|
|
}
|
|
highlighted: parent.highlightedIndex === index
|
|
background: Rectangle {
|
|
color: selectSession.highlightedIndex === index ? root.palette.highlight : "transparent"
|
|
}
|
|
}
|
|
|
|
indicator {
|
|
visible: false
|
|
}
|
|
|
|
contentItem: Text {
|
|
id: displayedItem
|
|
text: (config.TranslateSession || (textConstantSession + ":")) + " " + selectSession.currentText
|
|
color: root.palette.text
|
|
verticalAlignment: Text.AlignVCenter
|
|
anchors.left: parent.left
|
|
anchors.leftMargin: 3
|
|
font.pointSize: root.font.pointSize * 0.8
|
|
}
|
|
|
|
background: Rectangle {
|
|
color: "transparent"
|
|
border.width: parent.visualFocus ? 1 : 0
|
|
border.color: "transparent"
|
|
height: parent.visualFocus ? 2 : 0
|
|
width: displayedItem.implicitWidth
|
|
anchors.top: parent.bottom
|
|
anchors.left: parent.left
|
|
anchors.leftMargin: 3
|
|
}
|
|
|
|
popup: Popup {
|
|
id: popupHandler
|
|
y: parent.height - 1
|
|
rightMargin: config.ForceRightToLeft == "true" ? root.padding + sessionButton.width / 2 : undefined
|
|
width: sessionButton.width
|
|
implicitHeight: contentItem.implicitHeight
|
|
padding: 10
|
|
|
|
contentItem: ListView {
|
|
clip: true
|
|
implicitHeight: contentHeight + 20
|
|
model: selectSession.popup.visible ? selectSession.delegateModel : null
|
|
currentIndex: selectSession.highlightedIndex
|
|
ScrollIndicator.vertical: ScrollIndicator { }
|
|
}
|
|
|
|
background: Rectangle {
|
|
radius: config.RoundCorners / 2
|
|
color: "#444"
|
|
layer.enabled: true
|
|
layer.effect: DropShadow {
|
|
transparentBorder: true
|
|
horizontalOffset: 0
|
|
verticalOffset: 0
|
|
radius: 100
|
|
samples: 201
|
|
cached: true
|
|
color: "#88000000"
|
|
}
|
|
}
|
|
|
|
enter: Transition {
|
|
NumberAnimation { property: "opacity"; from: 0; to: 1 }
|
|
}
|
|
}
|
|
|
|
states: [
|
|
State {
|
|
name: "pressed"
|
|
when: selectSession.down
|
|
PropertyChanges {
|
|
target: displayedItem
|
|
color: Qt.darker(root.palette.highlight, 1.1)
|
|
}
|
|
PropertyChanges {
|
|
target: selectSession.background
|
|
border.color: Qt.darker(root.palette.highlight, 1.1)
|
|
}
|
|
},
|
|
State {
|
|
name: "hovered"
|
|
when: selectSession.hovered
|
|
PropertyChanges {
|
|
target: displayedItem
|
|
color: Qt.lighter(root.palette.highlight, 1.1)
|
|
}
|
|
PropertyChanges {
|
|
target: selectSession.background
|
|
border.color: Qt.lighter(root.palette.highlight, 1.1)
|
|
}
|
|
},
|
|
State {
|
|
name: "focused"
|
|
when: selectSession.visualFocus
|
|
PropertyChanges {
|
|
target: displayedItem
|
|
color: root.palette.highlight
|
|
}
|
|
PropertyChanges {
|
|
target: selectSession.background
|
|
border.color: root.palette.highlight
|
|
}
|
|
}
|
|
]
|
|
|
|
transitions: [
|
|
Transition {
|
|
PropertyAnimation {
|
|
properties: "color, border.color"
|
|
duration: 150
|
|
}
|
|
}
|
|
]
|
|
|
|
}
|
|
|
|
}
|