1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-03 20:32:07 -04:00

top bar improvements

This commit is contained in:
bbedward
2025-09-02 15:58:34 -04:00
parent 544a17b0db
commit 809274a294
3 changed files with 1058 additions and 1008 deletions

View File

@@ -92,31 +92,6 @@ DankPopout {
border.width: 1
antialiasing: true
smooth: true
focus: true
Component.onCompleted: {
if (root.shouldBeVisible)
forceActiveFocus()
}
Keys.onPressed: function (event) {
if (event.key === Qt.Key_Escape) {
root.close()
event.accepted = true
} else {
event.accepted = false
}
}
Connections {
function onShouldBeVisibleChanged() {
if (root.shouldBeVisible)
Qt.callLater(function () {
controlContent.forceActiveFocus()
})
}
target: root
}
Column {
id: mainColumn

View File

@@ -19,12 +19,15 @@ PanelWindow {
property var modelData
property string screenName: modelData.name
property real backgroundTransparency: SettingsData.topBarTransparency
readonly property int notificationCount: NotificationService.notifications.length
property bool autoHide: SettingsData.topBarAutoHide
property bool reveal: SettingsData.topBarVisible && (!autoHide || topBarMouseArea.containsMouse)
readonly property real effectiveBarHeight: Math.max(root.widgetHeight + SettingsData.topBarInnerPadding + 4, Theme.barHeight - 4 - (8 - SettingsData.topBarInnerPadding))
readonly property real widgetHeight: Math.max(20, 26 + SettingsData.topBarInnerPadding * 0.6)
readonly property real effectiveBarHeight: Math.max(
root.widgetHeight
+ SettingsData.topBarInnerPadding + 4,
Theme.barHeight - 4
- (8 - SettingsData.topBarInnerPadding))
readonly property real widgetHeight: Math.max(
20,
26 + SettingsData.topBarInnerPadding * 0.6)
screen: modelData
implicitHeight: effectiveBarHeight + SettingsData.topBarSpacing
@@ -102,10 +105,6 @@ PanelWindow {
}
Connections {
function onTopBarTransparencyChanged() {
root.backgroundTransparency = SettingsData.topBarTransparency
}
function onTopBarLeftWidgetsChanged() {
root.updateGpuTempConfig()
}
@@ -155,15 +154,56 @@ PanelWindow {
right: true
}
exclusiveZone: !SettingsData.topBarVisible || autoHide ? -1 : root.effectiveBarHeight + SettingsData.topBarSpacing - 2 + SettingsData.topBarBottomGap
exclusiveZone: topBarCore.autoHide ? -1 : root.effectiveBarHeight + SettingsData.topBarSpacing
- 2 + SettingsData.topBarBottomGap
mask: Region {
item: topBarMouseArea
}
Item {
id: topBarCore
anchors.fill: parent
property real backgroundTransparency: SettingsData.topBarTransparency
property bool autoHide: SettingsData.topBarAutoHide
property bool reveal: SettingsData.topBarVisible
&& (!autoHide || topBarMouseArea.containsMouse || hasActivePopout)
readonly property bool hasActivePopout: {
var result = false
if (typeof appDrawerLoader !== "undefined" && appDrawerLoader.item)
result = result || appDrawerLoader.item.shouldBeVisible
if (typeof centcomPopoutLoader !== "undefined" && centcomPopoutLoader.item)
result = result || centcomPopoutLoader.item.shouldBeVisible
if (typeof processListPopoutLoader !== "undefined" && processListPopoutLoader.item)
result = result || processListPopoutLoader.item.shouldBeVisible
if (typeof notificationCenterLoader !== "undefined" && notificationCenterLoader.item)
result = result || notificationCenterLoader.item.shouldBeVisible
if (typeof batteryPopoutLoader !== "undefined" && batteryPopoutLoader.item)
result = result || batteryPopoutLoader.item.shouldBeVisible
if (typeof vpnPopoutLoader !== "undefined" && vpnPopoutLoader.item)
result = result || vpnPopoutLoader.item.shouldBeVisible
if (typeof controlCenterLoader !== "undefined" && controlCenterLoader.item)
result = result || controlCenterLoader.item.shouldBeVisible
if (typeof notepadModalLoader !== "undefined" && notepadModalLoader.item)
result = result || notepadModalLoader.item.visible
if (typeof clipboardHistoryModalPopup !== "undefined" && clipboardHistoryModalPopup.item)
result = result || clipboardHistoryModalPopup.item.visible
return result
}
Connections {
function onTopBarTransparencyChanged() {
topBarCore.backgroundTransparency = SettingsData.topBarTransparency
}
target: SettingsData
}
MouseArea {
id: topBarMouseArea
height: root.reveal ? effectiveBarHeight + SettingsData.topBarSpacing : 4
height: parent.reveal ? root.effectiveBarHeight + SettingsData.topBarSpacing : 4
anchors {
top: parent.top
left: parent.left
@@ -184,7 +224,7 @@ PanelWindow {
transform: Translate {
id: topBarSlide
y: root.reveal ? 0 : -(effectiveBarHeight - 4)
y: topBarCore.reveal ? 0 : -(root.effectiveBarHeight - 4)
Behavior on y {
NumberAnimation {
@@ -207,7 +247,7 @@ PanelWindow {
color: Qt.rgba(Theme.surfaceContainer.r,
Theme.surfaceContainer.g,
Theme.surfaceContainer.b,
root.backgroundTransparency)
topBarCore.backgroundTransparency)
layer.enabled: true
Rectangle {
@@ -273,15 +313,16 @@ PanelWindow {
readonly property int leftSectionRightEdge: estimatedLeftSectionWidth
readonly property int mediaLeftEdge: clockLeftEdge - mediaMaxWidth
- Theme.spacingS
readonly property int rightSectionLeftEdge: availableWidth - rightSectionWidth
readonly property int rightSectionLeftEdge: availableWidth
- rightSectionWidth
readonly property int leftToClockGap: Math.max(
0,
clockLeftEdge - leftSectionRightEdge)
clockLeftEdge
- leftSectionRightEdge)
readonly property int leftToMediaGap: mediaMaxWidth > 0 ? Math.max(0, mediaLeftEdge - leftSectionRightEdge) : leftToClockGap
readonly property int mediaToClockGap: mediaMaxWidth > 0 ? Theme.spacingS : 0
readonly property int clockToRightGap: validLayout ? Math.max(
0,
rightSectionLeftEdge - clockRightEdge) : 1000
readonly property int mediaToClockGap: mediaMaxWidth
> 0 ? Theme.spacingS : 0
readonly property int clockToRightGap: validLayout ? Math.max(0, rightSectionLeftEdge - clockRightEdge) : 1000
readonly property bool spacingTight: validLayout
&& (leftToMediaGap < 150
|| clockToRightGap < 100)
@@ -404,8 +445,12 @@ PanelWindow {
}
anchors.fill: parent
anchors.leftMargin: Math.max(Theme.spacingXS, SettingsData.topBarInnerPadding * 0.8)
anchors.rightMargin: Math.max(Theme.spacingXS, SettingsData.topBarInnerPadding * 0.8)
anchors.leftMargin: Math.max(
Theme.spacingXS,
SettingsData.topBarInnerPadding * 0.8)
anchors.rightMargin: Math.max(
Theme.spacingXS,
SettingsData.topBarInnerPadding * 0.8)
anchors.topMargin: SettingsData.topBarInnerPadding / 2
anchors.bottomMargin: SettingsData.topBarInnerPadding / 2
clip: true
@@ -434,7 +479,6 @@ PanelWindow {
opacity: topBarContent.getWidgetEnabled(
model.enabled) ? 1 : 0
asynchronous: false
}
}
}
@@ -477,7 +521,8 @@ PanelWindow {
let parentCenterX = width / 2
if (totalWidgets % 2 === 1) {
let middleIndex = Math.floor(totalWidgets / 2)
let middleIndex = Math.floor(
totalWidgets / 2)
let currentX = parentCenterX
- (centerWidgets[middleIndex].width / 2)
centerWidgets[middleIndex].x = currentX
@@ -501,11 +546,13 @@ PanelWindow {
let rightMiddleIndex = totalWidgets / 2
let gapCenter = parentCenterX
let halfSpacing = spacing / 2
centerWidgets[leftMiddleIndex].x = gapCenter - halfSpacing
- centerWidgets[leftMiddleIndex].width
centerWidgets[leftMiddleIndex].anchors.horizontalCenter = undefined
centerWidgets[leftMiddleIndex].x = gapCenter
- halfSpacing - centerWidgets[leftMiddleIndex].width
centerWidgets[leftMiddleIndex].anchors.horizontalCenter
= undefined
centerWidgets[rightMiddleIndex].x = gapCenter + halfSpacing
centerWidgets[rightMiddleIndex].anchors.horizontalCenter = undefined
centerWidgets[rightMiddleIndex].anchors.horizontalCenter
= undefined
let currentX = centerWidgets[leftMiddleIndex].x
for (var i = leftMiddleIndex - 1; i >= 0; i--) {
currentX -= (spacing + centerWidgets[i].width)
@@ -568,7 +615,8 @@ PanelWindow {
item.onWidthChanged.connect(
centerSection.updateLayout)
if (model.widgetId === "spacer")
item.spacerSize = Qt.binding(() => {
item.spacerSize = Qt.binding(
() => {
return model.size
|| 20
})
@@ -614,7 +662,6 @@ PanelWindow {
opacity: topBarContent.getWidgetEnabled(
model.enabled) ? 1 : 0
asynchronous: false
}
}
}
@@ -628,7 +675,8 @@ PanelWindow {
height: root.widgetHeight
radius: SettingsData.topBarNoBackground ? 0 : Theme.cornerRadius
color: {
if (SettingsData.topBarNoBackground) return "transparent"
if (SettingsData.topBarNoBackground)
return "transparent"
const baseColor = clipboardArea.containsMouse ? Theme.primaryHover : Theme.secondaryHover
return Qt.rgba(
baseColor.r, baseColor.g,
@@ -718,9 +766,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "left"
}
@@ -739,9 +789,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "center"
}
@@ -771,9 +823,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "center"
}
@@ -801,9 +855,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "center"
}
@@ -840,9 +896,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "right"
}
@@ -859,9 +917,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "right"
}
@@ -887,9 +947,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "right"
}
@@ -915,9 +977,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "right"
}
@@ -943,9 +1007,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "right"
}
@@ -980,9 +1046,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "right"
}
@@ -1010,9 +1078,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "right"
}
@@ -1039,9 +1109,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "right"
}
@@ -1069,9 +1141,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "right"
}
@@ -1103,9 +1177,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "right"
}
@@ -1167,9 +1243,11 @@ PanelWindow {
section: {
if (parent && parent.parent === leftSection)
return "left"
if (parent && parent.parent === rightSection)
if (parent
&& parent.parent === rightSection)
return "right"
if (parent && parent.parent === centerSection)
if (parent
&& parent.parent === centerSection)
return "center"
return "right"
}
@@ -1190,4 +1268,5 @@ PanelWindow {
}
}
}
}
}

View File

@@ -137,32 +137,28 @@ PanelWindow {
active: root.visible
asynchronous: false
}
}
FocusScope {
Item {
anchors.fill: parent
visible: shouldBeVisible
focus: shouldBeVisible
focus: true
Keys.onPressed: event => {
if (event.key === Qt.Key_Escape) {
close()
event.accepted = true
} else {
// Forward all non-escape keys to content
event.accepted = false
}
}
onVisibleChanged: {
if (visible) {
Qt.callLater(function () {
if (contentLoader.item) {
contentLoader.item.forceActiveFocus()
} else {
Component.onCompleted: {
forceActiveFocus()
}
onVisibleChanged: {
if (visible) {
forceActiveFocus()
}
})
}
}
}