diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-03-31 18:47:56 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-01 09:10:26 +0200 |
commit | 0e6ee136c91432d4ceeeda64e5a5fa88231398d4 (patch) | |
tree | 6060e002af2900007895f6efa757989dd4c190c9 /src/widgets | |
parent | 418869d9158ea5cd998ba30778b0b7173b48161b (diff) | |
parent | 17294c5e4d15d5776f6e414b03671a4a9ed4993d (diff) |
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
src/testlib/qtestblacklist.cpp
src/widgets/accessible/qaccessiblewidgets.cpp
Change-Id: If032adb9296428f62384ed835dbf41ee7a0b886c
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 10 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 5 | ||||
-rw-r--r-- | src/widgets/kernel/qopenglwidget.cpp | 27 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 3 | ||||
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 5 | ||||
-rw-r--r-- | src/widgets/styles/qproxystyle.cpp | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 131 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox_p.h | 9 | ||||
-rw-r--r-- | src/widgets/widgets/qtabbar.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol.cpp | 4 |
10 files changed, 135 insertions, 65 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 455111225e..6a1374e3ee 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -976,6 +976,16 @@ QDir QFileDialog::directory() const \note The non-native QFileDialog supports only local files. + \note On Windows, it is possible to pass URLs representing + one of the \e {virtual folders}, such as "Computer" or "Network". + This is done by passing a QUrl using the scheme \c clsid followed + by the CLSID value with the curly braces removed. For example the URL + \c clsid:374DE290-123F-4565-9164-39C4925E467B denotes the download + location. For a complete list of possible values, see the MSDN documentation on + \l{https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457.aspx}{KNOWNFOLDERID}. + This feature was added in Qt 5.5. + + \sa QUuid \since 5.2 */ void QFileDialog::setDirectoryUrl(const QUrl &directory) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 78c842f7e1..00f590ebc2 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -978,8 +978,7 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis || event->type() == QEvent::LayoutRequest || event->type() == QEvent::Resize || event->type() == QEvent::Move - || event->type() == QEvent::LanguageChange - || event->type() == QEvent::InputMethod)) { + || event->type() == QEvent::LanguageChange)) { for (QPostEventList::const_iterator it = postedEvents->constBegin(); it != postedEvents->constEnd(); ++it) { const QPostEvent &cur = *it; if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type()) @@ -993,8 +992,6 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis ((QMoveEvent *)(cur.event))->p = ((QMoveEvent *)event)->p; } else if (cur.event->type() == QEvent::LanguageChange) { ; - } else if ( cur.event->type() == QEvent::InputMethod ) { - *(QInputMethodEvent *)(cur.event) = *(QInputMethodEvent *)event; } else { continue; } diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 8faa9f8681..d4d23604a3 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -46,6 +46,7 @@ #include <QtGui/private/qopenglextensions_p.h> #include <QtGui/private/qfont_p.h> #include <QtGui/private/qopenglpaintdevice_p.h> +#include <QtGui/private/qopenglcontext_p.h> #include <QtWidgets/private/qwidget_p.h> QT_BEGIN_NAMESPACE @@ -435,6 +436,23 @@ QT_BEGIN_NAMESPACE each frame. To restore the preserved behavior, call setUpdateBehavior() with \c PartialUpdate. + \section1 Alternatives + + Adding a QOpenGLWidget into a window turns on OpenGL-based + compositing for the entire window. In some special cases this may + not be ideal, and the old QGLWidget-style behavior with a separate, + native child window is desired. Desktop applications that understand + the limitations of this approach (for example when it comes to + overlaps, transparency, scroll views and MDI areas), can use + QOpenGLWindow with QWidget::createWindowContainer(). This is a + modern alternative to QGLWidget and is faster than QOpenGLWidget due + to the lack of the additional composition step. It is strongly + recommended to limit the usage of this approach to cases where there + is no other choice. Note that this option is not suitable for most + embedded and mobile platforms, and it is known to have issues on + certain desktop platforms (e.g. OS X) too. The stable, + cross-platform solution is always QOpenGLWidget. + \e{OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.} @@ -775,11 +793,18 @@ void QOpenGLWidgetPrivate::resolveSamples() void QOpenGLWidgetPrivate::invokeUserPaint() { Q_Q(QOpenGLWidget); - QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); + + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + Q_ASSERT(ctx && fbo); + + QOpenGLFunctions *f = ctx->functions(); + QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = fbo->handle(); f->glViewport(0, 0, q->width() * q->devicePixelRatio(), q->height() * q->devicePixelRatio()); q->paintGL(); flushPending = true; + + QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = 0; } void QOpenGLWidgetPrivate::render() diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 5f0fb430bc..efe7d9415b 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -465,7 +465,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) } if (qApp->activePopupWidget() != activePopupWidget - && qt_replay_popup_mouse_event) { + && qt_replay_popup_mouse_event + && QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool()) { if (m_widget->windowType() != Qt::Popup) qt_button_down = 0; if (event->type() == QEvent::MouseButtonPress) { diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 1f7a87e23d..a5fc4eb3a2 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -3608,6 +3608,11 @@ int QFusionStyle::styleHint(StyleHint hint, const QStyleOption *option, const QW case SH_Menu_SupportsSections: return 1; +#if defined(Q_OS_IOS) + case SH_ComboBox_UseNativePopup: + return 1; +#endif + case SH_ToolBox_SelectedPageTitleBold: case SH_ScrollView_FrameOnlyAroundContents: case SH_Menu_AllowActiveAndDisabled: diff --git a/src/widgets/styles/qproxystyle.cpp b/src/widgets/styles/qproxystyle.cpp index 4b1c58dc50..61f836b23c 100644 --- a/src/widgets/styles/qproxystyle.cpp +++ b/src/widgets/styles/qproxystyle.cpp @@ -101,8 +101,8 @@ void QProxyStylePrivate::ensureBaseStyle() const /*! Constructs a QProxyStyle object for overriding behavior in the - specified base \a style, or in the current \l{QApplication::style()} - {application style} if base \a style is not specified. + specified \a style, or in the default native \l{QApplication::style()} + {style} if \a style is not specified. Ownership of \a style is transferred to QProxyStyle. */ diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index ab4c7bfff6..7a8fcc2c76 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -93,12 +93,22 @@ QComboBoxPrivate::QComboBoxPrivate() hoverControl(QStyle::SC_None), autoCompletionCaseSensitivity(Qt::CaseInsensitive), indexBeforeChange(-1) +#ifdef Q_OS_MAC + , m_platformMenu(0) +#endif #ifndef QT_NO_COMPLETER , completer(0) #endif { } +QComboBoxPrivate::~QComboBoxPrivate() +{ +#ifdef Q_OS_MAC + cleanupNativePopup(); +#endif +} + QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewItem &option, const QModelIndex &index) const { @@ -2398,7 +2408,7 @@ QSize QComboBox::sizeHint() const return d->recomputeSizeHint(d->sizeHint); } -#ifdef Q_OS_OSX +#ifdef Q_OS_MAC namespace { struct IndexSetter { @@ -2409,6 +2419,19 @@ struct IndexSetter { }; } +void QComboBoxPrivate::cleanupNativePopup() +{ + if (!m_platformMenu) + return; + + int count = int(m_platformMenu->tag()); + for (int i = 0; i < count; ++i) + m_platformMenu->menuItemAt(i)->deleteLater(); + + delete m_platformMenu; + m_platformMenu = 0; +} + /*! * \internal * @@ -2419,60 +2442,62 @@ bool QComboBoxPrivate::showNativePopup() { Q_Q(QComboBox); - QPlatformTheme *theme = QGuiApplicationPrivate::instance()->platformTheme(); - if (QPlatformMenu *menu = theme->createPlatformMenu()) { - int itemsCount = q->count(); - - QList<QPlatformMenuItem *> items; - items.reserve(itemsCount); - QPlatformMenuItem *currentItem = 0; - int currentIndex = q->currentIndex(); - - for (int i = 0; i < itemsCount; ++i) { - QPlatformMenuItem *item = theme->createPlatformMenuItem(); - QModelIndex rowIndex = model->index(i, modelColumn, root); - QVariant textVariant = model->data(rowIndex, Qt::EditRole); - item->setText(textVariant.toString()); - QVariant iconVariant = model->data(rowIndex, Qt::DecorationRole); - if (iconVariant.canConvert<QIcon>()) - item->setIcon(iconVariant.value<QIcon>()); - item->setCheckable(true); - item->setChecked(i == currentIndex); - if (!currentItem || i == currentIndex) - currentItem = item; - - IndexSetter setter = { i, q }; - QObject::connect(item, &QPlatformMenuItem::activated, setter); - - menu->insertMenuItem(item, 0); - menu->syncMenuItem(item); - } + cleanupNativePopup(); - QWindow *tlw = q->window()->windowHandle(); - menu->setFont(q->font()); - menu->setMinimumWidth(q->rect().width()); - QPoint offset = QPoint(0, 7); - if (q->testAttribute(Qt::WA_MacSmallSize)) - offset = QPoint(-1, 7); - else if (q->testAttribute(Qt::WA_MacMiniSize)) - offset = QPoint(-2, 6); - menu->showPopup(tlw, QRect(tlw->mapFromGlobal(q->mapToGlobal(offset)), QSize()), currentItem); - menu->deleteLater(); - Q_FOREACH (QPlatformMenuItem *item, items) - item->deleteLater(); - - // The Cocoa popup will swallow any mouse release event. - // We need to fake one here to un-press the button. - QMouseEvent mouseReleased(QEvent::MouseButtonRelease, q->pos(), Qt::LeftButton, - Qt::MouseButtons(Qt::LeftButton), Qt::KeyboardModifiers()); - qApp->sendEvent(q, &mouseReleased); + QPlatformTheme *theme = QGuiApplicationPrivate::instance()->platformTheme(); + m_platformMenu = theme->createPlatformMenu(); + if (!m_platformMenu) + return false; + + int itemsCount = q->count(); + m_platformMenu->setTag(quintptr(itemsCount)); + + QPlatformMenuItem *currentItem = 0; + int currentIndex = q->currentIndex(); + + for (int i = 0; i < itemsCount; ++i) { + QPlatformMenuItem *item = theme->createPlatformMenuItem(); + QModelIndex rowIndex = model->index(i, modelColumn, root); + QVariant textVariant = model->data(rowIndex, Qt::EditRole); + item->setText(textVariant.toString()); + QVariant iconVariant = model->data(rowIndex, Qt::DecorationRole); + if (iconVariant.canConvert<QIcon>()) + item->setIcon(iconVariant.value<QIcon>()); + item->setCheckable(true); + item->setChecked(i == currentIndex); + if (!currentItem || i == currentIndex) + currentItem = item; + + IndexSetter setter = { i, q }; + QObject::connect(item, &QPlatformMenuItem::activated, setter); + + m_platformMenu->insertMenuItem(item, 0); + m_platformMenu->syncMenuItem(item); + } + + QWindow *tlw = q->window()->windowHandle(); + m_platformMenu->setFont(q->font()); + m_platformMenu->setMinimumWidth(q->rect().width()); + QPoint offset = QPoint(0, 7); + if (q->testAttribute(Qt::WA_MacSmallSize)) + offset = QPoint(-1, 7); + else if (q->testAttribute(Qt::WA_MacMiniSize)) + offset = QPoint(-2, 6); + + m_platformMenu->showPopup(tlw, QRect(tlw->mapFromGlobal(q->mapToGlobal(offset)), QSize()), currentItem); - return true; - } +#ifdef Q_OS_OSX + // The Cocoa popup will swallow any mouse release event. + // We need to fake one here to un-press the button. + QMouseEvent mouseReleased(QEvent::MouseButtonRelease, q->pos(), Qt::LeftButton, + Qt::MouseButtons(Qt::LeftButton), Qt::KeyboardModifiers()); + qApp->sendEvent(q, &mouseReleased); +#endif - return false; + return true; } -#endif // Q_OS_OSX + +#endif // Q_OS_MAC /*! Displays the list of items in the combobox. If the list is empty @@ -2494,7 +2519,7 @@ void QComboBox::showPopup() initStyleOption(&opt); const bool usePopup = style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this); -#ifdef Q_OS_OSX +#ifdef Q_OS_MAC if (usePopup && (!d->container || (view()->metaObject()->className() == QByteArray("QComboBoxListView") @@ -2502,7 +2527,7 @@ void QComboBox::showPopup() && style->styleHint(QStyle::SH_ComboBox_UseNativePopup, &opt, this) && d->showNativePopup()) return; -#endif // Q_OS_OSX +#endif // Q_OS_MAC #ifdef QT_KEYPAD_NAVIGATION #ifndef QT_NO_COMPLETER diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 5ee7d72e8e..580054780f 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -71,6 +71,7 @@ QT_BEGIN_NAMESPACE class QAction; +class QPlatformMenu; class QComboBoxListView : public QListView { @@ -331,7 +332,7 @@ class Q_AUTOTEST_EXPORT QComboBoxPrivate : public QWidgetPrivate Q_DECLARE_PUBLIC(QComboBox) public: QComboBoxPrivate(); - ~QComboBoxPrivate() {} + ~QComboBoxPrivate(); void init(); QComboBoxPrivateContainer* viewContainer(); void updateLineEditGeometry(); @@ -372,7 +373,8 @@ public: void updateViewContainerPaletteAndOpacity(); void updateFocusPolicy(); -#ifdef Q_OS_OSX +#ifdef Q_OS_MAC + void cleanupNativePopup(); bool showNativePopup(); #endif @@ -401,6 +403,9 @@ public: QPersistentModelIndex root; Qt::CaseSensitivity autoCompletionCaseSensitivity; int indexBeforeChange; +#ifdef Q_OS_MAC + QPlatformMenu *m_platformMenu; +#endif #ifndef QT_NO_COMPLETER QPointer<QCompleter> completer; #endif diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 02c34d9ef6..02967e33c1 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -2031,10 +2031,12 @@ void QTabBar::keyPressEvent(QKeyEvent *event) #ifndef QT_NO_WHEELEVENT void QTabBar::wheelEvent(QWheelEvent *event) { +#ifndef Q_OS_MAC Q_D(QTabBar); int offset = event->delta() > 0 ? -1 : 1; d->setCurrentNextEnabledIndex(offset); QWidget::wheelEvent(event); +#endif } #endif //QT_NO_WHEELEVENT diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index f259f7e3a4..759e41a5fa 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -936,7 +936,7 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields) delete [] m_maskData; m_maskData = 0; m_maxLength = 32767; - internalSetText(QString()); + internalSetText(QString(), -1, false); } return; } @@ -1022,7 +1022,7 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields) } } } - internalSetText(m_text); + internalSetText(m_text, -1, false); } |