summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qapplication.cpp4
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm15
-rw-r--r--src/gui/kernel/qcursor_mac.mm10
-rw-r--r--src/gui/widgets/qlineedit.cpp9
4 files changed, 24 insertions, 14 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index b0a23d4..5f5e29f 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -186,11 +186,9 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T
gestureManager = 0;
gestureWidget = 0;
-#if defined(Q_WS_X11) || defined(Q_WS_WIN)
move_cursor = 0;
copy_cursor = 0;
link_cursor = 0;
-#endif
#if defined(Q_WS_WIN)
ignore_cursor = 0;
#endif
@@ -1045,11 +1043,9 @@ QApplication::~QApplication()
qt_clipboard = 0;
#endif
-#if defined(Q_WS_X11) || defined(Q_WS_WIN)
delete d->move_cursor; d->move_cursor = 0;
delete d->copy_cursor; d->copy_cursor = 0;
delete d->link_cursor; d->link_cursor = 0;
-#endif
#if defined(Q_WS_WIN)
delete d->ignore_cursor; d->ignore_cursor = 0;
#endif
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 9c5380b..dd12f65 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -673,13 +673,14 @@ static int qCocoaViewCount = 0;
// 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);
- }
+ // This mouse move event should be sendt, even when mouse
+ // tracking is switched off (to trigger tooltips):
+ 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/qcursor_mac.mm b/src/gui/kernel/qcursor_mac.mm
index 03e38b0..c3d6c54 100644
--- a/src/gui/kernel/qcursor_mac.mm
+++ b/src/gui/kernel/qcursor_mac.mm
@@ -224,6 +224,15 @@ QPoint QCursor::pos()
void QCursor::setPos(int x, int y)
{
+#ifdef QT_MAC_USE_COCOA
+ CGPoint pos;
+ pos.x = x;
+ pos.y = y;
+
+ CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0);
+ CGEventPost(kCGHIDEventTap, e);
+ CFRelease(e);
+#else
CGWarpMouseCursorPosition(CGPointMake(x, y));
/* I'm not too keen on doing this, but this makes it a lot easier, so I just
@@ -240,6 +249,7 @@ void QCursor::setPos(int x, int y)
QApplication::mouseButtons(), QApplication::keyboardModifiers());
qt_sendSpontaneousEvent(widget, &me);
}
+#endif
}
void QCursorData::initCursorFromBitmap()
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 0b8dca9..655fc61 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1869,13 +1869,18 @@ void QLineEdit::paintEvent(QPaintEvent *)
}
QRect lineRect(r.x() + d->horizontalMargin, d->vscroll, r.width() - 2*d->horizontalMargin, fm.height());
+ int minLB = qMax(0, -fm.minLeftBearing());
+ int minRB = qMax(0, -fm.minRightBearing());
+
if (d->control->text().isEmpty()) {
if (!hasFocus() && !d->placeholderText.isEmpty()) {
QColor col = pal.text().color();
col.setAlpha(128);
QPen oldpen = p.pen();
p.setPen(col);
- p.drawText(lineRect, va, d->placeholderText);
+ lineRect.adjust(minLB, 0, 0, 0);
+ QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width());
+ p.drawText(lineRect, va, elidedText);
p.setPen(oldpen);
return;
}
@@ -1889,8 +1894,6 @@ void QLineEdit::paintEvent(QPaintEvent *)
// the below code handles all scrolling based on the textline (widthUsed,
// minLB, minRB), the line edit rect (lineRect) and the cursor position
// (cix).
- int minLB = qMax(0, -fm.minLeftBearing());
- int minRB = qMax(0, -fm.minRightBearing());
int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB;
if ((minLB + widthUsed) <= lineRect.width()) {
// text fits in lineRect; use hscroll for alignment