The NSTextInputClient protocol expects marked (composed) and selected
text ranges to be relative to the document, not to the current editing
block as Qt typically expects.
Luckily we can use the absolute cursor position to compute an absolute
offset that we can apply to any other positions, such as the selection.
Now that we are computing the ranges correctly we can also use them
during text insertion, when the incoming replacementRange is not valid.
We then transform and sanitize the replacement range to the format that
Qt expects for QInputMethodEvent::setCommitString().
Pick-to: 6.2
Change-Id: I4cb2f7c63adb92e407f38af05adce539c9bed7e2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The nested widget might be a QGraphicsView as well (documented to be
supported), and QGraphicsScene maintains it's own activation status by
counting Window(De)Activate events. We need to make sure that the
embedded widget is informed about its activation status so that deeper
nested children can receive focus.
Forward WindowActivate/Deactivate events to the nested widget, which
will pass it on to all its children. Add test case, which without this
fix fails when verifying the inner scene's isActive state, or later
when testing that focusInEvent is delivered to the embedded widget.
Fixes: QTBUG-94091
Pick-to: 5.15 6.1 6.2
Change-Id: I4e0ecef50685ed081d15c7f76b6c1a4a40ed2682
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
An oversight in the code kept the algorithm in the GB11 state, even if
the codepoint that is being processed wouldn't allow for that (for
instance a sequence of ExtPic, Ext and Any).
Refactor the code of GB11/GB12/GB13 to deal with code points that break
the sequences (falling back to "normal" handling).
Add some manual tests; interestingly enough, the failing cases are not
covered by Unicode's tests, as we now pass the entire test suite.
Amends a794c5e287.
Fixes: QTBUG-94951
Pick-to: 6.1 5.15
Change-Id: If987d5ccf7c6b13de36d049b1b3d88a3c4b6dd00
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The mapping of the dash offset into the dash pattern was susceptible
to int overflow.
Pick-to: 6.2 6.1 5.15
Change-Id: I254ed40b323ef516d10abc8e6008b14cfc23d2a0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Since the dashing is computed even outside the clipping and device
area, painting very long dashed lines could consume unexpected amounts
of time and resources. Fix by placing a limit on the dashing, and fall
back to solid line drawing if hit.
Fixes: QTBUG-95594
Pick-to: 6.2 6.1 5.15
Change-Id: Ida05ecd8fe6df402c9e669206fd5cec4a9f5386a
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
The "wantedMask" check in the xml generator didn't distinguish slots
from invokables, so exporting an object with just ExportScriptableInvokables
didn't allow calling Q_SCRIPTABLE methods.
Change-Id: I7b408755da5b28e67a9384d9df95e22dc5de2369
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This, however, has to wait for Qt 7 for compat reasons.
Change-Id: I84db4715bf2e9d080d1446d24f0996c78a875e63
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Need to disable zstd compression if its support is not built in Qt
for Android. The flag is dected when configuring user's project and
is a part of the deployment settings. This partially fixes loading of
android_rcc_bundle.rcc.
Pick-to: 6.2
Task-number: QTBUG-93340
Task-number: QTBUG-95969
Change-Id: I635afb3f9e182a559d53e9344e07f62788f9837d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
QInputMethodEvent::Selection unfortunately doesn't apply to the
preedit text, and QInputMethodEvent::Cursor which does, doesn't
support setting a selection. Until we've introduced attributes
that allow us to propagate the preedit selection semantically
we resort to styling the selection via the TextFormat attribute,
so that the preedit selection is visible to the user.
This allows us to remove the fallback we had for thick and double
underline styles, where we mapped those to the wiggly underline style.
This was needed to distinguish the selected cluster when composing
CJK, but looked out of place.
One disadvantage of faking the selection via text format is that
we will not update the selection color on theme change, e.g. when
switching from light to dark mode, but this is a minor issue that we
can live with until we've introduced a proper QInputMethodEvent
attribute for the preedit selection.
Pick-to: 6.2
Change-Id: I1c45c310107697962e328a4db908d29d2358f756
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
When we are unable to get the line thickness from a font, we
fall back to calculating this based on pixel size and weight.
But the font weight scale has changed in Qt 6, causing the
calculated font weight to be 10x as thick as it should.
This happened e.g. for Titillium Web, but only when using 100%
UI scaling, because the GDI engine was unable to get the correct
line thickness from the font, whereas the DirectWrite engine
succeeded.
[ChangeLog][Windows] Fixes an issue where underlines and other
decorations would be too thick for some fonts.
Pick-to: 6.1 6.2
Fixes: QTBUG-94529
Change-Id: Id2c88f0a145776151be0399ee646f28b3bdf9072
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
The current code assumed that the lack of persistent permissions means
we cannot access the file at all. That however isn't the case for
content: URLs we get e.g. via Intents, those are accessible perfectly
fine via QFile, we just don't have (and can't obtain) persistent
permissions for them.
This is done by continuing in the case of not having persistent
permissions and checking for SecurityExceptions that are thrown when
accessing content: URLs we really have no permission for.
Pick-to: 6.2 5.15
Change-Id: I39115a7730d717eb9517e4f1c1a57e40988001a5
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
In the process, actually use the constants as the size of some arrays,
instead of making [1024] arrays and then only using a few entries.
Change-Id: I9f36b322840393b8680788190cf8b40a828f4957
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
The call getStateCount() was introduced in 29, so cases for
lower API should be handled.
Pick-to: 6.2 6.1
Change-Id: I7f58541c0b16fed91835e6f390afa89378a7af3e
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
It tried to find its test-data-directory locally, instead of asking
FileSystem where it was keeping its files, relative to a temporary
directory. Its expected counts didn't match the arcane results of its
data file; since this is a benchmark, not a regression test, I'm
assuming that's just because it was never right or the rules for
QDirIterator's filtering have changed.
Tidied up somewhat in the process.
Change-Id: Ib2dcd314b11cb0f1a6fc425633afd0e9c39bd036
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
If in a QLineEdit the placeholderText uses e.g. Tibetan language, then the
height of font as reported by QFontMetrics might be less than the height
of the boundingRect calculated for the placeholderText. This can cause the
placeholderText to display incompletely.
Fix this by using QFontMetrics::boundingRect instead of QFontMetrics::height
when computing lineRect.
Fixes: QTBUG-95341
Pick-to: 5.15 6.1 6.2
Change-Id: I9eef35fd89c5c1d79f6dd703355634d6905ca967
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
As QPropertyAlias was public by accident in 6.0, we have to ensure that
it still works in 6.2.
This re-adds some tests for it, and reimplements the unlinking
functionality. To avoid performance regressions in hot-paths,
a new unlink_fast function is added, which behaves like the old unlink:
It ignores the special handling for QPropertyAlias, so that we can skip
the tag check. It is only used in QPropertyObserverNodeProtector and
clearDependencyObservers, where we already know the type of the
observer.
Fixes: QTBUG-95846
Pick-to: 6.2
Change-Id: Ifb405b8327c4d61c673b1a912ed6e169d27c2d8f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
When documenting a CMake command, document the unversioned command
'qt_foo' and use '\versionlessCMakeCommandNote qt6_foo' to refer to the
versioned command. This avoids duplicating the command signature.
Use the new macro where applicable.
Pick-to: 6.2
Task-number: QTBUG-95796
Change-Id: I2e4180fbda0b89acf3d8c036459f591eb2f46475
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Found by CodeChecker.
The function returns early in case of empty path, but the bool
parameter is never updated in this case. It's not a problem
with the current codebase though.
As it's a static local function, the reasonable solution is just
to add an assert, so that we do not get hit in case of refactoring.
Task-number: QTBUG-95727
Pick-to: 6.2
Change-Id: Idc00356c61b5db8b2204a574612c1ea8e65f4a69
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
adjusted(1, 1, -2, -2) makes the rectangle smaller, but when
rect.x1-rect.x2 = 0. Then x1 + 1, x2-2 leads to x1> x2. This will
make the rectangle flip in advance. So there is a difference
between the updated area and the drawn area.
Add a judgment, when the rectangle we get is large enough, draw the inner rectangle.
Fixes: QTBUG-95716
Done-with: Oliver Eftevaag <oliver.eftevaag@qt.io>
Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io>
Pick-to: 6.2
Change-Id: I0d081a4ad7aee4a563acb988c0ef19a646bf1eea
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
[ChangeLog][Text] Updated bundled Harfbuzz to
version 2.9.0.
Pick-to: 6.2
Change-Id: Ib8fed753b99a127d5a4cc793c5c1d55a0090f902
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Rewrite the whole function for readability _and_ performance:
- Extract Method isValidSuffix() as a lambda
- Extract Method isNumeric() as a lambda
- Use a C array of QLatin1String instead of a QStringList to hold the
statically-sized list of candidate suffixes. This has the nice
side-effect that the compiler will now throw an error in case the
#ifdef'ery yields zero candidates (C arrays cannot have no
elements), e.g. when porting to a new platform.
- Last, not least, replace the parsing with a loop that makes clear
what's going on and which is forward-iteration-only-compatible, so
we can use QStringTokenizer directly, without toContainer() to get a
random-access sequence.
Need to use the C++20 version of all_of(), since QStringTokenizer uses
sentinels instead of end-iterators.
Even though we use higher-level constructs now, the code is still more
efficient than the index-twisting we had before.
Change-Id: I9f3faf3e30f58c9eb8a1487a7ca190681e87767b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The cursor position as reflected by these two properties is not affected
by the offset of the cursor in the preedit area. That means that when
composing text, the cursor position stays the same, at the preedit
insertion point, regardless of where the cursor is positioned within
the preedit string by the QInputMethodEvent::Cursor attribute.
Pick-to: 6.2
Change-Id: Ic2584369f92271e3f242d51f2e647f6f05c72d53
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
When the marked text was not an attributed string with built in styling
we used to fall back to a hard-coded underline style.
We now pick up the default marked text style via the markedTextAttributes
property of a temporarily created NSView, which by default is a yellow
background color.
The implementation in NSView respects text system configuration toggles
such as NSMarkedTextAttribute and NSMarkedTextColor, so by setting the
user default NSMarkedTextAttribute to "Underline" the marked text will
look like our old hard-coded default. This can be done in many ways,
including passing `-NSMarkedTextAttribute Underline` on the command
line, or by QSettings::setValue("NSMarkedTextAttribute", "Underline");
Pick-to: 6.2
Change-Id: Iede74836ed1449e77018c13733a675f8e9d84f7d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The logic was not taking into account that we were always adding
an QInputMethodEvent::Cursor attribute, so we would never hit the
fallback code.
Pick-to: 6.2
Change-Id: I25bd725025152241a55e3fea60444c20e27db4f9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
We don't need to condition this on IM enablement. The attributes are
only used if we are actually marking text, which only happens for IM
enabled views.
Pick-to: 6.2
Change-Id: I47377cf53cf2bf44a1d9513d317f82c73f083fa3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
When assigning multiple variables to a specific section, both GCC
and Clang legitimately error out if those variables wouldn't end
up in the same section (e.g. if one of them is going to a read-only
section while the other one is going to a read-write section).
In C++, when a seemingly const variable needs dynamic initialization,
it needs to be stored in a read-write section.
Clang 13 changed internals for how some constants are materialized.
Now, when a variable is initialized with an expression containing
plain old fashioned casts, it is considered to be potentially
runtime initialized (at the point when section assignment conflicts
is evaluated). Therefore, Clang 13 errors out on fakeplugin.cpp
with errors like:
fakeplugin.cpp:36:39: error: 'message' causes a section type conflict with 'pluginSection'
QT_PLUGIN_METADATA_SECTION const char message[] = "QTMETADATA";
^
fakeplugin.cpp:32:40: note: declared here
QT_PLUGIN_METADATA_SECTION void *const pluginSection = (void*)(0xc0ffeec0ffeeL);
^
See https://bugs.llvm.org/show_bug.cgi?id=51442 for discussion
on the matter in Clang.
To simplify things, just initialize the fake pointers as regular
uintptr_t instead, avoiding the whole matter. This produces the
exact same contents in the section as before.
For what it's worth, the actual manually constructed metadata in
fakeplugin.cpp doesn't seem to have any effect on running the
QPluginLoader tests on either ELF or MachO right now.
Change-Id: Ib84a2ceb20cb8e3a1bb5132a5715538e08049616
Pick-to: 6.2 6.1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Now it's possible to display a configure help screen per module with
qt-configure-module <module-source-dir> -help
Pick-to: 6.2
Fixes: QTBUG-95943
Change-Id: I7d26006246af4b38b5a2ec6deca3f45c5313afec
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This is a preparation for adding the -help argument to
qt-configure-module.bat.
Consider the call
qt-configure-module.bat path/to/qt-module -help
Internally, we called
cmake ... -P .../QtWriteArgsFile.cmake path/to/qt-module -help
which was supposed to separate the arguments and write them into
config.opt.
However, passing arbitrary arguments after "-P script.cmake" only worked
by accident and is not supported. As soon as arguments are passed that
are valid CMake arguments, like -help or -G, the CMake call would fail.
Now, we let configure.bat and qt-configure-module.bat write the
arguments as is into config.opt.in and let QtWriteArgsFile.cmake read
this file, separate the arguments and write config.opt.
Pick-to: 6.2
Task-number: QTBUG-95943
Change-Id: I80f298a2aaf55b0f79fed86320a055eb2d2b6faa
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
URLs can contain underscores, not "undercores".
Pick-to: 6.2
Change-Id: I000ed89649cee0e7c6f283f2d930097961379445
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
This reverts commit 64c111e10f.
The claim of the commit message, that we cannot use the gold linker,
does not seem to be true (anymore?). This is underlined by the fact
that CMake *forces* the gold linker for Android, whenever LTCG is
enabled (see Modules/Compiler/Clang.cmake as of CMake 3.21.1).
Change-Id: I90edac8555be4abdd44cd367228aeffb0d66b895
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
The incorrect "scoping" of q_IOObjectRetain and q_IOObjectRelease
luckily did not affect their functionality as QIOType helpers.
Pick-to: 6.2
Change-Id: I9b9c2312464c7e6f8e2d2a5856e35efa99ec0c41
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
When forcing software scrolling through QScroller::scrollTo,
it will start from (0, 0). QGraphicsViewPrivate::canStartScrollingAt
should consider the locationof points, not just the flags of item.
Fixes: QTBUG-70255
Pick-to: 5.15 6.1 6.2
Change-Id: Iebdd5568baa3bdb41c705204dadb2895cfe9c0e2
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
The standard palette had no value set for ButtonText. The
result was the we drew button text in QtQuickControls2
using Text color instead, which would be wrong in dark
mode, and result in a dark color instead of white.
Note: Widgets hardcode the color "white" directly
in the mac style, and was not affected by the
missing value.
Fixes: QTBUG-89177
Pick-to: 6.2 6.1
Change-Id: Ie2d99bfac9fcc70d45e5bd40ea45becf3fd70d87
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Add painting of sets of lines, both connected and unconnected, that go
outside the device area.
This prepares for fixes & improvements in the painting code.
Pick-to: 6.2 6.1 5.15
Change-Id: I9cffc760524e9ade42362c9a04949270ac24180f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
SetProcessDpiAwarenessContext() returns ERROR_ACCESS_DENIED if the
DPI awareness has already been set, and not E_ACCESSDENIED like
SetProcessDpiAwareness() does.
Pick-to: 6.2
Change-Id: I6b29214773776f31c0622a35494d98c5c9637b0b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
We're passing -Oz for release builds, but that's not a flag the linker
understands when -ltcg is enabled. The build fails with:
ld.gold: fatal error: Optimization level must be between 0 and 3
Fix this by using -O2, which -Oz is based on, and -O3 for the "full
optimization" that is used for core and gui.
Pick-to: 6.2
Fixes: QTBUG-89472
Change-Id: Ie1a86888baefce5ca97026e7d635f10d2819f9f4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
On macOS, we close active popups when handling mouse-down events in the
NSView, but not for such events in the window frame. This allows users
to close a window that has a context menu open via the window's close
button, which then leaves open popups behind.
Factor the popup-closing code out into a dedicated method that we can
call from within the NSWindow::sendEvent implementation for mouse down
events.
Fixes: QTBUG-30522
Pick-to: 6.2 6.1 5.15
Change-Id: I9c354efc449cfefff3ed84fa34b1cd8a0da3b4a7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
For better overview of the flow and functionality of the
NSTextInputClient protocol.
Pick-to: 6.2
Change-Id: I8658405c7ff4ae762bfe3e4c11f9a157ae2b9a09
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>