mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
fix: Notepad refactor w/Dual displays
This commit is contained in:
@@ -21,20 +21,6 @@ Variants {
|
|||||||
|
|
||||||
signal colorPickerRequested()
|
signal colorPickerRequested()
|
||||||
|
|
||||||
function getNotepadInstanceForScreen() {
|
|
||||||
if (typeof notepadSlideoutVariants === "undefined" || !notepadSlideoutVariants || !notepadSlideoutVariants.instances) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < notepadSlideoutVariants.instances.length; i++) {
|
|
||||||
var slideout = notepadSlideoutVariants.instances[i]
|
|
||||||
if (slideout.modelData && slideout.modelData.name === root.screen?.name) {
|
|
||||||
return slideout
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return notepadSlideoutVariants.instances.length > 0 ? notepadSlideoutVariants.instances[0] : null
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: PanelWindow {
|
delegate: PanelWindow {
|
||||||
id: root
|
id: root
|
||||||
@@ -170,8 +156,6 @@ Variants {
|
|||||||
return SettingsData.dankBarVisible && (!autoHide || topBarMouseArea.containsMouse || hasActivePopout || revealSticky)
|
return SettingsData.dankBarVisible && (!autoHide || topBarMouseArea.containsMouse || hasActivePopout || revealSticky)
|
||||||
}
|
}
|
||||||
|
|
||||||
property var notepadInstance: null
|
|
||||||
property bool notepadInstanceVisible: notepadInstance?.isVisible ?? false
|
|
||||||
|
|
||||||
readonly property bool hasActivePopout: {
|
readonly property bool hasActivePopout: {
|
||||||
const loaders = [{
|
const loaders = [{
|
||||||
@@ -202,7 +186,7 @@ Variants {
|
|||||||
"loader": systemUpdateLoader,
|
"loader": systemUpdateLoader,
|
||||||
"prop": "shouldBeVisible"
|
"prop": "shouldBeVisible"
|
||||||
}]
|
}]
|
||||||
return notepadInstanceVisible || loaders.some(item => {
|
return loaders.some(item => {
|
||||||
if (item.loader) {
|
if (item.loader) {
|
||||||
return item.loader?.item?.[item.prop]
|
return item.loader?.item?.[item.prop]
|
||||||
}
|
}
|
||||||
@@ -210,9 +194,6 @@ Variants {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
notepadInstance = dankBarVariants.getNotepadInstanceForScreen()
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
function onDankBarTransparencyChanged() {
|
function onDankBarTransparencyChanged() {
|
||||||
@@ -1245,18 +1226,10 @@ Variants {
|
|||||||
id: notepadButtonComponent
|
id: notepadButtonComponent
|
||||||
|
|
||||||
NotepadButton {
|
NotepadButton {
|
||||||
property var notepadInstance: topBarCore.notepadInstance
|
|
||||||
isActive: notepadInstance?.isVisible ?? false
|
|
||||||
widgetHeight: root.widgetHeight
|
widgetHeight: root.widgetHeight
|
||||||
barHeight: root.effectiveBarHeight
|
barHeight: root.effectiveBarHeight
|
||||||
section: topBarContent.getWidgetSection(parent) || "right"
|
section: topBarContent.getWidgetSection(parent) || "right"
|
||||||
popupTarget: notepadInstance
|
|
||||||
parentScreen: root.screen
|
parentScreen: root.screen
|
||||||
onClicked: {
|
|
||||||
if (notepadInstance) {
|
|
||||||
notepadInstance.toggle()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
|
import Quickshell.Hyprland
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
@@ -6,9 +7,7 @@ import qs.Widgets
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property bool isActive: false
|
|
||||||
property string section: "right"
|
property string section: "right"
|
||||||
property var popupTarget: null
|
|
||||||
property var parentScreen: null
|
property var parentScreen: null
|
||||||
property real widgetHeight: 30
|
property real widgetHeight: 30
|
||||||
property real barHeight: 48
|
property real barHeight: 48
|
||||||
@@ -16,6 +15,34 @@ Rectangle {
|
|||||||
|
|
||||||
signal clicked()
|
signal clicked()
|
||||||
|
|
||||||
|
readonly property string focusedScreenName: (
|
||||||
|
CompositorService.isHyprland && typeof Hyprland !== "undefined" && Hyprland.focusedWorkspace && Hyprland.focusedWorkspace.monitor ? (Hyprland.focusedWorkspace.monitor.name || "") :
|
||||||
|
CompositorService.isNiri && typeof NiriService !== "undefined" && NiriService.currentOutput ? NiriService.currentOutput : ""
|
||||||
|
)
|
||||||
|
|
||||||
|
function resolveNotepadInstance() {
|
||||||
|
if (typeof notepadSlideoutVariants === "undefined" || !notepadSlideoutVariants || !notepadSlideoutVariants.instances) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try focused screen first
|
||||||
|
const targetScreen = focusedScreenName
|
||||||
|
if (targetScreen) {
|
||||||
|
for (var i = 0; i < notepadSlideoutVariants.instances.length; i++) {
|
||||||
|
var slideout = notepadSlideoutVariants.instances[i]
|
||||||
|
if (slideout.modelData && slideout.modelData.name === targetScreen) {
|
||||||
|
return slideout
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to first available
|
||||||
|
return notepadSlideoutVariants.instances.length > 0 ? notepadSlideoutVariants.instances[0] : null
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property var notepadInstance: resolveNotepadInstance()
|
||||||
|
readonly property bool isActive: notepadInstance?.isVisible ?? false
|
||||||
|
|
||||||
width: notepadIcon.width + horizontalPadding * 2
|
width: notepadIcon.width + horizontalPadding * 2
|
||||||
height: widgetHeight
|
height: widgetHeight
|
||||||
radius: SettingsData.dankBarNoBackground ? 0 : Theme.cornerRadius
|
radius: SettingsData.dankBarNoBackground ? 0 : Theme.cornerRadius
|
||||||
@@ -57,7 +84,11 @@ Rectangle {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onPressed: {
|
onPressed: {
|
||||||
root.clicked();
|
const inst = root.notepadInstance
|
||||||
|
if (inst) {
|
||||||
|
inst.toggle()
|
||||||
|
}
|
||||||
|
root.clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user