diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-06-03 10:23:56 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-06-03 10:23:56 +0200 |
commit | e2f66f921594b7be4af4a058c959557489e86879 (patch) | |
tree | cc44931708b57bd5a761906797c7dee0360d1d6b /src/widgets | |
parent | 933bf178aab88ab5df8a68cbf02611d6d8744b1b (diff) | |
parent | 754efa57d89c62d1796e01b407e9222e67450f52 (diff) |
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
src/corelib/global/qnamespace.qdoc
src/corelib/io/qwindowspipereader.cpp
src/corelib/io/qwindowspipereader_p.h
src/corelib/statemachine/qstatemachine.cpp
src/corelib/statemachine/qstatemachine_p.h
src/plugins/platforms/xcb/qxcbconnection.h
tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
tests/auto/tools/qmake/tst_qmake.cpp
tests/manual/touch/main.cpp
Change-Id: I917d694890e79ee3da7d65134b5b085e23e0dd62
Diffstat (limited to 'src/widgets')
39 files changed, 337 insertions, 213 deletions
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 65def6d4b8..6676a3ccba 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -534,7 +534,10 @@ int QDialog::exec() QPointer<QDialog> guard = this; if (d->nativeDialogInUse) { - d->platformHelper()->exec(); + if (windowModality() == Qt::WindowModal) + d->platformHelper()->execModalForWindow(d->parentWindow()); + else + d->platformHelper()->exec(); } else { QEventLoop eventLoop; d->eventLoop = &eventLoop; diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 1be2f93478..41522bfa19 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -893,6 +893,12 @@ void QFileDialogPrivate::_q_goToUrl(const QUrl &url) /*! Sets the file dialog's current \a directory. + + \note On iOS, if you set \a directory to \l{QStandardPaths::standardLocations()} + {QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last()}, + a native image picker dialog will be used for accessing the user's photo album. + The filename returned can be loaded using QFile and related APIs. + This feature was added in Qt 5.5. */ void QFileDialog::setDirectory(const QString &directory) { diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp index df07de7975..7329019a87 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/widgets/dialogs/qfileinfogatherer.cpp @@ -185,6 +185,8 @@ void QFileInfoGatherer::removePath(const QString &path) #ifndef QT_NO_FILESYSTEMWATCHER QMutexLocker locker(&mutex); watcher->removePath(path); +#else + Q_UNUSED(path); #endif } diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 04238f242a..4859231d95 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -544,7 +544,7 @@ QModelIndex QFileSystemModel::parent(const QModelIndex &index) const QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(index); Q_ASSERT(indexNode != 0); - QFileSystemModelPrivate::QFileSystemNode *parentNode = (indexNode ? indexNode->parent : 0); + QFileSystemModelPrivate::QFileSystemNode *parentNode = indexNode->parent; if (parentNode == 0 || parentNode == &d->root) return QModelIndex(); @@ -653,10 +653,12 @@ int QFileSystemModel::columnCount(const QModelIndex &parent) const */ QVariant QFileSystemModel::myComputer(int role) const { +#ifndef QT_NO_FILESYSTEMWATCHER Q_D(const QFileSystemModel); +#endif switch (role) { case Qt::DisplayRole: - return d->myComputer(); + return QFileSystemModelPrivate::myComputer(); #ifndef QT_NO_FILESYSTEMWATCHER case Qt::DecorationRole: return d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer); diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 701fea1c03..a4b37f360b 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -361,6 +361,36 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type) Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &); +static LOGFONT getCaptionLogFont(HANDLE hTheme) +{ + LOGFONT result = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } }; + + if (!hTheme || FAILED(pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &result))) { + NONCLIENTMETRICS ncm; + ncm.cbSize = sizeof(NONCLIENTMETRICS); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false); + result = ncm.lfMessageFont; + } + return result; +} + +static bool getCaptionQFont(int dpi, QFont *result) +{ + if (!pOpenThemeData) + return false; + const HANDLE hTheme = + pOpenThemeData(QApplicationPrivate::getHWNDForWidget(QApplication::desktop()), L"WINDOW"); + if (!hTheme) + return false; + // Call into QWindowsNativeInterface to convert the LOGFONT into a QFont. + const LOGFONT logFont = getCaptionLogFont(hTheme); + QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface(); + return ni && QMetaObject::invokeMethod(ni, "logFontToQFont", Qt::DirectConnection, + Q_RETURN_ARG(QFont, *result), + Q_ARG(const void *, &logFont), + Q_ARG(int, dpi)); +} + void QVistaHelper::drawTitleBar(QPainter *painter) { Q_ASSERT(backButton_); @@ -378,7 +408,9 @@ void QVistaHelper::drawTitleBar(QPainter *painter) const int verticalCenter = (btnTop + btnHeight / 2) - 1; const QString text = wizard->window()->windowTitle(); - const QFont font = QApplication::font("QMdiSubWindowTitleBar"); + QFont font; + if (!isWindow || !getCaptionQFont(wizard->logicalDpiY() * wizard->devicePixelRatio(), &font)) + font = QApplication::font("QMdiSubWindowTitleBar"); const QFontMetrics fontMetrics(font); const QRect brect = fontMetrics.boundingRect(text); int textHeight = brect.height(); @@ -649,19 +681,6 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event) return false; } -HFONT QVistaHelper::getCaptionFont(HANDLE hTheme) -{ - LOGFONT lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } }; - - if (!hTheme || FAILED(pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &lf))) { - NONCLIENTMETRICS ncm; - ncm.cbSize = sizeof(NONCLIENTMETRICS); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false); - lf = ncm.lfMessageFont; - } - return CreateFontIndirect(&lf); -} - // Return a HDC for the wizard along with the transformation if the // wizard is a child window. HDC QVistaHelper::backingStoreDC(const QWidget *wizard, QPoint *offset) @@ -713,7 +732,8 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0); // Set up the DC - HFONT hCaptionFont = getCaptionFont(hTheme); + const LOGFONT captionLogFont = getCaptionLogFont(hTheme); + const HFONT hCaptionFont = CreateFontIndirect(&captionLogFont); HBITMAP hOldBmp = (HBITMAP)SelectObject(dcMem, (HGDIOBJ) bmp); HFONT hOldFont = (HFONT)SelectObject(dcMem, (HGDIOBJ) hCaptionFont); diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h index 8c36472bee..84b795d506 100644 --- a/src/widgets/dialogs/qwizard_win_p.h +++ b/src/widgets/dialogs/qwizard_win_p.h @@ -105,7 +105,6 @@ public: static HDC backingStoreDC(const QWidget *wizard, QPoint *offset); private: - static HFONT getCaptionFont(HANDLE hTheme); HWND wizardHWND() const; bool drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc); static bool drawBlackRect(const QRect &rect, HDC hdc); diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h index b025730bb1..68382bf498 100644 --- a/src/widgets/graphicsview/qgraphicsscene.h +++ b/src/widgets/graphicsview/qgraphicsscene.h @@ -282,6 +282,10 @@ protected: QWidget *widget = 0); protected Q_SLOTS: + // ### Qt 6: make unconditional +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + virtual +#endif bool focusNextPrevChild(bool next); Q_SIGNALS: diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index 402d54d2d8..e9ab6dffec 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -64,9 +64,7 @@ void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFl adjustWindowFlags(&wFlags); windowFlags = wFlags; - if (parentItem) - setParentItemHelper(parentItem, 0, 0); - + q->setParentItem(parentItem); q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::DefaultType)); q->setGraphicsItem(q); diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index b792228312..016c50436b 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -168,8 +168,20 @@ public: QModelIndex index; int col = -1; int row = -1; + const QMimeData *mime = event->mimeData(); + + // Drag enter event shall always be accepted, if mime type and action match. + // Whether the data can actually be dropped will be checked in drag move. + if (event->type() == QEvent::DragEnter) { + const QStringList modelTypes = model->mimeTypes(); + for (int i = 0; i < modelTypes.count(); ++i) + if (mime->hasFormat(modelTypes.at(i)) + && (event->dropAction() & model->supportedDropActions())) + return true; + } + if (dropOn(event, &row, &col, &index)) { - return model->canDropMimeData(event->mimeData(), + return model->canDropMimeData(mime, dragDropMode == QAbstractItemView::InternalMove ? Qt::MoveAction : event->dropAction(), row, col, index); } diff --git a/src/widgets/itemviews/qcolumnview_p.h b/src/widgets/itemviews/qcolumnview_p.h index ed30b5f085..0c0bdb5d1f 100644 --- a/src/widgets/itemviews/qcolumnview_p.h +++ b/src/widgets/itemviews/qcolumnview_p.h @@ -89,6 +89,16 @@ public: QAbstractScrollArea::resizeEvent(event); } + void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE + { + if (!previewWidget) + return; + scrollDirtyRegion(dx, dy); + viewport()->scroll(dx, dy); + + QAbstractItemView::scrollContentsBy(dx, dy); + } + QRect visualRect(const QModelIndex &) const Q_DECL_OVERRIDE { return QRect(); diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 66ff472724..bca315f80b 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -1879,13 +1879,13 @@ void QHeaderView::sectionsInserted(const QModelIndex &parent, // insert sections into hiddenSectionSize QHash<int, int> newHiddenSectionSize; // from logical index to section size - for (int i = 0; i < logicalFirst; ++i) - if (isSectionHidden(i)) - newHiddenSectionSize[i] = d->hiddenSectionSize[i]; - for (int j = logicalLast + 1; j < d->sectionCount(); ++j) - if (isSectionHidden(j)) - newHiddenSectionSize[j] = d->hiddenSectionSize[j - insertCount]; - d->hiddenSectionSize = newHiddenSectionSize; + for (QHash<int, int>::const_iterator it = d->hiddenSectionSize.cbegin(), + end = d->hiddenSectionSize.cend(); it != end; ++it) { + const int oldIndex = it.key(); + const int newIndex = (oldIndex < logicalFirst) ? oldIndex : oldIndex + insertCount; + newHiddenSectionSize[newIndex] = it.value(); + } + d->hiddenSectionSize.swap(newHiddenSectionSize); d->doDelayedResizeSections(); emit sectionCountChanged(oldCount, count()); diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 29a6629bcd..9b07564db9 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -1877,8 +1877,17 @@ void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step) const bool bothScrollBarsAuto = qq->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded && qq->horizontalScrollBarPolicy() == Qt::ScrollBarAsNeeded; - if (bothScrollBarsAuto && contentsSize.width() - qq->verticalScrollBar()->width() <= viewport()->width() - && contentsSize.height() - qq->horizontalScrollBar()->height() <= viewport()->height()) { + const QSize viewportSize(viewport()->width() + (qq->verticalScrollBar()->maximum() > 0 ? qq->verticalScrollBar()->width() : 0), + viewport()->height() + (qq->horizontalScrollBar()->maximum() > 0 ? qq->horizontalScrollBar()->height() : 0)); + + bool verticalWantsToShow = contentsSize.height() > viewportSize.height(); + bool horizontalWantsToShow; + if (verticalWantsToShow) + horizontalWantsToShow = contentsSize.width() > viewportSize.width() - qq->verticalScrollBar()->width(); + else + horizontalWantsToShow = contentsSize.width() > viewportSize.width(); + + if (bothScrollBarsAuto && !horizontalWantsToShow) { // break the infinite loop described above by setting the range to 0, 0. // QAbstractScrollArea will then hide the scroll bar for us horizontalScrollBar()->setRange(0, 0); @@ -1899,8 +1908,17 @@ void QCommonListViewBase::updateVerticalScrollBar(const QSize &step) const bool bothScrollBarsAuto = qq->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded && qq->horizontalScrollBarPolicy() == Qt::ScrollBarAsNeeded; - if (bothScrollBarsAuto && contentsSize.width() - qq->verticalScrollBar()->width() <= viewport()->width() - && contentsSize.height() - qq->horizontalScrollBar()->height() <= viewport()->height()) { + const QSize viewportSize(viewport()->width() + (qq->verticalScrollBar()->maximum() > 0 ? qq->verticalScrollBar()->width() : 0), + viewport()->height() + (qq->horizontalScrollBar()->maximum() > 0 ? qq->horizontalScrollBar()->height() : 0)); + + bool horizontalWantsToShow = contentsSize.width() > viewportSize.width(); + bool verticalWantsToShow; + if (horizontalWantsToShow) + verticalWantsToShow = contentsSize.height() > viewportSize.height() - qq->horizontalScrollBar()->height(); + else + verticalWantsToShow = contentsSize.height() > viewportSize.height(); + + if (bothScrollBarsAuto && !verticalWantsToShow) { // break the infinite loop described above by setting the range to 0, 0. // QAbstractScrollArea will then hide the scroll bar for us verticalScrollBar()->setRange(0, 0); diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 43db43fcd4..9b3e270fdd 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -3658,6 +3658,7 @@ void QTreeViewPrivate::updateScrollBars() if (!viewportSize.isValid()) viewportSize = QSize(0, 0); + executePostedLayout(); if (viewItems.isEmpty()) { q->doItemsLayout(); } diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri index 88c1e2595b..21a982f349 100644 --- a/src/widgets/kernel/kernel.pri +++ b/src/widgets/kernel/kernel.pri @@ -49,6 +49,7 @@ SOURCES += \ kernel/qlayoutengine.cpp \ kernel/qlayoutitem.cpp \ kernel/qshortcut.cpp \ + kernel/qsizepolicy.cpp \ kernel/qstackedlayout.cpp \ kernel/qtooltip.cpp \ kernel/qwhatsthis.cpp \ diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 401fb47dc8..f457993168 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -4272,15 +4272,16 @@ void QApplicationPrivate::cleanupMultitouch_sys() { } -QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos) +QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QTouchEvent::TouchPoint &touchPoint) { + const QPointF screenPos = touchPoint.screenPos(); int closestTouchPointId = -1; QObject *closestTarget = 0; qreal closestDistance = qreal(0.); QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it = activeTouchPoints.constBegin(), ite = activeTouchPoints.constEnd(); while (it != ite) { - if (it.key().device == device) { + if (it.key().device == device && it.key().touchPointId != touchPoint.id()) { const QTouchEvent::TouchPoint &touchPoint = it->touchPoint; qreal dx = screenPos.x() - touchPoint.screenPos().x(); qreal dy = screenPos.y() - touchPoint.screenPos().y(); @@ -4336,7 +4337,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, } if (device->type() == QTouchDevice::TouchScreen) { - QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint.screenPos()); + QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint); QWidget *widget = static_cast<QWidget *>(target.data()); if (closestWidget && (widget->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget))) { @@ -4356,8 +4357,10 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, #ifdef Q_OS_OSX // Single-touch events are normally not sent unless WA_TouchPadAcceptSingleTouchEvents is set. - // In Qt 4 this check was in OS X-only coode. That behavior is preserved here by the #ifdef. - if (touchPoints.count() == 1 && !targetWidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents)) + // In Qt 4 this check was in OS X-only code. That behavior is preserved here by the #ifdef. + if (touchPoints.count() == 1 + && device->type() == QTouchDevice::TouchPad + && !targetWidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents)) continue; #endif @@ -4373,7 +4376,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin(); const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd(); for (; it != end; ++it) { - QWidget *widget = it.key(); + const QPointer<QWidget> widget = it.key(); if (!QApplicationPrivate::tryModalHelper(widget, 0)) continue; @@ -4413,7 +4416,8 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, // has been implicitly accepted and continue to send touch events if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted()) { accepted = true; - widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent); + if (!widget.isNull()) + widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent); } break; } diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 46359d7940..ba8d7ff63c 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -280,7 +280,7 @@ public: void initializeMultitouch_sys(); void cleanupMultitouch(); void cleanupMultitouch_sys(); - QWidget *findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos); + QWidget *findClosestTouchPointTarget(QTouchDevice *device, const QTouchEvent::TouchPoint &touchPoint); void appendTouchPoint(const QTouchEvent::TouchPoint &touchPoint); void removeTouchPoint(int touchPointId); static bool translateRawTouchEvent(QWidget *widget, diff --git a/src/widgets/kernel/qgesture.cpp b/src/widgets/kernel/qgesture.cpp index 713a019cc3..7b7d465070 100644 --- a/src/widgets/kernel/qgesture.cpp +++ b/src/widgets/kernel/qgesture.cpp @@ -36,7 +36,7 @@ #include "private/qstandardgestures_p.h" #include "qgraphicsview.h" -#include <QtCore/QDebug> +#include <private/qdebug_p.h> #ifndef QT_NO_GESTURES QT_BEGIN_NAMESPACE @@ -1091,9 +1091,12 @@ QPointF QGestureEvent::mapToGraphicsScene(const QPointF &gesturePoint) const static void formatGestureHeader(QDebug d, const char *className, const QGesture *gesture) { - d << className << "(state=" << gesture->state(); - if (gesture->hasHotSpot()) - d << ",hotSpot=" << gesture->hotSpot(); + d << className << "(state="; + QtDebugUtils::formatQEnum(d, gesture->state()); + if (gesture->hasHotSpot()) { + d << ",hotSpot="; + QtDebugUtils::formatQPoint(d, gesture->hotSpot()); + } } Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGesture *gesture) @@ -1103,31 +1106,42 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGesture *gesture) switch (gesture->gestureType()) { case Qt::TapGesture: formatGestureHeader(d, "QTapGesture", gesture); - d << ",position=" << static_cast<const QTapGesture*>(gesture)->position() << ')'; + d << ",position="; + QtDebugUtils::formatQPoint(d, static_cast<const QTapGesture*>(gesture)->position()); + d << ')'; break; case Qt::TapAndHoldGesture: { const QTapAndHoldGesture *tap = static_cast<const QTapAndHoldGesture*>(gesture); formatGestureHeader(d, "QTapAndHoldGesture", tap); - d << ",position=" << tap->position() << ",timeout=" << tap->timeout() << ')'; + d << ",position="; + QtDebugUtils::formatQPoint(d, tap->position()); + d << ",timeout=" << tap->timeout() << ')'; } break; case Qt::PanGesture: { const QPanGesture *pan = static_cast<const QPanGesture*>(gesture); formatGestureHeader(d, "QPanGesture", pan); - d << ",lastOffset=" << pan->lastOffset() << ",offset=" << pan->offset() - << ",acceleration=" << pan->acceleration() - << ",delta=" << pan->delta() << ')'; + d << ",lastOffset="; + QtDebugUtils::formatQPoint(d, pan->lastOffset()); + d << pan->lastOffset(); + d << ",offset="; + QtDebugUtils::formatQPoint(d, pan->offset()); + d << ",acceleration=" << pan->acceleration() << ",delta="; + QtDebugUtils::formatQPoint(d, pan->delta()); + d << ')'; } break; case Qt::PinchGesture: { const QPinchGesture *pinch = static_cast<const QPinchGesture*>(gesture); formatGestureHeader(d, "QPinchGesture", pinch); d << ",totalChangeFlags=" << pinch->totalChangeFlags() - << ",changeFlags=" << pinch->changeFlags() - << ",startCenterPoint=" << pinch->startCenterPoint() - << ",lastCenterPoint=" << pinch->lastCenterPoint() - << ",centerPoint=" << pinch->centerPoint() - << ",totalScaleFactor=" << pinch->totalScaleFactor() + << ",changeFlags=" << pinch->changeFlags() << ",startCenterPoint="; + QtDebugUtils::formatQPoint(d, pinch->startCenterPoint()); + d << ",lastCenterPoint="; + QtDebugUtils::formatQPoint(d, pinch->lastCenterPoint()); + d << ",centerPoint="; + QtDebugUtils::formatQPoint(d, pinch->centerPoint()); + d << ",totalScaleFactor=" << pinch->totalScaleFactor() << ",lastScaleFactor=" << pinch->lastScaleFactor() << ",scaleFactor=" << pinch->scaleFactor() << ",totalRotationAngle=" << pinch->totalRotationAngle() @@ -1138,9 +1152,11 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGesture *gesture) case Qt::SwipeGesture: { const QSwipeGesture *swipe = static_cast<const QSwipeGesture*>(gesture); formatGestureHeader(d, "QSwipeGesture", swipe); - d << ",horizontalDirection=" << swipe->horizontalDirection() - << ",verticalDirection=" << swipe->verticalDirection() - << ",swipeAngle=" << swipe->swipeAngle() << ')'; + d << ",horizontalDirection="; + QtDebugUtils::formatQEnum(d, swipe->horizontalDirection()); + d << ",verticalDirection="; + QtDebugUtils::formatQEnum(d, swipe->verticalDirection()); + d << ",swipeAngle=" << swipe->swipeAngle() << ')'; } break; default: diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index dcacea4777..e74f17b6f7 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -1470,85 +1470,4 @@ QSize QLayout::closestAcceptableSize(const QWidget *widget, const QSize &size) return result; } -void QSizePolicy::setControlType(ControlType type) -{ - /* - The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10, - etc. In memory, we pack it onto the available bits (CTSize) in - setControlType(), and unpack it here. - - Example: - - 0x00000001 maps to 0 - 0x00000002 maps to 1 - 0x00000004 maps to 2 - 0x00000008 maps to 3 - etc. - */ - - int i = 0; - while (true) { - if (type & (0x1 << i)) { - bits.ctype = i; - return; - } - ++i; - } -} - -QSizePolicy::ControlType QSizePolicy::controlType() const -{ - return QSizePolicy::ControlType(1 << bits.ctype); -} - -#ifndef QT_NO_DATASTREAM - -/*! - \relates QSizePolicy - \since 4.2 - - Writes the size \a policy to the data stream \a stream. - - \sa{Serializing Qt Data Types}{Format of the QDataStream operators} -*/ -QDataStream &operator<<(QDataStream &stream, const QSizePolicy &policy) -{ - // The order here is for historical reasons. (compatibility with Qt4) - quint32 data = (policy.bits.horPolicy | // [0, 3] - policy.bits.verPolicy << 4 | // [4, 7] - policy.bits.hfw << 8 | // [8] - policy.bits.ctype << 9 | // [9, 13] - policy.bits.wfh << 14 | // [14] - policy.bits.retainSizeWhenHidden << 15 | // [15] - policy.bits.verStretch << 16 | // [16, 23] - policy.bits.horStretch << 24); // [24, 31] - return stream << data; -} - -#define VALUE_OF_BITS(data, bitstart, bitcount) ((data >> bitstart) & ((1 << bitcount) -1)) - -/*! - \relates QSizePolicy - \since 4.2 - - Reads the size \a policy from the data stream \a stream. - - \sa{Serializing Qt Data Types}{Format of the QDataStream operators} -*/ -QDataStream &operator>>(QDataStream &stream, QSizePolicy &policy) -{ - quint32 data; - stream >> data; - policy.bits.horPolicy = VALUE_OF_BITS(data, 0, 4); - policy.bits.verPolicy = VALUE_OF_BITS(data, 4, 4); - policy.bits.hfw = VALUE_OF_BITS(data, 8, 1); - policy.bits.ctype = VALUE_OF_BITS(data, 9, 5); - policy.bits.wfh = VALUE_OF_BITS(data, 14, 1); - policy.bits.retainSizeWhenHidden = VALUE_OF_BITS(data, 15, 1); - policy.bits.verStretch = VALUE_OF_BITS(data, 16, 8); - policy.bits.horStretch = VALUE_OF_BITS(data, 24, 8); - return stream; -} -#endif // QT_NO_DATASTREAM - QT_END_NAMESPACE diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index b21925e1d4..21f4c9a221 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -34,7 +34,6 @@ #include "qlayout.h" #include "qapplication.h" -#include "qdebug.h" #include "qlayoutengine_p.h" #include "qmenubar.h" #include "qtoolbar.h" @@ -68,14 +67,6 @@ inline static QSize toLayoutItemSize(QWidgetPrivate *priv, const QSize &size) } /*! - Returns a QVariant storing this QSizePolicy. -*/ -QSizePolicy::operator QVariant() const -{ - return QVariant(QVariant::SizePolicy, this); -} - -/*! \class QLayoutItem \brief The QLayoutItem class provides an abstract item that a QLayout manipulates. @@ -847,14 +838,4 @@ int QWidgetItemV2::heightForWidth(int width) const return height; } -#ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QSizePolicy &p) -{ - QDebugStateSaver saver(dbg); - dbg.nospace() << "QSizePolicy(horizontalPolicy = " << p.horizontalPolicy() - << ", verticalPolicy = " << p.verticalPolicy() << ')'; - return dbg; -} -#endif - QT_END_NAMESPACE diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index d4d23604a3..9bfdc62e60 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -104,6 +104,12 @@ QT_BEGIN_NAMESPACE non-sharable. To overcome this issue, prefer using QSurfaceFormat::setDefaultFormat() instead of setFormat(). + \note Calling QSurfaceFormat::setDefaultFormat() before constructing + the QApplication instance is mandatory on some platforms (for example, + OS X) when an OpenGL core profile context is requested. This is to + ensure that resource sharing between contexts stays functional as all + internal contexts are created using the correct version and profile. + \section1 Painting Techniques As described above, subclass QOpenGLWidget to render pure 3D content in the @@ -739,6 +745,7 @@ void QOpenGLWidgetPrivate::initialize() QScopedPointer<QOpenGLContext> ctx(new QOpenGLContext); ctx->setShareContext(shareContext); ctx->setFormat(requestedFormat); + ctx->setScreen(shareContext->screen()); if (!ctx->create()) { qWarning("QOpenGLWidget: Failed to create context"); return; @@ -762,6 +769,7 @@ void QOpenGLWidgetPrivate::initialize() // in QQuickWidget, use a dedicated QOffscreenSurface. surface = new QOffscreenSurface; surface->setFormat(ctx->format()); + surface->setScreen(ctx->screen()); surface->create(); if (!ctx->makeCurrent(surface)) { diff --git a/src/widgets/kernel/qsizepolicy.qdoc b/src/widgets/kernel/qsizepolicy.cpp index e84412bc46..1476b4c5d7 100644 --- a/src/widgets/kernel/qsizepolicy.qdoc +++ b/src/widgets/kernel/qsizepolicy.cpp @@ -3,9 +3,9 @@ ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** -** This file is part of the documentation of the Qt Toolkit. +** This file is part of the QtWidgets module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:FDL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -14,17 +14,31 @@ ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "qsizepolicy.h" + +#include <qdatastream.h> +#include <qdebug.h> +#include <qvariant.h> + +QT_BEGIN_NAMESPACE + /*! \class QSizePolicy \brief The QSizePolicy class is a layout attribute describing horizontal @@ -207,15 +221,18 @@ */ /*! - \fn ControlType QSizePolicy::controlType() const \since 4.3 Returns the control type associated with the widget for which this size policy applies. */ +QSizePolicy::ControlType QSizePolicy::controlType() const +{ + return QSizePolicy::ControlType(1 << bits.ctype); +} + /*! - \fn void QSizePolicy::setControlType(ControlType type) \since 4.3 Sets the control type associated with the widget for which this @@ -230,6 +247,31 @@ \sa QStyle::layoutSpacing() */ +void QSizePolicy::setControlType(ControlType type) +{ + /* + The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10, + etc. In memory, we pack it onto the available bits (CTSize) in + setControlType(), and unpack it here. + + Example: + + 0x00000001 maps to 0 + 0x00000002 maps to 1 + 0x00000004 maps to 2 + 0x00000008 maps to 3 + etc. + */ + + int i = 0; + while (true) { + if (type & (0x1 << i)) { + bits.ctype = i; + return; + } + ++i; + } +} /*! \fn void QSizePolicy::setHeightForWidth(bool dependent) @@ -344,7 +386,8 @@ \fn void QSizePolicy::retainSizeWhenHidden() const \since 5.2 - Returns if the layout should retain the widgets size when it is hidden. This is by default false. + Returns whether the layout should retain the widget's size when it is hidden. + This is \c false by default. \sa setRetainSizeWhenHidden() */ @@ -353,8 +396,8 @@ \fn void QSizePolicy::setRetainSizeWhenHidden(bool retainSize) \since 5.2 - Set if a layout should retain the widgets size when it is hidden. - If \a retainSize is true the layout will not be changed by hiding the widget. + Sets whether a layout should retain the widget's size when it is hidden. + If \a retainSize is \c true, the layout will not be changed by hiding the widget. \sa retainSizeWhenHidden() */ @@ -385,3 +428,72 @@ \sa setControlType(), controlType() */ +/*! + Returns a QVariant storing this QSizePolicy. +*/ +QSizePolicy::operator QVariant() const +{ + return QVariant(QVariant::SizePolicy, this); +} + +#ifndef QT_NO_DATASTREAM + +/*! + \relates QSizePolicy + \since 4.2 + + Writes the size \a policy to the data stream \a stream. + + \sa{Serializing Qt Data Types}{Format of the QDataStream operators} +*/ +QDataStream &operator<<(QDataStream &stream, const QSizePolicy &policy) +{ + // The order here is for historical reasons. (compatibility with Qt4) + quint32 data = (policy.bits.horPolicy | // [0, 3] + policy.bits.verPolicy << 4 | // [4, 7] + policy.bits.hfw << 8 | // [8] + policy.bits.ctype << 9 | // [9, 13] + policy.bits.wfh << 14 | // [14] + policy.bits.retainSizeWhenHidden << 15 | // [15] + policy.bits.verStretch << 16 | // [16, 23] + policy.bits.horStretch << 24); // [24, 31] + return stream << data; +} + +#define VALUE_OF_BITS(data, bitstart, bitcount) ((data >> bitstart) & ((1 << bitcount) -1)) + +/*! + \relates QSizePolicy + \since 4.2 + + Reads the size \a policy from the data stream \a stream. + + \sa{Serializing Qt Data Types}{Format of the QDataStream operators} +*/ +QDataStream &operator>>(QDataStream &stream, QSizePolicy &policy) +{ + quint32 data; + stream >> data; + policy.bits.horPolicy = VALUE_OF_BITS(data, 0, 4); + policy.bits.verPolicy = VALUE_OF_BITS(data, 4, 4); + policy.bits.hfw = VALUE_OF_BITS(data, 8, 1); + policy.bits.ctype = VALUE_OF_BITS(data, 9, 5); + policy.bits.wfh = VALUE_OF_BITS(data, 14, 1); + policy.bits.retainSizeWhenHidden = VALUE_OF_BITS(data, 15, 1); + policy.bits.verStretch = VALUE_OF_BITS(data, 16, 8); + policy.bits.horStretch = VALUE_OF_BITS(data, 24, 8); + return stream; +} +#endif // QT_NO_DATASTREAM + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QSizePolicy &p) +{ + QDebugStateSaver saver(dbg); + dbg.nospace() << "QSizePolicy(horizontalPolicy = " << p.horizontalPolicy() + << ", verticalPolicy = " << p.verticalPolicy() << ')'; + return dbg; +} +#endif + +QT_END_NAMESPACE diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index 2376a2c644..6cd511f513 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -112,7 +112,7 @@ public: bool operator==(const QSizePolicy& s) const { return data == s.data; } bool operator!=(const QSizePolicy& s) const { return data != s.data; } - operator QVariant() const; // implemented in qlayoutitem.cpp + operator QVariant() const; int horizontalStretch() const { return static_cast<int>(bits.horStretch); } int verticalStretch() const { return static_cast<int>(bits.verStretch); } @@ -155,7 +155,6 @@ Q_DECLARE_TYPEINFO(QSizePolicy, Q_PRIMITIVE_TYPE); Q_DECLARE_OPERATORS_FOR_FLAGS(QSizePolicy::ControlTypes) #ifndef QT_NO_DATASTREAM -// implemented in qlayout.cpp Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &, const QSizePolicy &); Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &); #endif diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index b49fd9b3b6..b4943bbe05 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -4859,7 +4859,7 @@ void QWidget::unsetLayoutDirection() \fn QFontMetrics QWidget::fontMetrics() const Returns the font metrics for the widget's current font. - Equivalent to QFontMetrics(widget->font()). + Equivalent to \c QFontMetrics(widget->font()). \sa font(), fontInfo(), setFont() */ @@ -4868,7 +4868,7 @@ void QWidget::unsetLayoutDirection() \fn QFontInfo QWidget::fontInfo() const Returns the font info for the widget's current font. - Equivalent to QFontInto(widget->font()). + Equivalent to \c QFontInfo(widget->font()). \sa font(), fontMetrics(), setFont() */ @@ -7334,6 +7334,8 @@ bool QWidget::restoreGeometry(const QByteArray &geometry) stream >> restoredScreenWidth; const QDesktopWidget * const desktop = QApplication::desktop(); + if (restoredScreenNumber >= desktop->numScreens()) + restoredScreenNumber = desktop->primaryScreen(); const qreal screenWidthF = qreal(desktop->screenGeometry(restoredScreenNumber).width()); // Sanity check bailing out when large variations of screen sizes occur due to // high DPI scaling or different levels of DPI awareness. @@ -7361,9 +7363,6 @@ bool QWidget::restoreGeometry(const QByteArray &geometry) .expandedTo(d_func()->adjustedSize())); } - if (restoredScreenNumber >= desktop->numScreens()) - restoredScreenNumber = desktop->primaryScreen(); - const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber); // Modify the restored geometry if we are about to restore to coordinates @@ -12093,6 +12092,7 @@ QOpenGLContext *QWidgetPrivate::shareContext() const QOpenGLContext *ctx = new QOpenGLContext; ctx->setShareContext(qt_gl_global_share_context()); ctx->setFormat(extra->topextra->window->format()); + ctx->setScreen(extra->topextra->window->screen()); ctx->create(); that->extra->topextra->shareContext = ctx; } diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 485cf82078..d1070839fa 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -962,7 +962,8 @@ static void findTextureWidgetsRecursively(QWidget *tlw, QWidget *widget, QPlatfo QPlatformTextureList::Flags flags = 0; if (widget->testAttribute(Qt::WA_AlwaysStackOnTop)) flags |= QPlatformTextureList::StacksOnTop; - widgetTextures->appendTexture(widget, wd->textureId(), QRect(widget->mapTo(tlw, QPoint()), widget->size()), flags); + const QRect rect(widget->mapTo(tlw, QPoint()), widget->size()); + widgetTextures->appendTexture(widget, wd->textureId(), rect, wd->clipRect(), flags); } for (int i = 0; i < wd->children.size(); ++i) { @@ -1156,7 +1157,7 @@ void QWidgetBackingStore::doSync() #ifndef QT_NO_OPENGL if (widgetTextures && widgetTextures->count()) { for (int i = 0; i < widgetTextures->count(); ++i) { - QWidget *w = widgetTextures->widget(i); + QWidget *w = static_cast<QWidget *>(widgetTextures->source(i)); if (dirtyRenderToTextureWidgets.contains(w)) { const QRect rect = widgetTextures->geometry(i); // mapped to the tlw already dirty += rect; diff --git a/src/widgets/styles/qcommonstylepixmaps_p.h b/src/widgets/styles/qcommonstylepixmaps_p.h index 471903e927..8075256158 100644 --- a/src/widgets/styles/qcommonstylepixmaps_p.h +++ b/src/widgets/styles/qcommonstylepixmaps_p.h @@ -348,7 +348,7 @@ static const char * const qt_unshade_xpm[] = { "..........", ".........."}; -static const char * dock_widget_close_xpm[] = { +static const char * const dock_widget_close_xpm[] = { "8 8 2 1", "# c #000000", ". c None", diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 862a4302f3..1849331b79 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -2368,8 +2368,8 @@ QDebug operator<<(QDebug debug, QStyle::State state) return operator<< <QStyle::StateFlag>(debug, state); # else Q_UNUSED(state); -# endif return debug; +# endif } # endif // !QT_NO_DEBUG_STREAM #endif // QT_VERSION < QT_VERSION_CHECK(6,0,0) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 86b5632d2e..40b8aaae9a 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -586,7 +586,7 @@ public: }; /////////////////////////////////////////////////////////////////////////////////////////// -static const char *knownStyleHints[] = { +static const char *const knownStyleHints[] = { "activate-on-singleclick", "alignment", "arrow-keys-navigate-into-children", diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 40597a41f3..db8a649931 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -299,8 +299,8 @@ void QWindowsStyle::polish(QPalette &pal) int QWindowsStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *, const QWidget *widget) { - switch (pm) { #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) + switch (pm) { case QStyle::PM_DockWidgetFrameWidth: # ifndef Q_OS_WINCE return GetSystemMetrics(SM_CXFRAME); @@ -337,13 +337,14 @@ int QWindowsStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, const # else return GetSystemMetrics(SM_CYDLGFRAME); # endif -#else - Q_UNUSED(widget) -#endif // Q_OS_WIN default: break; } +#else // Q_OS_WIN && !Q_OS_WINRT + Q_UNUSED(pm); + Q_UNUSED(widget); +#endif return QWindowsStylePrivate::InvalidMetric; } diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index f715d93298..daa8ab12a9 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -250,8 +250,6 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt int state = option->state; if (!QWindowsVistaStylePrivate::useVista()) { - foreach (const QObject *target, d->animationTargets()) - d->stopAnimation(target); QWindowsStyle::drawPrimitive(element, option, painter, widget); return; } @@ -810,8 +808,6 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func()); if (!QWindowsVistaStylePrivate::useVista()) { - foreach (const QObject *target, d->animationTargets()) - d->stopAnimation(target); QWindowsStyle::drawControl(element, option, painter, widget); return; } @@ -1494,8 +1490,6 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle { QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func()); if (!QWindowsVistaStylePrivate::useVista()) { - foreach (const QObject *target, d->animationTargets()) - d->stopAnimation(target); QWindowsStyle::drawComplexControl(control, option, painter, widget); return; } diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 76f923904d..ef80e359df 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -3034,7 +3034,7 @@ void QComboBoxPrivate::showPopupFromMouseEvent(QMouseEvent *e) QStyle::SubControl sc = q->style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, e->pos(), q); if (e->button() == Qt::LeftButton - && sc != QStyle::SC_None + && !(sc == QStyle::SC_None && e->type() == QEvent::MouseButtonRelease) && (sc == QStyle::SC_ComboBoxArrow || !q->isEditable()) && !viewContainer()->isVisible()) { if (sc == QStyle::SC_ComboBoxArrow) diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index b1749fa5d3..a8da78a025 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -2316,9 +2316,9 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event) QString QDateTimeEditPrivate::getAmPmText(AmPm ap, Case cs) const { if (ap == AmText) { - return (cs == UpperCase ? QDateTimeEdit::tr("AM") : QDateTimeEdit::tr("am")); + return (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am")); } else { - return (cs == UpperCase ? QDateTimeEdit::tr("PM") : QDateTimeEdit::tr("pm")); + return (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm")); } } diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 237eb775b9..3e8c08f923 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -852,9 +852,19 @@ void QDialogButtonBoxPrivate::_q_handleButtonClicked() { Q_Q(QDialogButtonBox); if (QAbstractButton *button = qobject_cast<QAbstractButton *>(q->sender())) { + // Can't fetch this *after* emitting clicked, as clicked may destroy the button + // or change its role. Now changing the role is not possible yet, but arguably + // both clicked and accepted/rejected/etc. should be emitted "atomically" + // depending on whatever role the button had at the time of the click. + const QDialogButtonBox::ButtonRole buttonRole = q->buttonRole(button); + QPointer<QDialogButtonBox> guard(q); + emit q->clicked(button); - switch (q->buttonRole(button)) { + if (!guard) + return; + + switch (buttonRole) { case QPlatformDialogHelper::AcceptRole: case QPlatformDialogHelper::YesRole: emit q->accepted(); diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 6a41c3791f..ad3a92d35a 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -440,6 +440,10 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE Q_Q(QLineEdit); if (!newAction) return 0; + if (!hasSideWidgets()) { // initial setup. + QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString))); + lastTextSize = q->text().size(); + } QWidget *w = 0; // Store flags about QWidgetAction here since removeAction() may be called from ~QAction, // in which a qobject_cast<> no longer works. @@ -456,10 +460,6 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE toolButton->setDefaultAction(newAction); w = toolButton; } - if (!hasSideWidgets()) { // initial setup. - QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString))); - lastTextSize = q->text().size(); - } // If there is a 'before' action, it takes preference PositionIndexPair positionIndex = before ? findSideWidget(before) : PositionIndexPair(position, -1); SideWidgetEntryList &list = positionIndex.first == QLineEdit::TrailingPosition ? trailingSideWidgets : leadingSideWidgets; diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 1ede07e4cb..4654262ea7 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE // QLineEditIconButton: This is a simple helper class that represents clickable icons that fade in with text -class QLineEditIconButton : public QToolButton +class Q_AUTOTEST_EXPORT QLineEditIconButton : public QToolButton { Q_OBJECT Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) diff --git a/src/widgets/widgets/qmacnativewidget_mac.h b/src/widgets/widgets/qmacnativewidget_mac.h index b27d877e8f..761e55656b 100644 --- a/src/widgets/widgets/qmacnativewidget_mac.h +++ b/src/widgets/widgets/qmacnativewidget_mac.h @@ -52,7 +52,6 @@ public: NSView *nativeView() const; protected: - void init(NSView *parentView); bool event(QEvent *ev); private: diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 19f6b78853..4403deda8e 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -183,7 +183,7 @@ void QMenuPrivate::setPlatformMenu(QPlatformMenu *menu) } // forward declare function -static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* item); +static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item, QPlatformMenu *itemsMenu); void QMenuPrivate::syncPlatformMenu() { @@ -200,7 +200,7 @@ void QMenuPrivate::syncPlatformMenu() menuItem->setTag(reinterpret_cast<quintptr>(action)); QObject::connect(menuItem, SIGNAL(activated()), action, SLOT(trigger()), Qt::QueuedConnection); QObject::connect(menuItem, SIGNAL(hovered()), action, SIGNAL(hovered()), Qt::QueuedConnection); - copyActionToPlatformItem(action, menuItem); + copyActionToPlatformItem(action, menuItem, platformMenu.data()); platformMenu->insertMenuItem(menuItem, beforeItem); beforeItem = menuItem; } @@ -3104,7 +3104,7 @@ QMenu::timerEvent(QTimerEvent *e) } } -static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* item) +static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item, QPlatformMenu *itemsMenu) { item->setText(action->text()); item->setIsSeparator(action->isSeparator()); @@ -3130,6 +3130,8 @@ static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* i item->setEnabled(action->isEnabled()); if (action->menu()) { + if (!action->menu()->platformMenu()) + action->menu()->setPlatformMenu(itemsMenu->createSubMenu()); item->setMenu(action->menu()->platformMenu()); } else { item->setMenu(0); @@ -3184,7 +3186,7 @@ void QMenu::actionEvent(QActionEvent *e) menuItem->setTag(reinterpret_cast<quintptr>(e->action())); QObject::connect(menuItem, SIGNAL(activated()), e->action(), SLOT(trigger())); QObject::connect(menuItem, SIGNAL(hovered()), e->action(), SIGNAL(hovered())); - copyActionToPlatformItem(e->action(), menuItem); + copyActionToPlatformItem(e->action(), menuItem, d->platformMenu); QPlatformMenuItem* beforeItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->before())); d->platformMenu->insertMenuItem(menuItem, beforeItem); } else if (e->type() == QEvent::ActionRemoved) { @@ -3194,7 +3196,7 @@ void QMenu::actionEvent(QActionEvent *e) } else if (e->type() == QEvent::ActionChanged) { QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action())); if (menuItem) { - copyActionToPlatformItem(e->action(), menuItem); + copyActionToPlatformItem(e->action(), menuItem, d->platformMenu); d->platformMenu->syncMenuItem(menuItem); } } diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 4659d9cf6c..1ad99bed9c 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1632,7 +1632,7 @@ QSize QMenuBar::sizeHint() const if(d->leftWidget) { QSize sz = d->leftWidget->sizeHint(); sz.rheight() += margin; - ret.expandedTo(sz); + ret = ret.expandedTo(sz); } if(d->rightWidget) { QSize sz = d->rightWidget->sizeHint(); diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp index 2cec8a0b9c..19a2edf0f2 100644 --- a/src/widgets/widgets/qstackedwidget.cpp +++ b/src/widgets/widgets/qstackedwidget.cpp @@ -182,7 +182,9 @@ int QStackedWidget::insertWidget(int index, QWidget *widget) not deleted but simply removed from the stacked layout, causing it to be hidden. - \b{Note:} Ownership of \a widget reverts to the application. + \note Parent object and parent widget of \a widget will remain the + QStackedWidget. If the application wants to reuse the removed + \a widget, then it is recommended to re-parent it. \sa addWidget(), insertWidget(), currentWidget() */ diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp index 5a56c592a6..8473b261fc 100644 --- a/src/widgets/widgets/qtoolbutton.cpp +++ b/src/widgets/widgets/qtoolbutton.cpp @@ -897,7 +897,7 @@ void QToolButton::setDefaultAction(QAction *action) return; if (!actions().contains(action)) addAction(action); - setText(action->iconText()); + setText(action->text()); setIcon(action->icon()); #ifndef QT_NO_TOOLTIP setToolTip(action->toolTip()); |