Better Menu in PlasmaComponents3
add the missing MenuSeparator component support for radio buttons like the desktop style, put icons and checkboxes in two separate columns, making them all aligned to each other when there is a combination of neither, only icon, only checkbox, both
This commit is contained in:
parent
fa06d610dd
commit
c2f281452c
@ -14,6 +14,13 @@ install(DIRECTORY kirigamiplasmadesktopstyle/ DESTINATION ${KDE_INSTALL_QMLDIR}/
|
||||
|
||||
set(QQC2_VERSION "2.${Qt5QuickControls2_VERSION_MINOR}")
|
||||
|
||||
if (Qt5Qml_VERSION_STRING VERSION_GREATER_EQUAL 5.14)
|
||||
set(DISABLE_UNDER_QT_5_14 "")
|
||||
set(DISABLE_AT_QT_5_14 "//Disabled since Qt 5.14 ")
|
||||
else()
|
||||
set(DISABLE_UNDER_QT_5_14 "//Needs Qt 5.14 ")
|
||||
set(DISABLE_AT_QT_5_14 "")
|
||||
endif()
|
||||
|
||||
# Find all the source qml files
|
||||
FILE(GLOB_RECURSE inFiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
|
@ -50,6 +50,23 @@ T.Menu {
|
||||
T.ScrollBar.vertical: ScrollBar {}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: control.contentItem.contentItem
|
||||
|
||||
@DISABLE_AT_QT_5_14@ onChildrenChanged: {
|
||||
@DISABLE_UNDER_QT_5_14@ function onChildrenChanged() {
|
||||
for (var i in control.contentItem.contentItem.children) {
|
||||
var child = control.contentItem.contentItem.children[i];
|
||||
if (child.checkable) {
|
||||
control.contentItem.hasCheckables = true;
|
||||
}
|
||||
if (child.icon && child.icon.hasOwnProperty("name") && (child.icon.name.length > 0 || child.icon.source.length > 0)) {
|
||||
control.contentItem.hasIcons = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enter: Transition {
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
|
@ -55,7 +55,7 @@ T.MenuItem {
|
||||
//FIXME: either migrate to Kirigami icon or add color to IconItem
|
||||
// color: controlRoot.icon ? controlRoot.icon.color : "transparent"
|
||||
//hovered is for retrocompatibility
|
||||
status: (controlRoot.highlighted || controlRoot.hovered) ? PlasmaCore.Svg.Selected : PlasmaCore.Svg.Normal
|
||||
// status: (controlRoot.highlighted || controlRoot.hovered) ? PlasmaCore.Svg.Selected : PlasmaCore.Svg.Normal
|
||||
Layout.preferredHeight: Math.max(label.height, Kirigami.Units.iconSizes.small)
|
||||
Layout.preferredWidth: Layout.preferredHeight
|
||||
}
|
||||
@ -84,13 +84,26 @@ T.MenuItem {
|
||||
@DISABLE_UNDER_QQC2_2_3@ visible: controlRoot.subMenu
|
||||
@DISABLE_UNDER_QQC2_2_3@ }
|
||||
|
||||
indicator: CheckIndicator {
|
||||
indicator: Loader {
|
||||
x: controlRoot.mirrored ? controlRoot.width - width - controlRoot.rightPadding : controlRoot.leftPadding
|
||||
y: controlRoot.topPadding + (controlRoot.availableHeight - height) / 2
|
||||
|
||||
visible: controlRoot.checkable
|
||||
sourceComponent: controlRoot.autoExclusive ? radioComponent : checkComponent
|
||||
}
|
||||
|
||||
Component {
|
||||
id: radioComponent
|
||||
RadioIndicator {
|
||||
control: controlRoot
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: checkComponent
|
||||
CheckIndicator {
|
||||
control: controlRoot
|
||||
}
|
||||
}
|
||||
|
||||
background: Item {
|
||||
implicitWidth: units.gridUnit * 8
|
||||
|
30
src/declarativeimports/plasmacomponents3/MenuSeparator.qml
Normal file
30
src/declarativeimports/plasmacomponents3/MenuSeparator.qml
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2019 Alexander Stippich <a.stippich@gmx.net>
|
||||
SPDX-FileCopyrightText: 2017 The Qt Company Ltd.
|
||||
|
||||
SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
|
||||
import QtQuick 2.6
|
||||
import QtQuick.Templates @QQC2_VERSION@ as T
|
||||
import org.kde.kirigami 2.4 as Kirigami
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
|
||||
T.MenuSeparator {
|
||||
id: controlRoot
|
||||
|
||||
implicitHeight: topPadding + bottomPadding + separator.implicitHeight
|
||||
width: parent.width
|
||||
topPadding: Math.floor(PlasmaCore.Units.smallSpacing / 2)
|
||||
bottomPadding: Math.floor(PlasmaCore.Units.smallSpacing / 2)
|
||||
|
||||
contentItem: Rectangle {
|
||||
id: separator
|
||||
color: PlasmaCore.ColorScope.textColor
|
||||
opacity: 0.2
|
||||
anchors.centerIn: controlRoot
|
||||
width: controlRoot.width
|
||||
implicitHeight: PlasmaCore.Units.devicePixelRatio
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ ItemDelegate 3.0 ItemDelegate.qml
|
||||
Label 3.0 Label.qml
|
||||
MenuItem 3.0 MenuItem.qml
|
||||
Menu 3.0 Menu.qml
|
||||
MenuSeparator 3.0 MenuSeparator.qml
|
||||
Popup 3.0 Popup.qml
|
||||
ProgressBar 3.0 ProgressBar.qml
|
||||
RadioButton 3.0 RadioButton.qml
|
||||
|
Loading…
Reference in New Issue
Block a user