Compare commits

..

3 commits

Author SHA1 Message Date
Benjamin Palko
ce3ec5d37b stat formatting 2025-08-29 18:49:34 -04:00
Benjamin Palko
69923dbfa3 improve formatting 2025-08-29 17:47:47 -04:00
Benjamin Palko
c983cf206b update styledbutton to extend button 2025-08-29 17:22:04 -04:00
12 changed files with 84 additions and 138 deletions

View file

@ -1,32 +1,37 @@
import qs.config
import QtQuick
import Quickshell.Widgets
import QtQuick.Controls
WrapperMouseArea {
Button {
id: root
required property Component content
property alias padding: rectangle.margin
property alias color: rectangle.color
property alias border: rectangle.border
property alias radius: rectangle.radius
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
font.pixelSize: 14
padding: 6
WrapperRectangle {
id: rectangle
margin: 8
radius: 8
color: root.containsMouse && root.hoverEnabled ? Theme.palette.primary : Theme.palette.base100
Behavior on color {
palette.button: hovered ? Theme.palette.primary : Theme.palette.base100
Behavior on palette.button {
ColorAnimation {
duration: 200
easing.type: Easing.InOutQuad
duration: 100
}
}
Loader {
active: true
sourceComponent: root.content
palette.buttonText: hoverEnabled && hovered ? Theme.palette.primarycontent : Theme.palette.basecontent
Behavior on palette.buttonText {
ColorAnimation {
duration: 100
}
}
wheelEnabled: true
HoverHandler {
cursorShape: Qt.PointingHandCursor
}
background: Rectangle {
id: rectangle
color: root.palette.button
radius: 8
}
}

View file

@ -16,8 +16,11 @@ StyledButton {
showTemp = !showTemp;
}
content: RowLayout {
contentItem: RowLayout {
id: row
spacing: 0
Ref {
service: SystemInfo
}
@ -28,17 +31,15 @@ StyledButton {
font.pixelSize: Dimensions.cpu.iconSize
font.bold: true
text: Icons.cpu
color: root.containsMouse ? Theme.palette.base300 : Theme.palette.basecontent
color: root.hovered ? Theme.palette.primarycontent : Theme.palette.basecontent
}
StyledText {
id: text
font.pixelSize: Dimensions.cpu.fontSize
text: ` ${(SystemInfo.cpuPerc * 100).toFixed()}%`
color: root.containsMouse ? Theme.palette.base300 : Theme.palette.basecontent
text: ` ${(SystemInfo.cpuPerc * 100).toFixed().toString().padStart(2, "_")}%`
color: root.hovered ? Theme.palette.primarycontent : Theme.palette.basecontent
states: [
State {
@ -46,7 +47,7 @@ StyledButton {
when: root.showTemp
PropertyChanges {
text {
text: ` ${(SystemInfo.cpuTemp)}`
text: ` ${SystemInfo.cpuTemp.toFixed().toString().padStart(2, "_")}`
}
}
}

View file

@ -16,8 +16,11 @@ StyledButton {
root.showTemp = !root.showTemp;
}
content: RowLayout {
contentItem: RowLayout {
id: row
spacing: 0
Ref {
service: SystemInfo
}
@ -28,14 +31,15 @@ StyledButton {
font.pixelSize: Dimensions.gpu.iconSize
font.bold: true
text: Icons.gpu
color: root.hovered ? Theme.palette.primarycontent : Theme.palette.basecontent
}
StyledText {
id: text
font.pixelSize: Dimensions.gpu.fontSize
text: ` ${(SystemInfo.gpuPerc * 100).toFixed()}%`
text: ` ${(SystemInfo.gpuPerc * 100).toFixed().toString().padStart(2, "_")}%`
color: root.hovered ? Theme.palette.primarycontent : Theme.palette.basecontent
states: [
State {
@ -43,7 +47,7 @@ StyledButton {
when: root.showTemp
PropertyChanges {
text {
text: ` ${(SystemInfo.gpuTemp)}`
text: ` ${SystemInfo.gpuTemp.toFixed().toString().padStart(2, "_")}`
}
}
}

View file

@ -1,51 +1,15 @@
pragma ComponentBehavior: Bound
import qs.components
import qs.config
import qs.services
import qs.widgets
import QtQuick
import QtQuick.Layouts
StyledButton {
id: root
text: `${Mpris.active?.isPlaying ? "" : ""} ${Mpris.active?.trackTitle} - ${Mpris.active?.trackArtist}`
onClicked: {
Visibility.dashboard = !Visibility.dashboard;
}
content: ColumnLayout {
id: content
spacing: 0
implicitWidth: text.width
implicitHeight: text.height
StyledText {
id: text
text: `${Mpris.active?.isPlaying ? "" : ""} ${Mpris.active?.trackTitle} - ${Mpris.active?.trackArtist}`
font.pixelSize: Dimensions.mpris.fontSize
states: State {
name: "hovered"
when: root.containsMouse
PropertyChanges {
text {
color: Theme.palette.primarycontent
}
}
}
transitions: Transition {
from: ""
to: "hovered"
reversible: true
ColorAnimation {
properties: "color"
duration: 100
easing.type: Easing.InOutCubic
}
}
}
}
}

View file

@ -1,20 +1,18 @@
import qs.components
import qs.config
import qs.services
import qs.widgets
import QtQuick
StyledButton {
id: root
onClicked: mouse => {
if (mouse.button == Qt.LeftButton) {
text: `${Pipewire.muted ? " " : Pipewire.volume <= 0 ? " " : " "} ${(Pipewire.volume * 100).toFixed()}%`
onClicked: {
Pipewire.toggleMute();
} else if (mouse.button == Qt.RightButton) {
popup.opened = !popup.opened;
}
}
WheelHandler {
onWheel: event => {
if (event.angleDelta.y > 0) {
Pipewire.incrementVolume();
@ -22,6 +20,7 @@ StyledButton {
Pipewire.decrementVolume();
}
}
}
states: [
State {
@ -29,17 +28,9 @@ StyledButton {
when: Pipewire.muted
PropertyChanges {
root {
color: Theme.palette.error
palette.button: Theme.palette.error
}
}
}
]
content: StyledText {
id: text
property string icon: Pipewire.muted ? " " : Pipewire.volume <= 0 ? " " : " "
text: `${icon} ${(Pipewire.volume * 100).toFixed()}%`
font.pixelSize: Dimensions.pipewire.fontSize
color: root.containsMouse || Pipewire.muted ? Theme.palette.base300 : Theme.palette.basecontent
}
}

View file

@ -1,7 +1,6 @@
pragma ComponentBehavior: Bound
import qs.components
import qs.config
import qs.widgets
import QtQuick
import QtQuick.Layouts
@ -31,13 +30,11 @@ StyledLabel {
}
StyledButton {
Layout.alignment: Qt.AlignRight
hoverEnabled: !root.modelData.pairing
color: containsMouse ? Theme.palette.primary : Theme.palette.base200
content: StyledText {
text: 'Pair'
font.pixelSize: 12
}
onClicked: {
if (!hoverEnabled) {
return;

View file

@ -80,11 +80,9 @@ StyledLabel {
StyledButton {
Layout.alignment: Qt.AlignRight
color: containsMouse ? Theme.palette.error : Theme.palette.base200
content: StyledText {
text: 'Disconnect'
font.pixelSize: 12
}
palette.button: hovered ? Theme.palette.error : Theme.palette.base200
onClicked: {
if (root.modelData.state != BluetoothDeviceState.Connected) {
return;

View file

@ -34,11 +34,8 @@ StyledLabel {
Layout.alignment: Qt.AlignRight
StyledButton {
hoverEnabled: root.modelData.state == BluetoothDeviceState.Disconnected
color: containsMouse ? Theme.palette.primary : Theme.palette.base200
content: StyledText {
text: 'Connect'
font.pixelSize: 12
}
onClicked: {
if (!hoverEnabled) {
return;
@ -49,11 +46,10 @@ StyledLabel {
StyledButton {
hoverEnabled: root.modelData.state == BluetoothDeviceState.Disconnected
color: containsMouse ? Theme.palette.error : Theme.palette.base200
content: StyledText {
text: 'Unpair'
font.pixelSize: 12
}
palette.button: hovered ? Theme.palette.error : Theme.palette.base100
onClicked: {
if (!hoverEnabled) {
return;

View file

@ -7,7 +7,6 @@ import qs.widgets
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import Quickshell.Widgets
StyledPopupWindow {
@ -34,11 +33,8 @@ StyledPopupWindow {
StyledButton {
id: clearButton
Layout.alignment: Qt.AlignRight
onClicked: Notifications.clear()
content: StyledText {
text: "Clear"
color: clearButton.containsMouse ? Theme.palette.base300 : Theme.palette.basecontent
}
onClicked: Notifications.clear()
}
}

View file

@ -1,13 +1,12 @@
import qs.components
import qs.widgets
import Quickshell
StyledButton {
id: root
property QsMenuEntry menuEntry
onClicked: menuEntry.triggered()
content: StyledText {
font.pixelSize: 14
text: root.menuEntry.text
}
onClicked: menuEntry.triggered()
}

View file

@ -25,13 +25,12 @@ StyledDrawer {
Layout.alignment: Qt.AlignHCenter
StyledButton {
StyledIconButton {
id: previousPlayerButton
visible: Mpris.players.length > 1
content: LucideIcon {
color: previousPlayerButton.containsMouse ? Theme.palette.primarycontent : Theme.palette.basecontent
text: Icons.chevronLeft
}
onClicked: {
Mpris.previousPlayer();
}
@ -52,10 +51,9 @@ StyledDrawer {
StyledButton {
id: nextPlayerButton
visible: Mpris.players.length > 1
content: LucideIcon {
color: nextPlayerButton.containsMouse ? Theme.palette.primarycontent : Theme.palette.basecontent
text: Icons.chevronRight
}
onClicked: {
Mpris.nextPlayer();
}

View file

@ -108,10 +108,7 @@ StyledWindow {
Layout.alignment: Qt.AlignHCenter
content: StyledText {
text: "Reset"
font.pixelSize: 14
}
onClicked: {
Pomodoro.reset();