BarContent: remove useless Item wrapping left/right sides

This commit is contained in:
end-4
2025-08-15 17:46:02 +07:00
parent 85a522ba14
commit fb89ca98f6
+171 -185
View File
@@ -54,6 +54,7 @@ Item { // Bar content region
id: barLeftSideMouseArea id: barLeftSideMouseArea
anchors.left: parent.left anchors.left: parent.left
implicitHeight: Appearance.sizes.baseBarHeight implicitHeight: Appearance.sizes.baseBarHeight
implicitWidth: leftSectionRowLayout.implicitWidth
height: Appearance.sizes.barHeight height: Appearance.sizes.barHeight
width: (root.width - middleSection.width) / 2 width: (root.width - middleSection.width) / 2
property bool hovered: false property bool hovered: false
@@ -75,6 +76,7 @@ Item { // Bar content region
GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen; GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen;
} }
} }
// Scroll to change brightness // Scroll to change brightness
WheelHandler { WheelHandler {
onWheel: event => { onWheel: event => {
@@ -99,66 +101,61 @@ Item { // Bar content region
} }
} }
} }
Item {
// Left section // Visual content
anchors.fill: parent ScrollHint {
implicitHeight: leftSectionRowLayout.implicitHeight reveal: barLeftSideMouseArea.hovered
implicitWidth: leftSectionRowLayout.implicitWidth icon: "light_mode"
tooltipText: Translation.tr("Scroll to change brightness")
side: "left"
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
}
ScrollHint { RowLayout {
reveal: barLeftSideMouseArea.hovered id: leftSectionRowLayout
icon: "light_mode" anchors.fill: parent
tooltipText: Translation.tr("Scroll to change brightness") spacing: 10
side: "left"
anchors.left: parent.left RippleButton {
anchors.verticalCenter: parent.verticalCenter // Left sidebar button
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
Layout.leftMargin: Appearance.rounding.screenRounding
Layout.fillWidth: false
property real buttonPadding: 5
implicitWidth: distroIcon.width + buttonPadding * 2
implicitHeight: distroIcon.height + buttonPadding * 2
buttonRadius: Appearance.rounding.full
colBackground: barLeftSideMouseArea.hovered ? Appearance.colors.colLayer1Hover : ColorUtils.transparentize(Appearance.colors.colLayer1Hover, 1)
colBackgroundHover: Appearance.colors.colLayer1Hover
colRipple: Appearance.colors.colLayer1Active
colBackgroundToggled: Appearance.colors.colSecondaryContainer
colBackgroundToggledHover: Appearance.colors.colSecondaryContainerHover
colRippleToggled: Appearance.colors.colSecondaryContainerActive
toggled: GlobalStates.sidebarLeftOpen
property color colText: toggled ? Appearance.m3colors.m3onSecondaryContainer : Appearance.colors.colOnLayer0
onPressed: {
GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen;
}
CustomIcon {
id: distroIcon
anchors.centerIn: parent
width: 19.5
height: 19.5
source: Config.options.bar.topLeftIcon == 'distro' ? SystemInfo.distroIcon : `${Config.options.bar.topLeftIcon}-symbolic`
colorize: true
color: Appearance.colors.colOnLayer0
}
} }
RowLayout { // Content ActiveWindow {
id: leftSectionRowLayout visible: root.useShortenedForm === 0
anchors.fill: parent Layout.rightMargin: Appearance.rounding.screenRounding
spacing: 10 Layout.fillWidth: true
Layout.fillHeight: true
RippleButton {
// Left sidebar button
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
Layout.leftMargin: Appearance.rounding.screenRounding
Layout.fillWidth: false
property real buttonPadding: 5
implicitWidth: distroIcon.width + buttonPadding * 2
implicitHeight: distroIcon.height + buttonPadding * 2
buttonRadius: Appearance.rounding.full
colBackground: barLeftSideMouseArea.hovered ? Appearance.colors.colLayer1Hover : ColorUtils.transparentize(Appearance.colors.colLayer1Hover, 1)
colBackgroundHover: Appearance.colors.colLayer1Hover
colRipple: Appearance.colors.colLayer1Active
colBackgroundToggled: Appearance.colors.colSecondaryContainer
colBackgroundToggledHover: Appearance.colors.colSecondaryContainerHover
colRippleToggled: Appearance.colors.colSecondaryContainerActive
toggled: GlobalStates.sidebarLeftOpen
property color colText: toggled ? Appearance.m3colors.m3onSecondaryContainer : Appearance.colors.colOnLayer0
onPressed: {
GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen;
}
CustomIcon {
id: distroIcon
anchors.centerIn: parent
width: 19.5
height: 19.5
source: Config.options.bar.topLeftIcon == 'distro' ? SystemInfo.distroIcon : `${Config.options.bar.topLeftIcon}-symbolic`
colorize: true
color: Appearance.colors.colOnLayer0
}
}
ActiveWindow {
visible: root.useShortenedForm === 0
Layout.rightMargin: Appearance.rounding.screenRounding
Layout.fillWidth: true
Layout.fillHeight: true
}
} }
} }
} }
@@ -171,7 +168,7 @@ Item { // Bar content region
BarGroup { BarGroup {
id: leftCenterGroup id: leftCenterGroup
Layout.preferredWidth: root.centerSideModuleWidth Layout.preferredWidth: root.centerSideModuleWidth
Layout.fillHeight: true Layout.fillHeight: false
Resources { Resources {
alwaysShowAllResources: root.useShortenedForm === 2 alwaysShowAllResources: root.useShortenedForm === 2
@@ -252,6 +249,7 @@ Item { // Bar content region
id: barRightSideMouseArea id: barRightSideMouseArea
anchors.right: parent.right anchors.right: parent.right
implicitWidth: rightSectionRowLayout.implicitWidth
implicitHeight: Appearance.sizes.baseBarHeight implicitHeight: Appearance.sizes.baseBarHeight
height: Appearance.sizes.barHeight height: Appearance.sizes.barHeight
width: (root.width - middleSection.width) / 2 width: (root.width - middleSection.width) / 2
@@ -278,6 +276,7 @@ Item { // Bar content region
MprisController.activePlayer.next(); MprisController.activePlayer.next();
} }
} }
// Scroll to change volume // Scroll to change volume
WheelHandler { WheelHandler {
onWheel: event => { onWheel: event => {
@@ -305,138 +304,125 @@ Item { // Bar content region
} }
} }
Item { // Visual content
anchors.fill: parent ScrollHint {
implicitHeight: rightSectionRowLayout.implicitHeight reveal: barRightSideMouseArea.hovered
implicitWidth: rightSectionRowLayout.implicitWidth icon: "volume_up"
tooltipText: Translation.tr("Scroll to change volume")
side: "right"
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
ScrollHint { RowLayout {
reveal: barRightSideMouseArea.hovered id: rightSectionRowLayout
icon: "volume_up" anchors.fill: parent
tooltipText: Translation.tr("Scroll to change volume") spacing: 5
side: "right" layoutDirection: Qt.RightToLeft
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter RippleButton { // Right sidebar button
id: rightSidebarButton
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.rightMargin: Appearance.rounding.screenRounding
Layout.fillWidth: false
implicitWidth: indicatorsRowLayout.implicitWidth + 10 * 2
implicitHeight: indicatorsRowLayout.implicitHeight + 5 * 2
buttonRadius: Appearance.rounding.full
colBackground: barRightSideMouseArea.hovered ? Appearance.colors.colLayer1Hover : ColorUtils.transparentize(Appearance.colors.colLayer1Hover, 1)
colBackgroundHover: Appearance.colors.colLayer1Hover
colRipple: Appearance.colors.colLayer1Active
colBackgroundToggled: Appearance.colors.colSecondaryContainer
colBackgroundToggledHover: Appearance.colors.colSecondaryContainerHover
colRippleToggled: Appearance.colors.colSecondaryContainerActive
toggled: GlobalStates.sidebarRightOpen
property color colText: toggled ? Appearance.m3colors.m3onSecondaryContainer : Appearance.colors.colOnLayer0
Behavior on colText {
animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this)
}
onPressed: {
GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen;
}
RowLayout {
id: indicatorsRowLayout
anchors.centerIn: parent
property real realSpacing: 15
spacing: 0
Revealer {
reveal: Audio.sink?.audio?.muted ?? false
Layout.fillHeight: true
Layout.rightMargin: reveal ? indicatorsRowLayout.realSpacing : 0
Behavior on Layout.rightMargin {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
}
MaterialSymbol {
text: "volume_off"
iconSize: Appearance.font.pixelSize.larger
color: rightSidebarButton.colText
}
}
Revealer {
reveal: Audio.source?.audio?.muted ?? false
Layout.fillHeight: true
Layout.rightMargin: reveal ? indicatorsRowLayout.realSpacing : 0
Behavior on Layout.rightMargin {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
}
MaterialSymbol {
text: "mic_off"
iconSize: Appearance.font.pixelSize.larger
color: rightSidebarButton.colText
}
}
Loader {
active: HyprlandXkb.layoutCodes.length > 1
visible: active
Layout.rightMargin: indicatorsRowLayout.realSpacing
sourceComponent: StyledText {
text: HyprlandXkb.currentLayoutCode
font.pixelSize: Appearance.font.pixelSize.small
color: rightSidebarButton.colText
}
}
MaterialSymbol {
Layout.rightMargin: indicatorsRowLayout.realSpacing
text: Network.materialSymbol
iconSize: Appearance.font.pixelSize.larger
color: rightSidebarButton.colText
}
MaterialSymbol {
text: Bluetooth.bluetoothConnected ? "bluetooth_connected" : Bluetooth.bluetoothEnabled ? "bluetooth" : "bluetooth_disabled"
iconSize: Appearance.font.pixelSize.larger
color: rightSidebarButton.colText
}
}
} }
RowLayout { SysTray {
id: rightSectionRowLayout visible: root.useShortenedForm === 0
anchors.fill: parent Layout.fillWidth: false
spacing: 5 Layout.fillHeight: true
layoutDirection: Qt.RightToLeft }
RippleButton { // Right sidebar button Item {
id: rightSidebarButton Layout.fillWidth: true
Layout.fillHeight: true
}
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter // Weather
Layout.rightMargin: Appearance.rounding.screenRounding Loader {
Layout.fillWidth: false Layout.leftMargin: 8
Layout.fillHeight: true
implicitWidth: indicatorsRowLayout.implicitWidth + 10 * 2 active: Config.options.bar.weather.enable
implicitHeight: indicatorsRowLayout.implicitHeight + 5 * 2 sourceComponent: BarGroup {
implicitHeight: Appearance.sizes.baseBarHeight
buttonRadius: Appearance.rounding.full WeatherBar {}
colBackground: barRightSideMouseArea.hovered ? Appearance.colors.colLayer1Hover : ColorUtils.transparentize(Appearance.colors.colLayer1Hover, 1)
colBackgroundHover: Appearance.colors.colLayer1Hover
colRipple: Appearance.colors.colLayer1Active
colBackgroundToggled: Appearance.colors.colSecondaryContainer
colBackgroundToggledHover: Appearance.colors.colSecondaryContainerHover
colRippleToggled: Appearance.colors.colSecondaryContainerActive
toggled: GlobalStates.sidebarRightOpen
property color colText: toggled ? Appearance.m3colors.m3onSecondaryContainer : Appearance.colors.colOnLayer0
Behavior on colText {
animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this)
}
onPressed: {
GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen;
}
RowLayout {
id: indicatorsRowLayout
anchors.centerIn: parent
property real realSpacing: 15
spacing: 0
Revealer {
reveal: Audio.sink?.audio?.muted ?? false
Layout.fillHeight: true
Layout.rightMargin: reveal ? indicatorsRowLayout.realSpacing : 0
Behavior on Layout.rightMargin {
NumberAnimation {
duration: Appearance.animation.elementMoveFast.duration
easing.type: Appearance.animation.elementMoveFast.type
easing.bezierCurve: Appearance.animation.elementMoveFast.bezierCurve
}
}
MaterialSymbol {
text: "volume_off"
iconSize: Appearance.font.pixelSize.larger
color: rightSidebarButton.colText
}
}
Revealer {
reveal: Audio.source?.audio?.muted ?? false
Layout.fillHeight: true
Layout.rightMargin: reveal ? indicatorsRowLayout.realSpacing : 0
Behavior on Layout.rightMargin {
NumberAnimation {
duration: Appearance.animation.elementMoveFast.duration
easing.type: Appearance.animation.elementMoveFast.type
easing.bezierCurve: Appearance.animation.elementMoveFast.bezierCurve
}
}
MaterialSymbol {
text: "mic_off"
iconSize: Appearance.font.pixelSize.larger
color: rightSidebarButton.colText
}
}
Loader {
active: HyprlandXkb.layoutCodes.length > 1
visible: active
Layout.rightMargin: indicatorsRowLayout.realSpacing
sourceComponent: StyledText {
text: HyprlandXkb.currentLayoutCode
font.pixelSize: Appearance.font.pixelSize.small
color: rightSidebarButton.colText
}
}
MaterialSymbol {
Layout.rightMargin: indicatorsRowLayout.realSpacing
text: Network.materialSymbol
iconSize: Appearance.font.pixelSize.larger
color: rightSidebarButton.colText
}
MaterialSymbol {
text: Bluetooth.bluetoothConnected ? "bluetooth_connected" : Bluetooth.bluetoothEnabled ? "bluetooth" : "bluetooth_disabled"
iconSize: Appearance.font.pixelSize.larger
color: rightSidebarButton.colText
}
}
}
SysTray {
visible: root.useShortenedForm === 0
Layout.fillWidth: false
Layout.fillHeight: true
}
Item {
Layout.fillWidth: true
Layout.fillHeight: true
}
// Weather
Loader {
Layout.leftMargin: 8
Layout.fillHeight: true
active: Config.options.bar.weather.enable
sourceComponent: BarGroup {
implicitHeight: Appearance.sizes.baseBarHeight
WeatherBar {}
}
} }
} }
} }