Commit Graph

7114 Commits

Author SHA1 Message Date
Tor Arne Vestbø
842dbca617 macOS: Detect menu bar roles for untranslated menu titles as well
If an application added an "About" menu action, and then loaded
the qtbase translations, we would try to match the incoming menu
title ("About") against QCoreApplication::translate("QCocoaMenuItem",
"About"), which since qtbase provides translation in the QCocoaMenuItem
context would fail, and we would not detect the menu item role
successfully.

For this to work, the application developer would need to add their
own translations for every menu item, and these translations would
have to match the QCocoaMenuItem translations in qtbase.

By also comparing the menu titles against the untranslated heuristics
we now account for the situation that the app has not translated
its menu items.

If the app does add translations of its menu items these still need
to match the QCocoaMenuItem context translations.

Change-Id: Ic2f019cd42b7e080187f9738840f84b0cec239df
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-16 20:09:38 +02:00
Volker Hilsheimer
b7c15f7f24 Remove the "classwizard" example
It adds nothing new to what the trivial and license wizard examples
show, other than a bunch of somewhat messy and outdated code to generate
C++ code files based on the input.

The example is referenced in a few parts of the documentation, but there
are equivalent snippets in the trivial and license wizard examples, so
point at those instead, and add some relevant API usage where needed.

Pick-to: 6.5
Change-Id: If1ff57e775bad28920d9e019aeccae69d1f4d127
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-16 18:33:18 +02:00
Volker Hilsheimer
11da92ba94 Convert "extension" dialog example into snippets
Pick-to: 6.5
Task-number: QTBUG-108751
Change-Id: I8ca4e058b832674dc0c8b84024cb70a667ee8db4
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-16 18:33:18 +02:00
Oliver Wolff
47e63d436e Don't grab QWhatsThis background on Windows
The workaround also is no longer needed on Windows so it can be removed
completely.

This patch amends 6a28b391f7.

Task-number: QTBUG-113556
Pick-to: 6.5
Change-Id: I69155e54da26acd49faf72816d1439fb3e322de9
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-16 15:55:49 +00:00
Volker Hilsheimer
8e94af2ed0 Revamp the shapedclock example
Rename it to "Translucent Background", as that's what the example shows
how to do. And modern applications shouldn't use a (binary) mask to
create shaped windows. Instead, set the TranslucentBackground attribute,
don't paint pixels that should be fully transparent and use anti-aliased
or semi-opaque painting for pixels that should be translucent.

Adjust the example and documentation accordingly. Move the statment that
widget masks create coarse visual clipping to the QWidget::setMask
documentation.

Pick-to: 6.5
Change-Id: Id49d854093f2cb471afb178d32723081c7543543
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-16 13:37:38 +02:00
Tor Arne Vestbø
6a28b391f7 Don't grab QWhatsThis background on non-Windows platforms
The logic was introduced in 186589abd48b17fdb9b631211008753e2d1701b3
due to Windows supposedly not supporting NoSystemBackground. It's
not clear whether this is still the case, but as this workaround
causes problems on other platforms, such as bringing up the screen
capturing permission dialog on macOS, it should be limited to Windows.

Fixes: QTBUG-113556
Pick-to: 6.5
Change-Id: I197adb5fc177faebc0f2fcd28612e3daa0c22ed5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 18:20:20 +02:00
Volker Hilsheimer
f4b338833e Move the addressbook tutorial into manual tests
The tutorial is building an elaborate UI around a QMap. It doesn't use
structured data, and it doesn't use model/view (which the dedicated
addressbook example in itemviews does).

It's not a good way of building an application, and the individual APIs
for creating layouts, dialogs, or import/export are explained well
enough in other examples.

Pick-to: 6.5
Change-Id: Iffe47a0f6e04a933edb917c877ae845f50b74b4a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-15 14:52:17 +02:00
Topi Reinio
cb8a71dac6 Doc: Replace mentions of deprecated macro
Q_ENUMS() is deprecated in favor of Q_ENUM().

Pick-to: 6.5
Task-number: QTBUG-113229
Change-Id: I29cc23c87b1d6e8eeb49dd1d3ddaf4ca7d2cf8c2
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-05-15 08:57:02 +00:00
Yuhang Zhao
b5d874e36f Fix the QT_REQUIRE_VERSION macro
Rewrite the whole macro as a function and use QVersionNumber instead
of manual parsing to make it more modern and more readable.

Change-Id: I25498320ef6cd9f19be9267421e2727cd28cfd7c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-15 08:47:17 +00:00
Marc Mutz
e3442c05bd QStyleSheetStyle: avoid #define ceil()
There's only one user of this function-like macro and already broke
unity-build, so make it a lambda instead and scope it close.

Remove the previous work-around (#undef at end of TU).

Pick-to: 6.5
Change-Id: I0bd7cd41b89a6f32144d2040ff2b4a18d0045d21
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-05-11 12:47:53 +02:00
Marc Mutz
ad398b2df6 QStyleSheetStyle: fix unity-build with chunk-size 13
The definition of ceil() as a function-style preprocessor macro
appears to clash with the definiton of QFixed::ceil(), included
later. That's an educated guess, though, because the error is
completely different:

    qstylesheetstyle.cpp:141:19: error: expected unqualified-id before ‘int’
      141 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
          |                   ^~~
    qstylesheetstyle.cpp:141:19: note: in definition of macro ‘ceil’
      141 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
          |                   ^~~
    qstylesheetstyle.cpp:141:19: error: expected ‘)’ before ‘int’
      141 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
          |                  ~^~~
    qstylesheetstyle.cpp:141:19: note: in definition of macro ‘ceil’
      141 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
          |                   ^~~
    qstylesheetstyle.cpp:141:19: error: expected ‘)’ before ‘int’
      141 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
          |                 ~ ^~~
    qstylesheetstyle.cpp:141:19: note: in definition of macro ‘ceil’
      141 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
          |                   ^~~

Fix by #undef'ing at the end of the TU. This is a minimal fix,
suitable for backporting to older branches. A more modern fix will be
forthcoming as a follow-up patch.

Pick-to: 6.5 6.2
Change-Id: I8c1b6c7834e55b2bf28044a78ddf5bb544b23c65
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-10 12:00:28 +02:00
Tor Arne Vestbø
e51ff5c493 a11y: Don't add scrollbar container as a11y child if scroll bar is re-parented
If someone has, for unknown reasons, re-parented the scroll bar of a
scroll area to outside the scroll area, we should not blindly add the
parent widget of the scroll bar as an a11y child of the scroll area.

We don't need to explicitly add the scroll bar itself as a child either,
as that will be handled by whoever is the new parent widget, as a normal
scroll bar would.

Fixes: QTBUG-93768
Pick-to: 6.5 6.2
Change-Id: Ib26f31674602e2221311e864ad31bbf141cad8f6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-05-10 02:20:18 +02:00
Jaishree Vyas
8f6ec8cea2 Clarify module changes in Qt6
Changed Briefs for better understanding

Fixes: QTBUG-109324
Pick-to: 6.5
Change-Id: I15b0c0dc12b1bf96626fb8ea4ad16d04b2b118ca
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-05-09 22:36:06 +00:00
Yuhang Zhao
59f8da17e6 QWizard: Win: fix wrong frame size and title bar size
The frame size is resize border size + padded border size [1], so our
current calculation is not correct, and thus the title bar size is
also wrong.

[1] We also use this calculation in the Windows QPA, and it's also
widely used by many open-source repositories, including Microsoft's
own products.

Change-Id: I5a4c1f91a31a22cade6227131659a6de73bb6808
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-06 06:21:52 +00:00
Antti Määttä
fa67cd0334 Use boolean to indicate QTableWidgetItem is header item
QTableWidgetItem uses additional enum flag ItemIsHeaderItem which has
the same numerical value as ItemFlag ItemNeverHasChildren.
This causes conflict since the user can set the latter flag using
the setFlags, while the ItemIsHeaderItem is only used internally
to mark header items.

Remove the additional flag and use boolean instead to fix the conflict.

Pick-to: 6.2 6.5 6.5.1
Fixes: QTBUG-113209
Change-Id: Icff549c7e452d9f84575a524361719204817274e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-05 05:28:19 +00:00
Volker Hilsheimer
2434573f5e QTabBar: don't overshoot when scrolling right
Amends ca15f650a1, after which scrolling
right to fill any gap might have resulted in overshooting to a negative
scrollOffset.

When we scroll right to fit the current tab, then we never want to end
up with a negative scroll, so clamp the result accordingly.

Augment test case accordingly. Since some styles align the tab bar in
the center, replace the calculation of the scroll offset with access to
the private data member (which inverts the sign when compared to the
calculated value).

Task-number: QTBUG-113140
Fixes: QTBUG-113376
Pick-to: 6.5 6.5.1
Change-Id: Ibdc6686b9dbd41b1ae3560e2227fa121d9b20e18
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-04 19:58:50 +00:00
Volker Hilsheimer
a43ca591c1 Fix hiding in QComboBox when there is no selection
If there is an effect on the selected item we want to show it,
but if there is no item to highligh we just close the combo.

Fixes: QTBUG-113311
Pick-to: 6.5
Change-Id: I287af75d27e6f6ff969e4706e16cc8c4812129ea
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-04 19:40:32 +02:00
Thorbjørn Lund Martsum
29b2506e8c Allow disable native messagebox dialog
The native style may not match the program style and it
makes sense to give an option rather than forcing native style.

Before it could only be done with setting AA_DontUseNativeDialogs
on the app, but it is reasonable to use native file dialogs and
Qt styled messageboxes - and it is extremely cumbersome - especially
since messageboxes often can start save dialogs.

It can look a bit strange that these introduced options has just one
option (DontUseNativeDialog) and four functions, but this way it works
similar to QColorDialog, QFileDialog and QFontDialog.

[ChangeLog][QWidgets][QMessageBox] Added options functionality to
QMessagebox. The currently only option available is DontUseNativeDialog.

Change-Id: I70282fcfaa66f245f7e679b8897c607bcaff333f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-02 10:37:17 +02:00
Topi Reinio
37dc52d4f2 Doc: Fix documentation warnings
These warnings slipped in during a time period where documentation
testing in the CI was disabled.

src/network/kernel/qhostinfo.cpp:254: (qdoc) warning: clang couldn't
    find function when parsing \fn template<typename Functor>
    int QHostInfo::lookupHost(const QString &name, Functor functor)

src/widgets/widgets/qcheckbox.cpp:102: (qdoc) warning: clang couldn't
    find function when parsing
    \fn void QCheckBox::stateChanged(Qt::CheckState state)

src/corelib/kernel/qcoreapplication.cpp:2769: (qdoc) warning: clang
    couldn't find function when parsing
    \fn template<typename Functor> void
        QCoreApplication::requestPermission(
        const QPermission &permission, Functor functor)

src/corelib/serialization/qxmlstream.cpp:3806: (qdoc) warning: clang
    couldn't find function when parsing
    \fn bool QXmlStreamAttributes::hasAttribute(
        const QString &qualifiedName) const

src/corelib/text/qtliterals.qdoc:11: (qdoc) warning: Multiple topic
    commands found in comment: \namespace and \headerfile.

Pick-to: 6.5
Change-Id: I38c605f358dbca1ef3e2bfe20a6424f7a4d44b4a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-29 13:22:21 +00:00
Volker Hilsheimer
127e33d4c6 Don't set focus when moving the cursor with a touch pad
On macOS, swiping with a single finger on the track pad (which Qt
identifies as a QInputDevice::DeviceType::TouchPad) results in a
TouchBegin event. For widgets that accept touch events (perhaps
implicitly because they want pan gestures, like QGraphicsView),
this results in a TouchBegin event to be delivered.

QApplication::notify will then check the widget's focus policy, and with
ClickFocus set, will set focus on the widget.

This is not what we want for a TouchBegin on a touch pad, so skip the
setting of the focus for that device type.

Pick-to: 6.5
Fixes: QTBUG-112922
Change-Id: Ie828793a784cc0e2fa47954bf5b396d6a44bd5e8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-04-28 16:12:07 +02:00
Leena Miettinen
3abfd4aa7c Doc: Use qt_add_executable() not add_executable() in snippets
Changes code snippets that are visible in the docs.

Task-number: QTBUG-113116
Pick-to: 6.5
Change-Id: If743234bfe6947acf02307bf1144daad4fba5d73
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-04-26 17:25:50 +02:00
Volker Hilsheimer
ca15f650a1 QTabBar: don't scroll when laying out the tabs
QTabBar lays out the tabs when the bar's size or content changes,
often lazily. This should not change the scroll offset of the tabbar,
which is controlled by the user, or at most when a tab needs to be made
visible (e.g. when it becomes the current tab).

Move the logic of updating the scoll offset into the makeVisible
function, so that the scroll is only adjusted to either leave no gap
between the last tab and the right edge of the widget of there is still
a scroll; or to reset it to 0 if there is enough space for the entire
tab bar. Since layoutTabs does show and hide the scroll buttons, we
cannot skip this when the buttons are invisible. However, the
normalizedScrollRect helper now needs to return the entire widget rect
if there are no visible scroll buttons.

Add a test case that simulates the previously broken behavior where
the scroll got unnecessarily reset to 0 when resizing.

Fixes: QTBUG-113140
Pick-to: 6.5
Change-Id: Ic19fbb82821ea09cc5e7646dcbce3aa7607909c2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-04-26 12:50:49 +02:00
David Schulz
c818acda97 Improve style drawing under DPR scaling further
Rounding distances up can result in coordinates outside of
the clip rect. So stick to always round distances down when we multiply
a scaling.

Fixes: QTBUG-109640
Pick-to: 6.5
Change-Id: I784b7c90da9b6e7f5a925d4275eb67497616001d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-04-25 09:00:24 +00:00
Axel Spoerl
72d6768ec1 Add missing nullptr check in QWidget::setFocusProxy
b1802a164b added handling for a parent to
become focus proxy of a child. The respective 'else if' branch didn't
check whether setFocusProxy() was called with a nullptr argument.

This patch adds the missing nullptr check.
It also adds functionality to tst_QWidget::tabOrderComboBox() to test
the removal of a focus proxy, as well as the complete removal of an
element from the focus chain.

Change-Id: I4cb865b9ac4497fc5e2595910738fb77694f5837
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-25 04:26:10 +02:00
Amir Masoud Abdol
c11cfc2d8d Use QCss:: namespace when accessing Value on Integrity
There seems to be a Value already defined in Integrity, and we `#undef`
it here: `text/qcssparser_p.h:39` to avoid symbol confusion. However,
this is not robust during the unity build where we might not necessary
end up with the preferred ordered of things.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Ide37ab2035f0aa482a1d53d8e1511e0ab0109b3a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-04-23 15:29:43 +02:00
Axel Spoerl
b1802a164b Handle parent being a child's focus procy in QWidget::setFocusProxy
When a parent became a new child's focus proxy in an existing focus
chain, the child was appended at the end of the chain.
That leads to broken tab order, e.g. with a QComboBox which became
editable after a focus chain has been set.

This patch captures the case and insertes the new child after its
parent in the focus chain.

A corresponding test function is added in tst_QWidget.

Fixes: QTBUG-111978
Pick-to: 6.5
Change-Id: I3a426c0560fa830b7b7ffead54f26dd0adef499f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-22 14:57:46 +02:00
Axel Spoerl
d4b40fa96b QTabBar: draw text within moving tab
When a tab was moved by dragging, the tab's rectangle was drawn empty,
without the tab text. When a tab was moved by animated snap back to
its original position, the tab text was already drawn on the original
position, while the rectangle was still moving due to animation.

Adds the enum value QStyleOptionTab::TabPosition::Moving
When this option is set, QCommonStyle draws the tab text at the
current position instead of the original home position of the tab.

The QMacStyle switches over the TabPosition enum. As a moving tab
is laid out like the last tab in the given orientation, the enum value
Moving is treated like End.


Fixes: QTBUG-112277
Change-Id: I42a2d9c269dadfe9819c12dbc69e3ae995a45b09
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-20 16:02:42 +02:00
Liang Qi
fed79b873e QWidgetTextControl: emit cursorPositionChanged() when select all
Fixes: QTBUG-91643
Pick-to: 6.5
Change-Id: I31745a3106321da0be4074a33768da8b84a8ae3f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-20 15:17:25 +02:00
Liang Qi
70f064f270 QWidgetTextControl: ignore invalid input method event
to avoid update the text document.

Fixes: QTBUG-112953
Pick-to: 6.5 6.2 5.15
Change-Id: Ib72de57133314e4eb38a15758b8318d901196d75
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2023-04-19 19:01:54 +02:00
David Faure
b06ae63e8f QComboBox: don't call index(-1, 0) on the underlying model
This is invalid and might assert in the model (e.g. in
QConcatenateTablesProxyModel)

Pick-to: 6.5 6.2
Change-Id: I6602d8b9eca83ef6cae760944a999d55244bb181
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-19 14:11:35 +00:00
David Faure
fed4c3ecba QComboBox: don't call data(invalid index) on the underlying model
QComboBoxPrivate::itemIcon() wasn't checking for an invalid index,
unlike QComboBoxPrivate::itemText().
QComboBoxPrivate::setCurrentIndex calls updateLineEditGeometry,
which calls QComboBox::itemIcon, even for an invalid combobox.

Pick-to: 6.5 6.2
Change-Id: I5e6105ae56836cd237a91a405d331f1424f49b37
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-18 22:32:32 +00:00
Morten Sørvig
e3c9dce0b6 Use QHighDpiScaling when determining scale factor
The makes sure that the scale factor used by the style
is identical to the scale factor used by Qt Gui, by for
instance taking scale factor rounding into account.

Task-id: QTBUG-109715
Change-Id: Ia0354a7ce0f51eb9fd5f2591ee6c4057291943f3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-04-18 12:42:45 +00:00
Mikolaj Boc
020f03c47e FileDialog: Use well-known DeleteOnClose instead of custom lambda
The custom dialog-deleting lambda in QFileDialog::saveFileContent
is redundant

Change-Id: I03c2fa29ab0502b981460e34674a40a704a22e2d
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-18 13:39:20 +02:00
Volker Hilsheimer
ca978e2c12 QStyleSheet: rotate QSizeGrip image around center
Depending on the corner that the size grip lives in, the style sheet
style rotates the painter before rendering the drawable. However, that
needs to be done around the center of the size grip, not around the
origin, as otherwise the image rotates out of the rect.

Use a static array to map the corner to the rotation value, and
translate/rotate/translate back only if there is a rotation.

Pick-to: 6.5
Fixes: QTBUG-112252
Change-Id: I59f69385bd6699ecc8db46390c5f7cc933574ce8
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-04-18 13:23:48 +02:00
Friedemann Kleint
69d4ecd6ef Remove unused documentation code snippets
Modules:
- Core
- Gui
- Widgets
- Open(Widgets)
- PrintSupport
- Sql
- Network
- Concurrent
- Testlib

Pick-to: 6.5
Change-Id: I63e58c01bec4bd162486020f0085227fdaa83b18
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-04-17 21:02:32 +02:00
Christian Ehrlicher
8ca2d6ba09 CommonStyle/QSpinBox: fix rendering up/down symbols in high-dpi mode
The previous patch for QTBUG-112019 could lead to an uneven length which
in results in an incorrect center. Fix it by making sure that the length
(and width) of the two rectangles are even so we always get a proper
center without fiddling around with float values. Also honor
PM_ButtonShiftHorizontal/Vertical now (was forgotten in the last patch).

Pick-to: 6.5
Fixes: QTBUG-112019
Fixes: QTBUG-112861
Change-Id: Ifc19b863c761ae545208b996ba60d1f33bceb2b3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-15 13:56:27 +02:00
Amir Masoud Abdol
38d56e2b72 Add [[maybe_unused]] attribute to an unused variable
Otherwise, it could break the unity build.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Ic1b3ac51b8a9e8bb93a3b1a4d6717fa45099e91b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-04-14 18:34:05 +02:00
Tor Arne Vestbø
06499383ca Use LANGUAGE OBJCXX rather than COMPILE_FLAGS "-x objective-c++"
We sometimes use Objective-C++ code in files with a .cpp extension,
to avoid the churn of adding a foo_mac.mm file. Instead of manually
telling the compiler to build these files in Objective-C++ mode, we
use CMake's intended mechanism, which means genex constructs such as
$<$<COMPILE_LANGUAGE:OBJCXX> will work for these files as well.

Pick-to: 6.5 6.2
Change-Id: If295c3f34f6bee9f4d9f877f519c9c7770665fee
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-04-13 14:36:26 +02:00
Axel Spoerl
d953bc76bb QAbstractButton::setChecked() - don't update accessibility if stale
A QPointer is used as a guard for calling setChecked on a stale object.
The guard is not checked on accessibility updates.

This patch wraps the accessibility update in a guard check.

Fixes: QTBUG-112759
Pick-to: 6.5
Change-Id: Ida47c181b7968911c1805dc244b86347e7afe81b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-13 10:03:52 +02:00
Colin Snover
fc9853dcbf QMainWindow: fix potential crash when restoring tab bar state
Don't activate the mainwindow layout while it is being restored.
Otherwise we might end up in recursive calls to setGeometry.

Pick-to: 6.5
Fixes: QTBUG-111538
Change-Id: I4b6cba9e0abfbae479f71a65b1c4526d92dac081
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-11 18:13:14 +02:00
Colin Snover
5b8ffc6d2a QMainWindow: fix potential assert when restoring dock widget state
Don't append separator widgets at the end if their slot in the list is
still free.

Pick-to: 6.5
Task-number: QTBUG-111538
Change-Id: Id9ada2c083345cfd69633e506cceedc9ae6f2ae4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-11 18:13:14 +02:00
Volker Hilsheimer
7199498fb9 QPushButton: use QMenu::popup instead of exec to show menu
QMenu::exec opens a blocking loop, which is problematic for webassembly.
Replace with QMenu::popup, and reset the down-state of the button when
the menu is about to hide. QMenu emits aboutToHide immediately before
existing the event loop in the hideEvent override, so the timing is the
same.

Change-Id: Iccb418d10fcb25f6ad1f73f9cdce6ea6581bd73b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-04-11 12:58:58 +02:00
Volker Hilsheimer
cf5d9e9eb5 QWidget: add overload to set tab order as a list of widgets
The "two widgets at a time" API to set the tab order is awkward and
easily misused (as the documentation explicitly explains). Add an inline
overload that takes an initializer_list, and call the existing function
for each consecutive pair of widgets in the list.

Add documentation with snippet, and a test.

Change-Id: I8e6f14a242866e3ee7cfb8ecade4697d6bdfb4d4
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-04-11 12:58:58 +02:00
Kaj Grönholm
a2dccbafcf Clear invalid QApplication styleOverride
When QStyleFactory::create() is unable to find/create an override style
set with QT_STYLE_OVERRIDE or "-style", clear the styleOverride. Reason
for this is that Qt Quick Controls otherwise tries to use this invalid
style.

Task-number: QTBUG-100563
Pick-to: 6.5
Change-Id: I48fa6c211ce27d902e2eaf90c34cb5694ad7ecfd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-06 16:28:23 +03:00
Joni Poikelin
588eab99d2 Fix some extra semicolon warnings
Fixes: QTBUG-112648
Pick-to: 6.5
Change-Id: I71446459c7fd6018ecb4deb60a7b9b412c0972ba
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-05 18:59:22 +03:00
Christian Ehrlicher
7763b83c4c Widgets/Styles: pass correct style option struct to subelements
QHeaderView is using QStyleOptionHeaderV2 which should later be used in
the subelements drawings. But since the subelement rect must be
adjusted, a copy is done - sadly only to QStyleOptionHeader so we're
loosing the V2 information.
Therefore explicitly check if it's a V2 and copy it over to the correct
structure.

Pick-to: 6.5 6.2
Fixes: QTBUG-97571
Change-Id: I1482f118e2114cd6ef21c2a800785bd9910c1c5b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-04-04 19:23:37 +02:00
Amir Masoud Abdol
7e074bd8a0 Use Qt CMake APIs to exclude files from Unity Build
This is a bit of a cleanup, mainly around unity build, and a few other
minor things:

- I replaced the direct inclusion of sources files using
  `set_source_files_properties`, and instead used
  `NO_UNITY_BUILD_SOURCES` when possible. In most cases, they are being
  excluded in their respective `qt_internal_extend_target` but sometimes
  I had to make a new extension.
- In few cases, we had to manually exclude the NO_PCH files, so, I
  instead passed them directly to the NO_PCH_SOURCES which also exclude
  them from the unity build as well.
- Removed a few unnecessary ""

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: I466576592c1d115a2da4d88672c1e4b9f995f2ed
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-04-03 12:41:14 +02:00
Sebastian Beckmann
9f44553b3d QComboBox: Disable items marked as disabled in native popups
Fixes: QTBUG-56064
Pick-to: 6.5 6.2 5.15
Change-Id: I00a17a19b4c14c874e16ec863e794218f0570346
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-31 18:35:40 +02:00
Christian Ehrlicher
a1dd9a9f77 CommonStyle/QSpinBox: fix rendering up/down symbols in high-dpi mode
Render the Up/Down and Plus/Minus images for QSpinBox in high-dpi mode.
Found during investigation of QTBUG-112019.

Pick-to: 6.5
Task-number: QTBUG-112019
Change-Id: Ie531311b657180790b0e12a36663012a5f4da6be
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-03-31 12:10:04 +00:00
Axel Spoerl
a815c40e73 QListView: No-op, when a list item is dropped directly behind itself
QListView generates a move, when an item is dropped directly behind
itself. This causes unexpected behavior, e.g. item widgets getting
discarded.

This patch prevents a move from being generated in that case.

It adds an autotest to tst_QWidget, to verify item widgets and item
data do not get discarded in case of a no-op drag&drop.

Fixes: QTBUG-100128
Pick-to: 6.5 6.2
Change-Id: I02a755320a7b71dad218293c9c94c88da6507423
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-03-31 13:09:39 +02:00