summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qmenu.cpp
diff options
context:
space:
mode:
authorminiak <milan.burda@gmail.com>2010-04-07 09:01:04 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2010-04-07 09:01:20 (GMT)
commitee3a237262071721755075d6ae958aec744f5c87 (patch)
tree9601540104240fff5609bf3a01fc4b7d914e2186 /src/gui/widgets/qmenu.cpp
parentc1ce854d745b28e2f14057d29e726b8327034e9b (diff)
downloadQt-ee3a237262071721755075d6ae958aec744f5c87.zip
Qt-ee3a237262071721755075d6ae958aec744f5c87.tar.gz
Qt-ee3a237262071721755075d6ae958aec744f5c87.tar.bz2
QMenu::popup() code style fixes
Merge-request: 551 Reviewed-by: Benjamin Poulain <benjamin.poulain@nokia.com>
Diffstat (limited to 'src/gui/widgets/qmenu.cpp')
-rw-r--r--src/gui/widgets/qmenu.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 42f3a15..b752ae2 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -1803,7 +1803,7 @@ QSize QMenu::sizeHint() const
void QMenu::popup(const QPoint &p, QAction *atAction)
{
Q_D(QMenu);
- if (d->scroll) { //reset scroll state from last popup
+ if (d->scroll) { // reset scroll state from last popup
d->scroll->scrollOffset = 0;
d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;
}
@@ -1858,9 +1858,9 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
}
#endif
if (d->ncols > 1) {
- pos.setY(screen.top()+desktopFrame);
+ pos.setY(screen.top() + desktopFrame);
} else if (atAction) {
- for(int i = 0, above_height = 0; i < d->actions.count(); i++) {
+ for (int i = 0, above_height = 0; i < d->actions.count(); i++) {
QAction *action = d->actions.at(i);
if (action == atAction) {
int newY = pos.y() - above_height;
@@ -1875,7 +1875,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
if (d->scroll && d->scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone
&& !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, 0, this)) {
int below_height = above_height + d->scroll->scrollOffset;
- for(int i2 = i; i2 < d->actionRects.count(); i2++)
+ for (int i2 = i; i2 < d->actionRects.count(); i2++)
below_height += d->actionRects.at(i2).height();
size.setHeight(below_height);
}
@@ -1888,28 +1888,28 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
QPoint mouse = QCursor::pos();
d->mousePopupPos = mouse;
- const bool snapToMouse = (QRect(p.x()-3, p.y()-3, 6, 6).contains(mouse));
+ const bool snapToMouse = (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse));
if (adjustToDesktop) {
- //handle popup falling "off screen"
+ // handle popup falling "off screen"
if (isRightToLeft()) {
- if(snapToMouse) //position flowing left from the mouse
- pos.setX(mouse.x()-size.width());
+ if (snapToMouse) // position flowing left from the mouse
+ pos.setX(mouse.x() - size.width());
#ifndef QT_NO_MENUBAR
- //if in a menubar, it should be right-aligned
+ // if in a menubar, it should be right-aligned
if (qobject_cast<QMenuBar*>(d->causedPopup.widget))
pos.rx() -= size.width();
#endif //QT_NO_MENUBAR
- if (pos.x() < screen.left()+desktopFrame)
- pos.setX(qMax(p.x(), screen.left()+desktopFrame));
- if (pos.x()+size.width()-1 > screen.right()-desktopFrame)
- pos.setX(qMax(p.x()-size.width(), screen.right()-desktopFrame-size.width()+1));
+ if (pos.x() < screen.left() + desktopFrame)
+ pos.setX(qMax(p.x(), screen.left() + desktopFrame));
+ if (pos.x() + size.width() - 1 > screen.right() - desktopFrame)
+ pos.setX(qMax(p.x() - size.width(), screen.right() - desktopFrame - size.width() + 1));
} else {
- if (pos.x()+size.width()-1 > screen.right()-desktopFrame)
- pos.setX(screen.right()-desktopFrame-size.width()+1);
- if (pos.x() < screen.left()+desktopFrame)
+ if (pos.x() + size.width() - 1 > screen.right() - desktopFrame)
+ pos.setX(screen.right() - desktopFrame - size.width() + 1);
+ if (pos.x() < screen.left() + desktopFrame)
pos.setX(screen.left() + desktopFrame);
}
if (pos.y() + size.height() - 1 > screen.bottom() - desktopFrame) {
@@ -1922,14 +1922,14 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
if (pos.y() < screen.top() + desktopFrame)
pos.setY(screen.top() + desktopFrame);
- if (pos.y()+size.height()-1 > screen.bottom() - desktopFrame) {
+ if (pos.y() + size.height() - 1 > screen.bottom() - desktopFrame) {
if (d->scroll) {
d->scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown);
int y = qMax(screen.y(),pos.y());
- size.setHeight(screen.bottom()-(desktopFrame*2)-y);
+ size.setHeight(screen.bottom() - (desktopFrame * 2) - y);
} else {
// Too big for screen, bias to see bottom of menu (for some reason)
- pos.setY(screen.bottom()-size.height()+1);
+ pos.setY(screen.bottom() - size.height() + 1);
}
}
}
@@ -1938,19 +1938,19 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
int hGuess = isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll;
int vGuess = QEffects::DownScroll;
if (isRightToLeft()) {
- if ((snapToMouse && (pos.x() + size.width()/2 > mouse.x())) ||
- (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width()/2 > d->causedPopup.widget->x()))
+ if ((snapToMouse && (pos.x() + size.width() / 2 > mouse.x())) ||
+ (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 > d->causedPopup.widget->x()))
hGuess = QEffects::RightScroll;
} else {
- if ((snapToMouse && (pos.x() + size.width()/2 < mouse.x())) ||
- (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width()/2 < d->causedPopup.widget->x()))
+ if ((snapToMouse && (pos.x() + size.width() / 2 < mouse.x())) ||
+ (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 < d->causedPopup.widget->x()))
hGuess = QEffects::LeftScroll;
}
#ifndef QT_NO_MENUBAR
- if ((snapToMouse && (pos.y() + size.height()/2 < mouse.y())) ||
+ if ((snapToMouse && (pos.y() + size.height() / 2 < mouse.y())) ||
(qobject_cast<QMenuBar*>(d->causedPopup.widget) &&
- pos.y() + size.width()/2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()))
+ pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()))
vGuess = QEffects::UpScroll;
#endif
if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) {