mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-17 11:37:10 +03:00
fix: improve popup geometry update
This should fix using wrong coordinates when text overflows
This commit is contained in:
parent
8c013ac7bc
commit
1f02e47a37
@ -20,8 +20,7 @@ Item {
|
|||||||
source: "popup.qml"
|
source: "popup.qml"
|
||||||
|
|
||||||
function show(text) {
|
function show(text) {
|
||||||
var area = workspace.clientArea(KWin.FullScreenArea, workspace.activeScreen, workspace.currentDesktop);
|
this.item.show(text);
|
||||||
this.item.show(text, area);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import QtQuick.Controls 2.0
|
|||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore;
|
import org.kde.plasma.core 2.0 as PlasmaCore;
|
||||||
import org.kde.plasma.components 3.0 as PC3
|
import org.kde.plasma.components 3.0 as PC3
|
||||||
|
import org.kde.kwin 2.0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Component Documentation
|
* Component Documentation
|
||||||
@ -24,6 +25,12 @@ PlasmaCore.Dialog {
|
|||||||
location: PlasmaCore.Types.Floating
|
location: PlasmaCore.Types.Floating
|
||||||
outputOnly: true
|
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
|
visible: false
|
||||||
|
|
||||||
mainItem: RowLayout {
|
mainItem: RowLayout {
|
||||||
@ -52,25 +59,21 @@ PlasmaCore.Dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
// NOTE: IDK what this is, but this is necessary to keep the window working.
|
|
||||||
KWin.registerWindow(this);
|
KWin.registerWindow(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(text, area) {
|
function show(text) {
|
||||||
// Abort any previous timers
|
// Abort any previous timers
|
||||||
hideTimer.stop();
|
hideTimer.stop();
|
||||||
|
|
||||||
|
// Update current screen information
|
||||||
|
this.screenGeometry = workspace.clientArea(KWin.FullScreenArea, workspace.activeScreen, workspace.currentDesktop);
|
||||||
|
|
||||||
// Set the text for the popup
|
// Set the text for the popup
|
||||||
messageLabel.text = text;
|
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;
|
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
|
// Start popup hide timer
|
||||||
hideTimer.interval = 3000;
|
hideTimer.interval = 3000;
|
||||||
hideTimer.start();
|
hideTimer.start();
|
||||||
|
Loading…
Reference in New Issue
Block a user