mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-21 22:50:14 +03:00
provide a way for LatteComboBox to draw icons
This commit is contained in:
parent
06c965248c
commit
2c0087d16d
@ -42,10 +42,15 @@ T.ComboBox {
|
||||
|
||||
wheelEnabled: false
|
||||
|
||||
property bool blankSpaceForEmptyIcons: false
|
||||
property string iconRole
|
||||
|
||||
delegate: ItemDelegate {
|
||||
width: control.popup.width
|
||||
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData
|
||||
icon: control.iconRole ? (Array.isArray(control.model) ? modelData[control.iconRole] : model[control.iconRole]) : ''
|
||||
highlighted: mouseArea.pressed ? listView.currentIndex == index : control.currentIndex == index
|
||||
blankSpaceForEmptyIcons: control.blankSpaceForEmptyIcons
|
||||
property bool separatorVisible: false
|
||||
}
|
||||
|
||||
|
@ -42,14 +42,19 @@ PlasmaComponents.Button {
|
||||
property bool checkable: false
|
||||
|
||||
property bool comboBoxEnabled: true
|
||||
property bool comboBoxBlankSpaceForEmptyIcons: false
|
||||
property string comboBoxTextRole: ""
|
||||
property string comboBoxIconRole: ""
|
||||
|
||||
LatteComponents.ComboBox {
|
||||
id: mainComboBox
|
||||
anchors.fill: parent
|
||||
enabled: comboBoxEnabled
|
||||
|
||||
iconRole: comboBoxIconRole
|
||||
textRole: comboBoxTextRole
|
||||
|
||||
blankSpaceForEmptyIcons: comboBoxBlankSpaceForEmptyIcons
|
||||
}
|
||||
|
||||
//overlayed button
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Templates 2.2 as T
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import "private" as Private
|
||||
@ -27,7 +28,7 @@ T.CheckDelegate {
|
||||
|
||||
implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding
|
||||
implicitHeight: Math.max(contentItem.implicitHeight,
|
||||
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding
|
||||
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding
|
||||
hoverEnabled: true
|
||||
|
||||
topPadding: margin
|
||||
@ -36,19 +37,41 @@ T.CheckDelegate {
|
||||
rightPadding: margin
|
||||
spacing: units.smallSpacing
|
||||
|
||||
property bool blankSpaceForEmptyIcons: false
|
||||
property string icon
|
||||
|
||||
readonly property int margin: 4
|
||||
|
||||
contentItem: Label {
|
||||
leftPadding: control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0
|
||||
rightPadding: !control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0
|
||||
contentItem: RowLayout {
|
||||
Layout.leftMargin: control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0
|
||||
Layout.rightMargin: !control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0
|
||||
spacing: units.smallSpacing
|
||||
|
||||
text: control.text
|
||||
font: control.font
|
||||
color: theme.viewTextColor
|
||||
elide: Text.ElideRight
|
||||
visible: control.text
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
PlasmaCore.IconItem {
|
||||
height: parent.height
|
||||
width: parent.height
|
||||
source: control.icon
|
||||
visible: icon
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
//blank space when no icon is shown
|
||||
Layout.minimumHeight: parent.height
|
||||
Layout.minimumWidth: parent.height
|
||||
visible: !icon && control.blankSpaceForEmptyIcons
|
||||
color: "transparent"
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: control.text
|
||||
font: control.font
|
||||
color: theme.viewTextColor
|
||||
elide: Text.ElideRight
|
||||
visible: control.text
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
|
||||
//background: Private.DefaultListItemBackground {}
|
||||
|
@ -28,6 +28,9 @@ import org.kde.latte.components 1.0 as LatteComponents
|
||||
LatteComponents.ComboBoxButton{
|
||||
buttonText: "Unity"
|
||||
comboBoxTextRole: "name"
|
||||
comboBoxIconRole: "icon"
|
||||
comboBoxBlankSpaceForEmptyIcons: true
|
||||
|
||||
property string type: "org.kde.latte.unity"
|
||||
|
||||
Component.onCompleted: reloadModel();
|
||||
@ -43,12 +46,6 @@ LatteComponents.ComboBoxButton{
|
||||
var pluginIds = latteView.indicator.customPluginIds;
|
||||
var pluginNames = latteView.indicator.customPluginNames;
|
||||
|
||||
console.log(latteView.indicator.customPluginsCount);
|
||||
console.log(latteView.indicator.customPluginIds);
|
||||
console.log(latteView.indicator.customPluginNames);
|
||||
console.log(pluginIds);
|
||||
console.log(pluginNames);
|
||||
|
||||
for(var i=0; i<pluginIds.length; ++i) {
|
||||
var element = {pluginId: pluginIds[i], name: pluginNames[i], icon: ''};
|
||||
actionsModel.append(element);
|
||||
@ -56,7 +53,7 @@ LatteComponents.ComboBoxButton{
|
||||
}
|
||||
|
||||
//! download
|
||||
var downloadElement = {pluginId: 'more:', name: 'More...', icon: ''};
|
||||
var downloadElement = {pluginId: 'more:', name: 'More...', icon: 'favorites'};
|
||||
actionsModel.append(downloadElement);
|
||||
|
||||
comboBox.model = actionsModel;
|
||||
|
Loading…
x
Reference in New Issue
Block a user