forked from qt-creator/qt-creator
QmlDesigner: Fix PopupDialog popup location
* Restrict popup location to single screen given by global position * Reintroduce PopupDialog title bar drag * Fix global popup show on linux Change-Id: If1923151cb9d0ec4286f27aeae2baa292e017eb5 Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
245bd90a6e
commit
c3f9d43aca
@@ -49,7 +49,7 @@ StudioControls.PopupDialog {
|
|||||||
root.close()
|
root.close()
|
||||||
}
|
}
|
||||||
function onPopupShouldOpen() {
|
function onPopupShouldOpen() {
|
||||||
root.showGlobal()
|
Qt.callLater(root.showGlobal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,9 +33,8 @@ QtObject {
|
|||||||
|
|
||||||
signal closing(close: var)
|
signal closing(close: var)
|
||||||
|
|
||||||
function showGlobal()
|
function showGlobal() {
|
||||||
{
|
var pos = WindowManager.globalCursorPosition()
|
||||||
var pos = WindowManager.globalCursorPosition();
|
|
||||||
root.__itemGlobal = Qt.rect(pos.x, pos.y, 300, 20)
|
root.__itemGlobal = Qt.rect(pos.x, pos.y, 300, 20)
|
||||||
root.chevronVisible = false
|
root.chevronVisible = false
|
||||||
root.layout()
|
root.layout()
|
||||||
@@ -57,11 +56,8 @@ QtObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function layout() {
|
function layout() {
|
||||||
// Setup
|
let position = Qt.point(root.__itemGlobal.x, root.__itemGlobal.y)
|
||||||
var screen = Qt.rect(0, //Screen.virtualX, // TODO
|
var screen = WindowManager.getScreenGeometry(position)
|
||||||
0, //Screen.virtualY, // TODO
|
|
||||||
Screen.desktopAvailableWidth,
|
|
||||||
Screen.desktopAvailableHeight)
|
|
||||||
|
|
||||||
// Collect region information
|
// Collect region information
|
||||||
let edges = window.getRegions(screen, root.__itemGlobal)
|
let edges = window.getRegions(screen, root.__itemGlobal)
|
||||||
@@ -165,9 +161,18 @@ QtObject {
|
|||||||
var targetCenter = Qt.point(target.x + (target.width * 0.5),
|
var targetCenter = Qt.point(target.x + (target.width * 0.5),
|
||||||
target.y + (target.height * 0.5))
|
target.y + (target.height * 0.5))
|
||||||
|
|
||||||
|
// Just as a reminder why calculating custom right and bottom:
|
||||||
|
// > Note that for historical reasons this function returns top() + height() - 1;
|
||||||
|
// > use y() + height() to retrieve the true y-coordinate.
|
||||||
|
let sourceRight = source.x + source.width
|
||||||
|
let sourceBottom = source.y + source.height
|
||||||
|
|
||||||
// TOP
|
// TOP
|
||||||
let topAnchor = Qt.point(targetCenter.x, target.y)
|
let topAnchor = Qt.point(targetCenter.x, target.y)
|
||||||
let topRegion = Qt.rect(source.x, source.y, source.width, Math.max(0, topAnchor.y))
|
let topRegion = Qt.rect(source.x,
|
||||||
|
source.y,
|
||||||
|
source.width,
|
||||||
|
(topAnchor.y < source.top) ? 0 : Math.abs(topAnchor.y - source.top))
|
||||||
|
|
||||||
edges[Qt.TopEdge] = {
|
edges[Qt.TopEdge] = {
|
||||||
anchor: topAnchor,
|
anchor: topAnchor,
|
||||||
@@ -180,7 +185,7 @@ QtObject {
|
|||||||
let rightAnchor = Qt.point(target.x + target.width, targetCenter.y)
|
let rightAnchor = Qt.point(target.x + target.width, targetCenter.y)
|
||||||
let rightRegion = Qt.rect(rightAnchor.x,
|
let rightRegion = Qt.rect(rightAnchor.x,
|
||||||
source.y,
|
source.y,
|
||||||
Math.max(0, source.width - rightAnchor.x),
|
(rightAnchor.x > sourceRight) ? 0 : Math.abs(sourceRight - rightAnchor.x),
|
||||||
source.height)
|
source.height)
|
||||||
|
|
||||||
edges[Qt.RightEdge] = {
|
edges[Qt.RightEdge] = {
|
||||||
@@ -195,7 +200,7 @@ QtObject {
|
|||||||
let bottomRegion = Qt.rect(source.x,
|
let bottomRegion = Qt.rect(source.x,
|
||||||
bottomAnchor.y,
|
bottomAnchor.y,
|
||||||
source.width,
|
source.width,
|
||||||
Math.max(0, source.height - bottomAnchor.y))
|
(bottomAnchor.y > sourceBottom) ? 0 : Math.abs(sourceBottom - bottomAnchor.y))
|
||||||
|
|
||||||
edges[Qt.BottomEdge] = {
|
edges[Qt.BottomEdge] = {
|
||||||
anchor: bottomAnchor,
|
anchor: bottomAnchor,
|
||||||
@@ -206,7 +211,10 @@ QtObject {
|
|||||||
|
|
||||||
// LEFT
|
// LEFT
|
||||||
let leftAnchor = Qt.point(target.x, targetCenter.y)
|
let leftAnchor = Qt.point(target.x, targetCenter.y)
|
||||||
let leftRegion = Qt.rect(source.x, source.y, Math.max(0, leftAnchor.x), source.height)
|
let leftRegion = Qt.rect(source.x,
|
||||||
|
source.y,
|
||||||
|
(leftAnchor.x < source.left) ? 0 : Math.abs(leftAnchor.x - source.left),
|
||||||
|
source.height)
|
||||||
|
|
||||||
edges[Qt.LeftEdge] = {
|
edges[Qt.LeftEdge] = {
|
||||||
anchor: leftAnchor,
|
anchor: leftAnchor,
|
||||||
@@ -392,6 +400,19 @@ QtObject {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
height: StudioTheme.Values.titleBarHeight
|
height: StudioTheme.Values.titleBarHeight
|
||||||
|
|
||||||
|
DragHandler {
|
||||||
|
id: dragHandler
|
||||||
|
|
||||||
|
target: null
|
||||||
|
grabPermissions: PointerHandler.CanTakeOverFromAnything
|
||||||
|
onActiveChanged: {
|
||||||
|
if (dragHandler.active)
|
||||||
|
window.startSystemMove() // QTBUG-102488
|
||||||
|
|
||||||
|
root.chevronVisible = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: row
|
id: row
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QScreen>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
|
|
||||||
namespace QmlDesignerBase {
|
namespace QmlDesignerBase {
|
||||||
@@ -43,4 +44,14 @@ QPoint WindowManager::globalCursorPosition()
|
|||||||
return QCursor::pos();
|
return QCursor::pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRect WindowManager::getScreenGeometry(QPoint point)
|
||||||
|
{
|
||||||
|
QScreen *screen = QGuiApplication::screenAt(point);
|
||||||
|
|
||||||
|
if (!screen)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return screen->geometry();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace QmlDesignerBase
|
} // namespace QmlDesignerBase
|
||||||
|
@@ -25,6 +25,7 @@ public:
|
|||||||
static void registerDeclarativeType();
|
static void registerDeclarativeType();
|
||||||
|
|
||||||
Q_INVOKABLE QPoint globalCursorPosition();
|
Q_INVOKABLE QPoint globalCursorPosition();
|
||||||
|
Q_INVOKABLE QRect getScreenGeometry(QPoint point);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void focusWindowChanged(QWindow *window);
|
void focusWindowChanged(QWindow *window);
|
||||||
|
Reference in New Issue
Block a user