forked from Shinonome/dots-hyprland
put right sidebar in loader
This commit is contained in:
@@ -21,176 +21,187 @@ Scope {
|
|||||||
id: sidebarVariants
|
id: sidebarVariants
|
||||||
model: Quickshell.screens
|
model: Quickshell.screens
|
||||||
|
|
||||||
PanelWindow {
|
Loader {
|
||||||
id: sidebarRoot
|
id: sidebarLoader
|
||||||
visible: false
|
active: false
|
||||||
focusable: true
|
|
||||||
|
|
||||||
onVisibleChanged: {
|
|
||||||
GlobalStates.sidebarRightOpenCount += visible ? 1 : -1
|
|
||||||
}
|
|
||||||
|
|
||||||
property var modelData
|
property var modelData
|
||||||
|
onActiveChanged: {
|
||||||
screen: modelData
|
GlobalStates.sidebarRightOpenCount += active ? 1 : -1
|
||||||
exclusiveZone: 0
|
|
||||||
implicitWidth: sidebarWidth
|
|
||||||
WlrLayershell.namespace: "quickshell:sidebarRight"
|
|
||||||
// Hyprland 0.49: Focus is always exclusive and setting this breaks mouse focus grab
|
|
||||||
// WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
|
||||||
color: "transparent"
|
|
||||||
|
|
||||||
anchors {
|
|
||||||
top: true
|
|
||||||
right: true
|
|
||||||
bottom: true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HyprlandFocusGrab {
|
PanelWindow {
|
||||||
id: grab
|
id: sidebarRoot
|
||||||
windows: [ sidebarRoot ]
|
visible: sidebarLoader.active
|
||||||
active: false
|
focusable: true
|
||||||
onCleared: () => {
|
|
||||||
if (!active) sidebarRoot.visible = false
|
onVisibleChanged: {
|
||||||
|
if (!visible) sidebarLoader.active = false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
function hide() {
|
||||||
target: sidebarRoot
|
sidebarLoader.active = false
|
||||||
function onVisibleChanged() {
|
|
||||||
delayedGrabTimer.start()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
screen: modelData
|
||||||
id: delayedGrabTimer
|
exclusiveZone: 0
|
||||||
interval: ConfigOptions.hacks.arbitraryRaceConditionDelay
|
implicitWidth: sidebarWidth
|
||||||
repeat: false
|
WlrLayershell.namespace: "quickshell:sidebarRight"
|
||||||
onTriggered: {
|
// Hyprland 0.49: Focus is always exclusive and setting this breaks mouse focus grab
|
||||||
grab.active = sidebarRoot.visible
|
// WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
||||||
|
color: "transparent"
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
top: true
|
||||||
|
right: true
|
||||||
|
bottom: true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Background
|
HyprlandFocusGrab {
|
||||||
Rectangle {
|
id: grab
|
||||||
id: sidebarRightBackground
|
windows: [ sidebarRoot ]
|
||||||
|
active: false
|
||||||
anchors.centerIn: parent
|
onCleared: () => {
|
||||||
width: parent.width - Appearance.sizes.hyprlandGapsOut * 2
|
if (!active) sidebarRoot.hide()
|
||||||
height: parent.height - Appearance.sizes.hyprlandGapsOut * 2
|
|
||||||
color: Appearance.colors.colLayer0
|
|
||||||
radius: Appearance.rounding.screenRounding - Appearance.sizes.elevationMargin + 1
|
|
||||||
|
|
||||||
Keys.onPressed: (event) => {
|
|
||||||
if (event.key === Qt.Key_Escape) {
|
|
||||||
sidebarRoot.visible = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
Connections {
|
||||||
anchors.fill: parent
|
target: sidebarRoot
|
||||||
anchors.margins: sidebarPadding
|
function onVisibleChanged() {
|
||||||
|
delayedGrabTimer.start()
|
||||||
spacing: sidebarPadding
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
Timer {
|
||||||
Layout.fillHeight: false
|
id: delayedGrabTimer
|
||||||
spacing: 10
|
interval: ConfigOptions.hacks.arbitraryRaceConditionDelay
|
||||||
Layout.margins: 10
|
repeat: false
|
||||||
Layout.topMargin: 5
|
onTriggered: {
|
||||||
Layout.bottomMargin: 0
|
grab.active = sidebarRoot.visible
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
// Background
|
||||||
implicitWidth: distroIcon.width
|
Rectangle {
|
||||||
implicitHeight: distroIcon.height
|
id: sidebarRightBackground
|
||||||
CustomIcon {
|
|
||||||
id: distroIcon
|
anchors.centerIn: parent
|
||||||
width: 25
|
width: parent.width - Appearance.sizes.hyprlandGapsOut * 2
|
||||||
height: 25
|
height: parent.height - Appearance.sizes.hyprlandGapsOut * 2
|
||||||
source: SystemInfo.distroIcon
|
color: Appearance.colors.colLayer0
|
||||||
|
radius: Appearance.rounding.screenRounding - Appearance.sizes.elevationMargin + 1
|
||||||
|
|
||||||
|
Keys.onPressed: (event) => {
|
||||||
|
if (event.key === Qt.Key_Escape) {
|
||||||
|
sidebarRoot.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: sidebarPadding
|
||||||
|
|
||||||
|
spacing: sidebarPadding
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillHeight: false
|
||||||
|
spacing: 10
|
||||||
|
Layout.margins: 10
|
||||||
|
Layout.topMargin: 5
|
||||||
|
Layout.bottomMargin: 0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
implicitWidth: distroIcon.width
|
||||||
|
implicitHeight: distroIcon.height
|
||||||
|
CustomIcon {
|
||||||
|
id: distroIcon
|
||||||
|
width: 25
|
||||||
|
height: 25
|
||||||
|
source: SystemInfo.distroIcon
|
||||||
|
}
|
||||||
|
ColorOverlay {
|
||||||
|
anchors.fill: distroIcon
|
||||||
|
source: distroIcon
|
||||||
|
color: Appearance.colors.colOnLayer0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ColorOverlay {
|
|
||||||
anchors.fill: distroIcon
|
StyledText {
|
||||||
source: distroIcon
|
font.pixelSize: Appearance.font.pixelSize.normal
|
||||||
color: Appearance.colors.colOnLayer0
|
color: Appearance.colors.colOnLayer0
|
||||||
|
text: `Uptime: ${DateTime.uptime}`
|
||||||
|
textFormat: Text.MarkdownText
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
QuickToggleButton {
|
||||||
|
toggled: false
|
||||||
|
buttonIcon: "power_settings_new"
|
||||||
|
onClicked: {
|
||||||
|
Hyprland.dispatch("global quickshell:sessionOpen")
|
||||||
|
}
|
||||||
|
StyledToolTip {
|
||||||
|
content: qsTr("Session")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
Rectangle {
|
||||||
font.pixelSize: Appearance.font.pixelSize.normal
|
Layout.alignment: Qt.AlignHCenter
|
||||||
color: Appearance.colors.colOnLayer0
|
Layout.fillHeight: false
|
||||||
text: `Uptime: ${DateTime.uptime}`
|
radius: Appearance.rounding.full
|
||||||
textFormat: Text.MarkdownText
|
color: Appearance.colors.colLayer1
|
||||||
|
implicitWidth: sidebarQuickControlsRow.implicitWidth + 10
|
||||||
|
implicitHeight: sidebarQuickControlsRow.implicitHeight + 10
|
||||||
|
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: sidebarQuickControlsRow
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 5
|
||||||
|
spacing: 5
|
||||||
|
|
||||||
|
NetworkToggle {}
|
||||||
|
BluetoothToggle {}
|
||||||
|
NightLight {}
|
||||||
|
GameMode {}
|
||||||
|
IdleInhibitor {}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
// Center widget group
|
||||||
|
CenterWidgetGroup {
|
||||||
|
focus: sidebarRoot.visible
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickToggleButton {
|
BottomWidgetGroup {
|
||||||
toggled: false
|
Layout.alignment: Qt.AlignHCenter
|
||||||
buttonIcon: "power_settings_new"
|
Layout.fillHeight: false
|
||||||
onClicked: {
|
Layout.fillWidth: true
|
||||||
Hyprland.dispatch("global quickshell:sessionOpen")
|
Layout.preferredHeight: implicitHeight
|
||||||
}
|
|
||||||
StyledToolTip {
|
|
||||||
content: qsTr("Session")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
Layout.alignment: Qt.AlignHCenter
|
|
||||||
Layout.fillHeight: false
|
|
||||||
radius: Appearance.rounding.full
|
|
||||||
color: Appearance.colors.colLayer1
|
|
||||||
implicitWidth: sidebarQuickControlsRow.implicitWidth + 10
|
|
||||||
implicitHeight: sidebarQuickControlsRow.implicitHeight + 10
|
|
||||||
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: sidebarQuickControlsRow
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: 5
|
|
||||||
spacing: 5
|
|
||||||
|
|
||||||
NetworkToggle {}
|
|
||||||
BluetoothToggle {}
|
|
||||||
NightLight {}
|
|
||||||
GameMode {}
|
|
||||||
IdleInhibitor {}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Center widget group
|
|
||||||
CenterWidgetGroup {
|
|
||||||
focus: sidebarRoot.visible
|
|
||||||
Layout.alignment: Qt.AlignHCenter
|
|
||||||
Layout.fillHeight: true
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
|
|
||||||
BottomWidgetGroup {
|
|
||||||
Layout.alignment: Qt.AlignHCenter
|
|
||||||
Layout.fillHeight: false
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.preferredHeight: implicitHeight
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Shadow
|
// Shadow
|
||||||
DropShadow {
|
DropShadow {
|
||||||
anchors.fill: sidebarRightBackground
|
anchors.fill: sidebarRightBackground
|
||||||
horizontalOffset: 0
|
horizontalOffset: 0
|
||||||
verticalOffset: 2
|
verticalOffset: 2
|
||||||
radius: Appearance.sizes.elevationMargin
|
radius: Appearance.sizes.elevationMargin
|
||||||
samples: Appearance.sizes.elevationMargin * 2 + 1 // Ideally should be 2 * radius + 1, see qt docs
|
samples: Appearance.sizes.elevationMargin * 2 + 1 // Ideally should be 2 * radius + 1, see qt docs
|
||||||
color: Appearance.colors.colShadow
|
color: Appearance.colors.colShadow
|
||||||
source: sidebarRightBackground
|
source: sidebarRightBackground
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -200,30 +211,22 @@ Scope {
|
|||||||
|
|
||||||
function toggle(): void {
|
function toggle(): void {
|
||||||
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
||||||
let panelWindow = sidebarVariants.instances[i];
|
let loader = sidebarVariants.instances[i];
|
||||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
loader.active = !loader.active;
|
||||||
panelWindow.visible = !panelWindow.visible;
|
|
||||||
if(panelWindow.visible) Notifications.timeoutAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function close(): void {
|
function close(): void {
|
||||||
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
||||||
let panelWindow = sidebarVariants.instances[i];
|
let loader = sidebarVariants.instances[i];
|
||||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
loader.active = false;
|
||||||
panelWindow.visible = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function open(): void {
|
function open(): void {
|
||||||
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
||||||
let panelWindow = sidebarVariants.instances[i];
|
let loader = sidebarVariants.instances[i];
|
||||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
loader.active = true;
|
||||||
panelWindow.visible = true;
|
|
||||||
if(panelWindow.visible) Notifications.timeoutAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,11 +237,8 @@ Scope {
|
|||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
||||||
let panelWindow = sidebarVariants.instances[i];
|
let loader = sidebarVariants.instances[i];
|
||||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
loader.active = !loader.active;
|
||||||
panelWindow.visible = !panelWindow.visible;
|
|
||||||
if(panelWindow.visible) Notifications.timeoutAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,11 +248,8 @@ Scope {
|
|||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
||||||
let panelWindow = sidebarVariants.instances[i];
|
let loader = sidebarVariants.instances[i];
|
||||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
loader.active = true;
|
||||||
panelWindow.visible = true;
|
|
||||||
if(panelWindow.visible) Notifications.timeoutAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,11 +259,8 @@ Scope {
|
|||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
||||||
let panelWindow = sidebarVariants.instances[i];
|
let loader = sidebarVariants.instances[i];
|
||||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
loader.active = false;
|
||||||
panelWindow.visible = false;
|
|
||||||
if(panelWindow.visible) Notifications.timeoutAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user