Notification backend usable
This commit is contained in:
@@ -10,70 +10,68 @@ Singleton {
|
||||
|
||||
property var sortedTopLevels: {
|
||||
if (!ToplevelManager.toplevels || !ToplevelManager.toplevels.values) {
|
||||
return []
|
||||
return [];
|
||||
}
|
||||
|
||||
const topLevels = Array.from(Hyprland.toplevels.values)
|
||||
const topLevels = Array.from(Hyprland.toplevels.values);
|
||||
const sortedHyprland = topLevels.sort((a, b) => {
|
||||
if (a.monitor && b.monitor) {
|
||||
const monitorCompare = a.monitor.name.localeCompare(b.monitor.name)
|
||||
if (monitorCompare !== 0) {
|
||||
return monitorCompare
|
||||
}
|
||||
}
|
||||
if (a.monitor && b.monitor) {
|
||||
const monitorCompare = a.monitor.name.localeCompare(b.monitor.name);
|
||||
if (monitorCompare !== 0) {
|
||||
return monitorCompare;
|
||||
}
|
||||
}
|
||||
|
||||
if (a.workspace && b.workspace) {
|
||||
const workspaceCompare = a.workspace.id - b.workspace.id
|
||||
if (workspaceCompare !== 0) {
|
||||
return workspaceCompare
|
||||
}
|
||||
}
|
||||
if (a.workspace && b.workspace) {
|
||||
const workspaceCompare = a.workspace.id - b.workspace.id;
|
||||
if (workspaceCompare !== 0) {
|
||||
return workspaceCompare;
|
||||
}
|
||||
}
|
||||
|
||||
if (a.lastIpcObject && b.lastIpcObject && a.lastIpcObject.at && b.lastIpcObject.at) {
|
||||
const aX = a.lastIpcObject.at[0]
|
||||
const bX = b.lastIpcObject.at[0]
|
||||
const aY = a.lastIpcObject.at[1]
|
||||
const bY = b.lastIpcObject.at[1]
|
||||
if (a.lastIpcObject && b.lastIpcObject && a.lastIpcObject.at && b.lastIpcObject.at) {
|
||||
const aX = a.lastIpcObject.at[0];
|
||||
const bX = b.lastIpcObject.at[0];
|
||||
const aY = a.lastIpcObject.at[1];
|
||||
const bY = b.lastIpcObject.at[1];
|
||||
|
||||
const xCompare = aX - bX
|
||||
if (Math.abs(xCompare) > 10) {
|
||||
return xCompare
|
||||
}
|
||||
return aY - bY
|
||||
}
|
||||
const xCompare = aX - bX;
|
||||
if (Math.abs(xCompare) > 10) {
|
||||
return xCompare;
|
||||
}
|
||||
return aY - bY;
|
||||
}
|
||||
|
||||
if (a.lastIpcObject && !b.lastIpcObject) {
|
||||
return -1
|
||||
}
|
||||
if (!a.lastIpcObject && b.lastIpcObject) {
|
||||
return 1
|
||||
}
|
||||
if (a.lastIpcObject && !b.lastIpcObject) {
|
||||
return -1;
|
||||
}
|
||||
if (!a.lastIpcObject && b.lastIpcObject) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (a.title && b.title) {
|
||||
return a.title.localeCompare(b.title)
|
||||
}
|
||||
|
||||
return 0
|
||||
})
|
||||
return sortedHyprland.filter(tl => tl.wayland !== null)
|
||||
if (a.title && b.title) {
|
||||
return a.title.localeCompare(b.title);
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
return sortedHyprland.filter(tl => tl.wayland !== null);
|
||||
}
|
||||
|
||||
property var topLevelWorkspaces: {
|
||||
return sortedTopLevels.map(topLevel => topLevel.workspace)
|
||||
return sortedTopLevels.map(topLevel => topLevel.workspace);
|
||||
}
|
||||
|
||||
property var sortedDesktopApplications: {
|
||||
const sortedWayland = sortedTopLevels.map(topLevel => topLevel.wayland).filter(wayland=> wayland !== null)
|
||||
|
||||
const desktopEntries = sortedWayland.map( topLevel => {
|
||||
return DesktopEntries.heuristicLookup(topLevel.appId)
|
||||
})
|
||||
const workspace = sortedTopLevels.map( topLevel => {
|
||||
return topLevel.workspace.id
|
||||
})
|
||||
const workspaceDesktopEntries = new Map()
|
||||
const sortedWayland = sortedTopLevels.map(topLevel => topLevel.wayland).filter(wayland => wayland !== null);
|
||||
|
||||
const desktopEntries = sortedWayland.map(topLevel => {
|
||||
return DesktopEntries.heuristicLookup(topLevel.appId);
|
||||
});
|
||||
const workspace = sortedTopLevels.map(topLevel => {
|
||||
return topLevel.workspace.id;
|
||||
});
|
||||
const workspaceDesktopEntries = new Map();
|
||||
|
||||
for (let i = 0; i < workspace.length; i++) {
|
||||
const key = workspace[i];
|
||||
@@ -85,8 +83,6 @@ Singleton {
|
||||
workspaceDesktopEntries.set(key, [value]);
|
||||
}
|
||||
}
|
||||
return workspaceDesktopEntries
|
||||
|
||||
return workspaceDesktopEntries;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,13 @@ pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Services.Notifications
|
||||
import Quickshell.Widgets
|
||||
import qs.Widgets
|
||||
|
||||
Singleton {
|
||||
id: notificationRoot
|
||||
|
||||
|
||||
readonly property var notificationServer: notificationServer
|
||||
readonly property var trackedNotifications: notificationServer.trackedNotifications
|
||||
readonly property var notificationsNumber: notificationServer.trackedNotifications.values.length
|
||||
@@ -29,6 +26,9 @@ Singleton {
|
||||
notif.dismiss();
|
||||
return;
|
||||
}
|
||||
if (notif.traked) {
|
||||
return;
|
||||
}
|
||||
notif.tracked = true;
|
||||
notificationRoot.currentNotification = notif;
|
||||
notificationRoot.shouldShowOsd = true;
|
||||
@@ -47,19 +47,33 @@ Singleton {
|
||||
|
||||
LazyLoader {
|
||||
id: popupLoader
|
||||
active: currentNotification && shouldShowOsd
|
||||
active: notificationRoot.currentNotification && notificationRoot.shouldShowOsd
|
||||
|
||||
component: NotificationPopup {
|
||||
notification: currentNotification
|
||||
// No signal handler here!
|
||||
}
|
||||
component: PanelWindow {
|
||||
id: notificationWindow
|
||||
|
||||
onItemChanged: {
|
||||
if (item) {
|
||||
item.dismissed.connect(function() {
|
||||
notificationRoot.shouldShowOsd = false
|
||||
currentNotification.dismiss()
|
||||
})
|
||||
anchors.top: true
|
||||
margins.top: screen.height / 100
|
||||
exclusiveZone: 0
|
||||
|
||||
implicitWidth: 400
|
||||
implicitHeight: 905
|
||||
color: "transparent"
|
||||
|
||||
NotificationWrapper {
|
||||
id: notificationWrapper
|
||||
|
||||
notification: notificationRoot.currentNotification
|
||||
implicitWidth: notificationWindow.implicitWidth
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log(notificationWrapper.height);
|
||||
popupLoader.implicitHeight = notificationWrapper.implicitHeight;
|
||||
}
|
||||
onDismissed: {
|
||||
notificationRoot.shouldShowOsd = false;
|
||||
notificationRoot.currentNotification.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,33 +8,32 @@ import Quickshell.Widgets
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
|
||||
|
||||
Singleton {
|
||||
|
||||
function start(component, type) {
|
||||
HoverMediator.component = component
|
||||
HoverMediator.type = type
|
||||
hoverPopUp.anchor.updateAnchor()
|
||||
hoverTimer.start()
|
||||
HoverMediator.component = component;
|
||||
HoverMediator.type = type;
|
||||
hoverPopUp.anchor.updateAnchor();
|
||||
hoverTimer.start();
|
||||
}
|
||||
|
||||
function exit() {
|
||||
hoverTimer.stop()
|
||||
hoverPopUp.visible = false
|
||||
hoverTimer.stop();
|
||||
hoverPopUp.visible = false;
|
||||
}
|
||||
|
||||
PopupWindow {
|
||||
id: hoverPopUp
|
||||
id: hoverPopUp
|
||||
|
||||
anchor.item: HoverMediator.component
|
||||
property bool initialized: false
|
||||
anchor.rect.y: HoverMediator.y
|
||||
anchor.rect.x: (HoverMediator.x - this.implicitWidth)/2
|
||||
implicitHeight: wsPopUp.implicitHeight
|
||||
implicitWidth: wsPopUp.implicitWidth
|
||||
anchor.item: HoverMediator.component
|
||||
property bool initialized: false
|
||||
anchor.rect.y: HoverMediator.y
|
||||
anchor.rect.x: (HoverMediator.x - this.implicitWidth) / 2
|
||||
implicitHeight: wsPopUp.implicitHeight
|
||||
implicitWidth: wsPopUp.implicitWidth
|
||||
|
||||
color: "transparent"
|
||||
|
||||
color:"transparent"
|
||||
|
||||
Component {
|
||||
id: stub
|
||||
Text {
|
||||
@@ -45,15 +44,19 @@ Singleton {
|
||||
color: Theme.textColor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Component {
|
||||
id: systray
|
||||
Text {
|
||||
text: {
|
||||
if (!HoverMediator.component.model) return ""
|
||||
if (HoverMediator.component.model.tooltipTitle) return HoverMediator.component.model.tooltipTitle
|
||||
if (HoverMediator.component.model.title) return HoverMediator.component.model.title
|
||||
else return ""
|
||||
if (!HoverMediator.component.model)
|
||||
return "";
|
||||
if (HoverMediator.component.model.tooltipTitle)
|
||||
return HoverMediator.component.model.tooltipTitle;
|
||||
if (HoverMediator.component.model.title)
|
||||
return HoverMediator.component.model.title;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
font.bold: true
|
||||
font.pixelSize: Theme.pixelSize
|
||||
@@ -65,7 +68,7 @@ Singleton {
|
||||
Component {
|
||||
id: time
|
||||
Text {
|
||||
property string calendar:(HoverMediator.component.calendar)? HoverMediator.component.calendar: ""
|
||||
property string calendar: (HoverMediator.component.calendar) ? HoverMediator.component.calendar : ""
|
||||
|
||||
text: calendar
|
||||
font.bold: true
|
||||
@@ -78,7 +81,7 @@ Singleton {
|
||||
Component {
|
||||
id: audio
|
||||
Text {
|
||||
property string sinkDescription:(HoverMediator.component.sink)? HoverMediator.component.sink.description : ""
|
||||
property string sinkDescription: (HoverMediator.component.sink) ? HoverMediator.component.sink.description : ""
|
||||
text: sinkDescription
|
||||
font.bold: true
|
||||
font.pixelSize: Theme.pixelSize
|
||||
@@ -97,14 +100,15 @@ Singleton {
|
||||
|
||||
Repeater {
|
||||
|
||||
property var modelo: HyprlandService.sortedDesktopApplications.get(parent.workspaceIndexAlign)
|
||||
property var modelo: HyprlandService.sortedDesktopApplications.get(parent.workspaceIndexAlign)
|
||||
|
||||
model: modelo
|
||||
delegate: IconImage {
|
||||
|
||||
required property var modelData
|
||||
|
||||
width:30; height:30
|
||||
width: 30
|
||||
height: 30
|
||||
source: (modelData && modelData.icon) ? Quickshell.iconPath(modelData.icon, 1) : ""
|
||||
}
|
||||
}
|
||||
@@ -122,21 +126,28 @@ Singleton {
|
||||
radius: 25
|
||||
opacity: 1
|
||||
Behavior on opacity {
|
||||
NumberAnimation { property: "opacity"; duration: Theme.animationDuration}
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
duration: Theme.animationDuration
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: hoverLoader
|
||||
sourceComponent: {
|
||||
if(!HoverMediator.type) return stub
|
||||
if(HoverMediator.type === "workspace") return workspaceComponent
|
||||
if(HoverMediator.type === "audio") return audio
|
||||
if(HoverMediator.type === "time") return time
|
||||
if(HoverMediator.type === "systray") return systray
|
||||
if (!HoverMediator.type)
|
||||
return stub;
|
||||
if (HoverMediator.type === "workspace")
|
||||
return workspaceComponent;
|
||||
if (HoverMediator.type === "audio")
|
||||
return audio;
|
||||
if (HoverMediator.type === "time")
|
||||
return time;
|
||||
if (HoverMediator.type === "systray")
|
||||
return systray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Timer {
|
||||
@@ -145,7 +156,7 @@ Singleton {
|
||||
interval: 300
|
||||
onTriggered: {
|
||||
// wsPopUp.opacity = 1
|
||||
hoverPopUp.visible = true
|
||||
hoverPopUp.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,4 @@ Singleton {
|
||||
|
||||
precision: SystemClock.Seconds
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user