Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frame/popupwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ PopupWindow::PopupWindow(QWindow *parent)
});
}

void PopupWindow::setWindowGeometry(int px, int py, int pw, int ph)
{
this->setGeometry(px, py, pw, ph);
}

void PopupWindow::mouseReleaseEvent(QMouseEvent *event)
{
QQuickApplicationWindow::mouseReleaseEvent(event);
Expand Down
2 changes: 2 additions & 0 deletions frame/popupwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
QML_NAMED_ELEMENT(PopupWindow)

public:
PopupWindow(QWindow *parent = nullptr);

Check warning on line 19 in frame/popupwindow.h

View workflow job for this annotation

GitHub Actions / cppcheck

Class 'PopupWindow' has a constructor with 1 argument that is not explicit. Such, so called "Converting constructors", should in general be explicit for type safety reasons as that prevents unintended implicit conversions.

bool x11GrabFocusTransition() const { return m_x11GrabFocusTransition; }
Q_INVOKABLE void setWindowGeometry(int px, int py, int pw, int ph);

protected:
void mouseReleaseEvent(QMouseEvent *event) override;
Expand Down
4 changes: 2 additions & 2 deletions frame/qml/PanelPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Item {

Binding {
when: readyBinding
target: popupWindow; property: "width"
target: popupWindow; property: "requestedWidth"
value: popup.width
}
Binding {
when: readyBinding
target: popupWindow; property: "height"
target: popupWindow; property: "requestedHeight"
value: popup.height
}
Binding {
Expand Down
26 changes: 19 additions & 7 deletions frame/qml/PanelPopupWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ PopupWindow {
property real yOffset: 0
property int margins: 10
property Item currentItem
property int requestedWidth: 10
property int requestedHeight: 10
signal requestUpdateGeometry()
signal updateGeometryFinished()

// order to update screen and (x,y)
property var updateGeometryer : function updateGeometry()
{
if (root.width <= 10 || root.height <= 10) {
return
if (root.requestedWidth <= 10 || root.requestedHeight <= 10) {
root.width = root.requestedWidth;
root.height = root.requestedHeight;
return;
}
if (!root.transientParent)
return
Expand All @@ -33,9 +37,11 @@ PopupWindow {
let bounding = Qt.rect(root.screen.virtualX + margins, root.screen.virtualY + margins,
root.screen.width - margins * 2, root.screen.height - margins * 2)
let pos = Qt.point(transientParent ? transientParent.x + xOffset : xOffset,
transientParent ? transientParent.y + yOffset : YOffset)
x = selectValue(pos.x, bounding.left, bounding.right - root.width)
y = selectValue(pos.y, bounding.top, bounding.bottom - root.height)
transientParent ? transientParent.y + yOffset : yOffset)
let newX = selectValue(pos.x, bounding.left, bounding.right - root.requestedWidth)
let newY = selectValue(pos.y, bounding.top, bounding.bottom - root.requestedHeight)

root.setWindowGeometry(newX, newY, root.requestedWidth, root.requestedHeight)
}

function selectValue(value, min, max) {
Expand Down Expand Up @@ -84,6 +90,8 @@ PopupWindow {
if(root.visible)
return
currentItem = null
root.requestedWidth = 10
root.requestedHeight = 10
root.width = 10
root.height = 10
DS.closeChildrenWindows(root)
Expand Down Expand Up @@ -117,8 +125,12 @@ PopupWindow {
}
}

onHeightChanged: requestUpdateGeometry()
onWidthChanged: requestUpdateGeometry()
onRequestedHeightChanged: {
requestUpdateGeometry()
}
onRequestedWidthChanged: {
requestUpdateGeometry()
}
onXOffsetChanged: requestUpdateGeometry()
onYOffsetChanged: requestUpdateGeometry()

Expand Down
Loading