summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
Commit message (Collapse)AuthorAgeFilesLines
* Fix QMenu size on first showThorbjørn Lund Martsum2022-05-231-0/+9
| | | | | | | | | | | | QWidget::metric is used to calculate the size of the menu, but it only respects a sceen from a Window handle, so we need to make sure such a thing is created. Task-number: QTBUG-103309 Pick-to: 6.2 6.3 Change-Id: Ie73e362cdcb3b59f46ad51c4901fdbeda7258baa Reviewed-by: Morten Kristensen <me@mortens.dev> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Don't hide a widget that is swapped into a hidden splitterVolker Hilsheimer2022-05-231-2/+10
| | | | | | | | | | | | | | | | | When replacing a widget in a hidden splitter, then we only need to keep the new widget hidden if the previous widget was hidden. If the new widget is not explicitly hidden, and the splitter is already visible, then we need to explicitly show the new widget. Augment test case; the existing test cases already cover swapping out a collapsed or hidden widget. Fixes: QTBUG-102134 Pick-to: 6.3 6.2 Change-Id: I9b60711a5c1cab79777ce4183783114a16ac3394 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix crash in tst_qquicktext::implicitSizeEskil Abrahamsen Blomfeldt2022-05-201-1/+1
| | | | | | | | | | | | | This reverts commit 1e938c348b936328fafbcaae4c0c7d91003143e5 and bb2f4d08d9d138e4f70d6d6db46e24e34500becc. bb2f4d08d9d causes the crash, but 1e938c348b93 amends it, so this reverts both. When the cause of the crash has been determined and mitigated, the patches can be recreated. Fixes: QTBUG-103719 Change-Id: Ifc36b3771a96f6c85387a5306a0402d4c508d006 Reviewed-by: David Faure <david.faure@kdab.com>
* QKeySequenceEdit: Extract Method Private::rebuildKeySequence()Marc Mutz2022-05-182-3/+4
| | | | | | | | | | Factor the construction of Private::keySequence from Private::key into a helper function, as we'll need this functionality in more places when we add a maxKeyCount property to the class. Change-Id: I6b08a619c3b6b2a9ff660e9f51b02632c2359a47 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtWidgets: restore Qt 5 compatibility for save/restore stateGiuseppe D'Angelo2022-05-183-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Several classes in QWidget use QDataStream internally in order to save and restore state. These QDataStream usages were not versioned, meaning that if Qt changes the serialization for some datatype, then the data saved between different Qt versions becomes incompatible. Note that the save/restore API in question just produce opaque blobs as QByteArrays -- the user has no control over the QDataStream objects and thus versions. Fix by version the usages. In QHeaderView this has caused a regression because QBitArray *did* change version between Qt 5 and 6. In general, using QDataStream without explicit versioning is a mistake, so deploy the same fix elsewhere as well. Fixes: QTBUG-99487 Pick-to: 5.15 6.2 6.3 Change-Id: I82bb5c266f4e5dedc0887cbef855dccab1015e29 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: <doctor.whom@gmail.com>
* QTextDocument/QGraphicsTextItem: skip layout in setTextWidth(0)David Faure2022-05-171-1/+1
| | | | | | | | | | | | | | | | | | In a QGraphicsTextItem without a width yet, there's no need to do any layouting. The use case is obviously items with an app-defined size, not the default where text items adapt to their contents. Results: 0.065 msecs to create a QGraphicsTextItem with some text (layouted) 0.036 msecs to set everything up in a QGraphicsTextItem with 0 width QTextEdit was abusing the width 0 to mean "no wrap, width comes from contents", but since the value -1 means that already in QTextDocument, QTextEdit now uses a width of -1 for that meaning. Change-Id: I67ad59c305e5dd34830886e4e6c56dde03c93668 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QWidgetTextControl: don't clear() a new empty documentDavid Faure2022-05-161-1/+1
| | | | | | | | | | | | | | Before: 0.063 msecs per iteration After: 0.054 msecs per iteration clear() takes time because: 1) QTextDocumentLayout::documentChanged() => doLayout() => layoutFrame() 2) QTextDocumentPrivate::init() => insertBlock() => finishEdit() => QTextDocumentLayout::documentChanged() => layoutStep() => ... => doLayout() again Pick-to: 6.3 6.2 Change-Id: I7a13164d06a1ed77226f2b9d7d12e69ce5b31dfe Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-16143-5439/+291
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add a clear action to QKeySequenceEditLaszlo Papp2022-05-112-2/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This can be really helpful for deleting shortcuts that one may never intend to use so that they do not accidentally get in the way while interacting with the user interface. The workaround is to try to find the QLineEdit child of the QKeySequenceEdit widget, but it is suboptimal. Some first-class citizen API for this would be a more stable and cleaner solution as opposed to poking implementation details as a user of the QKeySequenceEdit API. The clear action would be configurable and opt-in as not everyone may potentially want this to be turned on. Or at least, not by default anyway. Also, not to suddenly change existing QKeySequenceEdit uses with surprising UI changes after a Qt upgrade, this needs to be opt-in. Moreover, some customers may have already used findChild<QLineEdit *>() to add actions to QKeySequenceEdit in this way on the client side. So, if it was enabled by default, they would suddenly get multiple actions potentially for the same clear action. This would be certainly undesirable. The new clear property is based on the corresponding QLineEdit API for consistency. [ChangeLog][QtWidgets][QKeySequenceEdit] Added a clear action to QKeySequenceEdit to be able to remove existing hotkey configurations. Change-Id: I3a90bfacd49bff10c1284abb155d7edd4f537900 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QWidgetTextControl: port to new-style connects (faster)David Faure2022-05-102-17/+20
| | | | | | | | | | | | | | | This speeds up creating a QGraphicsTextItem by 14% in an optimized build Before: 0.070 msecs per iteration After: 0.060 msecs per iteration Those connects were showing up when profiling, because of the string parsing that is necessary when using SIGNAL/SLOT macros. The stacktrace was connect() => decodeMethodSignature() => argumentTypesFromString() => QArgumentType constructor => qMetaTypeInternal(const char*). Pick-to: 6.3 6.2 5.15 Change-Id: I3cf5655c5450f121005140bdb587fafa083cce6a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtWidgets: replace remaining uses of QL1String with QL1StringViewSona Kurazyan2022-05-024-6/+7
| | | | | | | Task-number: QTBUG-98434 Change-Id: If20e217e6e4fecd18c7707bf94650f5ba856893f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtWidgets: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-05-0225-93/+134
| | | | | | Task-number: QTBUG-98434 Change-Id: I310ea8f19d73a79d985ebfb8bfbff7a02c424360 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtWidgets: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-2619-76/+73
| | | | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: I133b80334b66e0a5ab9546dd8e1ff0631e79601e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix crash when calling QMainWindow::restoreState()André de la Rocha2022-04-241-2/+2
| | | | | | | | | | | | | | | Restoring the state of a window with a dock widget could cause a crash in a multiple display configuration if the scale or screen arrangement in the system had changed after the state was saved. In this case, the original top-left coordinate of the window could now lie outside of any screens, which would result in a NULL QScreen pointer being dereferenced inside QDockAreaLayout::constrainedRect(). Fixes: QTBUG-102718 Fixes: QTBUG-102541 Pick-to: 6.2 6.3 Change-Id: Ie5e3209b82a33a1dc4568611c1b2ee3a6d8830b7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QGraphicsScene: Fix popup position for QGraphicsProxyWidgetVolodymyr Zibarov2022-04-222-2/+2
| | | | | | | | | | | | | screenGeometry() for proxy widget was returning visible part of the scene instead of screen geometry for enclosing first view Pass button center position to screenGeometry() to get correct screen for cases when graphics view occupies two screens Fixes: QTBUG-98785 Pick-to: 6.2 6.3 Change-Id: Idaeb3c3faf739751c93624a06fa0fd3d65388236 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Clarify comment for QDockAreaLayout::sepAxel Spoerl2022-04-221-1/+1
| | | | | | | | | QDockAreaLayout::sep represents the visual margin between a dock widget and its frame, i.e. a dock within the main window. The comment 'separator extent' has been replaced by a clearer version. Change-Id: Icfb3d549a5bcb00c5f1cf4558c5a1c4f995e31f0 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Shrink dock areas if main window width/height is below 160pxAxel Spoerl2022-04-221-11/+16
| | | | | | | | | | | | | | | Empty drop areas have a fixed size of 80 pixels in QDockAreaLayout. If a main window is below 160 pixels wide or high, drop areas start to overlap. If a main window's width or height is 80px or less, drop areas fully overlap. Dock widgets can't be dropped in overlapping areas, because the dock area becomes ambigous. This patch decreases the width and height used to calculate the drop area rectangle by the extent necessary to prevent docking. QDockAreaLayout::sep (margin between a dock widget and its dock) is used as the new minimum height and width. Change-Id: I1db3282cfc7c602b59bb2f20ba616efe1719b0cb Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Fix QDockWidget parenting and dock permissionsAxel Spoerl2022-04-196-141/+331
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Check DockWidgetArea permissions of QDockWidgetGroupWindows with single dock widget. Obtain a dock widget's tab position from a dock widget group window if it can't be established otherwise. Remove hardcoded assumption that a dock widget is in the left dock. Both cases have lead to inconsistent entries and dangling pointers in QDockAreaLayoutInfo::item_list. Remove warning: QMainWindowLayout::tabPosition called with out-of-bounds value '0', which becomes obsolete by the fix. Create a QDockWidgetGroup window prepered to become a floating tab, whenever a dock widget is being hovered over. Store it in item_list so it can be found and deleted when required. No longer call e->ignore() after propagating close events to the first dock widget and thus preventing others from receiving the event. Add logging category qt.widgets.dockwidgets Update dock widget autotest with tests to check the fixes mentioned: plugging, unplugging, hiding, showing, closing and deleting. Blackist closeAndDelete, floatingTabs test on macos, QEMU, arm, android due to flaky isFloating() response after a dock widget has been closed or plugged. QSKIP dockPermissions and floatingTabs test on Windows due to mouse simulation malfunction. QSKIP hideAndShow test on Linux in case of xcb error (QTBUG-82059) Fixes: QTBUG-99136 Pick-to: 6.3 6.2 Change-Id: Ibd353e0acc9831a0d67c9f682429ab46b94bdbb0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Replace uses of _qs with _s in sources and examplesSona Kurazyan2022-04-191-2/+4
| | | | | | Task-number: QTBUG-101408 Change-Id: I48360ba3b23965cd3d90ac243c100a0656a4cde8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* TextEdit: Avoid scrolling to cursor during app switch on GNOMEVolodymyr Zibarov2022-04-142-0/+8
| | | | | | | | | | | | | | GNOME sends empty InputMethod event when switching applications with Alt-Tab. As long as this event is empty, we don't need to scroll to cursor, because we're not adding any input text to it. This also fixes "out of scope" bug QTCREATORBUG-26628 Fixes: QTBUG-100039 Task-number: QTCREATORBUG-26628 Pick-to: 6.2 6.3 Change-Id: I3ccfea50ae52f6f0cbf82c29f07944894050e7dd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove unnecessary type conversionXiao YaoBing2022-04-061-11/+11
| | | | | Change-Id: I09e3e4596a8c79b3ece08c694010c76e05d8a22b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QSplitter: Don't move handle in non-pressed stateNodir Temirkhodjaev2022-04-051-10/+13
| | | | | | | Fixes: QTBUG-102249 Pick-to: 6.2 6.3 Change-Id: Ib1d74447e346760d1fc9960e11486e8dc7ea3bc0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Correct documentation in QMainWindow in regards to centralwidgetDavid Skoland2022-04-051-4/+1
| | | | | | | | | | | It's quite clear from the code in qmainwindow.cpp and qmainwindowlayout.cpp that centralWidget returns nullptr (not zero) if it's not set. This also seems to be perfectly well supported, contrary to the note given. Change-Id: Ib7ab37f3645089fb85d7262717b7147b5871c1ad Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Remove declared but not defined functionAlbert Astals Cid2022-04-011-1/+0
| | | | | Change-Id: I78a39f87118b3a2d4bc693c2b87a29c46e40032d Reviewed-by: David Faure <david.faure@kdab.com>
* Doc: Add \relates command for documented global functions/macrosTopi Reinio2022-03-251-2/+2
| | | | | | | | | | | | | Global functions need an associated header file/class/namespace to make the documentation visible. Remove QDoc comment tag (/*!) for an internal function. Pick-to: 6.3 Task-number: QTBUG-99578 Change-Id: Id390d433d7e081fc90fa57a02097b6c37fa13bee Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* QNX: Fix compiler warning by when FEATURE_clipboard is not enabledPasi Petäjäjärvi2022-03-221-0/+2
| | | | | | | | | warning: unused parameter 'selectionClipboard' [-Wunused-parameter] Pick-to: 6.2 6.3 5.15 Task-number: QTBUG-101382 Change-Id: I4f42a6f41c8f8a8b3edd3a042c89b7a2a49a96fe Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix warning from deprecated QMouseEvent constructor on macOSVolker Hilsheimer2022-03-211-2/+2
| | | | | | | | Pass global position explicitly. Pick-to: 6.3 Change-Id: I4b9bf735635528c4a289be7db6026162d5a7aff6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QMainWindow: Fix unused separator widgets blocking mouse eventsEike Ziller2022-03-162-0/+9
| | | | | | | | | | | We need to hide separator widgets that are unused, otherwise they block mouse events from the underlying widgets. Pick-to: 6.2 6.3 Fixes: QTCREATORBUG-24600 Change-Id: I98c6d4860f683a861b89c4cad042bb734f590000 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Restore C++20-deprecated mixed-enum bitwise operatorsMarc Mutz2022-03-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C++20 deprecated arithmetic on enum types. For enums used on QFlags<>, these operators have always been user-defined, but when the two enums are of different type, such as QFrame::Shape and QFrame::Shadow, the deprecation warning pops up. We have in the past fixed these in our headers by manual casts, but that doesn't help our users when our API requires them to OR together enums of different type. Until we can rework these APIs to use a variadic QFlags type, we need to fix it in an SC and BC way, which is what this patch sets out to do. The idea is simply to mark pairs of enums that are designed to be ORed together and replace the deprecated built-in bitwise operators with user-defined ones in C++20. To ensure SC and BC, we pass an explicit result type and use that to check, in C++17 builds, that it matches the decltype of the result of the built-in operator. This patch is the first in a series of similar patches. It introduces said markup macro and applies it to all enum pairs that create warnings on (my) Linux GCC 11.3 and Clang 10.0.0 builds. It is expected that more such markups are needed, for other modules, and for symmetry. Even with this patch, there is one mixed-enum warning left, in qxcbwindow.cpp. This appears to be a genuine bug (cf. QTBUG-101306), so this patch doesn't mark the enums involved in it as designed to be used together. This patch also unearthed that QT_TYPESAFE_FLAGS, possibly unsurprisingly so, breaks several mixed bitwise flags-enum operations (QTBUG-101344). Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-99948 Change-Id: I86ec11c1e4d31dfa81e2c3aad031b2aa113503eb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Compose render-to-texture widgets through QRhiLaszlo Agocs2022-03-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QPlatformTextureList holds a QRhiTexture instead of GLuint. A QPlatformBackingStore now optionally can own a QRhi and a QRhiSwapChain for the associated window. Non-GL rendering must use this QRhi everywhere, whereas GL (QOpenGLWidget) can choose to still rely on resource sharing between contexts. A widget tells that it wants QRhi and the desired configuration in a new virtual function in QWidgetPrivate returning a QPlatformBackingStoreRhiConfig. This is evaluated (among a top-level's all children) upon create() before creating the repaint manager and the QWidgetWindow. In QOpenGLWidget what do request is obvious: it will request an OpenGL-based QRhi. QQuickWidget (or a potential future QRhiWidget) will be more interesting: it needs to honor the standard Qt Quick env.vars. and QQuickWindow APIs (or, in whatever way the user configured the QRhiWidget), and so will set up the config struct accordingly. In addition, the rhiconfig and surface type is (re)evaluated when (re)parenting a widget to a new tlw. If needed, this will now trigger a destroy - create on the tlw. This should be be safe to do in setParent. When multiple child widgets report an enabled rhiconfig, the first one (the first child encountered) wins. So e.g. attempting to have a QOpenGLWidget and a Vulkan-based QQuickWidget in the same top-level window will fail one of the widgets (it likely won't render). RasterGLSurface is no longer used by widgets. Rather, the appropriate surface type is chosen. The rhi support in the backingstore is usable without widgets as well. To make rhiFlush() functional, one needs to call setRhiConfig() after creating the QBackingStore. (like QWidget does to top-level windows) Most of the QT_NO_OPENGL ifdefs are eliminated all over the place. Everything with QRhi is unconditional code at compile time, except the actual initialization. Having to plumb the widget tlw's shareContext (or, now, the QRhi) through QWindowPrivate is no longer needed. The old approach does not scale: to implement composeAndFlush (now rhiFlush) we need more than just a QRhi object, and this way we no longer pollute everything starting from the widget level (QWidget's topextra -> QWidgetWindow -> QWindowPrivate) just to send data around. The BackingStoreOpenGLSupport interface and the QtGui - QtOpenGL split is all gone. Instead, there is a QBackingStoreDefaultCompositor in QtGui which is what the default implementations of composeAndFlush and toTexture call. (overriding composeAndFlush and co. f.ex. in eglfs should continue working mostly as-is, apart from adapting to the texture list changes and getting the native OpenGL texture id out of the QRhiTexture) As QQuickWidget is way too complicated to just port as-is, an rhi manual test (rhiwidget) is introduced as a first step, in ordewr to exercise a simple, custom render-to-texture widget that does something using a (not necessarily OpenGL-backed) QRhi and acts as fully functional QWidget (modeled after QOpenGLWidget). This can also form the foundation of a potential future QRhiWidget. It is also possible to force the QRhi-based flushing always, regardless of the presence of render-to-texture widgets. To exercise this, set the env.var. QT_WIDGETS_RHI=1. This picks a platform-specific default, and can be overridden with QT_WIDGETS_RHI_BACKEND. (in sync with Qt Quick) This can eventually be extended to query the platform plugin as well to check if the platform plugin prefers to always do flushes with a 3D API. QOpenGLWidget should work like before from the user's perspective, while internally it has to do some things differently to play nice and prevent regressions with the new rendering architecture. To exercise this better, the qopenglwidget example gets a new tab-based view (that could perhaps replace the example's main window later on?). The openglwidget manual test is made compatible with Qt 6, and gets a counterpart in form of the dockedopenglwidget manual test, which is a modified version of the cube example that features dock widgets. This is relevant in particular because render-to-texture widgets within a QDockWidget has its own specific quirks, with logic taking this into account, hence testing is essential. For existing applications there are two important consequences with this patch in place: - Once the rhi-based composition is enabled, it stays active for the lifetime of the top-level window. - Dynamically creating and parenting the first render-to-texture widget to an already created tlw will destroy and recreate the tlw (and the underlying window). The visible effects of this depend on the platform. (e.g. the window may disappear and reappear on some, whereas with other windowing systems it is not noticeable at all - this is not really different from similar situtions with reparenting or when moving windows between screens, so should be acceptable in practice) - On iOS raster windows are flushed with Metal (and rhi) from now on (previously this was through OpenGL by making flush() call composeAndFlush(). Change-Id: Id05bd0f7a26fa845f8b7ad8eedda3b0e78ab7a4e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix QDockWidget's dock area permissions after hoveringAxel Spoerl2022-03-111-2/+12
| | | | | | | | | | | | | | | | | When a QDockWidget's dock areas are restricted by setAllowedAreas(...) and a second QDockWidget is hovered over it, the first QDockWidget can be docked to any dock area of the main window. Area restrictions will be ignored. That is due to the first QDockWidget being implicitely mutated into a QDockWidgetGroupWindow upon hovering. By definition, the latter has no docking restricitons. This fix adds a check if a QDockWidgetGroupWindow has a single QDockWidget child. In that case, the single child's area permissions will restrict docking. Fixes: QTBUG-100670 Pick-to: 6.3 6.2 5.15 Change-Id: I903b074739953791634f482c9cf4b9a95a1d93d3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Widgets: use QPlatformTheme::ButtonPressKeys for pressing buttonsNoah Davis2022-03-093-39/+49
| | | | | | | | | QComboBox is included because it works like a button when it is not editable. QGroupBox is included because it has a checkbox and QCheckBox is a subclass of QAbstractButton. Change-Id: Iad89259314e77f78c915dce83ec601df94c88941 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QLabel: remove some dynamic allocationsGiuseppe D'Angelo2022-03-012-25/+21
| | | | | | | | | | | QLabelPrivate uses pointers and dynamically allocated objects as a form of optional. To add insult to injury, the objects are implictly shared, compounding the effects in terms of required allocations. Just use std::optional instead. Change-Id: Ica582dc0d2a9ab56f45ce305290541383b7ddeef Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QLabel::setPixmap(): remove the no-op self-maskingGiuseppe D'Angelo2022-02-241-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When calling QLabel::setPixmap() with a 1bpp pixmap (i.e. a bitmap), and that pixmap didn't have a mask set, QLabel would then set the pixmap as its own mask. This seems to be a no-op due to how QPixmap::setMask is coded: void QPixmap::setMask(const QBitmap &mask) { // ... if (static_cast<const QPixmap &>(mask).data == data) // trying to selfmask return; } Moreover, in order to convert the pixmap to a QBitmap, the code would just straight downcast it, triggering UB (if the input to setPixmap wasn't a QBitmap to begin with). I *guess* this was done this way to avoid a QBitmap::fromPixmap call, which however is not expensive at all if the pixmap is already 1bpp, which QLabel::setPixmap checks explicitly (before attempting to mask the pixmap). I don't know the historical reasons for the code to have the shape it had (and the code history is from before open governance). So get two birds with one stone: remove the no-op and also the UB. Change-Id: Ibab20492c2945bd1d01f98a18b168fabc56292b0 Pick-to: 6.3 6.2 5.15 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Protect headers against min/max macrosMarc Mutz2022-02-221-1/+1
| | | | | | | | | | | | ... using the usual pattern, which, being idiomatic, doesn't need a comment explaining it. Pick-to: 6.3 Change-Id: Id6b12450495a18f89e1f83f2018b6218b03ff6a7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Ensure QMainWindow has WA_TranslucentBackground when using unified toolbarTor Arne Vestbø2022-02-181-1/+8
| | | | | | | | | | | | Otherwise the QWindow will not end up with a surface format with an alpha. This issue had been hiding in the shadows because we hard-code the backing store image format to include an alpha, but was discovered when trying to use RHI to flush the backing store, which does respect the window format. Pick-to: 6.2 6.3 Change-Id: Ie2b28ca605fc7aa1b1ed22885c8f56e76d3a0305 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Core: Remove 'properties' featureKai Köhne2022-02-141-10/+0
| | | | | | | | | | | | | Even QtCore alone cannot be built without the properties feature since Qt 5.5. While fixing this is easy, other modules like dbus, networking are also using QObject::property() and friends liberally. All in all I doubt that anybody will miss the feature (otherwise it would have been fixed in the last decade). Change-Id: Iaf3cc20bda54ee2ff3b809fac8fa82b94ecc88c0 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QMdiSubwindow: respect minimum size of subwidgets when shown maximizedChristian Ehrlicher2022-02-111-1/+8
| | | | | | | | | | Size a QMdiSubWindow is no real toplevel widget, QLayout::activate() did not properly set the minimum size based on it's children. Fix this by treating a QMdiSubWindow as a toplevel widget during the calculation. Fixes: QTBUG-100494 Change-Id: Ia2e6c519c7214c36383facd244711bd932231d40 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QPlainTextEdit: fix the visibility of placeholderTextQiang Li2022-02-113-6/+5
| | | | | | | | | | | If one calls setPlainText("") before setting a placeholder text, the placeholder visibility is not updated, and the placeholder is not visible. Fix it by updating placeholderVisible properly. Fixes: QTBUG-96212 Pick-to: 5.15 6.2 6.3 Change-Id: I1bd3f0cb4c59973a847bcf3787e35d7c17b6d673 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* qtextstream.h: streamline includesFabian Kosmale2022-02-101-0/+1
| | | | | | | | | | | [ChangeLog][Potentially Source-Incompatible Changes] The qtextstream header no longer includes <QString>, <QStringEncoder> and <QStringDecoder>. Code which relied on the implicit inclusion of those classes might now need to include the headers explicitly. Task-number: QTBUG-97601 Change-Id: Ifb8c8452026195a772c0588dbbbc53fb51cac548 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make one QT_REMOVED_SINCE/QT_BUILD_REMOVED_API per moduleMarc Mutz2022-02-013-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A single global QT_REMOVED_SINCE will start hurting us once more modules downstream of QtCore start using the mechanism. With every use of feature, the set of code that needs to compile under QT_BUILD_REMOVED_API increases. Since we use QT_REMOVED_SINCE in situations where overloading the new and the old function don't work in general, this means all code included by any removed_api.cpp needs to be very carefully written to ensure that any calls to the overload set formed by the combination of old and new function(s) don't create ambiguities. Likewise, the set of APIs that change semantics under QT_BUILD_REMOVED_API also increases. At some point, the combination of removed_api.cpp including almost every module header and almost every header exposing source-incompatibilities when included in removed_api.cpp will make maintenance a headache. By making QT_REMOVED_SINCE and QT_BUILD_REMOVED_API per-module (QT_CORE_REMOVED_SINCE, ...), easy now that we generate the export macros using CMake, we limit the scope of this problem to the module using the feature. Downstream modules (say, QtWidgets) will now see the QtCore API like every other user, even in the widgets/compat/removed_api.cpp TU. Pick-to: 6.3 Change-Id: I177bc7bd5aa8791639f97946c98e4592d2c7f9d9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QTabBar: Improve scrolling with high resolution mouse wheelsNoah Davis2022-01-202-2/+17
| | | | | | | | | | | | | | | | | | | | | The current behavior for handling the angle delta of a wheel event changes index the instant there is a change in angle delta. This works fine for mouse wheels that send events with 120 angle delta units and there is also already behavior defined for devices with pixel deltas, but there is nothing good for handling events from high resolution mouse wheels that don't have pixel deltas. This patch makes it so that the current index doesn't change until the accumulated angle delta for the X or Y axis reaches 120. [ChangeLog][QtWidgets][QTabBar] Scrolling with a high resolution mouse wheel changes the current index at a rate more like a normal mouse wheel. Task-number: QTBUG-97844 Pick-to: 6.3 Change-Id: I2e7fd88984a253f6ef8a0008deb7233e4cb4d84a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use QStylePainter when painting widgetsMorten Johan Sørvig2022-01-205-11/+15
| | | | | | | | This makes it easier to set global painter options which affect all style painting. Change-Id: I6a38204ed2d874255e92345e6a6a50d27939fb24 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Remove mentioning of Fowler bookKai Köhne2022-01-1714-20/+14
| | | | | | | | | It is out of print since years, and probably quite dated by now (released 1997). Pick-to: 6.3 Change-Id: I1653eb404713c15d70b8a15858e8c7d12b2e71cb Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* QRollEffect: Remove assignments that have no effectIvan Tkachenko2022-01-131-2/+0
| | | | | | | | | | | Value of the member variable `done` will be overwritten after the end of each `if` block. Pointed out by PVS-Studio static analysis tool: https://habr.com/ru/company/pvs-studio/blog/542760 Change-Id: Icaf965aaebfa8a238dd3569689e1496a30d4b6d1 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Keep original text for text/plain mime dataKai Köhne2022-01-061-1/+1
| | | | | | | | | | | | | | | | | | | | | For historical reasons, QTextDocument[Fragment]::toPlainText replaces nbsp character (U+00A0) with a normal space, and U+2029, and U+2028 characters with a line feed character. This behavior differs from native (plain) text editors. It also creates an asymetry, because the characters in question can be pasted into the document, but not copied out of it. Use the newly introduced QTextDocumentFragment::toRawText() to avoid this conversion. [ChangeLog][QtGui][Drag&Drop] Special characters like &nbsp; are now preserved in the text/plain part of the clipboard when copied from a QTextEdit or QLineEdit. Fixes: QTBUG-99572 Change-Id: If01a5dd98127a59be15a425dc029c7303bce18f1 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix qobject_cast on partially destroyed QWidget/QWindowGiuseppe D'Angelo2022-01-051-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QWidget and QWindow use bits in QObjectPrivate to provide for a couple of shortcuts -- one in qobject_cast, and another in the isWidgetType() / isWindowType() functions in QObject. These can be optimized by simply looking at the bits, without actually doing more expensive runtime casts. These bits were set on construction, but not unset on destruction. The result was for instance that destroying a QWidget would report that the object was still a QWidget when ~QObject was reached. Fix this 1) by setting the bits only when QWidget / QWindow constructors start; 2) by resetting the bits once ~QWidget / ~QWindow are completed. Technically speaking this is not 100% correct in the presence of data members, but luckily those classes don't have any. Amend an existing test for QWidget (whose comment said exactly the opposite of what the test actually did) and add a test for QWindow. Some other code was wrongly relying on isWidgetType() returning true for destroyed QWidgets; amend it as needed. [ChangeLog][QtCore][QObject] Using qobject_cast on partially constructed or destroyed QWidget/QWindow instances now yields correct results. Similarly, using the convenience isWidgetType() / isWindowType() functions now correctly return false on such instances. Before, qobject_cast (and the convenience functions) would erroneously report that a given object was a QWidget (resp. QWindow) even during that object's construction (before QObject's constructor had completed) or destruction (after QWidget's (resp. QWindow's) destructors had been completed). This was semantically wrong and inconsistent with other ways of gathering runtime type information regarding such an object (e.g. dynamic_cast, obj->metaObject()->className() and so on). Pick-to: 6.3 Change-Id: Ic45a887951755a9d1a3b838590f1e9f2c4ae6e92 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QtWidgets: auto-test-export private classes, unbreaking ubsan buildsMarc Mutz2021-12-162-2/+2
| | | | | | | | | | | | These classes are used in their respective tests, but since these only seem to access data members, the missing export macro was never detected. UBSan, however, checks the type_info on each access, so it needs the (polymorphic) class exported. Do so (for -developer-builds). Change-Id: I97b41cfb5dd7f1665cdf4f7a819a42fbf0388621 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Widgets: setTransientParent() when a QMenu is a windowLiang Qi2021-12-082-0/+26
| | | | | | | | | | | | | On some platforms, such as X11 and Wayland with some compositors, QMenu could be a popup window, which should be set a transient parent to get relative position, which is requested by Wayland. Added transientParentWindow() for QMenuPrivate like QDialogPrivate. Fixes: QTBUG-68636 Pick-to: 6.2 Change-Id: I6d8880cb008ecf61a4c005898b38e3953379a13d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add QFontComboBox::setDisplayFontAlbert Astals Cid2021-12-032-0/+28
| | | | | | | | | Allows changing the font used to display a font family [ChangeLog][QtWidgets][QFontComboBox] Added the setDisplayFont() function, in order to be able to control the font used to render the font name and sample text (when previewing the fonts). Change-Id: I94bfef43142c5346237e3069449bd19dbacb7420 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>