Various fixes for various layout issues, make bar less thicc

This commit is contained in:
ferreo 2024-11-22 23:16:04 +00:00
parent b6e5bd54f8
commit afcb62dbb4
10 changed files with 158 additions and 103 deletions

View File

@ -11,7 +11,10 @@ QtObject {
property int fontWeight: 500 property int fontWeight: 500
property int tooltipFontSize: 14 property int tooltipFontSize: 14
property int textFontSize: 16 property int textFontSize: 16
property int smallTextFontSize: 12 property int textFontSizeMedium: 14
property int iconFontSize: 16 property int textFontSizeSmall: 12
property int iconFontSizeLarge: 20 property int smallTextFontSize: 10
property int iconFontSize: 18
property int iconFontSizeSmall: 14
property int iconFontSizeMedium: 16
} }

View File

@ -1,10 +1,11 @@
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import Quickshell import Quickshell
import Quickshell.Widgets
import "widgets" as Widgets import "widgets" as Widgets
PanelWindow { PanelWindow {
id: panel
property var weatherConfig: ({}) property var weatherConfig: ({})
property string sysInfoInterval: "2s" property string sysInfoInterval: "2s"
property int workspaces: 10 property int workspaces: 10
@ -15,82 +16,96 @@ PanelWindow {
right: true right: true
} }
height: 46 height: 30
width: 500
color: "transparent" color: "transparent"
Rectangle { Rectangle {
anchors.leftMargin: 10
anchors.rightMargin: 10
anchors.topMargin: 5
anchors.fill: parent anchors.fill: parent
color: "#141418" color: "#141418"
radius: 25
ShaderEffect { ShaderEffect {
id: shaderEffect id: shaderEffect
anchors.fill: parent anchors.fill: parent
property color baseColor: "#191823" property color baseColor: "#191823"
property color transparent: Qt.rgba(0, 0, 0, 0) property color transparent: Qt.rgba(0, 0, 0, 0)
property real rectWidth: parent.width property real rectWidth: panel.width
property real rectHeight: parent.height property real rectHeight: panel.height
property real cornerRadius: 25.0 property real cornerRadius: 0
property real time: 0.0 property real time: 0.0
fragmentShader: "gradient.frag.qsb" fragmentShader: "gradient.frag.qsb"
} }
RowLayout { RowLayout {
anchors.fill: parent spacing: 10
width: parent.width
height: parent.height
Layout.fillWidth: true
Layout.fillHeight: true
implicitWidth: parent.width
implicitHeight: parent.height
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredWidth: panel.width / 3
Layout.maximumWidth: panel.width / 3
Layout.fillHeight: true Layout.fillHeight: true
RowLayout { RowLayout {
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
spacing: 10 spacing: 10
Widgets.Workspaces { Widgets.Workspaces {
Layout.fillHeight: true id: workspacesWidget
workspaces: workspaces workspaces: workspaces
} }
Widgets.NowPlaying {
Layout.fillHeight: true
}
}
}
Widgets.ActiveWindow { Widgets.NowPlaying {
Layout.fillHeight: true maxWidth: panel.width / 3 - workspacesWidget.implicitWidth - 26
}
}
} }
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredWidth: panel.width / 3
Layout.maximumWidth: panel.width / 3
Layout.fillHeight: true Layout.fillHeight: true
RowLayout { RowLayout {
spacing: 10 anchors.centerIn: parent
anchors.right: parent.right width: parent.width
anchors.top: parent.top
anchors.bottom: parent.bottom Widgets.ActiveWindow {
Widgets.Stats { Layout.fillWidth: true
maxWidth: panel.width / 3
Layout.maximumWidth: parent.width
}
}
}
Item {
Layout.fillWidth: true
Layout.preferredWidth: panel.width / 3
Layout.maximumWidth: panel.width / 3
Layout.fillHeight: true Layout.fillHeight: true
RowLayout {
anchors {
right: parent.right
top: parent.top
bottom: parent.bottom
}
spacing: 10
Widgets.Stats {
updateInterval: sysInfoInterval updateInterval: sysInfoInterval
} }
Widgets.Weather { Widgets.Weather {
Layout.fillHeight: true
isAmerican: weatherConfig.isamerican ?? false isAmerican: weatherConfig.isamerican ?? false
city: weatherConfig.city ?? "London" city: weatherConfig.city ?? "London"
updateInterval: weatherConfig.weatherupdateinterval ?? 300000 updateInterval: weatherConfig.weatherupdateinterval ?? 300000
} }
Widgets.Power { Widgets.Power {}
Layout.fillHeight: true Widgets.SystemTray {}
} Widgets.Clock {}
Widgets.SystemTray {
Layout.fillHeight: true
}
Widgets.Clock {
Layout.fillHeight: true
}
} }
} }
} }

View File

@ -5,8 +5,11 @@ import Quickshell.Wayland
import Quickshell.Widgets import Quickshell.Widgets
import "root:/" import "root:/"
Row { BarWidget {
spacing: 10 id: wrapper
color: "transparent"
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);
@ -23,24 +26,40 @@ Row {
return icon; return icon;
} }
RowLayout {
width: parent.width
height: parent.height
spacing: 4
Item {
Layout.fillWidth: true
Layout.preferredWidth: parent.width / 2
}
IconImage { IconImage {
height: 42 id: icon
Layout.fillHeight: true implicitHeight: 20
implicitWidth: parent.height * 0.6 implicitWidth: 20
source: ToplevelManager.activeToplevel ? getIcon() : "" source: ToplevelManager.activeToplevel ? getIcon() : ""
} }
Text { Text {
id: text id: text
height: 42 Layout.fillWidth: false
Layout.maximumWidth: wrapper.maxWidth - icon.implicitWidth - 16
horizontalAlignment: Text.AlignLeft
text: ToplevelManager.activeToplevel?.title ?? "" text: ToplevelManager.activeToplevel?.title ?? ""
color: Globals.commonStyles.textColor color: Globals.commonStyles.textColor
font.pointSize: Globals.commonStyles.smallTextFontSize font.pointSize: Globals.commonStyles.textFontSizeSmall
font.family: Globals.commonStyles.fontFamily font.family: Globals.commonStyles.fontFamily
font.weight: Globals.commonStyles.fontWeight font.weight: Globals.commonStyles.fontWeight
elide: Text.ElideRight elide: Text.ElideRight
width: Math.min(implicitWidth, 200) maximumLineCount: 1
horizontalAlignment: Text.AlignHCenter }
verticalAlignment: Text.AlignVCenter
Item {
Layout.fillWidth: true
Layout.preferredWidth: parent.width / 2
}
} }
} }

View File

@ -6,20 +6,21 @@ import "root:/"
BarWidget { BarWidget {
id: clockWidget id: clockWidget
color: "transparent" color: "transparent"
Layout.minimumWidth: clockLayout.implicitWidth + 80 Layout.minimumWidth: clockLayout.implicitWidth + 20
Layout.alignment: Qt.AlignRight Layout.minimumHeight: clockLayout.implicitHeight
Layout.fillHeight: true widgetAnchors.margins: 10
radius: 25 radius: 25
widgetAnchors.margins: 0
property bool calendarOpen: false property bool calendarOpen: false
Rectangle { Rectangle {
id: background id: background
anchors.fill: parent
anchors.margins: 0 anchors.margins: 0
anchors.centerIn: parent
width: clockLayout.implicitWidth + 20
height: 30
color: "#40ffffff" color: "#40ffffff"
radius: 25 radius: 0
opacity: mouseArea.containsMouse ? 0.2 : 0 opacity: mouseArea.containsMouse ? 0.2 : 0
Behavior on opacity { Behavior on opacity {
NumberAnimation { NumberAnimation {
@ -30,18 +31,19 @@ BarWidget {
Column { Column {
id: clockLayout id: clockLayout
anchors.centerIn: parent anchors.horizontalCenter: parent.right
rightPadding: 0 anchors.verticalCenter: parent.verticalCenter
spacing: 2 rightPadding: 6
spacing: 0
Text { Text {
id: timeText id: timeText
anchors.right: parent.right anchors.right: parent.horizontalCenter
text: { text: {
let now = Globals.date; let now = Globals.date;
return now.toLocaleString(Qt.locale(), "HH:mm"); return now.toLocaleString(Qt.locale(), "HH:mm");
} }
font.pixelSize: Globals.commonStyles.textFontSize font.pixelSize: Globals.commonStyles.textFontSizeMedium
font.family: Globals.commonStyles.fontFamily font.family: Globals.commonStyles.fontFamily
font.weight: Globals.commonStyles.fontWeight font.weight: Globals.commonStyles.fontWeight
color: Globals.commonStyles.textColor color: Globals.commonStyles.textColor
@ -50,7 +52,7 @@ BarWidget {
Text { Text {
id: dateText id: dateText
anchors.right: parent.right anchors.right: parent.horizontalCenter
text: { text: {
let now = Globals.date; let now = Globals.date;
let dayName = now.toLocaleDateString(Qt.locale(), "ddd"); let dayName = now.toLocaleDateString(Qt.locale(), "ddd");

View File

@ -8,9 +8,13 @@ import "root:/"
BarWidget { BarWidget {
id: root id: root
property int maxWidth: 100
color: "transparent" color: "transparent"
implicitHeight: 42 implicitHeight: 30
implicitWidth: childrenRect.width implicitWidth: mainRect.implicitWidth
width: mainRect.implicitWidth
height: 30
property MprisPlayer player: Mpris.players.values[0] ?? null property MprisPlayer player: Mpris.players.values[0] ?? null
onPlayerChanged: updateProcessState() onPlayerChanged: updateProcessState()
@ -40,7 +44,7 @@ BarWidget {
try { try {
const data = JSON.parse(line); const data = JSON.parse(line);
for (let i = 0; i < data.length && i < visualizerRepeater.count; i++) { for (let i = 0; i < data.length && i < visualizerRepeater.count; i++) {
const newHeight = visualizerRepeater.itemAt(i).height = (data[i] / 1500) * 42 + 25; const newHeight = visualizerRepeater.itemAt(i).height = (data[i] / 1500) * 30 + 25;
} }
} catch (e) { } catch (e) {
console.log("Failed to parse cava output:", e); console.log("Failed to parse cava output:", e);
@ -52,9 +56,9 @@ BarWidget {
property double measuredWidth: { property double measuredWidth: {
if (!root.player) if (!root.player)
return 0; return 0;
let titleWidth = Math.min(titleText.width, 200); let titleWidth = titleText.width
let artistWidth = Math.min(artistText.width, 200); let artistWidth = artistText.width
return ((Math.max(titleWidth, artistWidth) / Screen.devicePixelRatio) + artContainer.width) * Screen.devicePixelRatio; return ((Math.max(titleWidth, artistWidth) / Screen.devicePixelRatio) + artContainer.width + 3) * Screen.devicePixelRatio;
} }
Repeater { Repeater {
@ -80,31 +84,36 @@ BarWidget {
leftMargin: 8 leftMargin: 8
rightMargin: 8 rightMargin: 8
} }
implicitWidth: artContainer.width + titleContainer.width + 48
color: "transparent" color: "transparent"
radius: 8 radius: 8
visible: root.player?.playbackState === MprisPlaybackState.Playing || root.player?.playbackState === MprisPlaybackState.Paused visible: root.player?.playbackState === MprisPlaybackState.Playing || root.player?.playbackState === MprisPlaybackState.Paused
Rectangle { Rectangle {
id: artContainer id: artContainer
width: 40 width: 30
height: 40 height: 30
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 32 anchors.leftMargin: 32
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: "transparent" color: "transparent"
radius: parent.radius radius: parent.radius
ClippingRectangle { ClippingWrapperRectangle {
anchors.fill: parent anchors.fill: parent
anchors.topMargin: 2
anchors.rightMargin: 2
color: "transparent" color: "transparent"
radius: parent.radius radius: parent.radius
resizeChild: true
border.color: "#9900246b" border.color: "#9900246b"
border.width: 2 border.width: 2
IconImage { child: Image {
id: artImage id: artImage
anchors.fill: parent
source: root.player?.trackArtUrl ?? "" source: root.player?.trackArtUrl ?? ""
fillMode: Image.PreserveAspectCrop
antialiasing: true
} }
} }
@ -120,7 +129,7 @@ BarWidget {
anchors.centerIn: parent anchors.centerIn: parent
text: root.player?.playbackState === MprisPlaybackState.Playing ? "pause" : "play_arrow" text: root.player?.playbackState === MprisPlaybackState.Playing ? "pause" : "play_arrow"
font.family: Globals.commonStyles.iconFontFamily font.family: Globals.commonStyles.iconFontFamily
font.pixelSize: Globals.commonStyles.iconFontSizeLarge font.pixelSize: Globals.commonStyles.iconFontSizeSmall
color: Globals.commonStyles.textColor color: Globals.commonStyles.textColor
opacity: mouseArea.containsMouse ? 1.0 : 0.0 opacity: mouseArea.containsMouse ? 1.0 : 0.0
Behavior on opacity { Behavior on opacity {
@ -145,11 +154,10 @@ BarWidget {
anchors.right: parent.right anchors.right: parent.right
anchors.leftMargin: 16 anchors.leftMargin: 16
anchors.rightMargin: 12 anchors.rightMargin: 12
height: 42 height: 30
Text { Text {
id: titleText id: titleText
width: Math.min(implicitWidth, 200)
anchors.left: parent.left anchors.left: parent.left
anchors.bottom: parent.verticalCenter anchors.bottom: parent.verticalCenter
anchors.bottomMargin: 4 anchors.bottomMargin: 4
@ -157,13 +165,13 @@ BarWidget {
elide: Text.ElideRight elide: Text.ElideRight
color: Globals.commonStyles.textColor color: Globals.commonStyles.textColor
font.family: Globals.commonStyles.fontFamily font.family: Globals.commonStyles.fontFamily
font.pixelSize: Globals.commonStyles.textFontSize font.pixelSize: Globals.commonStyles.textFontSizeMedium
font.weight: Globals.commonStyles.fontWeight font.weight: Globals.commonStyles.fontWeight
width: Math.min(implicitWidth, root.maxWidth - artContainer.width - 32)
} }
Text { Text {
id: artistText id: artistText
width: Math.min(implicitWidth, 200)
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.verticalCenter anchors.top: parent.verticalCenter
anchors.topMargin: -2 anchors.topMargin: -2
@ -173,6 +181,7 @@ BarWidget {
font.family: Globals.commonStyles.fontFamily font.family: Globals.commonStyles.fontFamily
font.pixelSize: Globals.commonStyles.smallTextFontSize font.pixelSize: Globals.commonStyles.smallTextFontSize
font.weight: Globals.commonStyles.fontWeight font.weight: Globals.commonStyles.fontWeight
width: Math.min(implicitWidth, root.maxWidth - artContainer.width - 32)
} }
} }
} }

View File

@ -22,9 +22,10 @@ Loader {
RowLayout { RowLayout {
anchors.fill: parent anchors.fill: parent
spacing: 5 spacing: 3
Text { Text {
Layout.alignment: Qt.AlignVCenter
font.family: Globals.commonStyles.iconFontFamily font.family: Globals.commonStyles.iconFontFamily
font.pixelSize: Globals.commonStyles.iconFontSize font.pixelSize: Globals.commonStyles.iconFontSize
color: Globals.commonStyles.textColor color: Globals.commonStyles.textColor
@ -45,6 +46,7 @@ Loader {
} }
Text { Text {
Layout.alignment: Qt.AlignVCenter
font.family: Globals.commonStyles.fontFamily font.family: Globals.commonStyles.fontFamily
font.weight: Globals.commonStyles.fontWeight font.weight: Globals.commonStyles.fontWeight
font.pixelSize: Globals.commonStyles.textFontSize font.pixelSize: Globals.commonStyles.textFontSize

View File

@ -8,7 +8,7 @@ import "root:/"
BarWidget { BarWidget {
id: root id: root
color: "transparent" color: "transparent"
implicitHeight: 42 implicitHeight: 30
implicitWidth: mainRect.width implicitWidth: mainRect.width
property string updateInterval: "2s" property string updateInterval: "2s"
@ -44,7 +44,8 @@ BarWidget {
RowLayout { RowLayout {
id: layout id: layout
anchors.centerIn: parent anchors.centerIn: parent
spacing: 20 anchors.verticalCenterOffset: 1
spacing: 10
// CPU Usage Component // CPU Usage Component
Item { Item {
@ -61,11 +62,13 @@ BarWidget {
RowLayout { RowLayout {
id: cpuUsageLayout id: cpuUsageLayout
spacing: 5 spacing: 3
Text { Text {
font.family: Globals.commonStyles.iconFontFamily font.family: Globals.commonStyles.iconFontFamily
font.pixelSize: Globals.commonStyles.iconFontSize font.pixelSize: Globals.commonStyles.iconFontSize
text: "developer_board" text: "developer_board"
verticalAlignment: Text.AlignVCenter
color: Globals.commonStyles.textColor color: Globals.commonStyles.textColor
} }
@ -109,11 +112,12 @@ BarWidget {
RowLayout { RowLayout {
id: cpuTempLayout id: cpuTempLayout
spacing: 5 spacing: 3
Text { Text {
font.family: Globals.commonStyles.iconFontFamily font.family: Globals.commonStyles.iconFontFamily
font.pixelSize: Globals.commonStyles.iconFontSize font.pixelSize: Globals.commonStyles.iconFontSize
text: "thermometer" text: "thermometer"
verticalAlignment: Text.AlignVCenter
color: Globals.commonStyles.textColor color: Globals.commonStyles.textColor
} }
@ -157,12 +161,13 @@ BarWidget {
RowLayout { RowLayout {
id: memoryUsageLayout id: memoryUsageLayout
spacing: 5 spacing: 3
Text { Text {
font.family: Globals.commonStyles.iconFontFamily font.family: Globals.commonStyles.iconFontFamily
font.pixelSize: Globals.commonStyles.iconFontSize font.pixelSize: Globals.commonStyles.iconFontSize
text: "memory" text: "memory"
color: Globals.commonStyles.textColor color: Globals.commonStyles.textColor
verticalAlignment: Text.AlignVCenter
} }
Text { Text {

View File

@ -15,10 +15,12 @@ BarWidget {
widgetAnchors.margins: 0 widgetAnchors.margins: 0
widgetAnchors.leftMargin: 3 widgetAnchors.leftMargin: 3
widgetAnchors.rightMargin: 3 widgetAnchors.rightMargin: 3
height: 30
implicitHeight: 30
RowLayout { RowLayout {
anchors.fill: parent anchors.fill: parent
anchors.bottomMargin: 4 anchors.bottomMargin: 0
spacing: 10 spacing: 10
Repeater { Repeater {
@ -43,7 +45,6 @@ BarWidget {
} else if (event.button == Qt.RightButton && item.hasMenu) { } else if (event.button == Qt.RightButton && item.hasMenu) {
const window = QsWindow.window; const window = QsWindow.window;
const widgetRect = window.contentItem.mapFromItem(delegate, 0, delegate.height, delegate.width, delegate.height); const widgetRect = window.contentItem.mapFromItem(delegate, 0, delegate.height, delegate.width, delegate.height);
menuAnchor.anchor.rect = widgetRect; menuAnchor.anchor.rect = widgetRect;
menuAnchor.open(); menuAnchor.open();
} }
@ -61,7 +62,7 @@ BarWidget {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
source: item && item.icon ? item.icon : "" source: item && item.icon ? item.icon : ""
visible: status === Image.Ready visible: status === Image.Ready
implicitSize: 24 implicitSize: 20
smooth: true smooth: true
} }
BarTooltip { BarTooltip {
@ -81,8 +82,7 @@ BarWidget {
QsMenuAnchor { QsMenuAnchor {
id: menuAnchor id: menuAnchor
menu: item.menu menu: item.menu
anchor.window: delegate.QsWindow.window?? null
anchor.window: delegate.QsWindow.window
anchor.adjustment: PopupAdjustment.Flip anchor.adjustment: PopupAdjustment.Flip
} }
} }

View File

@ -7,7 +7,7 @@ import "root:/"
BarWidget { BarWidget {
id: root id: root
color: "transparent" color: "transparent"
implicitHeight: 42 implicitHeight: 30
implicitWidth: mainRect.width implicitWidth: mainRect.width
property string city: "London" property string city: "London"
@ -102,7 +102,7 @@ BarWidget {
Rectangle { Rectangle {
id: mainRect id: mainRect
height: parent.height height: parent.height
width: layout.width + 16 width: layout.width + 10
color: "transparent" color: "transparent"
radius: 8 radius: 8
@ -131,20 +131,19 @@ BarWidget {
RowLayout { RowLayout {
id: layout id: layout
anchors.centerIn: parent anchors.centerIn: parent
spacing: 8 anchors.verticalCenterOffset: 1
spacing: 5
Text { Text {
id: weatherIcon id: weatherIcon
Layout.alignment: Qt.AlignVCenter
font.family: Globals.commonStyles.iconFontFamily font.family: Globals.commonStyles.iconFontFamily
font.pixelSize: Globals.commonStyles.iconFontSize font.pixelSize: Globals.commonStyles.iconFontSizeMedium
color: Globals.commonStyles.textColor color: Globals.commonStyles.textColor
text: "rainy" text: "rainy"
} }
Text { Text {
id: tempLabel id: tempLabel
Layout.alignment: Qt.AlignVCenter
font.family: Globals.commonStyles.fontFamily font.family: Globals.commonStyles.fontFamily
font.pixelSize: Globals.commonStyles.textFontSize font.pixelSize: Globals.commonStyles.textFontSize
color: Globals.commonStyles.textColor color: Globals.commonStyles.textColor

View File

@ -2,6 +2,7 @@ import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import Quickshell import Quickshell
import Quickshell.Hyprland import Quickshell.Hyprland
import Quickshell.Widgets
import "root:/" import "root:/"
BarWidget { BarWidget {
@ -15,7 +16,7 @@ BarWidget {
RowLayout { RowLayout {
anchors { anchors {
left: parent.left left: parent.left
leftMargin: 16 leftMargin: 12
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
} }
spacing: 0 spacing: 0
@ -24,8 +25,8 @@ BarWidget {
model: root.workspaces model: root.workspaces
Item { Item {
Layout.preferredWidth: 26 Layout.preferredWidth: 24
Layout.preferredHeight: 26 Layout.preferredHeight: 24
Rectangle { Rectangle {
id: wsRect id: wsRect