diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-11-27 01:00:36 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-11-27 01:00:36 +0100 |
commit | ec5e692c1c4d8576d19723bb1193703275efdc90 (patch) | |
tree | 976b6844203d60d4bf0b4c65dcfaf8eba7621506 /src | |
parent | f91d1e08099e67c77c8d7bcda362f07eec054ae8 (diff) | |
parent | ba13c6c08f30a4c2f188f69deeaf4ca6a020d7a1 (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I04afffdce6b78856d0301eb583f21d334c7466b0
Diffstat (limited to 'src')
22 files changed, 228 insertions, 147 deletions
diff --git a/src/gui/configure.pri b/src/gui/configure.pri index 2971fd136e..e21489ec28 100644 --- a/src/gui/configure.pri +++ b/src/gui/configure.pri @@ -55,7 +55,7 @@ defineTest(qtConfTest_qpaDefaultPlatform) { else: qnx: name = qnx else: integrity: name = integrityfb else: haiku: name = haiku - else: wasm: name = webassembly + else: wasm: name = wasm else: name = xcb $${1}.value = $$name diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index 36bd81c76b..21f880e7be 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -686,11 +686,7 @@ _hb_qt_font_create(QFontEngine *fe) const int x_ppem = (fe->fontDef.pixelSize * fe->fontDef.stretch) / 100; hb_font_set_funcs(font, hb_qt_get_font_funcs(), (void *)fe, NULL); -#ifdef Q_OS_MAC - hb_font_set_scale(font, QFixed(x_ppem).value(), QFixed(y_ppem).value()); -#else hb_font_set_scale(font, QFixed(x_ppem).value(), -QFixed(y_ppem).value()); -#endif hb_font_set_ppem(font, x_ppem, y_ppem); return font; diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp index d69fc47667..8f290e5107 100644 --- a/src/network/kernel/qnetworkinterface_unix.cpp +++ b/src/network/kernel/qnetworkinterface_unix.cpp @@ -38,6 +38,7 @@ ** ****************************************************************************/ +#include "qbytearray.h" #include "qset.h" #include "qnetworkinterface.h" #include "qnetworkinterface_p.h" @@ -500,7 +501,7 @@ static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList) iface->flags = convertFlags(ptr->ifa_flags); iface->hardwareAddress = iface->makeHwAddress(sdl->sdl_alen, (uchar*)LLADDR(sdl)); - strlcpy(mediareq.ifm_name, ptr->ifa_name, sizeof(mediareq.ifm_name)); + qstrncpy(mediareq.ifm_name, ptr->ifa_name, sizeof(mediareq.ifm_name)); iface->type = probeIfType(openSocket(socket), sdl->sdl_type, &mediareq); iface->mtu = getMtu(socket, &req); } @@ -524,7 +525,7 @@ static void getAddressExtraInfo(QNetworkAddressEntry *entry, struct sockaddr *sa return; } - strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + qstrncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); // get flags ifr.ifr_addr = *reinterpret_cast<struct sockaddr_in6 *>(sa); diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h index 8b72da397f..d93b53be0c 100644 --- a/src/network/socket/qlocalsocket_p.h +++ b/src/network/socket/qlocalsocket_p.h @@ -131,7 +131,6 @@ public: #elif defined(Q_OS_WIN) ~QLocalSocketPrivate(); void destroyPipeHandles(); - void setErrorString(const QString &function); void _q_canWrite(); void _q_pipeClosed(); void _q_winError(ulong windowsError, const QString &function); diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 8e20f9efbe..d6ee76043f 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -50,12 +50,6 @@ void QLocalSocketPrivate::init() q->connect(pipeReader, SIGNAL(winError(ulong,QString)), SLOT(_q_winError(ulong,QString))); } -void QLocalSocketPrivate::setErrorString(const QString &function) -{ - DWORD windowsError = GetLastError(); - _q_winError(windowsError, function); -} - void QLocalSocketPrivate::_q_winError(ulong windowsError, const QString &function) { Q_Q(QLocalSocket); @@ -127,7 +121,8 @@ void QLocalSocket::connectToServer(OpenMode openMode) { Q_D(QLocalSocket); if (state() == ConnectedState || state() == ConnectingState) { - setErrorString(tr("Trying to connect while connection is in progress")); + d->error = OperationError; + d->errorString = tr("Trying to connect while connection is in progress"); emit error(QLocalSocket::OperationError); return; } @@ -137,8 +132,8 @@ void QLocalSocket::connectToServer(OpenMode openMode) d->state = ConnectingState; emit stateChanged(d->state); if (d->serverName.isEmpty()) { - d->error = QLocalSocket::ServerNotFoundError; - setErrorString(QLocalSocket::tr("%1: Invalid name").arg(QLatin1String("QLocalSocket::connectToServer"))); + d->error = ServerNotFoundError; + d->errorString = tr("%1: Invalid name").arg(QLatin1String("QLocalSocket::connectToServer")); d->state = UnconnectedState; emit error(d->error); emit stateChanged(d->state); @@ -177,7 +172,8 @@ void QLocalSocket::connectToServer(OpenMode openMode) } if (localSocket == INVALID_HANDLE_VALUE) { - d->setErrorString(QLatin1String("QLocalSocket::connectToServer")); + const DWORD winError = GetLastError(); + d->_q_winError(winError, QLatin1String("QLocalSocket::connectToServer")); d->fullServerName = QString(); return; } diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 5ba2c40636..75ed3c16e0 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -161,7 +161,9 @@ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG) DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return) DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return) DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return) +#ifdef TLS1_3_VERSION DEFINEFUNC2(int, SSL_CTX_set_ciphersuites, SSL_CTX *ctx, ctx, const char *str, str, return 0, return) +#endif DEFINEFUNC3(size_t, SSL_get_client_random, SSL *a, a, unsigned char *out, out, size_t outlen, outlen, return 0, return) DEFINEFUNC3(size_t, SSL_SESSION_get_master_key, const SSL_SESSION *ses, ses, unsigned char *out, out, size_t outlen, outlen, return 0, return) DEFINEFUNC6(int, CRYPTO_get_ex_new_index, int class_index, class_index, long argl, argl, void *argp, argp, CRYPTO_EX_new *new_func, new_func, CRYPTO_EX_dup *dup_func, dup_func, CRYPTO_EX_free *free_func, free_func, return -1, return) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 1a3c7793c0..f9a03e5b58 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -358,8 +358,9 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of return [NSValue valueWithRange: NSMakeRange(0, 0)]; } else if ([attribute isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute]) { // FIXME This is not correct and may impact performance for big texts - return [NSValue valueWithRange: NSMakeRange(0, iface->textInterface()->characterCount())]; - + if (QAccessibleTextInterface *text = iface->textInterface()) + return [NSValue valueWithRange: NSMakeRange(0, text->characterCount())]; + return [NSValue valueWithRange: NSMakeRange(0, iface->text(QAccessible::Name).length())]; } else if ([attribute isEqualToString:NSAccessibilityInsertionPointLineNumberAttribute]) { if (QAccessibleTextInterface *text = iface->textInterface()) { int position = text->cursorPosition(); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 8515190bd7..774ccdbf4c 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -898,34 +898,36 @@ void QCocoaWindow::raise() qCDebug(lcQpaWindow) << "QCocoaWindow::raise" << window(); // ### handle spaces (see Qt 4 raise_sys in qwidget_mac.mm) - if (!isContentView()) - return; - - if (m_view.window.visible) { - { - // Clean up autoreleased temp objects from orderFront immediately. - // Failure to do so has been observed to cause leaks also beyond any outer - // autorelease pool (for example around a complete QWindow - // construct-show-raise-hide-delete cyle), counter to expected autoreleasepool - // behavior. - QMacAutoReleasePool pool; - [m_view.window orderFront:m_view.window]; - } - static bool raiseProcess = qt_mac_resolveOption(true, "QT_MAC_SET_RAISE_PROCESS"); - if (raiseProcess) { - [NSApp activateIgnoringOtherApps:YES]; + if (isContentView()) { + if (m_view.window.visible) { + { + // Clean up auto-released temp objects from orderFront immediately. + // Failure to do so has been observed to cause leaks also beyond any outer + // autorelease pool (for example around a complete QWindow + // construct-show-raise-hide-delete cycle), counter to expected autoreleasepool + // behavior. + QMacAutoReleasePool pool; + [m_view.window orderFront:m_view.window]; + } + static bool raiseProcess = qt_mac_resolveOption(true, "QT_MAC_SET_RAISE_PROCESS"); + if (raiseProcess) + [NSApp activateIgnoringOtherApps:YES]; } + } else { + [m_view.superview addSubview:m_view positioned:NSWindowAbove relativeTo:nil]; } } void QCocoaWindow::lower() { qCDebug(lcQpaWindow) << "QCocoaWindow::lower" << window(); - if (!isContentView()) - return; - if (m_view.window.visible) - [m_view.window orderBack:m_view.window]; + if (isContentView()) { + if (m_view.window.visible) + [m_view.window orderBack:m_view.window]; + } else { + [m_view.superview addSubview:m_view positioned:NSWindowBelow relativeTo:nil]; + } } bool QCocoaWindow::isExposed() const diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 03c5001270..7f826942f3 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -68,6 +68,8 @@ // Private interface @interface QT_MANGLE_NAMESPACE(QNSView) () - (BOOL)isTransparentForUserInput; +@property (assign) NSView* previousSuperview; +@property (assign) NSWindow* previousWindow; @end @interface QT_MANGLE_NAMESPACE(QNSView) (Drawing) <CALayerDelegate> @@ -153,6 +155,9 @@ self.focusRingType = NSFocusRingTypeNone; self.cursor = nil; + self.previousSuperview = nil; + self.previousWindow = nil; + [self initDrawing]; [self registerDragTypes]; @@ -195,8 +200,40 @@ return description; } +// ----------------------------- Re-parenting --------------------------------- + +- (void)removeFromSuperview +{ + QMacAutoReleasePool pool; + [super removeFromSuperview]; +} + +- (void)viewWillMoveToSuperview:(NSView *)newSuperview +{ + Q_ASSERT(!self.previousSuperview); + self.previousSuperview = self.superview; + + if (newSuperview == self.superview) + qCDebug(lcQpaWindow) << "Re-ordering" << self << "inside" << self.superview; + else + qCDebug(lcQpaWindow) << "Re-parenting" << self << "from" << self.superview << "to" << newSuperview; +} + - (void)viewDidMoveToSuperview { + auto cleanup = qScopeGuard([&] { self.previousSuperview = nil; }); + + if (self.superview == self.previousSuperview) { + qCDebug(lcQpaWindow) << "Done re-ordering" << self << "new index:" + << [self.superview.subviews indexOfObject:self]; + return; + } + + qCDebug(lcQpaWindow) << "Done re-parenting" << self << "into" << self.superview; + + // Note: at this point the view's window property hasn't been updated to match the window + // of the new superview. We have to wait for viewDidMoveToWindow for that to be reflected. + if (!m_platformWindow) return; @@ -210,6 +247,36 @@ } } +- (void)viewWillMoveToWindow:(NSWindow *)newWindow +{ + Q_ASSERT(!self.previousWindow); + self.previousWindow = self.window; + + // This callback is documented to be called also when a view is just moved between + // subviews in the same NSWindow, so we're not necessarily moving between NSWindows. + if (newWindow == self.window) + return; + + qCDebug(lcQpaWindow) << "Moving" << self << "from" << self.window << "to" << newWindow; + + // Note: at this point the superview has already been updated, so we know which view inside + // the new window the view will be a child of. +} + +- (void)viewDidMoveToWindow +{ + auto cleanup = qScopeGuard([&] { self.previousWindow = nil; }); + + // This callback is documented to be called also when a view is just moved between + // subviews in the same NSWindow, so we're not necessarily moving between NSWindows. + if (self.window == self.previousWindow) + return; + + qCDebug(lcQpaWindow) << "Done moving" << self << "to" << self.window; +} + +// ---------------------------------------------------------------------------- + - (QWindow *)topLevelWindow { if (!m_platformWindow) @@ -239,12 +306,6 @@ // viewDidUnhide so no reason to override it here. } -- (void)removeFromSuperview -{ - QMacAutoReleasePool pool; - [super removeFromSuperview]; -} - - (BOOL)isTransparentForUserInput { return m_platformWindow->window() && diff --git a/src/plugins/platforms/cocoa/qnsview_complextext.mm b/src/plugins/platforms/cocoa/qnsview_complextext.mm index d357082d33..6ff9b26ca4 100644 --- a/src/plugins/platforms/cocoa/qnsview_complextext.mm +++ b/src/plugins/platforms/cocoa/qnsview_complextext.mm @@ -307,8 +307,8 @@ { Q_UNUSED(textInputContextKeyboardSelectionDidChangeNotification) if (([NSApp keyWindow] == self.window) && self.window.firstResponder == self) { - QCocoaInputContext *ic = qobject_cast<QCocoaInputContext *>(QCocoaIntegration::instance()->inputContext()); - ic->updateLocale(); + if (QCocoaInputContext *ic = qobject_cast<QCocoaInputContext *>(QCocoaIntegration::instance()->inputContext())) + ic->updateLocale(); } } diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm index ce7f92f2c7..5c880b1cad 100644 --- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm @@ -313,7 +313,6 @@ static void qt_mac_draw_pattern(void *info, CGContextRef c) } pat->image = qt_mac_create_imagemask(pm, pm.rect()); CGImageRelease(swatch); - CGContextRelease(pm_ctx); w *= QMACPATTERN_MASK_MULTIPLIER; h *= QMACPATTERN_MASK_MULTIPLIER; #endif diff --git a/src/plugins/platforms/wasm/wasm.pro b/src/plugins/platforms/wasm/wasm.pro index f1205702ef..eaaba53aa2 100644 --- a/src/plugins/platforms/wasm/wasm.pro +++ b/src/plugins/platforms/wasm/wasm.pro @@ -1,4 +1,4 @@ -TARGET = wasm +TARGET = qwasm CONFIG += static plugin QT += \ core-private gui-private \ diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 2ffb5d2629..ddb8f45188 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -38,9 +38,6 @@ ****************************************************************************/ #include <QDebug> -#if QT_CONFIG(library) -#include <QLibrary> -#endif #include "qxcbwindow.h" #include "qxcbscreen.h" @@ -61,10 +58,6 @@ #include "qxcbglintegration.h" -#if !defined(QT_STATIC) && QT_CONFIG(dlopen) -#include <dlfcn.h> -#endif - QT_BEGIN_NAMESPACE typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*); @@ -627,41 +620,7 @@ void QGLXContext::swapBuffers(QPlatformSurface *surface) QFunctionPointer QGLXContext::getProcAddress(const char *procName) { -#ifdef QT_STATIC - return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName)); -#else - typedef void *(*qt_glXGetProcAddressARB)(const GLubyte *); - static qt_glXGetProcAddressARB glXGetProcAddressARB = 0; - static bool resolved = false; - - if (resolved && !glXGetProcAddressARB) - return 0; - if (!glXGetProcAddressARB) { - QList<QByteArray> glxExt = QByteArray(glXGetClientString(m_display, GLX_EXTENSIONS)).split(' '); - if (glxExt.contains("GLX_ARB_get_proc_address")) { -#if QT_CONFIG(dlopen) - void *handle = dlopen(NULL, RTLD_LAZY); - if (handle) { - glXGetProcAddressARB = (qt_glXGetProcAddressARB) dlsym(handle, "glXGetProcAddressARB"); - dlclose(handle); - } - if (!glXGetProcAddressARB) -#endif - { -#if QT_CONFIG(library) - QLibrary lib(QLatin1String("GL")); - if (!lib.load()) - lib.setFileNameAndVersion(QLatin1String("GL"), 1); - glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB"); -#endif - } - } - resolved = true; - } - if (!glXGetProcAddressARB) - return 0; - return (void (*)())glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName)); -#endif + return glXGetProcAddress(reinterpret_cast<const GLubyte *>(procName)); } QSurfaceFormat QGLXContext::format() const diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 32190151bc..ffbbe82856 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1832,8 +1832,9 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title) "<h3>About Qt</h3>" "<p>This program uses Qt version %1.</p>" ).arg(QLatin1String(QT_VERSION_STR)); - QString translatedTextAboutQtText; - translatedTextAboutQtText = QMessageBox::tr( + //: Leave this text untranslated or include a verbatim copy of it below + //: and note that it is the authoritative version in case of doubt. + const QString translatedTextAboutQtText = QMessageBox::tr( "<p>Qt is a C++ toolkit for cross-platform application " "development.</p>" "<p>Qt provides single-source portability across all major desktop " diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index 177dbc4871..513cf9d361 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -607,20 +607,20 @@ void QGraphicsProxyWidgetPrivate::setWidget_helper(QWidget *newWidget, bool auto for (QGraphicsItem *child : childItems) { if (child->d_ptr->isProxyWidget()) { QGraphicsProxyWidget *childProxy = static_cast<QGraphicsProxyWidget *>(child); - QWidget * parent = childProxy->widget(); - while (parent->parentWidget() != 0) { + QWidget *parent = childProxy->widget(); + while (parent && parent->parentWidget()) { if (parent == widget) break; parent = parent->parentWidget(); } if (!childProxy->widget() || parent != widget) continue; - childProxy->setWidget(0); + childProxy->setWidget(nullptr); delete childProxy; } } - widget = 0; + widget = nullptr; #ifndef QT_NO_CURSOR q->unsetCursor(); #endif diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 85a89b717e..ccfd3534cd 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1775,7 +1775,6 @@ void QWidgetPrivate::createTLExtra() x->posIncludesFrame = 0; x->sizeAdjusted = false; x->inTopLevelResize = false; - x->inRepaint = false; x->embedded = 0; x->window = 0; x->shareContext = 0; @@ -6596,20 +6595,25 @@ QWidget *QWidgetPrivate::deepestFocusProxy() const return focusProxy; } +static inline bool isEmbedded(const QWindow *w) +{ + const auto platformWindow = w->handle(); + return platformWindow && platformWindow->isEmbedded(); +} + void QWidgetPrivate::setFocus_sys() { Q_Q(QWidget); // Embedded native widget may have taken the focus; get it back to toplevel // if that is the case (QTBUG-25852) - const QWidget *topLevel = q->window(); - // Do not activate in case the popup menu opens another application (QTBUG-70810). - if (QGuiApplication::applicationState() == Qt::ApplicationActive - && topLevel->windowType() != Qt::Popup) { - if (QWindow *nativeWindow = q->window()->windowHandle()) { - if (nativeWindow != QGuiApplication::focusWindow() - && q->testAttribute(Qt::WA_WState_Created)) { - nativeWindow->requestActivate(); - } + // Do not activate in case the popup menu opens another application (QTBUG-70810) + // unless the application is embedded (QTBUG-71991). + if (QWindow *nativeWindow = q->testAttribute(Qt::WA_WState_Created) ? q->window()->windowHandle() : nullptr) { + if (nativeWindow->type() != Qt::Popup && nativeWindow != QGuiApplication::focusWindow() + && (QGuiApplication::applicationState() == Qt::ApplicationActive + || QCoreApplication::testAttribute(Qt::AA_PluginApplication) + || isEmbedded(nativeWindow))) { + nativeWindow->requestActivate(); } } } @@ -11036,11 +11040,8 @@ void QWidgetPrivate::repaint(T r) return; QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData(); - if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { - tlwExtra->inRepaint = true; + if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) tlwExtra->backingStoreTracker->markDirty(r, q, QWidgetBackingStore::UpdateNow); - tlwExtra->inRepaint = false; - } } /*! diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 0c7a5b1944..7ebc2cd58e 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -190,7 +190,6 @@ struct QTLWExtra { uint posIncludesFrame : 1; uint sizeAdjusted : 1; uint inTopLevelResize : 1; - uint inRepaint : 1; uint embedded : 1; // *************************** Platform specific values (bit fields first) ********** diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 81916bba90..d2680e5280 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -227,6 +227,12 @@ QWindowContainer::QWindowContainer(QWindow *embeddedWindow, QWidget *parent, Qt: embeddedWindow->setSurfaceType(QSurface::RasterGLSurface); d->window = embeddedWindow; + + QString windowName = d->window->objectName(); + if (windowName.isEmpty()) + windowName = QString::fromUtf8(d->window->metaObject()->className()); + d->fakeParent.setObjectName(windowName + "ContainerFakeParent"); + d->window->setParent(&d->fakeParent); setAcceptDrops(true); diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 242a4405ca..2ae2e16c89 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -488,7 +488,10 @@ void QLineEdit::setClearButtonEnabled(bool enable) QAction *clearAction = new QAction(d->clearButtonIcon(), QString(), this); clearAction->setEnabled(!isReadOnly()); clearAction->setObjectName(QLatin1String(clearButtonActionNameC)); - d->addAction(clearAction, 0, QLineEdit::TrailingPosition, QLineEditPrivate::SideWidgetClearButton | QLineEditPrivate::SideWidgetFadeInWithText); + + int flags = QLineEditPrivate::SideWidgetClearButton | QLineEditPrivate::SideWidgetFadeInWithText; + auto widgetAction = d->addAction(clearAction, nullptr, QLineEdit::TrailingPosition, flags); + widgetAction->setVisible(!text().isEmpty()); } else { QAction *clearAction = findChild<QAction *>(QLatin1String(clearButtonActionNameC)); Q_ASSERT(clearAction); diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index df8d534afa..6dcb2dd693 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -392,9 +392,47 @@ void QLineEditIconButton::setOpacity(qreal value) } #if QT_CONFIG(animation) +bool QLineEditIconButton::shouldHideWithText() const +{ + return m_hideWithText; +} + +void QLineEditIconButton::setHideWithText(bool hide) +{ + m_hideWithText = hide; +} + +void QLineEditIconButton::onAnimationFinished() +{ + if (shouldHideWithText() && isVisible() && !m_wasHidden) { + hide(); + + // Invalidate previous geometry to take into account new size of side widgets + if (auto le = lineEditPrivate()) + le->updateGeometry_helper(true); + } +} + +void QLineEditIconButton::animateShow(bool visible) +{ + m_wasHidden = visible; + + if (shouldHideWithText() && !isVisible()) { + show(); + + // Invalidate previous geometry to take into account new size of side widgets + if (auto le = lineEditPrivate()) + le->updateGeometry_helper(true); + } + + startOpacityAnimation(visible ? 1.0 : 0.0); +} + void QLineEditIconButton::startOpacityAnimation(qreal endValue) { QPropertyAnimation *animation = new QPropertyAnimation(this, QByteArrayLiteral("opacity")); + connect(animation, &QPropertyAnimation::finished, this, &QLineEditIconButton::onAnimationFinished); + animation->setDuration(160); animation->setEndValue(endValue); animation->start(QAbstractAnimation::DeleteWhenStopped); @@ -409,6 +447,16 @@ void QLineEditIconButton::updateCursor() } #endif // QT_CONFIG(toolbutton) +#if QT_CONFIG(animation) && QT_CONFIG(toolbutton) +static void displayWidgets(const QLineEditPrivate::SideWidgetEntryList &widgets, bool display) +{ + for (const auto &e : widgets) { + if (e.flags & QLineEditPrivate::SideWidgetFadeInWithText) + static_cast<QLineEditIconButton *>(e.widget)->animateShow(display); + } +} +#endif + void QLineEditPrivate::_q_textChanged(const QString &text) { if (hasSideWidgets()) { @@ -416,15 +464,9 @@ void QLineEditPrivate::_q_textChanged(const QString &text) if (!newTextSize || !lastTextSize) { lastTextSize = newTextSize; #if QT_CONFIG(animation) && QT_CONFIG(toolbutton) - const bool fadeIn = newTextSize > 0; - for (const SideWidgetEntry &e : leadingSideWidgets) { - if (e.flags & SideWidgetFadeInWithText) - static_cast<QLineEditIconButton *>(e.widget)->animateShow(fadeIn); - } - for (const SideWidgetEntry &e : trailingSideWidgets) { - if (e.flags & SideWidgetFadeInWithText) - static_cast<QLineEditIconButton *>(e.widget)->animateShow(fadeIn); - } + const bool display = newTextSize > 0; + displayWidgets(leadingSideWidgets, display); + displayWidgets(trailingSideWidgets, display); #endif } } @@ -541,8 +583,15 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE QLineEditIconButton *toolButton = new QLineEditIconButton(q); toolButton->setIcon(newAction->icon()); toolButton->setOpacity(lastTextSize > 0 || !(flags & SideWidgetFadeInWithText) ? 1 : 0); - if (flags & SideWidgetClearButton) + if (flags & SideWidgetClearButton) { QObject::connect(toolButton, SIGNAL(clicked()), q, SLOT(_q_clearButtonClicked())); + +#if QT_CONFIG(animation) + // The clear button is handled only by this widget. The button should be really + // shown/hidden in order to calculate size hints correctly. + toolButton->setHideWithText(true); +#endif + } toolButton->setDefaultAction(newAction); w = toolButton; #else @@ -606,33 +655,26 @@ void QLineEditPrivate::removeAction(QAction *action) #endif // QT_CONFIG(action) } -static bool isSideWidgetVisible(const QLineEditPrivate::SideWidgetEntry &e) +static int effectiveTextMargin(int defaultMargin, const QLineEditPrivate::SideWidgetEntryList &widgets, + const QLineEditPrivate::SideWidgetParameters ¶meters) { - return e.widget->isVisible(); + if (widgets.empty()) + return defaultMargin; + + return defaultMargin + (parameters.margin + parameters.widgetWidth) * + int(std::count_if(widgets.begin(), widgets.end(), + [](const QLineEditPrivate::SideWidgetEntry &e) { + return e.widget->isVisibleTo(e.widget->parentWidget()); })); } int QLineEditPrivate::effectiveLeftTextMargin() const { - int result = leftTextMargin; - if (!leftSideWidgetList().empty()) { - const SideWidgetParameters p = sideWidgetParameters(); - result += (p.margin + p.widgetWidth) - * int(std::count_if(leftSideWidgetList().begin(), leftSideWidgetList().end(), - isSideWidgetVisible)); - } - return result; + return effectiveTextMargin(leftTextMargin, leftSideWidgetList(), sideWidgetParameters()); } int QLineEditPrivate::effectiveRightTextMargin() const { - int result = rightTextMargin; - if (!rightSideWidgetList().empty()) { - const SideWidgetParameters p = sideWidgetParameters(); - result += (p.margin + p.widgetWidth) - * int(std::count_if(rightSideWidgetList().begin(), rightSideWidgetList().end(), - isSideWidgetVisible)); - } - return result; + return effectiveTextMargin(rightTextMargin, rightSideWidgetList(), sideWidgetParameters()); } diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 7cd91dfc29..12a2f1ddfd 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -90,7 +90,10 @@ public: qreal opacity() const { return m_opacity; } void setOpacity(qreal value); #if QT_CONFIG(animation) - void animateShow(bool visible) { startOpacityAnimation(visible ? 1.0 : 0.0); } + void animateShow(bool visible); + + bool shouldHideWithText() const; + void setHideWithText(bool hide); #endif protected: @@ -100,6 +103,10 @@ protected: private slots: void updateCursor(); +#if QT_CONFIG(animation) + void onAnimationFinished(); +#endif + private: #if QT_CONFIG(animation) void startOpacityAnimation(qreal endValue); @@ -107,6 +114,12 @@ private: QLineEditPrivate *lineEditPrivate() const; qreal m_opacity; + +#if QT_CONFIG(animation) + bool m_hideWithText = false; + bool m_wasHidden = false; +#endif + }; #endif // QT_CONFIG(toolbutton) diff --git a/src/winmain/winmain.pro b/src/winmain/winmain.pro index 4140ae48de..61e9f29d23 100644 --- a/src/winmain/winmain.pro +++ b/src/winmain/winmain.pro @@ -12,10 +12,10 @@ DEFINES += QT_NO_FOREACH qtConfig(debug_and_release): CONFIG += build_all -win32-msvc*:QMAKE_CFLAGS_DEBUG -= -Zi -win32-msvc*:QMAKE_CXXFLAGS_DEBUG -= -Zi -win32-msvc*:QMAKE_CFLAGS_DEBUG *= -Z7 -win32-msvc*:QMAKE_CXXFLAGS_DEBUG *= -Z7 +msvc: QMAKE_CFLAGS_DEBUG -= -Zi +msvc: QMAKE_CXXFLAGS_DEBUG -= -Zi +msvc: QMAKE_CFLAGS_DEBUG *= -Z7 +msvc: QMAKE_CXXFLAGS_DEBUG *= -Z7 mingw: DEFINES += QT_NEEDS_QMAIN winrt { |