diff options
Diffstat (limited to 'src/widgets/util')
-rw-r--r-- | src/widgets/util/qcompleter.cpp | 31 | ||||
-rw-r--r-- | src/widgets/util/qcompleter.h | 6 | ||||
-rw-r--r-- | src/widgets/util/qflickgesture.cpp | 22 | ||||
-rw-r--r-- | src/widgets/util/qscroller.cpp | 12 | ||||
-rw-r--r-- | src/widgets/util/qscroller_mac.mm | 3 | ||||
-rw-r--r-- | src/widgets/util/qscroller_p.h | 3 | ||||
-rw-r--r-- | src/widgets/util/qsystemtrayicon.cpp | 8 | ||||
-rw-r--r-- | src/widgets/util/qsystemtrayicon.h | 4 | ||||
-rw-r--r-- | src/widgets/util/qsystemtrayicon_win.cpp | 2 | ||||
-rw-r--r-- | src/widgets/util/qsystemtrayicon_x11.cpp | 35 | ||||
-rw-r--r-- | src/widgets/util/qundogroup.h | 2 | ||||
-rw-r--r-- | src/widgets/util/qundostack.h | 6 | ||||
-rw-r--r-- | src/widgets/util/qundoview.h | 6 |
13 files changed, 60 insertions, 80 deletions
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index fedc928f61..4382abaf50 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -432,7 +432,7 @@ void QCompletionEngine::filter(const QStringList& parts) QModelIndex parent; for (int i = 0; i < curParts.count() - 1; i++) { - QString part = curParts[i]; + QString part = curParts.at(i); int emi = filter(part, parent, -1).exactMatchIndex; if (emi == -1) return; @@ -442,10 +442,10 @@ void QCompletionEngine::filter(const QStringList& parts) // Note that we set the curParent to a valid parent, even if we have no matches // When filtering is disabled, we show all the items under this parent curParent = parent; - if (curParts.last().isEmpty()) + if (curParts.constLast().isEmpty()) curMatch = QMatchData(QIndexMapper(0, model->rowCount(curParent) - 1), -1, false); else - curMatch = filter(curParts.last(), curParent, 1); // build at least one + curMatch = filter(curParts.constLast(), curParent, 1); // build at least one curRow = curMatch.isValid() ? 0 : -1; } @@ -1337,6 +1337,11 @@ bool QCompleter::eventFilter(QObject *o, QEvent *e) } // default implementation for keys not handled by the widget when popup is open + if (ke->matches(QKeySequence::Cancel)) { + d->popup->hide(); + return true; + } + switch (key) { #ifdef QT_KEYPAD_NAVIGATION case Qt::Key_Select: @@ -1357,7 +1362,6 @@ bool QCompleter::eventFilter(QObject *o, QEvent *e) break; case Qt::Key_Backtab: - case Qt::Key_Escape: d->popup->hide(); break; @@ -1816,26 +1820,23 @@ QStringList QCompleter::splitPath(const QString& path) const return QStringList(completionPrefix()); QString pathCopy = QDir::toNativeSeparators(path); - QString sep = QDir::separator(); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\")) return QStringList(pathCopy); - QString doubleSlash(QLatin1String("\\\\")); - if (pathCopy.startsWith(doubleSlash)) + const bool startsWithDoubleSlash = pathCopy.startsWith(QLatin1String("\\\\")); + if (startsWithDoubleSlash) pathCopy = pathCopy.mid(2); - else - doubleSlash.clear(); #endif - QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']')); - QStringList parts = pathCopy.split(re); + const QChar sep = QDir::separator(); + QStringList parts = pathCopy.split(sep); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) - if (!doubleSlash.isEmpty()) - parts[0].prepend(doubleSlash); + if (startsWithDoubleSlash) + parts[0].prepend(QLatin1String("\\\\")); #else - if (pathCopy[0] == sep[0]) // readd the "/" at the beginning as the split removed it - parts[0] = QDir::fromNativeSeparators(QString(sep[0])); + if (pathCopy[0] == sep) // readd the "/" at the beginning as the split removed it + parts[0] = QLatin1Char('/'); #endif return parts; diff --git a/src/widgets/util/qcompleter.h b/src/widgets/util/qcompleter.h index 22230fc39e..32ee6296ca 100644 --- a/src/widgets/util/qcompleter.h +++ b/src/widgets/util/qcompleter.h @@ -76,10 +76,10 @@ public: CaseInsensitivelySortedModel }; - QCompleter(QObject *parent = 0); - QCompleter(QAbstractItemModel *model, QObject *parent = 0); + QCompleter(QObject *parent = Q_NULLPTR); + QCompleter(QAbstractItemModel *model, QObject *parent = Q_NULLPTR); #ifndef QT_NO_STRINGLISTMODEL - QCompleter(const QStringList& completions, QObject *parent = 0); + QCompleter(const QStringList& completions, QObject *parent = Q_NULLPTR); #endif ~QCompleter(); diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp index 0e598717c8..c7e0861a0f 100644 --- a/src/widgets/util/qflickgesture.cpp +++ b/src/widgets/util/qflickgesture.cpp @@ -66,8 +66,8 @@ static QMouseEvent *copyMouseEvent(QEvent *e) case QEvent::MouseButtonRelease: case QEvent::MouseMove: { QMouseEvent *me = static_cast<QMouseEvent *>(e); - QMouseEvent *cme = new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers()); - QGuiApplicationPrivate::setMouseEventSource(cme, me->source()); + QMouseEvent *cme = new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), + me->button(), me->buttons(), me->modifiers(), me->source()); return cme; } #ifndef QT_NO_GRAPHICSVIEW @@ -78,8 +78,8 @@ static QMouseEvent *copyMouseEvent(QEvent *e) #if 1 QEvent::Type met = me->type() == QEvent::GraphicsSceneMousePress ? QEvent::MouseButtonPress : (me->type() == QEvent::GraphicsSceneMouseRelease ? QEvent::MouseButtonRelease : QEvent::MouseMove); - QMouseEvent *cme = new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers()); - QGuiApplicationPrivate::setMouseEventSource(cme, me->source()); + QMouseEvent *cme = new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(), + me->button(), me->buttons(), me->modifiers(), me->source()); return cme; #else QGraphicsSceneMouseEvent *copy = new QGraphicsSceneMouseEvent(me->type()); @@ -155,9 +155,9 @@ public: mouseTarget = QApplication::widgetAt(pressDelayEvent->globalPos()); mouseButton = pressDelayEvent->button(); mouseEventSource = pressDelayEvent->source(); - qFGDebug() << "QFG: consuming/delaying mouse press"; + qFGDebug("QFG: consuming/delaying mouse press"); } else { - qFGDebug() << "QFG: NOT consuming/delaying mouse press"; + qFGDebug("QFG: NOT consuming/delaying mouse press"); } e->setAccepted(true); } @@ -194,7 +194,7 @@ public: void scrollerWasIntercepted() { - qFGDebug() << "QFG: deleting delayed mouse press, since scroller was only intercepted"; + qFGDebug("QFG: deleting delayed mouse press, since scroller was only intercepted"); if (pressDelayEvent) { // we still haven't even sent the press, so just throw it away now if (pressDelayTimer) { @@ -210,7 +210,7 @@ public: { if (pressDelayEvent) { // we still haven't even sent the press, so just throw it away now - qFGDebug() << "QFG: deleting delayed mouse press, since scroller is active now"; + qFGDebug("QFG: deleting delayed mouse press, since scroller is active now"); if (pressDelayTimer) { killTimer(pressDelayTimer); pressDelayTimer = 0; @@ -240,8 +240,7 @@ public: qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget; QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, farFarAway, mouseButton, QApplication::mouseButtons() & ~mouseButton, - QApplication::keyboardModifiers()); - QGuiApplicationPrivate::setMouseEventSource(&re, mouseEventSource); + QApplication::keyboardModifiers(), mouseEventSource); sendMouseEvent(&re, RegrabMouseAfterwards); // don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release! } @@ -291,8 +290,7 @@ protected: if (me) { QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()), mouseTarget->topLevelWidget()->mapFromGlobal(me->globalPos()), me->screenPos(), - me->button(), me->buttons(), me->modifiers()); - QGuiApplicationPrivate::setMouseEventSource(©, me->source()); + me->button(), me->buttons(), me->modifiers(), me->source()); qt_sendSpontaneousEvent(mouseTarget, ©); } diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index de12983f21..38b104f9e9 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -976,7 +976,7 @@ bool QScroller::handleInput(Input input, const QPointF &position, qint64 timesta { Q_D(QScroller); - qScrollerDebug() << "QScroller::handleInput(" << input << ", " << d->stateName(d->state) << ", " << position << ", " << timestamp << ")"; + qScrollerDebug() << "QScroller::handleInput(" << input << ", " << d->stateName(d->state) << ", " << position << ", " << timestamp << ')'; struct statechange { State state; Input input; @@ -1296,7 +1296,7 @@ void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qreal lowerSnapPos = nextSnapPos(startPos, -1, orientation); qreal higherSnapPos = nextSnapPos(startPos, 1, orientation); - qScrollerDebug() << " Real Delta:" << lowerSnapPos <<"-"<<nextSnap <<"-"<<higherSnapPos; + qScrollerDebug() << " Real Delta:" << lowerSnapPos << '-' << nextSnap << '-' <<higherSnapPos; // - check if we can reach another snap point if (nextSnap > higherSnapPos || qIsNaN(higherSnapPos)) @@ -1668,7 +1668,7 @@ bool QScrollerPrivate::releaseWhileDragging(const QPointF &position, qint64 time void QScrollerPrivate::timerEventWhileScrolling() { - qScrollerDebug() << "QScroller::timerEventWhileScrolling()"; + qScrollerDebug("QScroller::timerEventWhileScrolling()"); setContentPositionHelperScrolling(); if (xSegments.isEmpty() && ySegments.isEmpty()) @@ -1703,7 +1703,7 @@ void QScrollerPrivate::setState(QScroller::State newstate) if (state == newstate) return; - qScrollerDebug() << q << "QScroller::setState(" << stateName(newstate) << ")"; + qScrollerDebug() << q << "QScroller::setState(" << stateName(newstate) << ')'; switch (newstate) { case QScroller::Inactive: @@ -1870,8 +1870,8 @@ void QScrollerPrivate::setContentPositionHelperScrolling() newPos.setY(nextSegmentPosition(ySegments, now, newPos.y())); // -- set the position and handle overshoot - qScrollerDebug() << "QScroller::setContentPositionHelperScrolling()"; - qScrollerDebug() << " --> overshoot:" << overshootPosition << "- new pos:" << newPos; + qScrollerDebug() << "QScroller::setContentPositionHelperScrolling()\n" + " --> overshoot:" << overshootPosition << "- new pos:" << newPos; QPointF newClampedPos = clampToRect(newPos, contentPosRange); diff --git a/src/widgets/util/qscroller_mac.mm b/src/widgets/util/qscroller_mac.mm index 9120c43075..07de07de52 100644 --- a/src/widgets/util/qscroller_mac.mm +++ b/src/widgets/util/qscroller_mac.mm @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE QPointF QScrollerPrivate::realDpi(int screen) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + QMacAutoReleasePool pool; NSArray *nsscreens = [NSScreen screens]; if (screen < 0 || screen >= int([nsscreens count])) @@ -59,7 +59,6 @@ QPointF QScrollerPrivate::realDpi(int screen) } else { return QPointF(); } - [pool release]; } QT_END_NAMESPACE diff --git a/src/widgets/util/qscroller_p.h b/src/widgets/util/qscroller_p.h index bb00c12905..d09f78d130 100644 --- a/src/widgets/util/qscroller_p.h +++ b/src/widgets/util/qscroller_p.h @@ -196,6 +196,9 @@ public: QScroller *q_ptr; }; +template <> +class QTypeInfo<QScrollerPrivate::ScrollSegment> + : public QTypeInfoMerger<QScrollerPrivate::ScrollSegment, QEasingCurve> {}; QT_END_NAMESPACE diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index df3c291840..ebb29211a4 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE \l{http://standards.freedesktop.org/systemtray-spec/systemtray-spec-0.2.html freedesktop.org} XEmbed system tray specification. \li All X11 desktop environments that implement the D-Bus - \l{http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/ StatusNotifierItem} + \l{http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierItem} specification, including recent versions of KDE and Unity. \li All supported versions of OS X. Note that the Growl notification system must be installed for @@ -284,12 +284,6 @@ bool QSystemTrayIcon::isVisible() const */ bool QSystemTrayIcon::event(QEvent *e) { -#if defined(Q_DEAD_CODE_FROM_QT4_X11) - if (e->type() == QEvent::ToolTip) { - Q_D(QSystemTrayIcon); - return d->sys->deliverToolTipEvent(e); - } -#endif return QObject::event(e); } diff --git a/src/widgets/util/qsystemtrayicon.h b/src/widgets/util/qsystemtrayicon.h index a4da0861e9..aba126b4fc 100644 --- a/src/widgets/util/qsystemtrayicon.h +++ b/src/widgets/util/qsystemtrayicon.h @@ -59,8 +59,8 @@ class Q_WIDGETS_EXPORT QSystemTrayIcon : public QObject Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false) public: - QSystemTrayIcon(QObject *parent = 0); - QSystemTrayIcon(const QIcon &icon, QObject *parent = 0); + QSystemTrayIcon(QObject *parent = Q_NULLPTR); + QSystemTrayIcon(const QIcon &icon, QObject *parent = Q_NULLPTR); ~QSystemTrayIcon(); enum ActivationReason { diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp index 1809c36483..f1b86ba2df 100644 --- a/src/widgets/util/qsystemtrayicon_win.cpp +++ b/src/widgets/util/qsystemtrayicon_win.cpp @@ -395,7 +395,7 @@ void QSystemTrayIconPrivate::install_sys() sys->createIcon(); sys->trayMessage(NIM_ADD); } else { - qWarning("%s: The platform plugin failed to create a message window.", Q_FUNC_INFO); + qWarning("The platform plugin failed to create a message window."); } } } diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index 4060655d45..02bab236c8 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -52,6 +52,8 @@ #include <private/qguiapplication_p.h> #include <qdebug.h> +#include <QtPlatformHeaders/qxcbwindowfunctions.h> +#include <QtPlatformHeaders/qxcbintegrationfunctions.h> #ifndef QT_NO_SYSTEMTRAYICON QT_BEGIN_NAMESPACE @@ -112,17 +114,11 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn) // window to ParentRelative (so that it inherits the background of its X11 parent window), call // xcb_clear_region before painting (so that the inherited background is visible) and then grab // the just-drawn background from the X11 server. - bool hasAlphaChannel = false; - QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), - "systrayVisualHasAlphaChannel", Qt::DirectConnection, - Q_RETURN_ARG(bool, hasAlphaChannel)); + bool hasAlphaChannel = QXcbIntegrationFunctions::xEmbedSystemTrayVisualHasAlphaChannel(); setAttribute(Qt::WA_TranslucentBackground, hasAlphaChannel); if (!hasAlphaChannel) { createWinId(); - QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), - "setParentRelativeBackPixmap", Qt::DirectConnection, - Q_ARG(const QWindow *, windowHandle()) - ); + QXcbWindowFunctions::setParentRelativeBackPixmap(windowHandle()); // XXX: This is actually required, but breaks things ("QWidget::paintEngine: Should no // longer be called"). Why is this needed? When the widget is drawn, we use tricks to grab @@ -143,15 +139,9 @@ bool QSystemTrayIconSys::addToTray() createWinId(); setMouseTracking(true); - bool requestResult = false; - if (!QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), - "requestSystemTrayWindowDock", Qt::DirectConnection, - Q_RETURN_ARG(bool, requestResult), - Q_ARG(const QWindow *, windowHandle())) - || !requestResult) { - qWarning("requestSystemTrayWindowDock failed."); + if (!QXcbWindowFunctions::requestSystemTrayWindowDock(windowHandle())) return false; - } + if (!background.isNull()) background = QPixmap(); show(); @@ -171,15 +161,7 @@ void QSystemTrayIconSys::systemTrayWindowChanged(QScreen *) QRect QSystemTrayIconSys::globalGeometry() const { - QRect result; - if (!QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), - "systemTrayWindowGlobalGeometry", Qt::DirectConnection, - Q_RETURN_ARG(QRect, result), - Q_ARG(const QWindow *, windowHandle())) - || !result.isValid()) { - qWarning("systemTrayWindowGlobalGeometry failed."); - } - return result; + return QXcbWindowFunctions::systemTrayWindowGlobalGeometry(windowHandle()); } void QSystemTrayIconSys::mousePressEvent(QMouseEvent *ev) @@ -212,6 +194,9 @@ void QSystemTrayIconSys::mouseDoubleClickEvent(QMouseEvent *ev) bool QSystemTrayIconSys::event(QEvent *e) { switch (e->type()) { + case QEvent::ToolTip: + QApplication::sendEvent(q, e); + break; #ifndef QT_NO_WHEELEVENT case QEvent::Wheel: return QApplication::sendEvent(q, e); diff --git a/src/widgets/util/qundogroup.h b/src/widgets/util/qundogroup.h index ea4b226a18..ec6e67f4d3 100644 --- a/src/widgets/util/qundogroup.h +++ b/src/widgets/util/qundogroup.h @@ -52,7 +52,7 @@ class Q_WIDGETS_EXPORT QUndoGroup : public QObject Q_DECLARE_PRIVATE(QUndoGroup) public: - explicit QUndoGroup(QObject *parent = 0); + explicit QUndoGroup(QObject *parent = Q_NULLPTR); ~QUndoGroup(); void addStack(QUndoStack *stack); diff --git a/src/widgets/util/qundostack.h b/src/widgets/util/qundostack.h index f6589da4ec..0b14a442c2 100644 --- a/src/widgets/util/qundostack.h +++ b/src/widgets/util/qundostack.h @@ -51,8 +51,8 @@ class Q_WIDGETS_EXPORT QUndoCommand QUndoCommandPrivate *d; public: - explicit QUndoCommand(QUndoCommand *parent = 0); - explicit QUndoCommand(const QString &text, QUndoCommand *parent = 0); + explicit QUndoCommand(QUndoCommand *parent = Q_NULLPTR); + explicit QUndoCommand(const QString &text, QUndoCommand *parent = Q_NULLPTR); virtual ~QUndoCommand(); virtual void undo(); @@ -85,7 +85,7 @@ class Q_WIDGETS_EXPORT QUndoStack : public QObject Q_PROPERTY(int undoLimit READ undoLimit WRITE setUndoLimit) public: - explicit QUndoStack(QObject *parent = 0); + explicit QUndoStack(QObject *parent = Q_NULLPTR); ~QUndoStack(); void clear(); diff --git a/src/widgets/util/qundoview.h b/src/widgets/util/qundoview.h index a239d9b38e..2a15207ca5 100644 --- a/src/widgets/util/qundoview.h +++ b/src/widgets/util/qundoview.h @@ -55,10 +55,10 @@ class Q_WIDGETS_EXPORT QUndoView : public QListView Q_PROPERTY(QIcon cleanIcon READ cleanIcon WRITE setCleanIcon) public: - explicit QUndoView(QWidget *parent = 0); - explicit QUndoView(QUndoStack *stack, QWidget *parent = 0); + explicit QUndoView(QWidget *parent = Q_NULLPTR); + explicit QUndoView(QUndoStack *stack, QWidget *parent = Q_NULLPTR); #ifndef QT_NO_UNDOGROUP - explicit QUndoView(QUndoGroup *group, QWidget *parent = 0); + explicit QUndoView(QUndoGroup *group, QWidget *parent = Q_NULLPTR); #endif ~QUndoView(); |