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

dankbar: prevent double widget instances for horiz/vertical

This commit is contained in:
bbedward
2025-10-23 09:30:04 -04:00
parent b2e5565110
commit 85c00a9c4e
5 changed files with 35 additions and 8 deletions

View File

@@ -13,8 +13,10 @@ Item {
property var parentScreen: null property var parentScreen: null
property real widgetThickness: 30 property real widgetThickness: 30
property real barThickness: 48 property real barThickness: 48
property bool overrideAxisLayout: false
property bool forceVerticalLayout: false
readonly property bool isVertical: axis?.isVertical ?? false readonly property bool isVertical: overrideAxisLayout ? forceVerticalLayout : (axis?.isVertical ?? false)
readonly property real spacing: noBackground ? 2 : Theme.spacingXS readonly property real spacing: noBackground ? 2 : Theme.spacingXS
property var centerWidgets: [] property var centerWidgets: []

View File

@@ -585,18 +585,18 @@ Item {
function getWidgetSection(parentItem) { function getWidgetSection(parentItem) {
let current = parentItem let current = parentItem
while (current) { while (current) {
if (current.objectName === "leftSection" || current === hLeftSection || current === vLeftSection) { if (current.objectName === "leftSection") {
return "left" return "left"
} }
if (current.objectName === "centerSection" || current === hCenterSection || current === vCenterSection) { if (current.objectName === "centerSection") {
return "center" return "center"
} }
if (current.objectName === "rightSection" || current === hRightSection || current === vRightSection) { if (current.objectName === "rightSection") {
return "right" return "right"
} }
current = current.parent current = current.parent
} }
return "left" // fallback return "left"
} }
readonly property var widgetVisibility: ({ readonly property var widgetVisibility: ({
@@ -695,6 +695,9 @@ Item {
LeftSection { LeftSection {
id: hLeftSection id: hLeftSection
objectName: "leftSection"
overrideAxisLayout: true
forceVerticalLayout: false
anchors { anchors {
left: parent.left left: parent.left
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
@@ -710,6 +713,9 @@ Item {
RightSection { RightSection {
id: hRightSection id: hRightSection
objectName: "rightSection"
overrideAxisLayout: true
forceVerticalLayout: false
anchors { anchors {
right: parent.right right: parent.right
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
@@ -725,6 +731,9 @@ Item {
CenterSection { CenterSection {
id: hCenterSection id: hCenterSection
objectName: "centerSection"
overrideAxisLayout: true
forceVerticalLayout: false
anchors { anchors {
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter
@@ -746,6 +755,9 @@ Item {
LeftSection { LeftSection {
id: vLeftSection id: vLeftSection
objectName: "leftSection"
overrideAxisLayout: true
forceVerticalLayout: true
width: parent.width width: parent.width
anchors { anchors {
top: parent.top top: parent.top
@@ -762,6 +774,9 @@ Item {
CenterSection { CenterSection {
id: vCenterSection id: vCenterSection
objectName: "centerSection"
overrideAxisLayout: true
forceVerticalLayout: true
width: parent.width width: parent.width
anchors { anchors {
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
@@ -778,6 +793,9 @@ Item {
RightSection { RightSection {
id: vRightSection id: vRightSection
objectName: "rightSection"
overrideAxisLayout: true
forceVerticalLayout: true
width: parent.width width: parent.width
height: implicitHeight height: implicitHeight
anchors { anchors {

View File

@@ -11,8 +11,10 @@ Item {
property var parentScreen: null property var parentScreen: null
property real widgetThickness: 30 property real widgetThickness: 30
property real barThickness: 48 property real barThickness: 48
property bool overrideAxisLayout: false
property bool forceVerticalLayout: false
readonly property bool isVertical: axis?.isVertical ?? false readonly property bool isVertical: overrideAxisLayout ? forceVerticalLayout : (axis?.isVertical ?? false)
implicitHeight: layoutLoader.item ? (layoutLoader.item.implicitHeight || layoutLoader.item.height) : 0 implicitHeight: layoutLoader.item ? (layoutLoader.item.implicitHeight || layoutLoader.item.height) : 0
implicitWidth: layoutLoader.item ? (layoutLoader.item.implicitWidth || layoutLoader.item.width) : 0 implicitWidth: layoutLoader.item ? (layoutLoader.item.implicitWidth || layoutLoader.item.width) : 0

View File

@@ -11,8 +11,10 @@ Item {
property var parentScreen: null property var parentScreen: null
property real widgetThickness: 30 property real widgetThickness: 30
property real barThickness: 48 property real barThickness: 48
property bool overrideAxisLayout: false
property bool forceVerticalLayout: false
readonly property bool isVertical: axis?.isVertical ?? false readonly property bool isVertical: overrideAxisLayout ? forceVerticalLayout : (axis?.isVertical ?? false)
implicitHeight: layoutLoader.item ? layoutLoader.item.implicitHeight : 0 implicitHeight: layoutLoader.item ? layoutLoader.item.implicitHeight : 0
implicitWidth: layoutLoader.item ? layoutLoader.item.implicitWidth : 0 implicitWidth: layoutLoader.item ? layoutLoader.item.implicitWidth : 0

View File

@@ -18,7 +18,10 @@ Loader {
asynchronous: false asynchronous: false
active: getWidgetVisible(widgetId, DgopService.dgopAvailable) && readonly property bool orientationMatches: (axis?.isVertical ?? false) === isInColumn
active: orientationMatches &&
getWidgetVisible(widgetId, DgopService.dgopAvailable) &&
(widgetId !== "music" || MprisController.activePlayer !== null) (widgetId !== "music" || MprisController.activePlayer !== null)
sourceComponent: getWidgetComponent(widgetId, components) sourceComponent: getWidgetComponent(widgetId, components)
opacity: getWidgetEnabled(widgetData?.enabled) ? 1 : 0 opacity: getWidgetEnabled(widgetData?.enabled) ? 1 : 0