forked from qt-creator/qt-creator
Axivion: Redo positioning on screen
Fixes: QTCREATORBUG-32506 Change-Id: I2bd83b81fb379038149e20d751f0f3b32d239eab Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -41,19 +41,14 @@ static QString infoText()
|
|||||||
"!\"\" matches issues having any non-empty value in this column");
|
"!\"\" matches issues having any non-empty value in this column");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fixGlobalPosOnScreen(QPoint *globalPos, const QSize &size)
|
static QPoint globalPosOnScreen(const QPoint &orig, const QSize &size)
|
||||||
{
|
{
|
||||||
QScreen *qscreen = QGuiApplication::screenAt(*globalPos);
|
QScreen *qscreen = QGuiApplication::screenAt(orig);
|
||||||
if (!qscreen)
|
if (!qscreen)
|
||||||
qscreen = QGuiApplication::primaryScreen();
|
qscreen = QGuiApplication::primaryScreen();
|
||||||
const QRect screen = qscreen->availableGeometry();
|
const QRect screen = qscreen->availableGeometry();
|
||||||
|
|
||||||
if (globalPos->x() + size.width() > screen.width())
|
return QPoint(std::max(screen.x(), orig.x() - size.width()), orig.y() - size.height());
|
||||||
globalPos->setX(screen.width() - size.width());
|
|
||||||
if (globalPos->y() + size.height() > screen.height())
|
|
||||||
globalPos->setY(screen.height() - size.height());
|
|
||||||
if (globalPos->y() < 0)
|
|
||||||
globalPos->setY(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class FilterPopupWidget : public QFrame
|
class FilterPopupWidget : public QFrame
|
||||||
@@ -326,9 +321,8 @@ void IssueHeaderView::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
popup->setOnApply(onApply);
|
popup->setOnApply(onApply);
|
||||||
const int right = sectionViewportPosition(logical) + sectionSize(logical);
|
const int right = sectionViewportPosition(logical) + sectionSize(logical);
|
||||||
const QSize size = popup->sizeHint();
|
const QSize size = popup->sizeHint();
|
||||||
QPoint globalPos = mapToGlobal(QPoint{std::max(0, x() + right - size.width()),
|
const QPoint globalPos
|
||||||
this->y() - size.height()});
|
= globalPosOnScreen(mapToGlobal(QPoint{x() + right, this->y()}), size);
|
||||||
fixGlobalPosOnScreen(&globalPos, size);
|
|
||||||
popup->move(globalPos);
|
popup->move(globalPos);
|
||||||
popup->show();
|
popup->show();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user