mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
@@ -1,12 +1,9 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Services
|
|
||||||
|
|
||||||
Scope {
|
Scope {
|
||||||
id: overviewScope
|
id: overviewScope
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import QtQuick
|
|||||||
import QtQuick.Effects
|
import QtQuick.Effects
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Wayland
|
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Services
|
import qs.Services
|
||||||
@@ -13,6 +12,7 @@ Item {
|
|||||||
required property var panelWindow
|
required property var panelWindow
|
||||||
required property bool overviewOpen
|
required property bool overviewOpen
|
||||||
readonly property HyprlandMonitor monitor: Hyprland.monitorFor(panelWindow.screen)
|
readonly property HyprlandMonitor monitor: Hyprland.monitorFor(panelWindow.screen)
|
||||||
|
readonly property real dpr: CompositorService.getScreenScale(panelWindow.screen)
|
||||||
readonly property int workspacesShown: SettingsData.overviewRows * SettingsData.overviewColumns
|
readonly property int workspacesShown: SettingsData.overviewRows * SettingsData.overviewColumns
|
||||||
|
|
||||||
readonly property var allWorkspaces: Hyprland.workspaces?.values || []
|
readonly property var allWorkspaces: Hyprland.workspaces?.values || []
|
||||||
@@ -77,6 +77,9 @@ Item {
|
|||||||
readonly property int maxWorkspaceId: displayedWorkspaceIds.length > 0 ? displayedWorkspaceIds[displayedWorkspaceIds.length - 1] : workspacesShown
|
readonly property int maxWorkspaceId: displayedWorkspaceIds.length > 0 ? displayedWorkspaceIds[displayedWorkspaceIds.length - 1] : workspacesShown
|
||||||
readonly property int displayWorkspaceCount: displayedWorkspaceIds.length
|
readonly property int displayWorkspaceCount: displayedWorkspaceIds.length
|
||||||
|
|
||||||
|
readonly property int effectiveColumns: SettingsData.overviewColumns
|
||||||
|
readonly property int effectiveRows: Math.max(SettingsData.overviewRows, Math.ceil(displayWorkspaceCount / effectiveColumns))
|
||||||
|
|
||||||
function getWorkspaceMonitorName(workspaceId) {
|
function getWorkspaceMonitorName(workspaceId) {
|
||||||
if (!allWorkspaces || !workspaceId) return ""
|
if (!allWorkspaces || !workspaceId) return ""
|
||||||
try {
|
try {
|
||||||
@@ -103,8 +106,10 @@ Item {
|
|||||||
property real scale: SettingsData.overviewScale
|
property real scale: SettingsData.overviewScale
|
||||||
property color activeBorderColor: Theme.primary
|
property color activeBorderColor: Theme.primary
|
||||||
|
|
||||||
property real workspaceImplicitWidth: ((monitor.width / monitor.scale) * root.scale)
|
readonly property real monitorPhysicalWidth: panelWindow.screen ? (panelWindow.screen.width / root.dpr) : (monitor?.width ?? 1920)
|
||||||
property real workspaceImplicitHeight: ((monitor.height / monitor.scale) * root.scale)
|
readonly property real monitorPhysicalHeight: panelWindow.screen ? (panelWindow.screen.height / root.dpr) : (monitor?.height ?? 1080)
|
||||||
|
property real workspaceImplicitWidth: monitorPhysicalWidth * root.scale
|
||||||
|
property real workspaceImplicitHeight: monitorPhysicalHeight * root.scale
|
||||||
|
|
||||||
property int workspaceZ: 0
|
property int workspaceZ: 0
|
||||||
property int windowZ: 1
|
property int windowZ: 1
|
||||||
@@ -162,18 +167,18 @@ Item {
|
|||||||
spacing: workspaceSpacing
|
spacing: workspaceSpacing
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: SettingsData.overviewRows
|
model: root.effectiveRows
|
||||||
delegate: RowLayout {
|
delegate: RowLayout {
|
||||||
id: row
|
id: row
|
||||||
property int rowIndex: index
|
property int rowIndex: index
|
||||||
spacing: workspaceSpacing
|
spacing: workspaceSpacing
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: SettingsData.overviewColumns
|
model: root.effectiveColumns
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: workspace
|
id: workspace
|
||||||
property int colIndex: index
|
property int colIndex: index
|
||||||
property int workspaceIndex: rowIndex * SettingsData.overviewColumns + colIndex
|
property int workspaceIndex: rowIndex * root.effectiveColumns + colIndex
|
||||||
property int workspaceValue: (root.displayedWorkspaceIds && workspaceIndex < root.displayedWorkspaceIds.length) ? root.displayedWorkspaceIds[workspaceIndex] : -1
|
property int workspaceValue: (root.displayedWorkspaceIds && workspaceIndex < root.displayedWorkspaceIds.length) ? root.displayedWorkspaceIds[workspaceIndex] : -1
|
||||||
property bool workspaceExists: (root.allWorkspaceIds && workspaceValue > 0) ? root.allWorkspaceIds.includes(workspaceValue) : false
|
property bool workspaceExists: (root.allWorkspaceIds && workspaceValue > 0) ? root.allWorkspaceIds.includes(workspaceValue) : false
|
||||||
property var workspaceObj: (workspaceExists && Hyprland.workspaces?.values) ? Hyprland.workspaces.values.find(ws => ws?.id === workspaceValue) : null
|
property var workspaceObj: (workspaceExists && Hyprland.workspaces?.values) ? Hyprland.workspaces.values.find(ws => ws?.id === workspaceValue) : null
|
||||||
@@ -292,11 +297,12 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
readonly property int workspaceIndex: getWorkspaceIndex()
|
readonly property int workspaceIndex: getWorkspaceIndex()
|
||||||
readonly property int workspaceColIndex: workspaceIndex % SettingsData.overviewColumns
|
readonly property int workspaceColIndex: workspaceIndex % root.effectiveColumns
|
||||||
readonly property int workspaceRowIndex: Math.floor(workspaceIndex / SettingsData.overviewColumns)
|
readonly property int workspaceRowIndex: Math.floor(workspaceIndex / root.effectiveColumns)
|
||||||
|
|
||||||
toplevel: modelData
|
toplevel: modelData
|
||||||
scale: root.scale
|
scale: root.scale
|
||||||
|
monitorDpr: root.dpr
|
||||||
availableWorkspaceWidth: root.workspaceImplicitWidth
|
availableWorkspaceWidth: root.workspaceImplicitWidth
|
||||||
availableWorkspaceHeight: root.workspaceImplicitHeight
|
availableWorkspaceHeight: root.workspaceImplicitHeight
|
||||||
widgetMonitorId: root.monitor.id
|
widgetMonitorId: root.monitor.id
|
||||||
@@ -376,7 +382,7 @@ Item {
|
|||||||
z: root.monitorLabelZ
|
z: root.monitorLabelZ
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: SettingsData.overviewRows
|
model: root.effectiveRows
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: labelRow
|
id: labelRow
|
||||||
property int rowIndex: index
|
property int rowIndex: index
|
||||||
@@ -385,11 +391,11 @@ Item {
|
|||||||
height: root.workspaceImplicitHeight
|
height: root.workspaceImplicitHeight
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: SettingsData.overviewColumns
|
model: root.effectiveColumns
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: labelItem
|
id: labelItem
|
||||||
property int colIndex: index
|
property int colIndex: index
|
||||||
property int workspaceIndex: labelRow.rowIndex * SettingsData.overviewColumns + colIndex
|
property int workspaceIndex: labelRow.rowIndex * root.effectiveColumns + colIndex
|
||||||
property int workspaceValue: (root.displayedWorkspaceIds && workspaceIndex < root.displayedWorkspaceIds.length) ? root.displayedWorkspaceIds[workspaceIndex] : -1
|
property int workspaceValue: (root.displayedWorkspaceIds && workspaceIndex < root.displayedWorkspaceIds.length) ? root.displayedWorkspaceIds[workspaceIndex] : -1
|
||||||
property bool workspaceExists: (root.allWorkspaceIds && workspaceValue > 0) ? root.allWorkspaceIds.includes(workspaceValue) : false
|
property bool workspaceExists: (root.allWorkspaceIds && workspaceValue > 0) ? root.allWorkspaceIds.includes(workspaceValue) : false
|
||||||
property string workspaceMonitorName: (workspaceValue > 0) ? root.getWorkspaceMonitorName(workspaceValue) : ""
|
property string workspaceMonitorName: (workspaceValue > 0) ? root.getWorkspaceMonitorName(workspaceValue) : ""
|
||||||
|
|||||||
@@ -13,19 +13,21 @@ Item {
|
|||||||
property var availableWorkspaceWidth
|
property var availableWorkspaceWidth
|
||||||
property var availableWorkspaceHeight
|
property var availableWorkspaceHeight
|
||||||
property bool restrictToWorkspace: true
|
property bool restrictToWorkspace: true
|
||||||
|
property real monitorDpr: 1
|
||||||
|
|
||||||
readonly property var windowData: toplevel?.lastIpcObject || null
|
readonly property var windowData: toplevel?.lastIpcObject || null
|
||||||
readonly property var monitorObj: toplevel?.monitor
|
readonly property var monitorObj: toplevel?.monitor
|
||||||
readonly property var monitorData: monitorObj?.lastIpcObject || null
|
readonly property var monitorData: monitorObj?.lastIpcObject || null
|
||||||
|
readonly property real effectiveScale: root.scale / root.monitorDpr
|
||||||
|
|
||||||
property real initX: Math.max(((windowData?.at?.[0] ?? 0) - (monitorData?.x ?? 0) - (monitorData?.reserved?.[0] ?? 0)) * root.scale, 0) + xOffset
|
property real initX: Math.max(((windowData?.at?.[0] ?? 0) - (monitorData?.x ?? 0) - (monitorData?.reserved?.[0] ?? 0)) * effectiveScale, 0) + xOffset
|
||||||
property real initY: Math.max(((windowData?.at?.[1] ?? 0) - (monitorData?.y ?? 0) - (monitorData?.reserved?.[1] ?? 0)) * root.scale, 0) + yOffset
|
property real initY: Math.max(((windowData?.at?.[1] ?? 0) - (monitorData?.y ?? 0) - (monitorData?.reserved?.[1] ?? 0)) * effectiveScale, 0) + yOffset
|
||||||
property real xOffset: 0
|
property real xOffset: 0
|
||||||
property real yOffset: 0
|
property real yOffset: 0
|
||||||
property int widgetMonitorId: 0
|
property int widgetMonitorId: 0
|
||||||
|
|
||||||
property var targetWindowWidth: (windowData?.size?.[0] ?? 100) * scale
|
property var targetWindowWidth: (windowData?.size?.[0] ?? 100) * effectiveScale
|
||||||
property var targetWindowHeight: (windowData?.size?.[1] ?? 100) * scale
|
property var targetWindowHeight: (windowData?.size?.[1] ?? 100) * effectiveScale
|
||||||
property bool hovered: false
|
property bool hovered: false
|
||||||
property bool pressed: false
|
property bool pressed: false
|
||||||
|
|
||||||
@@ -37,8 +39,8 @@ Item {
|
|||||||
|
|
||||||
x: initX
|
x: initX
|
||||||
y: initY
|
y: initY
|
||||||
width: Math.min((windowData?.size?.[0] ?? 100) * root.scale, availableWorkspaceWidth)
|
width: Math.min((windowData?.size?.[0] ?? 100) * effectiveScale, availableWorkspaceWidth)
|
||||||
height: Math.min((windowData?.size?.[1] ?? 100) * root.scale, availableWorkspaceHeight)
|
height: Math.min((windowData?.size?.[1] ?? 100) * effectiveScale, availableWorkspaceHeight)
|
||||||
opacity: (monitorObj?.id ?? -1) == widgetMonitorId ? 1 : 0.4
|
opacity: (monitorObj?.id ?? -1) == widgetMonitorId ? 1 : 0.4
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|||||||
Reference in New Issue
Block a user