1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-30 00:12:50 -05:00

use loader pattern

This commit is contained in:
bbedward
2025-08-12 20:01:27 -04:00
parent a76f0de18e
commit 1037f010ed

View File

@@ -19,7 +19,7 @@ Rectangle {
height: 32 height: 32
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.surfaceContainer color: Theme.surfaceContainer
border.color: dropdownPopup.visible ? Theme.primary : (mouseArea.containsMouse ? Theme.outline : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.5)) border.color: dropdownLoader.active ? Theme.primary : (mouseArea.containsMouse ? Theme.outline : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.5))
border.width: 1 border.width: 1
property var iconCategories: [ property var iconCategories: [
@@ -66,11 +66,7 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onClicked: { onClicked: {
if (dropdownPopup.visible) { dropdownLoader.active = !dropdownLoader.active
dropdownPopup.visible = false
} else {
dropdownPopup.visible = true
}
} }
} }
@@ -102,7 +98,7 @@ Rectangle {
} }
DankIcon { DankIcon {
name: dropdownPopup.visible ? "expand_less" : "expand_more" name: dropdownLoader.active ? "expand_less" : "expand_more"
size: 16 size: 16
color: Theme.outline color: Theme.outline
anchors.right: parent.right anchors.right: parent.right
@@ -110,10 +106,15 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
PanelWindow { Loader {
id: dropdownLoader
active: false
asynchronous: true
sourceComponent: PanelWindow {
id: dropdownPopup id: dropdownPopup
visible: false visible: true
implicitWidth: 320 implicitWidth: 320
implicitHeight: Math.min(500, dropdownContent.implicitHeight + 32) implicitHeight: Math.min(500, dropdownContent.implicitHeight + 32)
color: "transparent" color: "transparent"
@@ -131,7 +132,7 @@ Rectangle {
// Click outside to close // Click outside to close
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: dropdownPopup.visible = false onClicked: dropdownLoader.active = false
} }
Rectangle { Rectangle {
@@ -232,7 +233,7 @@ Rectangle {
var trimmedText = text.trim() var trimmedText = text.trim()
if (trimmedText) { if (trimmedText) {
root.iconSelected(trimmedText, "text") root.iconSelected(trimmedText, "text")
dropdownPopup.visible = false dropdownLoader.active = false
} }
} }
} }
@@ -296,7 +297,7 @@ Rectangle {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
root.iconSelected(modelData, "icon") root.iconSelected(modelData, "icon")
dropdownPopup.visible = false dropdownLoader.active = false
} }
} }
@@ -315,6 +316,7 @@ Rectangle {
} }
} }
} }
}
function setIcon(iconName, type) { function setIcon(iconName, type) {
if (type === "text") { if (type === "text") {