summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-04-13 04:45:22 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-04-13 04:45:22 (GMT)
commitfbacd0fb2eb41470b090a3cbca7535f78689a382 (patch)
tree4f6ca32958fd9c5c95ae9ca2f599bf56067d2c45 /src/gui
parent3e94b3a77affeef80544e48949e018ced4e0d96e (diff)
parent9f0884773a451a4feef80812e015266bd487dcdc (diff)
downloadQt-fbacd0fb2eb41470b090a3cbca7535f78689a382.zip
Qt-fbacd0fb2eb41470b090a3cbca7535f78689a382.tar.gz
Qt-fbacd0fb2eb41470b090a3cbca7535f78689a382.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (61 commits) Revert Merge Request 551. This introduces regressions to Qt. Fixed scroll area size calculation on Mac. Fix a race where QThread::exit() is "lost" when called after start() make a partial build of linguist in no-gui config make the code less of a trap fix build from top level Partially revert MR 543 changes to Linguist. Apply f176759fc41abc4cb901c2cbaa15264f2a9ac85b to stdout too. Autotest: add some debugging, just in case there's something wrong Autotest: fix the fix for the rounding error. Fix compile error with QT_NO_LIBRARY in QtMultimedia the _setmode() prototype is different on win ce qdoc: Changed qdoc to output the new doc format. Doc: update 'developing on mac' fcntl.h doesn't seem to exist, either - contrary to an example on msdn Autotest: fix paths on the test server after update. Force the repaint during a window resize. fix compile on wince remove CONFIG += ordered again Assistant: Check namespace and virtual folder syntax of help projects. ...
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qapplication_mac.mm43
-rw-r--r--src/gui/kernel/qcocoasharedwindowmethods_mac_p.h25
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm30
-rw-r--r--src/gui/kernel/qeventdispatcher_mac.mm34
-rw-r--r--src/gui/kernel/qeventdispatcher_mac_p.h1
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm10
-rw-r--r--src/gui/kernel/qwidget_mac.mm5
-rw-r--r--src/gui/painting/qdrawhelper_p.h7
-rw-r--r--src/gui/text/qtextdocument_p.cpp32
-rw-r--r--src/gui/widgets/qmenu.cpp50
-rw-r--r--src/gui/widgets/qplaintextedit.cpp8
11 files changed, 120 insertions, 125 deletions
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index 28072fc..321492d 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -1221,7 +1221,7 @@ void qt_init(QApplicationPrivate *priv, int)
}
#endif
- if (!app_proc_ae_handlerUPP) {
+ if (!app_proc_ae_handlerUPP && !QApplication::testAttribute(Qt::AA_MacPluginApplication)) {
app_proc_ae_handlerUPP = AEEventHandlerUPP(QApplicationPrivate::globalAppleEventProcessor);
for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) {
// Install apple event handler, but avoid overwriting an already
@@ -2446,25 +2446,30 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
}
if(!handled_event) {
if(cmd.commandID == kHICommandQuit) {
- handled_event = true;
- HiliteMenu(0);
- bool handle_quit = true;
- if(QApplicationPrivate::modalState()) {
- int visible = 0;
- const QWidgetList tlws = QApplication::topLevelWidgets();
- for(int i = 0; i < tlws.size(); ++i) {
- if(tlws.at(i)->isVisible())
- ++visible;
+ // Quitting the application is not Qt's responsibility if
+ // used in a plugin or just embedded into a native application.
+ // In that case, let the event pass down to the native apps event handler.
+ if (!QApplication::testAttribute(Qt::AA_MacPluginApplication)) {
+ handled_event = true;
+ HiliteMenu(0);
+ bool handle_quit = true;
+ if(QApplicationPrivate::modalState()) {
+ int visible = 0;
+ const QWidgetList tlws = QApplication::topLevelWidgets();
+ for(int i = 0; i < tlws.size(); ++i) {
+ if(tlws.at(i)->isVisible())
+ ++visible;
+ }
+ handle_quit = (visible <= 1);
+ }
+ if(handle_quit) {
+ QCloseEvent ev;
+ QApplication::sendSpontaneousEvent(app, &ev);
+ if(ev.isAccepted())
+ app->quit();
+ } else {
+ QApplication::beep();
}
- handle_quit = (visible <= 1);
- }
- if(handle_quit) {
- QCloseEvent ev;
- QApplication::sendSpontaneousEvent(app, &ev);
- if(ev.isAccepted())
- app->quit();
- } else {
- QApplication::beep();
}
} else if(cmd.commandID == kHICommandSelectWindow) {
if((GetCurrentKeyModifiers() & cmdKey))
diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
index 129e0a5..ec00915 100644
--- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
+++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
@@ -58,7 +58,6 @@ QT_BEGIN_NAMESPACE
extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp
-extern bool qt_blockCocoaSettingModalWindowLevel; // qeventdispatcher_mac_p.h
Q_GLOBAL_STATIC(QPointer<QWidget>, currentDragTarget);
@@ -102,30 +101,6 @@ QT_END_NAMESPACE
return !(isPopup || isToolTip || isTool);
}
-- (void)orderWindow:(NSWindowOrderingMode)orderingMode relativeTo:(NSInteger)otherWindowNumber
-{
- if (qt_blockCocoaSettingModalWindowLevel) {
- // To avoid windows popping in front while restoring modal sessions
- // in the event dispatcher, we block cocoa from ordering this window
- // to front. The result of not doing this can be seen if executing
- // a native color dialog on top of another executing dialog.
- return;
- }
- [super orderWindow:orderingMode relativeTo:otherWindowNumber];
-}
-
-- (void)setLevel:(NSInteger)windowLevel
-{
- if (qt_blockCocoaSettingModalWindowLevel) {
- // To avoid windows popping in front while restoring modal sessions
- // in the event dispatcher, we block cocoa from ordering this window
- // to front. The result of not doing this can be seen if executing
- // a native color dialog on top of another executing dialog.
- return;
- }
- [super setLevel:windowLevel];
-}
-
- (void)toggleToolbarShown:(id)sender
{
macSendToolbarChangeEvent([self QT_MANGLE_NAMESPACE(qt_qwidget)]);
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 06eb7ff..9c5380b 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -657,23 +657,33 @@ static int qCocoaViewCount = 0;
{
if (!qwidget)
return;
-
if (qwidgetprivate->data.in_destructor)
return;
- QEvent enterEvent(QEvent::Enter);
- NSPoint windowPoint = [event locationInWindow];
- NSPoint globalPoint = [[event window] convertBaseToScreen:windowPoint];
- NSPoint viewPoint = [self convertPoint:windowPoint fromView:nil];
+
if (!qAppInstance()->activeModalWidget() || QApplicationPrivate::tryModalHelper(qwidget, 0)) {
+ QEvent enterEvent(QEvent::Enter);
+ NSPoint windowPoint = [event locationInWindow];
+ NSPoint globalPoint = [[event window] convertBaseToScreen:windowPoint];
+ NSPoint viewPoint = [self convertPoint:windowPoint fromView:nil];
QApplication::sendEvent(qwidget, &enterEvent);
qt_mouseover = qwidget;
- // Update cursor and dispatch hover events.
+ // Update cursor icon:
qt_mac_update_cursor_at_global_pos(flipPoint(globalPoint).toPoint());
- if (qwidget->testAttribute(Qt::WA_Hover) &&
- (!qAppInstance()->activePopupWidget() || qAppInstance()->activePopupWidget() == qwidget->window())) {
- QHoverEvent he(QEvent::HoverEnter, QPoint(viewPoint.x, viewPoint.y), QPoint(-1, -1));
- QApplicationPrivate::instance()->notify_helper(qwidget, &he);
+
+ // Send mouse move and hover events as well:
+ if (!qAppInstance()->activePopupWidget() || qAppInstance()->activePopupWidget() == qwidget->window()) {
+ if (qwidget->testAttribute(Qt::WA_MouseTracking)) {
+ NSEvent *mouseEvent = [NSEvent mouseEventWithType:NSMouseMoved
+ location:windowPoint modifierFlags:[event modifierFlags] timestamp:[event timestamp]
+ windowNumber:[event windowNumber] context:[event context] eventNumber:[event eventNumber]
+ clickCount:0 pressure:0];
+ qt_mac_handleMouseEvent(self, mouseEvent, QEvent::MouseMove, Qt::NoButton);
+ }
+ if (qwidget->testAttribute(Qt::WA_Hover)) {
+ QHoverEvent he(QEvent::HoverEnter, QPoint(viewPoint.x, viewPoint.y), QPoint(-1, -1));
+ QApplicationPrivate::instance()->notify_helper(qwidget, &he);
+ }
}
}
}
diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm
index a7f1224..0d93b9f 100644
--- a/src/gui/kernel/qeventdispatcher_mac.mm
+++ b/src/gui/kernel/qeventdispatcher_mac.mm
@@ -97,11 +97,6 @@ QT_BEGIN_NAMESPACE
QT_USE_NAMESPACE
/*****************************************************************************
- Internal variables and functions
- *****************************************************************************/
-bool qt_blockCocoaSettingModalWindowLevel = false;
-
-/*****************************************************************************
Externals
*****************************************************************************/
extern void qt_event_request_timer(MacTimerInfo *); //qapplication_mac.cpp
@@ -752,7 +747,6 @@ bool QEventDispatcherMacPrivate::interrupt = false;
#ifdef QT_MAC_USE_COCOA
QStack<QCocoaModalSessionInfo> QEventDispatcherMacPrivate::cocoaModalSessionStack;
bool QEventDispatcherMacPrivate::currentExecIsNSAppRun = false;
-bool QEventDispatcherMacPrivate::modalSessionsTemporarilyStopped = false;
bool QEventDispatcherMacPrivate::nsAppRunCalledByQt = false;
bool QEventDispatcherMacPrivate::cleanupModalSessionsNeeded = false;
NSModalSession QEventDispatcherMacPrivate::currentModalSessionCached = 0;
@@ -788,19 +782,14 @@ void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
// we need to stop all the modal session first. To avoid changing
// the stacking order of the windows while doing so, we put
// up a block that is used in QCocoaWindow and QCocoaPanel:
- QBoolBlocker block1(blockSendPostedEvents, true);
- QBoolBlocker block2(qt_blockCocoaSettingModalWindowLevel, true);
-
int stackSize = cocoaModalSessionStack.size();
for (int i=stackSize-1; i>=0; --i) {
QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
if (info.session) {
- [NSApp runModalSession:info.session];
[NSApp endModalSession:info.session];
info.session = 0;
}
}
- modalSessionsTemporarilyStopped = true;
currentModalSessionCached = 0;
}
@@ -834,29 +823,12 @@ NSModalSession QEventDispatcherMacPrivate::currentModalSession()
// When creating a modal session cocoa will rearrange the windows.
// In order to avoid windows to be put behind another we need to
// keep the window level.
- {
- int level = [window level];
- info.session = [NSApp beginModalSessionForWindow:window];
- [window setLevel:level];
- }
+ int level = [window level];
+ info.session = [NSApp beginModalSessionForWindow:window];
+ [window setLevel:level];
}
currentModalSessionCached = info.session;
}
-
- if (modalSessionsTemporarilyStopped && currentModalSessionCached) {
- // After a call to temporarilyStopAllModalSessions, cocoa have
- // now posted events to restore ended modal session windows to
- // the correct window level. Those events will be processed
- // _after_ our new calls to beginModalSessionForWindow have
- // taken effect, which will end up stacking the windows wrong on
- // screen. To work around this, we block cocoa from changing the
- // stacking order of the windows, and flush out the pending events
- // (the block is used in QCocoaWindow and QCocoaPanel):
- QBoolBlocker block1(blockSendPostedEvents, true);
- QBoolBlocker block2(qt_blockCocoaSettingModalWindowLevel, true);
- [NSApp runModalSession:currentModalSessionCached];
- }
- modalSessionsTemporarilyStopped = false;
return currentModalSessionCached;
}
diff --git a/src/gui/kernel/qeventdispatcher_mac_p.h b/src/gui/kernel/qeventdispatcher_mac_p.h
index 8ac7c65..a0afb84 100644
--- a/src/gui/kernel/qeventdispatcher_mac_p.h
+++ b/src/gui/kernel/qeventdispatcher_mac_p.h
@@ -176,7 +176,6 @@ public:
static bool currentExecIsNSAppRun;
static bool nsAppRunCalledByQt;
static bool cleanupModalSessionsNeeded;
- static bool modalSessionsTemporarilyStopped;
static NSModalSession currentModalSessionCached;
static NSModalSession currentModalSession();
static void updateChildrenWorksWhenModal();
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index b1e4c94..a05c7d5 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -882,7 +882,15 @@ void qt_mac_dispatchNCMouseMessage(void * /* NSWindow* */eventWindow, void * /*
}
}
- QMouseEvent qme(eventType, qlocalPoint, qglobalPoint, button, button, keyMods);
+ Qt::MouseButtons buttons = 0;
+ {
+ UInt32 mac_buttons;
+ if (GetEventParameter((EventRef)[event eventRef], kEventParamMouseChord, typeUInt32, 0,
+ sizeof(mac_buttons), 0, &mac_buttons) == noErr)
+ buttons = qt_mac_get_buttons(mac_buttons);
+ }
+
+ QMouseEvent qme(eventType, qlocalPoint, qglobalPoint, button, buttons, keyMods);
qt_sendSpontaneousEvent(widgetToGetEvent, &qme);
// We don't need to set the implicit grab widget here because we won't
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 3d86936..d7cd2eb 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -4267,6 +4267,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
QMacCocoaAutoReleasePool pool;
bool realWindow = isRealWindow();
+ BOOL needDisplay = realWindow ? YES : NO;
if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen)){
adjustWithinMaxAndMinSize(w, h);
@@ -4314,7 +4315,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
if (currTopLeft.x() == x && currTopLeft.y() == y
&& cocoaFrameRect.size.width != 0
&& cocoaFrameRect.size.height != 0) {
- [window setFrame:cocoaFrameRect display:NO];
+ [window setFrame:cocoaFrameRect display:needDisplay];
} else {
// The window is moved and resized (or resized to zero).
// Since Cocoa usually only sends us a resize callback after
@@ -4323,7 +4324,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
// would have the same origin as the setFrame call) we shift the
// window back and forth inbetween.
cocoaFrameRect.origin.y += 1;
- [window setFrame:cocoaFrameRect display:NO];
+ [window setFrame:cocoaFrameRect display:needDisplay];
cocoaFrameRect.origin.y -= 1;
[window setFrameOrigin:cocoaFrameRect.origin];
}
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index f5b17ea..acf765c 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -69,6 +69,13 @@
QT_BEGIN_NAMESPACE
+#if defined(Q_OS_MAC) && (defined(__ppc__) || defined(__ppc64__))
+#undef QT_HAVE_MMX
+#undef QT_HAVE_SSE
+#undef QT_HAVE_SSE2
+#undef QT_HAVE_3DNOW
+#endif
+
#if defined(Q_CC_MSVC) && _MSCVER <= 1300 && !defined(Q_CC_INTEL)
#define Q_STATIC_TEMPLATE_SPECIALIZATION static
#else
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 302a349..e2bca04 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -870,6 +870,7 @@ int QTextDocumentPrivate::undoRedo(bool undo)
undoEnabled = false;
beginEditBlock();
int editPos = -1;
+ int editLength = -1;
while (1) {
if (undo)
--undoState;
@@ -882,12 +883,16 @@ int QTextDocumentPrivate::undoRedo(bool undo)
PMDEBUG(" erase: from %d, length %d", c.pos, c.length);
c.command = QTextUndoCommand::Removed;
editPos = c.pos;
+ editLength = 0;
break;
case QTextUndoCommand::Removed:
PMDEBUG(" insert: format %d (from %d, length %d, strpos=%d)", c.format, c.pos, c.length, c.strPos);
insert_string(c.pos, c.strPos, c.length, c.format, (QTextUndoCommand::Operation)c.operation);
c.command = QTextUndoCommand::Inserted;
- editPos = c.pos + c.length;
+ if (editPos != (int)c.pos)
+ editLength = 0;
+ editPos = c.pos;
+ editLength += c.length;
break;
case QTextUndoCommand::BlockInserted:
case QTextUndoCommand::BlockAdded:
@@ -898,6 +903,7 @@ int QTextDocumentPrivate::undoRedo(bool undo)
else
c.command = QTextUndoCommand::BlockDeleted;
editPos = c.pos;
+ editLength = 0;
break;
case QTextUndoCommand::BlockRemoved:
case QTextUndoCommand::BlockDeleted:
@@ -908,7 +914,10 @@ int QTextDocumentPrivate::undoRedo(bool undo)
c.command = QTextUndoCommand::BlockInserted;
else
c.command = QTextUndoCommand::BlockAdded;
- editPos = c.pos + 1;
+ if (editPos != (int)c.pos)
+ editLength = 0;
+ editPos = c.pos;
+ editLength += 1;
break;
case QTextUndoCommand::CharFormatChanged: {
resetBlockRevision = -1; // ## TODO
@@ -919,7 +928,10 @@ int QTextDocumentPrivate::undoRedo(bool undo)
int oldFormat = it.value()->format;
setCharFormat(c.pos, c.length, formats.charFormat(c.format));
c.format = oldFormat;
- editPos = c.pos + c.length;
+ if (editPos != (int)c.pos)
+ editLength = 0;
+ editPos = c.pos;
+ editLength += c.length;
break;
}
case QTextUndoCommand::BlockFormatChanged: {
@@ -987,13 +999,19 @@ int QTextDocumentPrivate::undoRedo(bool undo)
break;
}
undoEnabled = true;
- if (editPos < 0 && docChangeFrom >= 0) {
- editPos = qMin(docChangeFrom + docChangeLength, length() - 1);
- }
+
+ int newCursorPos = -1;
+
+ if (editPos >=0)
+ newCursorPos = editPos + editLength;
+ else if (docChangeFrom >= 0)
+ newCursorPos= qMin(docChangeFrom + docChangeLength, length() - 1);
+
endEditBlock();
emitUndoAvailable(isUndoAvailable());
emitRedoAvailable(isRedoAvailable());
- return editPos;
+
+ return newCursorPos;
}
/*!
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 9e190b7..f9b132e 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -1805,7 +1805,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;
}
@@ -1860,9 +1860,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;
@@ -1877,7 +1877,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);
}
@@ -1890,28 +1890,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) {
@@ -1925,14 +1925,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);
}
}
}
@@ -1941,19 +1941,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)) {
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index ef9fac3..2734fba 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -944,8 +944,8 @@ void QPlainTextEditPrivate::_q_adjustScrollbars()
int vSliderLength = 0;
if (!centerOnScroll && q->isVisible()) {
QTextBlock block = doc->lastBlock();
- const int visible = static_cast<int>(viewport->rect().height() - margin - 1);
- int y = 0;
+ const qreal visible = viewport->rect().height() - margin - 1;
+ qreal y = 0;
int visibleFromBottom = 0;
while (block.isValid()) {
@@ -953,7 +953,7 @@ void QPlainTextEditPrivate::_q_adjustScrollbars()
block = block.previous();
continue;
}
- y += int(documentLayout->blockBoundingRect(block).height());
+ y += documentLayout->blockBoundingRect(block).height();
QTextLayout *layout = block.layout();
int layoutLineCount = layout->lineCount();
@@ -962,7 +962,7 @@ void QPlainTextEditPrivate::_q_adjustScrollbars()
while (lineNumber < layoutLineCount) {
QTextLine line = layout->lineAt(lineNumber);
const QRectF lr = line.naturalTextRect();
- if (int(lr.top()) >= y - visible)
+ if (lr.top() >= y - visible)
break;
++lineNumber;
}