mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-21 22:50:14 +03:00
improvements for ComboBoxButton
--improvements for popup placement and icon sizes
This commit is contained in:
parent
fbce535e85
commit
0a2bd9cc2d
@ -44,6 +44,7 @@ T.ComboBox {
|
||||
|
||||
property bool blankSpaceForEmptyIcons: false
|
||||
property bool forcePressed: false
|
||||
property bool popUpAlignRight: true
|
||||
property int minimumPopUpWidth: 150
|
||||
property int popUpRelativeX: 0
|
||||
property string enabledRole
|
||||
@ -263,11 +264,22 @@ T.ComboBox {
|
||||
|
||||
popup: T.Popup {
|
||||
x: {
|
||||
if (popUpRelativeX !== 0) {
|
||||
return control.mirrored ? -(width - popUpRelativeX) : popUpRelativeX
|
||||
if (!control.mirrored) {
|
||||
if (popUpRelativeX !== 0) {
|
||||
var adjustedX = exceedsContent && control.popUpAlignRight ? -(width - control.width) : popUpRelativeX;
|
||||
return adjustedX;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
//! mirrored case
|
||||
if (exceedsContent && control.popUpAlignRight) {
|
||||
var adjustedX = width - control.width - popUpRelativeX;
|
||||
return -adjustedX;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return control.mirrored ? control.width - width : 0
|
||||
}
|
||||
y: control.height
|
||||
width: Math.max(control.width, control.minimumPopUpWidth)
|
||||
@ -275,6 +287,17 @@ T.ComboBox {
|
||||
topMargin: 6
|
||||
bottomMargin: 6
|
||||
|
||||
readonly property bool exceedsContent: control.width < width
|
||||
|
||||
/*onVisibleChanged: {
|
||||
if (visible) {
|
||||
console.log(" mirrored:" + control.mirrored);
|
||||
console.log(" exceeds: " + exceedsContent);
|
||||
console.log(" popupAR: " + control.popUpAlignRight);
|
||||
console.log(" popupRX: " + popUpRelativeX);
|
||||
}
|
||||
}*/
|
||||
|
||||
contentItem: ListView {
|
||||
id: listView
|
||||
clip: true
|
||||
|
@ -48,6 +48,7 @@ Rectangle {
|
||||
property bool comboBoxEnabled: true
|
||||
property bool comboBoxBlankSpaceForEmptyIcons: false
|
||||
property bool comboBoxForcePressed: false
|
||||
property bool comboBoxPopUpAlignRight: true
|
||||
property int comboBoxMinimumPopUpWidth: 150
|
||||
property string comboBoxEnabledRole: ""
|
||||
property string comboBoxTextRole: ""
|
||||
@ -88,7 +89,10 @@ Rectangle {
|
||||
|
||||
blankSpaceForEmptyIcons: comboBoxBlankSpaceForEmptyIcons
|
||||
forcePressed: comboBoxForcePressed
|
||||
popUpRelativeX: Qt.application.layoutDirection === Qt.RightToLeft ? root.width : -(parent.width - width)
|
||||
popUpAlignRight: comboBoxPopUpAlignRight
|
||||
popUpRelativeX: Qt.application.layoutDirection === Qt.RightToLeft ?
|
||||
(popUpAlignRight ? root.width - width : 0) :
|
||||
(popUpAlignRight ? width : -(root.width - width))
|
||||
|
||||
minimumPopUpWidth: Math.max(comboBoxMinimumPopUpWidth, root.width)
|
||||
}
|
||||
|
@ -49,8 +49,12 @@ T.CheckDelegate {
|
||||
enabled: control.enabled
|
||||
|
||||
PlasmaCore.IconItem {
|
||||
height: parent.height
|
||||
width: parent.height
|
||||
Layout.minimumWidth: parent.height
|
||||
Layout.maximumWidth: parent.height
|
||||
Layout.minimumHeight: parent.height
|
||||
Layout.maximumHeight: parent.height
|
||||
//height: parent.height - 2*control.margin
|
||||
//width: parent.height - 2*control.margin
|
||||
colorGroup: PlasmaCore.Theme.ButtonColorGroup
|
||||
source: control.icon
|
||||
visible: icon
|
||||
|
@ -478,6 +478,7 @@ FocusScope {
|
||||
|
||||
comboBoxEnabled: true
|
||||
comboBoxBlankSpaceForEmptyIcons: true
|
||||
comboBoxPopUpAlignRight: Qt.application.layoutDirection === Qt.RightToLeft
|
||||
comboBoxEnabledRole: "enabled"
|
||||
comboBoxTextRole: "name"
|
||||
comboBoxIconRole: "icon"
|
||||
|
@ -522,19 +522,8 @@ PlasmaComponents.Page {
|
||||
checkable: true
|
||||
buttonExclusiveGroup: indicatorStyleGroup
|
||||
buttonToolTip: i18n("Use %0 style for your indicators and download more custom indicators to use").arg(buttonText)
|
||||
comboBoxMinimumPopUpWidth: 1.5 * customIndicator.width
|
||||
}
|
||||
|
||||
|
||||
/*PlasmaComponents.Button {
|
||||
Layout.fillWidth: true
|
||||
text: i18nc("unity indicator style", "Unity")
|
||||
checked: parent.type === type
|
||||
checkable: true
|
||||
exclusiveGroup: indicatorStyleGroup
|
||||
tooltip: i18n("Use Unity style for your indicators")
|
||||
|
||||
readonly property string type: "org.kde.latte.unity"
|
||||
}*/
|
||||
}
|
||||
|
||||
LatteComponents.SubHeader {
|
||||
|
@ -27,12 +27,14 @@ import org.kde.latte.components 1.0 as LatteComponents
|
||||
|
||||
LatteComponents.ComboBoxButton{
|
||||
id: custom
|
||||
buttonText: "Unity"
|
||||
|
||||
comboBoxTextRole: "name"
|
||||
comboBoxIconRole: "icon"
|
||||
comboBoxBlankSpaceForEmptyIcons: true
|
||||
comboBoxForcePressed: latteView.indicator.type === type
|
||||
comboBoxPopUpAlignRight: Qt.application.layoutDirection !== Qt.RightToLeft
|
||||
|
||||
buttonText: "Unity"
|
||||
property string type: "org.kde.latte.unity"
|
||||
|
||||
Component.onCompleted: reloadModel();
|
||||
@ -54,9 +56,7 @@ LatteComponents.ComboBoxButton{
|
||||
}
|
||||
}
|
||||
|
||||
//! download
|
||||
var downloadElement = {pluginId: 'more:', name: 'More...', icon: 'favorites'};
|
||||
actionsModel.append(downloadElement);
|
||||
appendDefaults();
|
||||
|
||||
comboBox.model = actionsModel;
|
||||
|
||||
@ -68,15 +68,21 @@ LatteComponents.ComboBoxButton{
|
||||
}
|
||||
|
||||
function emptyModel() {
|
||||
var actions = []
|
||||
//! download
|
||||
var downloadElement = {pluginId: 'more:', name: 'More...', icon: ''};
|
||||
|
||||
actionsModel.append(emptyElement);
|
||||
actionsModel.append(downloadElement);
|
||||
actionsModel.clear();
|
||||
appendDefaults();
|
||||
|
||||
comboBox.model = actionsModel;
|
||||
comboBox.currentIndex = -1;
|
||||
}
|
||||
|
||||
function appendDefaults() {
|
||||
//! add
|
||||
var addElement = {pluginId: 'add:', name: 'Add Indicator...', icon: 'list-add'};
|
||||
actionsModel.append(addElement);
|
||||
|
||||
//! download
|
||||
var downloadElement = {pluginId: 'download:', name: 'Get New Indicators...', icon: 'favorites'};
|
||||
actionsModel.append(downloadElement);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user