Bar widgets: modular loading refactoring via BarWidgetRegistry+NWidgetLoader
- Hot reload is working again. - Should also be more memory efficient on multi monitors.
This commit is contained in:
parent
a110a0d636
commit
a10d55e7f5
36 changed files with 514 additions and 446 deletions
|
|
@ -10,6 +10,10 @@ import qs.Services
|
|||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property ShellScreen screen: null
|
||||
property real scaling: ScalingService.scale(screen)
|
||||
|
||||
property bool isDestroying: false
|
||||
property bool hovered: false
|
||||
|
||||
|
|
@ -23,7 +27,8 @@ Item {
|
|||
|
||||
signal workspaceChanged(int workspaceId, color accentColor)
|
||||
|
||||
width: {
|
||||
implicitHeight: Math.round(36 * scaling)
|
||||
implicitWidth: {
|
||||
let total = 0
|
||||
for (var i = 0; i < localWorkspaces.count; i++) {
|
||||
const ws = localWorkspaces.get(i)
|
||||
|
|
@ -39,34 +44,35 @@ Item {
|
|||
return total
|
||||
}
|
||||
|
||||
height: Math.round(36 * scaling)
|
||||
|
||||
Component.onCompleted: {
|
||||
localWorkspaces.clear()
|
||||
for (var i = 0; i < WorkspaceService.workspaces.count; i++) {
|
||||
const ws = WorkspaceService.workspaces.get(i)
|
||||
if (ws.output.toLowerCase() === screen.name.toLowerCase()) {
|
||||
localWorkspaces.append(ws)
|
||||
}
|
||||
}
|
||||
workspaceRepeater.model = localWorkspaces
|
||||
updateWorkspaceFocus()
|
||||
refreshWorkspaces()
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
root.isDestroying = true
|
||||
}
|
||||
|
||||
onScreenChanged: refreshWorkspaces()
|
||||
|
||||
Connections {
|
||||
target: WorkspaceService
|
||||
function onWorkspacesChanged() {
|
||||
localWorkspaces.clear()
|
||||
refreshWorkspaces()
|
||||
}
|
||||
}
|
||||
|
||||
function refreshWorkspaces() {
|
||||
localWorkspaces.clear()
|
||||
if (screen !== null) {
|
||||
for (var i = 0; i < WorkspaceService.workspaces.count; i++) {
|
||||
const ws = WorkspaceService.workspaces.get(i)
|
||||
if (ws.output.toLowerCase() === screen.name.toLowerCase()) {
|
||||
localWorkspaces.append(ws)
|
||||
}
|
||||
}
|
||||
|
||||
workspaceRepeater.model = localWorkspaces
|
||||
updateWorkspaceFocus()
|
||||
}
|
||||
workspaceRepeater.model = localWorkspaces
|
||||
updateWorkspaceFocus()
|
||||
}
|
||||
|
||||
function triggerUnifiedWave() {
|
||||
|
|
@ -74,6 +80,17 @@ Item {
|
|||
masterAnimation.restart()
|
||||
}
|
||||
|
||||
function updateWorkspaceFocus() {
|
||||
for (var i = 0; i < localWorkspaces.count; i++) {
|
||||
const ws = localWorkspaces.get(i)
|
||||
if (ws.isFocused === true) {
|
||||
root.triggerUnifiedWave()
|
||||
root.workspaceChanged(ws.id, Color.mPrimary)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SequentialAnimation {
|
||||
id: masterAnimation
|
||||
PropertyAction {
|
||||
|
|
@ -101,17 +118,6 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
function updateWorkspaceFocus() {
|
||||
for (var i = 0; i < localWorkspaces.count; i++) {
|
||||
const ws = localWorkspaces.get(i)
|
||||
if (ws.isFocused === true) {
|
||||
root.triggerUnifiedWave()
|
||||
root.workspaceChanged(ws.id, Color.mPrimary)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: workspaceBackground
|
||||
width: parent.width - Style.marginS * scaling * 2
|
||||
|
|
@ -254,8 +260,4 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
root.isDestroying = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue