forked from Shinonome/dots-hyprland
init waffles
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import qs.modules.common
|
||||
import qs.modules.common.functions
|
||||
import qs.modules.waffle.looks
|
||||
|
||||
Button {
|
||||
id: root
|
||||
|
||||
Layout.fillHeight: true
|
||||
topInset: 4
|
||||
bottomInset: 4
|
||||
|
||||
property color borderColor: ColorUtils.transparentize(Looks.colors.bg1Border, (root.hovered && !root.down) ? Looks.fluentContentTransparency : 1)
|
||||
Behavior on borderColor {
|
||||
animation: Looks.transition.color.createObject(this)
|
||||
}
|
||||
onBorderColorChanged: {
|
||||
borderCanvas.requestPaint();
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
id: background
|
||||
color: {
|
||||
if (root.down) {
|
||||
return Looks.colors.bg1Active
|
||||
} else if (root.hovered) {
|
||||
return Looks.colors.bg1Hover
|
||||
} else {
|
||||
return ColorUtils.transparentize(Looks.colors.bg1)
|
||||
}
|
||||
}
|
||||
radius: Looks.radius.medium
|
||||
Behavior on color {
|
||||
animation: Looks.transition.color.createObject(this)
|
||||
}
|
||||
|
||||
// Top 1px border with color
|
||||
Canvas {
|
||||
id: borderCanvas
|
||||
anchors.fill: parent
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
|
||||
var borderColor = root.borderColor;
|
||||
|
||||
var r = background.radius;
|
||||
var fadeLength = Math.max(1, r);
|
||||
var fadeLengthPercent = fadeLength / width;
|
||||
|
||||
// Compute normalized stops
|
||||
var leftFadeStop = fadeLengthPercent;
|
||||
var rightFadeStop = 1 - fadeLengthPercent;
|
||||
|
||||
var grad = ctx.createLinearGradient(0, 0, width, 0);
|
||||
grad.addColorStop(0, Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0));
|
||||
grad.addColorStop(leftFadeStop, borderColor);
|
||||
grad.addColorStop(rightFadeStop, borderColor);
|
||||
grad.addColorStop(1, Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0));
|
||||
|
||||
ctx.strokeStyle = grad;
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(r, 0.5);
|
||||
ctx.lineTo(width - r, 0.5);
|
||||
// Top-right curve
|
||||
ctx.arcTo(width, 0.5, width, r + 0.5, r);
|
||||
// Top-left curve
|
||||
ctx.moveTo(width - r, 0.5);
|
||||
ctx.arcTo(0, 0.5, 0, r + 0.5, r);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import qs.services
|
||||
import qs.modules.common
|
||||
import qs.modules.waffle.looks
|
||||
|
||||
BarButton {
|
||||
id: root
|
||||
|
||||
// padding: 12
|
||||
|
||||
contentItem: Item {
|
||||
anchors.centerIn: root.background
|
||||
implicitHeight: column.implicitHeight
|
||||
implicitWidth: column.implicitWidth
|
||||
Row {
|
||||
id: column
|
||||
anchors.centerIn: parent
|
||||
|
||||
FluentIcon {
|
||||
icon: "speaker" // System icon
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import qs.services
|
||||
import qs.modules.common
|
||||
import qs.modules.waffle.looks
|
||||
|
||||
BarButton {
|
||||
id: root
|
||||
|
||||
rightInset: 12 // For now this is the rightmost button. Desktop peek is useless. (for now)
|
||||
padding: 12
|
||||
|
||||
contentItem: Item {
|
||||
anchors.centerIn: root.background
|
||||
implicitHeight: column.implicitHeight
|
||||
implicitWidth: column.implicitWidth
|
||||
Column {
|
||||
id: column
|
||||
anchors.centerIn: parent
|
||||
WText {
|
||||
anchors.right: parent.right
|
||||
text: DateTime.time
|
||||
}
|
||||
WText {
|
||||
anchors.right: parent.right
|
||||
text: DateTime.date
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
import qs
|
||||
import qs.services
|
||||
import qs.modules.common
|
||||
import qs.modules.common.widgets
|
||||
|
||||
Scope {
|
||||
id: bar
|
||||
property bool showBarBackground: Config.options.bar.showBackground
|
||||
|
||||
LazyLoader {
|
||||
id: barLoader
|
||||
active: GlobalStates.barOpen && !GlobalStates.screenLocked
|
||||
component: Variants {
|
||||
model: Quickshell.screens
|
||||
delegate: PanelWindow { // Bar window
|
||||
id: barRoot
|
||||
required property var modelData
|
||||
screen: modelData
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
exclusiveZone: implicitHeight
|
||||
WlrLayershell.namespace: "quickshell:wbar"
|
||||
|
||||
anchors {
|
||||
left: true
|
||||
right: true
|
||||
bottom: Config.options.waffles.bar.bottom
|
||||
top: !Config.options.waffles.bar.bottom
|
||||
}
|
||||
|
||||
color: "transparent"
|
||||
implicitHeight: content.implicitHeight
|
||||
implicitWidth: content.implicitWidth
|
||||
|
||||
WaffleBarContent {
|
||||
id: content
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "bar"
|
||||
|
||||
function toggle(): void {
|
||||
GlobalStates.barOpen = !GlobalStates.barOpen
|
||||
}
|
||||
|
||||
function close(): void {
|
||||
GlobalStates.barOpen = false
|
||||
}
|
||||
|
||||
function open(): void {
|
||||
GlobalStates.barOpen = true
|
||||
}
|
||||
}
|
||||
|
||||
GlobalShortcut {
|
||||
name: "barToggle"
|
||||
description: "Toggles bar on press"
|
||||
|
||||
onPressed: {
|
||||
GlobalStates.barOpen = !GlobalStates.barOpen;
|
||||
}
|
||||
}
|
||||
|
||||
GlobalShortcut {
|
||||
name: "barOpen"
|
||||
description: "Opens bar on press"
|
||||
|
||||
onPressed: {
|
||||
GlobalStates.barOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
GlobalShortcut {
|
||||
name: "barClose"
|
||||
description: "Closes bar on press"
|
||||
|
||||
onPressed: {
|
||||
GlobalStates.barOpen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import qs.modules.common
|
||||
import qs.modules.waffle.looks
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
color: Looks.colors.bg0
|
||||
implicitHeight: 48
|
||||
|
||||
Rectangle {
|
||||
id: border
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
top: Config.options.waffles.bar.bottom ? parent.top : undefined
|
||||
bottom: Config.options.waffles.bar.bottom ? undefined : parent.bottom
|
||||
}
|
||||
color: Looks.colors.bg0Border
|
||||
implicitHeight: 1
|
||||
}
|
||||
|
||||
BarGroupRow {
|
||||
id: bloatRow
|
||||
anchors.left: parent.left
|
||||
}
|
||||
|
||||
BarGroupRow {
|
||||
id: appsRow
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
BarGroupRow {
|
||||
id: systemRow
|
||||
anchors.right: parent.right
|
||||
SystemButton {}
|
||||
TimeButton {}
|
||||
}
|
||||
|
||||
component BarGroupRow: RowLayout {
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
spacing: 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user