support enabledRole for ComboBoxes

--more specific disable CopyDock when all
screen edges are occupied in the current
view screen
pull/5/head
Michail Vourlakos 6 years ago
parent 50cde5838e
commit 2bad1924f4

@ -46,10 +46,12 @@ T.ComboBox {
property bool forcePressed: false
property int minimumPopUpWidth: 150
property int popUpRelativeX: 0
property string enabledRole
property string iconRole
delegate: ItemDelegate {
width: control.popup.width
enabled: control.enabledRole ? (Array.isArray(control.model) ? modelData[control.enabledRole] : model[control.enabledRole]) : true
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

@ -49,6 +49,7 @@ Rectangle {
property bool comboBoxBlankSpaceForEmptyIcons: false
property bool comboBoxForcePressed: false
property int comboBoxMinimumPopUpWidth: 150
property string comboBoxEnabledRole: ""
property string comboBoxTextRole: ""
property string comboBoxIconRole: ""
@ -81,6 +82,7 @@ Rectangle {
enabled: comboBoxEnabled
enabledRole: comboBoxEnabledRole
iconRole: comboBoxIconRole
textRole: comboBoxTextRole

@ -46,6 +46,7 @@ T.CheckDelegate {
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
enabled: control.enabled
PlasmaCore.IconItem {
height: parent.height
@ -77,6 +78,7 @@ T.CheckDelegate {
//background: Private.DefaultListItemBackground {}
background: Rectangle {
visible: control.ListView.view ? control.ListView.view.highlight === null : true
enabled: control.enabled
opacity: {
if (control.highlighted || control.pressed) {
return 0.7;
@ -86,6 +88,7 @@ T.CheckDelegate {
return 0;
}
color: theme.highlightColor
}
}

@ -459,6 +459,9 @@ FocusScope {
function updateEnabled() {
var screenFreeEdges = latteView.managedLayout.qmlFreeEdges(latteView.positioner.currentScreenId);
actionsComboBtn.buttonEnabled = latteView.managedLayout.viewsCount<4 && screenFreeEdges.length > 0
if (actionsModel.count > 0) {
actionsModel.get(0).enabled = actionsComboBtn.buttonEnabled;
}
removeView.enabled = latteView.managedLayout.viewsCount>1 /*&& !(latteView.managedLayout.viewsWithTasks()===1 && latteView.tasksPresent())*/
}
@ -473,8 +476,9 @@ FocusScope {
buttonIconSource: "list-add"
buttonToolTip: i18n("Add a new dock")
comboBoxEnabled: buttonEnabled
comboBoxEnabled: true
comboBoxBlankSpaceForEmptyIcons: true
comboBoxEnabledRole: "enabled"
comboBoxTextRole: "name"
comboBoxIconRole: "icon"
comboBoxMinimumPopUpWidth: actionsModel.count > 1 ? dialog.width / 2 : 150
@ -495,6 +499,7 @@ FocusScope {
Component.onCompleted:{
actionsComboBtn.addModel();
actionButtons.updateEnabled();
}
onActivated: {
@ -525,7 +530,7 @@ FocusScope {
function addModel() {
actionsModel.clear();
var copy = {actionId: 'copy:', name: i18n("Copy Dock"), icon: 'edit-copy'};
var copy = {actionId: 'copy:', enabled: true, name: i18n("Copy Dock"), icon: 'edit-copy'};
actionsModel.append(copy);
var tempActiveLayouts = layoutManager.activeLayoutsNames();
@ -548,7 +553,7 @@ FocusScope {
function emptyModel() {
actionsModel.clear();
var copy = {actionId: 'copy:', name: i18n("Copy Dock"), icon: 'edit-copy'};
var copy = {actionId: 'copy:', enabled: true, name: i18n("Copy Dock"), icon: 'edit-copy'};
actionsModel.append(copy);
actionsComboBtn.comboBox.currentIndex = -1;
}

Loading…
Cancel
Save