summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp1
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp5
-rw-r--r--src/widgets/widgets/qmenu.cpp60
-rw-r--r--src/widgets/widgets/qmenu_p.h1
-rw-r--r--src/widgets/widgets/qwidgetresizehandler.cpp11
5 files changed, 37 insertions, 41 deletions
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index d091d1e970..abdd946c49 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -65,7 +65,6 @@
#include <private/qt_cocoa_helpers_mac_p.h>
#endif
#ifdef Q_OS_WIN
-# include <qlibrary.h>
# include <qt_windows.h>
#endif
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 5a789c2d66..a3e55114bb 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -711,8 +711,7 @@ void QDialogButtonBox::removeButton(QAbstractButton *button)
return;
// Remove it from the standard button hash first and then from the roles
- if (QPushButton *pushButton = qobject_cast<QPushButton *>(button))
- d->standardButtonHash.remove(pushButton);
+ d->standardButtonHash.remove(reinterpret_cast<QPushButton *>(button));
for (int i = 0; i < NRoles; ++i) {
QList<QAbstractButton *> &list = d->buttonLists[i];
for (int j = 0; j < list.count(); ++j) {
@@ -878,7 +877,7 @@ void QDialogButtonBoxPrivate::_q_handleButtonDestroyed()
Q_Q(QDialogButtonBox);
if (QObject *object = q->sender()) {
QBoolBlocker skippy(internalRemove);
- q->removeButton(static_cast<QAbstractButton *>(object));
+ q->removeButton(reinterpret_cast<QAbstractButton *>(object));
}
}
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 2917083415..1925b58326 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -401,17 +401,6 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
itemsDirty = 0;
}
-QSize QMenuPrivate::adjustMenuSizeForScreen(const QRect &screen)
-{
- Q_Q(QMenu);
- QSize ret = screen.size();
- itemsDirty = true;
- updateActionRects(screen);
- const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);
- ret.setWidth(actionRects.at(getLastVisibleAction()).right() + fw);
- return ret;
-}
-
int QMenuPrivate::getLastVisibleAction() const
{
//let's try to get the last visible action
@@ -2265,7 +2254,8 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
else
pos = p;
- QSize size = sizeHint();
+ const QSize menuSizeHint(sizeHint());
+ QSize size = menuSizeHint;
QRect screen;
#ifndef QT_NO_GRAPHICSVIEW
bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this);
@@ -2278,13 +2268,11 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen);
// if the screens have very different geometries and the menu is too big, we have to recalculate
- if (size.height() > screen.height() || size.width() > screen.width()) {
- size = d->adjustMenuSizeForScreen(screen);
- adjustToDesktop = true;
- }
- // Layout is not right, we might be able to save horizontal space
- if (d->ncols >1 && size.height() < screen.height()) {
- size = d->adjustMenuSizeForScreen(screen);
+ if ((size.height() > screen.height() || size.width() > screen.width()) ||
+ // Layout is not right, we might be able to save horizontal space
+ (d->ncols >1 && size.height() < screen.height())) {
+ size.setWidth(qMin(menuSizeHint.width(), screen.width() - desktopFrame * 2));
+ size.setHeight(qMin(menuSizeHint.height(), screen.height() - desktopFrame * 2));
adjustToDesktop = true;
}
@@ -2337,7 +2325,6 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
d->mousePopupPos = mouse;
const bool snapToMouse = !d->causedPopup.widget && (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse));
- const QSize menuSize(sizeHint());
if (adjustToDesktop) {
// handle popup falling "off screen"
if (isRightToLeft()) {
@@ -2371,7 +2358,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
if (pos.y() < screen.top() + desktopFrame)
pos.setY(screen.top() + desktopFrame);
- if (pos.y() + menuSize.height() - 1 > screen.bottom() - desktopFrame) {
+ if (pos.y() + menuSizeHint.height() - 1 > screen.bottom() - desktopFrame) {
if (d->scroll) {
d->scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown);
int y = qMax(screen.y(),pos.y());
@@ -2384,29 +2371,29 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
}
const int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this);
QMenu *caused = qobject_cast<QMenu*>(d_func()->causedPopup.widget);
- if (caused && caused->geometry().width() + menuSize.width() + subMenuOffset < screen.width()) {
+ if (caused && caused->geometry().width() + menuSizeHint.width() + subMenuOffset < screen.width()) {
QRect parentActionRect(caused->d_func()->actionRect(caused->d_func()->currentAction));
const QPoint actionTopLeft = caused->mapToGlobal(parentActionRect.topLeft());
parentActionRect.moveTopLeft(actionTopLeft);
if (isRightToLeft()) {
- if ((pos.x() + menuSize.width() > parentActionRect.left() - subMenuOffset)
+ if ((pos.x() + menuSizeHint.width() > parentActionRect.left() - subMenuOffset)
&& (pos.x() < parentActionRect.right()))
{
- pos.rx() = parentActionRect.left() - menuSize.width();
+ pos.rx() = parentActionRect.left() - menuSizeHint.width();
if (pos.x() < screen.x())
pos.rx() = parentActionRect.right();
- if (pos.x() + menuSize.width() > screen.x() + screen.width())
+ if (pos.x() + menuSizeHint.width() > screen.x() + screen.width())
pos.rx() = screen.x();
}
} else {
if ((pos.x() < parentActionRect.right() + subMenuOffset)
- && (pos.x() + menuSize.width() > parentActionRect.left()))
+ && (pos.x() + menuSizeHint.width() > parentActionRect.left()))
{
pos.rx() = parentActionRect.right();
- if (pos.x() + menuSize.width() > screen.x() + screen.width())
- pos.rx() = parentActionRect.left() - menuSize.width();
+ if (pos.x() + menuSizeHint.width() > screen.x() + screen.width())
+ pos.rx() = parentActionRect.left() - menuSizeHint.width();
if (pos.x() < screen.x())
- pos.rx() = screen.x() + screen.width() - menuSize.width();
+ pos.rx() = screen.x() + screen.width() - menuSizeHint.width();
}
}
}
@@ -3514,11 +3501,22 @@ void QMenu::internalDelayedPopup()
d->activeMenu->d_func()->causedPopup.widget = this;
d->activeMenu->d_func()->causedPopup.action = d->currentAction;
+ QRect screen;
+#ifndef QT_NO_GRAPHICSVIEW
+ bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this);
+ if (isEmbedded)
+ screen = d->popupGeometry(this);
+ else
+#endif
+ screen = d->popupGeometry(QApplication::desktop()->screenNumber(pos()));
+
int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this);
const QRect actionRect(d->actionRect(d->currentAction));
- const QPoint rightPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top())));
+ QPoint subMenuPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top())));
+ if (subMenuPos.x() > screen.right())
+ subMenuPos.setX(QCursor::pos().x());
- d->activeMenu->popup(rightPos);
+ d->activeMenu->popup(subMenuPos);
d->sloppyState.setSubMenuPopup(actionRect, d->currentAction, d->activeMenu);
#if !defined(Q_OS_DARWIN)
diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h
index 64291e842f..898fa3161b 100644
--- a/src/widgets/widgets/qmenu_p.h
+++ b/src/widgets/widgets/qmenu_p.h
@@ -311,7 +311,6 @@ public:
mutable uint ncols : 4; //4 bits is probably plenty
uint collapsibleSeparators : 1;
uint toolTipsVisible : 1;
- QSize adjustMenuSizeForScreen(const QRect & screen);
int getLastVisibleAction() const;
bool activationRecursionGuard;
diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp
index 016598849b..dc7353a6ca 100644
--- a/src/widgets/widgets/qwidgetresizehandler.cpp
+++ b/src/widgets/widgets/qwidgetresizehandler.cpp
@@ -112,9 +112,9 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee)
return false;
}
- QMouseEvent *e = (QMouseEvent*)ee;
- switch (e->type()) {
+ switch (ee->type()) {
case QEvent::MouseButtonPress: {
+ QMouseEvent *e = static_cast<QMouseEvent *>(ee);
if (w->isMaximized())
break;
if (!widget->rect().contains(widget->mapFromGlobal(e->globalPos())))
@@ -155,7 +155,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee)
case QEvent::MouseButtonRelease:
if (w->isMaximized())
break;
- if (e->button() == Qt::LeftButton) {
+ if (static_cast<QMouseEvent *>(ee)->button() == Qt::LeftButton) {
moveResizeMode = false;
buttonDown = false;
widget->releaseMouse();
@@ -171,6 +171,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee)
case QEvent::MouseMove: {
if (w->isMaximized())
break;
+ QMouseEvent *e = static_cast<QMouseEvent *>(ee);
buttonDown = buttonDown && (e->buttons() & Qt::LeftButton); // safety, state machine broken!
bool me = movingEnabled;
movingEnabled = (me && o == widget && (buttonDown || moveResizeMode));
@@ -184,11 +185,11 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee)
}
} break;
case QEvent::KeyPress:
- keyPressEvent((QKeyEvent*)e);
+ keyPressEvent(static_cast<QKeyEvent *>(ee));
break;
case QEvent::ShortcutOverride:
if (buttonDown) {
- ((QKeyEvent*)ee)->accept();
+ ee->accept();
return true;
}
break;