Possibly fix sizing issue

This commit is contained in:
2025-10-14 00:01:52 -03:00
parent 70a7b6c45b
commit 6e4d43b206
3 changed files with 132 additions and 141 deletions

View File

@@ -15,7 +15,6 @@ BackgroundRectangle {
property var notification: null property var notification: null
property bool startTimer: false property bool startTimer: false
property int timerDuration: 2000 property int timerDuration: 2000
property bool firstTime: true
property string image: { property string image: {
if (hasImage) { if (hasImage) {
@@ -26,62 +25,66 @@ BackgroundRectangle {
} }
return Quickshell.iconPath(notification?.appIcon); return Quickshell.iconPath(notification?.appIcon);
} }
property real targetHeight: notifLayout.implicitHeight + 20
property bool collapsed: false
implicitWidth: 400 implicitWidth: 400
implicitHeight: 0 readonly property real contentHeight: Math.max(notifLayout.implicitHeight + 20, 100)
// implicitHeight: Math.max(notifLayout.implicitHeight, 100)
Component.onCompleted: { height: collapsed ? 0 : contentHeight
root.implicitHeight = targetHeight;
}
clip: true
Behavior on implicitHeight { Behavior on height {
SequentialAnimation { SequentialAnimation {
NumberAnimation { NumberAnimation {
duration: 150 duration: 200
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
} }
ScriptAction { ScriptAction {
script: { script: {
if (clicked) if (root.clicked)
root.dismissed(); root.dismissed();
if (root.implicitHeight === 0) if (root.height === 0)
root.timedout(); root.timedout();
} }
} }
} }
} }
clip: true
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
root.clicked = true; root.clicked = true;
root.implicitHeight = 0; root.collapsed = true;
root.dismissed();
} }
} }
Timer { Timer {
id: notifTimer id: notifTimer
interval: timerDuration interval: timerDuration
running: root.startTimer running: root.startTimer
repeat: false
onTriggered: { onTriggered: {
root.implicitHeight = 0; root.collapsed = true;
} }
} }
RowLayout { RowLayout {
id: notifLayout id: notifLayout
implicitHeight: Math.max(iconImage.implicitHeight, gridRoot.implicitHeight) Layout.preferredHeight: Math.max(iconImage.implicitHeight, gridRoot.implicitHeight)
anchors { anchors {
fill: parent top: parent.top
left: parent.left
right: parent.right
margins: 10
} }
IconImage { IconImage {
id: iconImage id: iconImage
@@ -89,7 +92,7 @@ BackgroundRectangle {
Layout.leftMargin: 10 Layout.leftMargin: 10
implicitSize: 80 implicitSize: 80
visible: root.image ? true : false visible: root.image ? true : false
source: root.image source: root.image ? root.image : ""
} }
ColumnLayout { ColumnLayout {
@@ -115,9 +118,8 @@ BackgroundRectangle {
StyledText { StyledText {
id: summaryText id: summaryText
anchors.fill: parent anchors.fill: parent
wrapMode: Text.WordWrap
text: root.notification ? root.notification.summary : "" text: root.notification ? root.notification.summary : ""
} }
} }
@@ -137,9 +139,8 @@ BackgroundRectangle {
} }
StyledText { StyledText {
id: bodyText id: bodyText
anchors.fill: parent anchors.fill: parent
wrapMode: Text.WordWrap
text: root.notification ? root.notification.body : "" text: root.notification ? root.notification.body : ""
} }
} }

View File

@@ -11,119 +11,102 @@ Singleton {
id: root id: root
readonly property string hyprlandSignature: Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE") readonly property string hyprlandSignature: Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE")
readonly property var focusedMon: Hyprland.focusedMonitor readonly property var focusedMon: Hyprland.focusedMonitor
property var hasFullscreen: false property bool hasFullscreen: false
property var isScreencasting: false property bool isScreencasting: false
property var sortedTopLevels: {
if (!ToplevelManager.toplevels || !ToplevelManager.toplevels.values) {
return [];
}
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.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];
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.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);
}
property ListModel sortedDesktopApplicationsModel: ListModel {} property ListModel sortedDesktopApplicationsModel: ListModel {}
onSortedTopLevelsChanged: updateSortedDesktopApplications() // Derived property of sorted toplevels
property var sortedTopLevels: {
const topLevels = Array.from(Hyprland.toplevels?.values ?? []);
const sorted = 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.workspace && b.workspace) {
const workspaceCompare = a.workspace.id - b.workspace.id;
if (workspaceCompare !== 0) return workspaceCompare;
}
if (a.lastIpcObject?.at && b.lastIpcObject?.at) {
const xCompare = a.lastIpcObject.at[0] - b.lastIpcObject.at[0];
if (Math.abs(xCompare) > 10) return xCompare;
return a.lastIpcObject.at[1] - b.lastIpcObject.at[1];
}
if (a.title && b.title)
return a.title.localeCompare(b.title);
return 0;
});
return sorted.filter(tl => tl.wayland !== null);
}
function updateSortedDesktopApplications() { property var topLevelWorkspaces: {
sortedDesktopApplicationsModel.clear(); return sortedTopLevels.map(toplevel => toplevel.workspace);
}
for (const topLevel of sortedTopLevels) { onSortedTopLevelsChanged: refreshSortedDesktopApplications()
const entry = DesktopEntries.heuristicLookup(topLevel.wayland.appId);
sortedDesktopApplicationsModel.append({ Timer {
topLevel: topLevel, id: retryTimer
desktopEntry: entry interval: 300
}); repeat: false
onTriggered: refreshSortedDesktopApplications()
}
function refreshSortedDesktopApplications() {
if (!Hyprland.toplevels || Hyprland.toplevels.size === 0)
return;
try {
sortedDesktopApplicationsModel.clear();
for (const topLevel of sortedTopLevels) {
const entry = DesktopEntries.heuristicLookup(topLevel.wayland.appId);
if (!entry) {
retryTimer.restart();
return;
}
sortedDesktopApplicationsModel.append({
topLevel: topLevel,
desktopEntry: entry
});
}
} catch (err) {
retryTimer.restart();
} }
} }
function workspaceApps(workspaceIndexAlign) { function workspaceApps(workspaceIndexAlign) {
const list = []; const list = [];
const model = sortedDesktopApplicationsModel; for (let i = 0; i < sortedDesktopApplicationsModel.count; i++) {
for (let i = 0; i < model.count; i++) { const item = sortedDesktopApplicationsModel.get(i);
const item = model.get(i);
if (item.topLevel.workspace.id === workspaceIndexAlign) if (item.topLevel.workspace.id === workspaceIndexAlign)
list.push(item.desktopEntry); list.push(item.desktopEntry);
} }
return list; return list;
} }
// Hyprland socket listener
Socket { Socket {
path: `${Quickshell.env("XDG_RUNTIME_DIR")}/hypr/${Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE")}/.socket2.sock` path: `${Quickshell.env("XDG_RUNTIME_DIR")}/hypr/${root.hyprlandSignature}/.socket2.sock`
connected: true connected: true
parser: SplitParser { parser: SplitParser {
property var fullscreenRegex: new RegExp("fullscreen>>.") property var fullscreenRegex: /fullscreen>>./
property var screencastRegex: new RegExp("screencast>>.*") property var screencastRegex: /screencast>>.*/
onRead: msg => { onRead: msg => {
let match = fullscreenRegex.exec(msg); if (fullscreenRegex.test(msg)) {
if (match != null) { root.hasFullscreen = msg.split(">>")[1] === "1";
if (msg.split(">>")[1] === "1") {
root.hasFullscreen = true;
} else {
root.hasFullscreen = false;
}
} }
match = screencastRegex.exec(msg); if (screencastRegex.test(msg)) {
if (match != null) { root.isScreencasting = msg.split(">>")[1].split(',')[0] === "1";
if (msg.split(">>")[1].split(',')[0] === "1") {
root.isScreencasting = true;
} else {
root.isScreencasting = false;
}
} }
} }
} }
} }
} }

View File

@@ -36,7 +36,7 @@ PanelWindow {
Rectangle { Rectangle {
id: notifWindow id: notifWindow
anchors.centerIn:parent anchors.centerIn: parent
implicitHeight: 300 implicitHeight: 300
implicitWidth: listview.contentWidth implicitWidth: listview.contentWidth
@@ -51,32 +51,35 @@ PanelWindow {
spacing: 5 spacing: 5
orientation: ListView.Horizontal orientation: ListView.Horizontal
focus:true focus: true
highlight: Rectangle { color: "black"; radius: 5 } highlight: Rectangle {
color: "black"
radius: 5
}
highlightFollowsCurrentItem: true highlightFollowsCurrentItem: true
keyNavigationEnabled: false keyNavigationEnabled: false
Keys.onPressed: (event) => { Keys.onPressed: event => {
switch (event.key) { switch (event.key) {
case Qt.Key_L: // move down case Qt.Key_L: // move down
case Qt.Key_D: case Qt.Key_D:
if (currentIndex < count - 1) if (currentIndex < count - 1)
currentIndex++ currentIndex++;
event.accepted = true event.accepted = true;
break break;
case Qt.Key_H: // move up case Qt.Key_H: // move up
case Qt.Key_A: case Qt.Key_A:
if (currentIndex > 0) if (currentIndex > 0)
currentIndex-- currentIndex--;
event.accepted = true event.accepted = true;
break break;
case Qt.Key_Return: case Qt.Key_Return:
currentItem.activate() currentItem.activate();
event.accepted = true event.accepted = true;
break break;
case Qt.Key_Escape: case Qt.Key_Escape:
root.clear() root.clear();
break break;
} }
} }
@@ -91,30 +94,34 @@ PanelWindow {
color: "transparent" color: "transparent"
function activate() { function activate() {
modelData.topLevel.wayland.activate() modelData.topLevel.wayland.activate();
root.clear() root.clear();
} }
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: activate() onClicked: parent.activate()
} }
ScreencopyView { ScreencopyView {
anchors.fill: parent anchors.fill: parent
live: true live: true
captureSource: modelData.topLevel.wayland captureSource: parent.modelData.topLevel.wayland
} }
IconImage { IconImage {
anchors.bottom: parent.bottom
property int workspaceId: modelData.topLevel.workspace.id anchors {
property var desktopEntry: modelData.desktopEntry bottom: parent.bottom
horizontalCenter: parent.horizontalCenter
}
property int workspaceId: parent.modelData.topLevel.workspace.id
property var desktopEntry: parent.modelData.desktopEntry? parent.modelData.desktopEntry:null
width: 30 width: 30
height: 30 height: 30
source: (modelData && desktopEntry.icon) ? Quickshell.iconPath(desktopEntry.icon, 1) : "aaa" source: (parent.modelData && desktopEntry.icon) ? Quickshell.iconPath(desktopEntry.icon, 1) : "aaa"
} }
} }
} }