swaybar/modules/Workspaces.qml (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
import QtQuick
import QtQuick.Controls.Basic
import QtQuick.Layouts
import Quickshell
import Quickshell.I3
import Quickshell.Widgets
import "../classes" as Class
import "../../"
RowLayout {
spacing: 2
property var ws_focused: I3.focusedWorkspace?.number
Repeater {
model: I3.workspaces.values
Button {
id: ws_button
property var ws_special: (modelData.number >= 10)
MouseArea{
id: ws_mouse_area
hoverEnabled: true
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: I3.dispatch(`workspace number `+ modelData.name);
}
display: ws_special
? AbstractButton.IconOnly
: AbstractButton.TextOnly
icon.source: ({
"10": "../../icons/phosphor/regular/text-align-left.svg",
"11": "../../icons/phosphor/regular/download.svg",
"12": "../../icons/phosphor/regular/music.svg",
}) [modelData.name] ?? modelData.name
icon.color: (modelData.name == ws_focused)
? Resources.palette.bg
: Resources.palette.fg
icon.width: Resources.fontsize.topbar_text-1
icon.height: Resources.fontsize.topbar_text-1
padding: 0
background: Rectangle {
id: rect
height: Resources.barsize.topbar
width: Resources.barsize.topbar
implicitHeight: Resources.barsize.topbar
implicitWidth: Resources.barsize.topbar
anchors.verticalCenter: parent.verticalCenter
color: (modelData.name == ws_focused)
? Resources.palette.orange
: ws_mouse_area.containsMouse
? Resources.palette.altbg
: Resources.palette.bg
}
Class.TopbarText {
horizontalAlignment: rect.AlignHCenter
// verticalAlignment: rect.AlignVCenter
anchors.centerIn:parent
text: ws_special
? ""
: modelData.number
color: (modelData.name == ws_focused)
? Resources.palette.bg
: Resources.palette.fg
}
}
}
}
|