summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
Commit message (Collapse)AuthorAgeFilesLines
* Fix QDockWidget move between screens with different dprThorbjørn Lund Martsum2022-06-292-1/+30
| | | | | | | | | | | | | | | | | | | When partly moved back and forth between screens with different dprs (device pixel ratios) unexpected jumps and size changes could occur. (See the linked issue for details) This patch maps global coordinates to native ones and vice versa (in QDockWidgetPrivate::mouseMoveEvent()), so that the calculated position is the right coordinate on the right screen. Pick-to: 6.4 6.3 6.2 5.15 Fixes: QTBUG-104205 Change-Id: I0e59792a946e0444fed2e2b857f2f8b140afc9b7 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QKeySequenceEdit: Finish editing when losing focusLaszlo Papp2022-06-282-0/+11
| | | | | | | | | | Do not wait for the timer to time out. When losing the focus, finish editing immediately since we cannot really edit it further without focus. Pick-to: 6.4 Change-Id: If42926ef9b06fbea7592a294f48ea5e99ef57ef8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QKeySequenceEdit: add a maximumSquenceLength propertyLaszlo Papp2022-06-273-8/+60
| | | | | | | | | | | | | | | At the very least, it would be important to have a single combination key sequence. This is commonly seen in keyboard shortcut editors where QKeySequenceEdit is very much applicable. [ChangeLog][QtWidgets][QKeySequenceEdit] Added a maximumSquenceLength property. Done-with: Marc Mutz <marc.mutz@qt.io> Change-Id: Id7fa5a8593eb150fa67d7e89308492c0a200ac36 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Support markdown in QTextEditMimeData; fix pasting trailing newlinesShawn Rutledge2022-06-241-5/+18
| | | | | | | | | | | | | | | | | | | - Since 4edcea762d9ce334c4c1a78234c90c118b81da87 the dropsite example shows markdown if available; and now it shows that when we do DnD of a selection from the richtext example, text/markdown is available. - If we artificially make html unavailable, copying and pasting between widget-based rich text editors uses markdown. In case markdown writer output contains unnecessary backticks due to monospace fonts getting used, the workaround from 1ad456c908467212bc30223a69eb7524b64b86e1 is applied. Pick-to: 6.4 Task-number: QTBUG-76105 Task-number: QTBUG-103484 Change-Id: Ie6ca4dbb450dbc36b3d09fd0df1ae5909aaebca7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Replace a few more QString::fromLatin1() with _s literalsShawn Rutledge2022-06-221-2/+2
| | | | | | | | | Wasn't done in 7d79b94db7debdd1896d1912e3052d5950b05df5 Pick-to: 6.4 Task-number: QTBUG-98434 Change-Id: Id9c26f6b58e2c96a1c5f72154b735b136c57debc Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Add QStringDecoder::decoderForHtml()Lars Knoll2022-06-211-5/+4
| | | | | | | | | | | | | | Now that QStringConverter can handle non UTF encodings through ICU, add a way to get a decoder for arbitrary HTML code. Opposed to QStringConverter::encodingForHtml(), this method will try to create a valid string decoder also for non unicode codecs. Pick-to: 6.4 Change-Id: I343584da1b114396c744f482d9b433c9cedcc511 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMainWindow: fix restoreState() for toolbarsIvan Solovev2022-06-171-0/+4
| | | | | | | | | | | | | | | | | | Restoring the toolbar state of a QMainWindow could not update QWidgetPrivate::widgetItem for the QToolBar, because at that point it was still holding the pointer to the widgetItem of the previous state. Later on, when the new state was successfully applied, the previous state was deleted, and the corresponding widgetItem was reset to nullptr. This patch explicitly resets the QToolBar's widgetItem while updating the state, so that it is later correctly updated while creating a new QWidgetItemV2. Fixes: QTBUG-102395 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: I17613d62423edcc0faf85ecb0a714865a50d87e8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QComboBox: emit currentIndexChanged() and currentTextChanged() when the ↵Ivan Solovev2022-06-161-1/+5
| | | | | | | | | | | | | | | | | | model is cleared QComboBox uses QPersistentModelIndex to store the current index of the underlying model. When the model is cleared, that index is automatically invalidated, so calling QComboBoxPrivate::setCurrentIndex(QModelIndex()) does not result in signals being emitted, because we do not detect the index change. This patch uses indexBeforeChange to detect such situation and emit all necessary signals. Fixes: QTBUG-103007 Pick-to: 6.4 6.3 6.2 Change-Id: I29326830a30a17900839e8d1737a08bd940081ea Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-153-4/+4
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Replace QT_NO_ACCESSIBILITY with QT_CONFIG(accessibility)Allan Sandfeld Jensen2022-06-1525-66/+66
| | | | | | | Pick-to: 6.4 Change-Id: Iee4bd8970810be1b23bdba65a74de912401dca65 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Don't crash when removing the last visible tabVolker Hilsheimer2022-06-131-4/+3
| | | | | | | | | | | | | | | | | | | | The code incorrectly tried to ensure that the firstVisible tab was a valid index, even though there might not be any visible tab left after removing the last visible tab. The same logic didn't exist of the lastVisible tab, so we tripped the assert in qBound, as max (being -1) ended up smaller than min (0). Fix this by removing the wrong correcting of firstVisible to be always valid. Make sure we emit currentChanged with -1 when no visible tab is left after removing the current tab. Add a test. Fixes: QTBUG-104003 Pick-to: 6.3 6.2 Change-Id: I27e6438a02d0a0f1ac4d0e0160cee4f33b3f3766 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QMenu: Adjust the position of the submenuWang Fei2022-06-131-1/+1
| | | | | | | | | | When the submenu is about to exceed the screen, set the position of the submenu to the left border of the main menu Fixes: QTBUG-104050 Change-Id: I8935f1bfceb93cfa1097391689f4233991394978 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QSlider::mouseMoveEvent: Remove code that does nothingAlbert Astals Cid2022-05-301-2/+0
| | | | | Change-Id: If3aea2559051564916e00d8d13fa195fa88e1bab Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* 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>