Refactor Topbar and ActiveWindow layouts: enhance flexibility by removing width constraints and centering items appropriately

This commit is contained in:
ferreo 2024-11-23 01:34:31 +00:00
parent 60025be0c9
commit 29f1ce6b3d
2 changed files with 6 additions and 20 deletions

View File

@ -66,13 +66,10 @@ PanelWindow {
Layout.fillHeight: true Layout.fillHeight: true
RowLayout { RowLayout {
anchors.centerIn: parent anchors.fill: parent
width: parent.width
Widgets.ActiveWindow { Widgets.ActiveWindow {
Layout.fillWidth: true Layout.fillWidth: true
maxWidth: panel.width / 3
Layout.maximumWidth: parent.width
} }
} }
} }

View File

@ -7,8 +7,6 @@ import "root:/"
BarWidget { BarWidget {
id: wrapper id: wrapper
property int maxWidth: 100
Layout.fillWidth: true
function getIcon() { function getIcon() {
var icon = Quickshell.iconPath(ToplevelManager.activeToplevel.appId.toLowerCase(), true); var icon = Quickshell.iconPath(ToplevelManager.activeToplevel.appId.toLowerCase(), true);
@ -26,26 +24,22 @@ BarWidget {
} }
RowLayout { RowLayout {
width: parent.width anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(implicitWidth, parent.width)
height: parent.height height: parent.height
spacing: 4 spacing: 4
Item {
Layout.fillWidth: true
Layout.preferredWidth: parent.width / 2
}
IconImage { IconImage {
id: icon id: icon
implicitHeight: 20 implicitHeight: 20
implicitWidth: 20 implicitWidth: 20
source: ToplevelManager.activeToplevel ? getIcon() : "" source: ToplevelManager.activeToplevel ? getIcon() : ""
} }
Text { Text {
id: text id: text
Layout.fillWidth: false Layout.fillWidth: true
Layout.maximumWidth: wrapper.maxWidth - icon.implicitWidth - 32 Layout.maximumWidth: implicitWidth + 1
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
text: ToplevelManager.activeToplevel?.title ?? "" text: ToplevelManager.activeToplevel?.title ?? ""
color: Globals.commonStyles.textColor color: Globals.commonStyles.textColor
@ -55,10 +49,5 @@ BarWidget {
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 1 maximumLineCount: 1
} }
Item {
Layout.fillWidth: true
Layout.preferredWidth: parent.width / 2
}
} }
} }