diff --git a/res/ui/main.qml b/res/ui/main.qml index 8c2969f8..afada270 100644 --- a/res/ui/main.qml +++ b/res/ui/main.qml @@ -20,8 +20,7 @@ Item { source: "popup.qml" function show(text) { - var area = workspace.clientArea(KWin.FullScreenArea, workspace.activeScreen, workspace.currentDesktop); - this.item.show(text, area); + this.item.show(text); } } diff --git a/res/ui/popup.qml b/res/ui/popup.qml index f4c68392..fe456c0e 100644 --- a/res/ui/popup.qml +++ b/res/ui/popup.qml @@ -8,6 +8,7 @@ import QtQuick.Controls 2.0 import QtQuick.Layouts 1.15 import org.kde.plasma.core 2.0 as PlasmaCore; import org.kde.plasma.components 3.0 as PC3 +import org.kde.kwin 2.0; /* * Component Documentation @@ -24,6 +25,12 @@ PlasmaCore.Dialog { location: PlasmaCore.Types.Floating outputOnly: true + property rect screenGeometry + + // Spawn popup a little bit lower than the center of the screen for consistency + x: (screenGeometry.x + screenGeometry.width / 2) - width / 2; + y: (screenGeometry.y + screenGeometry.height * 2 / 3) - height / 2; + visible: false mainItem: RowLayout { @@ -52,25 +59,21 @@ PlasmaCore.Dialog { } Component.onCompleted: { - // NOTE: IDK what this is, but this is necessary to keep the window working. KWin.registerWindow(this); } - function show(text, area) { + function show(text) { // Abort any previous timers hideTimer.stop(); + // Update current screen information + this.screenGeometry = workspace.clientArea(KWin.FullScreenArea, workspace.activeScreen, workspace.currentDesktop); + // Set the text for the popup messageLabel.text = text; - // Width and height are not computed before the popup is visible - // therefore we need to make is visible sooner this.visible = true; - // Spawn popup a little bit lower than the center of the screen for consistency - this.x = (area.x + area.width / 2) - this.width / 2; - this.y = (area.y + area.height * 2 / 3) - this.height / 2; - // Start popup hide timer hideTimer.interval = 3000; hideTimer.start();