So we add the QTextDocument::ResourceType::MarkdownResource enum value to indicate
the type. QMimeDatabase is generally unable to detect markdown by "magic", so we
need to use the common file extensions to detect it (the same extensions as declared
in the mime database XML).
Change-Id: Ib71f03abd535c17e5a8c99bd92d0a6062e972837
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
It's necessary to make the test pass on certain platforms.
Change-Id: I717d492df437c0ffb75b21d9ef23ce602160fad1
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Since its initial implementation, QEventDispatcherWin32 manages a
delivery of the posted events from the window procedure through
WM_QT_SENDPOSTEDEVENTS message. That makes the implementation quite
difficult and unclear. As a result, posted events get stalled,
in case of using nested event loops or other recursion.
The proposed solution is to send posted events at the beginning of
processEvents() only once per iteration of the event loop. However,
in case of using a foreign event loop (e.g. by opening a native
modal dialog), we should leave the emission in the window procedure,
as we don't control its execution.
Task-number: QTBUG-74564
Change-Id: Ib7ce85b65405af6124823dda1451d1370aed9b1a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Flesh out copy-and-pasted code into a function and adjust the coding
style on the go.
Change-Id: I9b8a87d6dd5c33cc1ed9f613fe85daca52309369
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
There's talk that QScopedPointer may be deprecated. Don't use it
in examples anymore.
Change-Id: I3c4647a569b72cd3a628c9b92ef34c87fd588342
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
... instead of qPrintable(), %s, and explicit qt_error_string().
Saves 2KiB in text size on optimized Linux AMD64 GCC 9.1 builds.
Change-Id: I98b6717da1ed1b678f01167d704a96f10da47966
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
... instead of qPrintable() and %s. Avoids temporary QByteArrays.
Saves 1.2KiB in text size on optimized Linux AMD64 GCC 9.1
builds.
Change-Id: Ie626fc478667007ce9a6bc920b8d4ec0451f2cd0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The first two changes avoid creation of a temporary QString and QByteArray each,
by realisiing that QChar is more-or-less wchar_t on Windows and so we can just
use %ls to print the wchar_t array directly.
In msgFindNextFailed(), remove the inline keyword and mark the function as cold
(not sure this has any effect on Windows). When building the result, don't use
QTextStream. Everything that is streamed is text, so just use QString::op+=.
When using the result, use qUtf16Printable and %ls instead of qPrintable and %s,
to avoid the creation of a temporary QByteArray.
Change-Id: I09f576b894761fe342109b386c1de3532200e03c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This allows the QFile factory there to actually return the payload in
a unique_ptr instead of falling back to a raw pointer.
The use of a unique_ptr member requires that the destructor be
out-of-line, since QFile is only forward-declared in the header
file. This is good hygiene, so do it for ProgressDialog, too.
Change-Id: Idb6ed327f9592526bb7d0d5b2cfbffe9f08f3eea
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Collapse the two qWarnings() into one by just storing what is different between them.
Saves more than 400b in text size on optimized AMD64 Linux GCC 9.1 builds.
Change-Id: I16489d6165a550a9ad4ce6a77ca736a1d17a8c8a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
There are no QLatin1String overloads, so using QLatin1String as the
format string produced a temporary QString. Use QStringViewLiteral
instead.
Change-Id: I682eb8cfaa98fdcfb491edd290460db636a98a9f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Pack four qWarning() calls into a separate cold function.
Use qUtf16Printable().
Saves >600b in text size on optimized AMD64 Linux GCC 9.1 builds.
Change-Id: Ib25ea473d1d77faaecaf8750726c83675d87279e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
There's talk that QScopedPointer may be deprecated. Don't use it
in examples anymore.
Change-Id: I05a486c2a86fcc7015a9c21ed0ce9682b0c24034
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Scope a previous iterator variable better so we can re-use 'it' as the
iterator name.
Change-Id: I46d239ad2d3646168408d1ef29ed74fd07bc663f
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
When the families member was added to QFontDef, it was included
in op== and qHash(), however the seed was passed to two qHash()
calls for subobjects. With xor used as the combiner, it could
happen that the seed was xored out (e.g. on empty strings),
leaving a slight opening for prediciable hash values.
Fix by using QtPrivate::QHashCombine, which handles the seed in
such a way as to avoid the issue.
Change-Id: I8a3e4c2f368306446554249763695158df5ac634
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
There's talk that QScopedPointer may be deprecated. Don't use it
in examples anymore.
Change-Id: Ia50ef66de84dae2885f71a9dd83c5909bfa253f0
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Loading a session manager can be problemtatic for system services that
are always auto-activated or small DBus activated helpers which
shouldn't really be restored nor gain anything from a session.
The current solutions is to connect to commitDataRequest and
saveStateRequest and then reset a restart hint.
It's very unintuitive and somewhat wasteful given the X session manager
is full of slow blocking calls.
Rather than changing the behavior of QGuiApplication and handling null
pointers, this patch loads the base QPlatformSessionManager that is used
by QPAs that don't have a session manager.
Change-Id: I976521d551549e2d56076e968c6be5421e4a9c20
Reviewed-by: Albert Astals Cid <aacid@kde.org>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Fix clang warnings like:
warning: class 'QWindowsStaticOpenGLContext' defines a default destructor, a copy constructor and a copy assignment operator but does not define a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions
Change-Id: I736d20476ef407100b6ecb654d1112106e545758
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
The use of a unique_ptr member requires that the destructor be
out-of-line, since the payload is only forward-declared in the header
file. This is good hygiene, so do it for CompositionWidget, too.
Add 'explicit' and missing = nullptr to both constructors as a
drive-by.
Change-Id: Ied1c89864f90d3f2c13fb4e9a8bbbe2e6fd6f1d7
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
We have a problem. Our types don't play well with the std unordered
containers, because they do not specialize std::hash. We therefore
force our users to come up with an implementation, hindering
interoperability, since any two developers are unlikely to come up
with compatible implementations. So combining libraries written by
different developers will result in ODR violations.
Now that we depend on C++11, and thus the presence of std::hash, we
still face the problem that the standard does not provide us with a
means to compose new hash functions out of old ones. In particular, we
cannot, yet, depend on C++17's std::hash<std::string_view> to
implement std::hash<QByteArray>, say. There's also no std::hash for
std::tuple, which would allow easy composition by using std::tie().
So piggy-back on the work we have done over the years on qHash()
functions, and implement the std::hash specializations for Qt types
using the existing qHash() functions, with a twist: The standard
allows implementations to provide means against predictable hash
values. Qt has this, too, but the seed is managed by the container and
passed to the qHash() function as a separate argument. The standard
does not have this explicit seed, so any protection must be implicit
in the normal use of std::hash.
To reap whatever protection that std library has on offer, if any, we
calculate a seed value by hashing int(0). This will be subject to
constant folding if there's no actual seed, but will produce a value
dependent on the seed if there is one.
Add some tests.
A question that remains is how to document the specialization. Can we
have a \stdhashable QDoc macro that does everything for us?
Task-number: QTBUG-33428
Change-Id: Idfe775f1661f8489587353c4b148d76611ac76f3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
It's the same operations as boost::hash_combine, but without
explicit magic numbers.
Change-Id: Id65b6f6b7be3070e4ec349ed0cc062af473a95b3
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
... by replacing them with C++11 range-for loops.
To avoid detaches of these mutable Qt containers,
wrap the container in qAsConst().
Change-Id: I9b5c23c723be024b314a7ad873e21ad63b44b348
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
In a bootstrapped build QCAP does not inherit from QObjectPrivate,
meaning it won't get a polymorphic destructor, causing compile errors.
This is necessary in preparation to add virtuals to QCAP.
The "virtual" keyword is protected to avoid further warnings by
compilers or linters telling that it's unnecessary because the base
class' dtor is already virtual.
Change-Id: Ifbd218154f74b4f1d2f2c5a3ef1fc31970f1c24b
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
0.3.3 plus a few more patches, including the one that adds
MD_BLOCK_CODE_DETAIL::fence_char, which will enable smarter rewriting
of code blocks (indented vs. fenced).
Change-Id: Ibc892369947a8a8edfa4bc20b1df98a5c8153141
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
If any non-breakable content (such as a link) already went past
80 columns, or if a word ended on column 80, it didn't wrap the rest of
the paragraph following.
Change-Id: I27dc0474f18892c34ee2514ea6d5070dae29424f
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
When reading a document like
# heading
- list item
and then re-writing it, it turned into
# heading
- # list item
because QTextCursor::insertList() simply calls QTextCursor::insertBlock(), thus
inheriting block format from the previous block, without an opportunity to
explicitly define the block format. So be more consistent: use
QTextMarkdownImporter::insertBlock() for blocks inside list items too. Now it
fully defines blockFormat first, then inserts the block, and then adds it to
the current list only when the "paragraph" is actually the list item's text
(but not when it's a continuation paragraph). Also, be prepared for applying
and removing block markers to arbitrary blocks, just in case (they might be
useful for block quotes, for example).
Change-Id: I391820af9b65e75abce12abab45d2477c49c86ac
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Add QAbstractTextDocumentLayout::markerAt(pos) for hit testing.
(Qt Quick TextEdit needs it too.) Finds out whether the position
corresponds to a marker on a paragraph. I.e. it finds checkboxes in
GitHub-flavored markdown. This enables editor classes to toggle
checkboxes by clicking them.
Use it in QTextEdit to add the checkbox toggling feature. Also show the
"pointing finger" cursor when hovering a toggleable checkbox.
Change-Id: I036c967ab45e14c836272eac2cc7c7d652543c89
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Solve many duplication between _p_p.h and .cpp, sorted by module and
header name, and move headers for each features at the end of includes.
Change-Id: Ice9189c10d062bc473258b7ace279df057102167
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
By using NSDMI.
Change-Id: I171133b07ba2c7050e0d279caff0c393e03df182
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The "copy" name led me to mis-believe that it was a workaround
to the class being non-copiable, and was missing copying a
data member.
This is instead deliberate; so rename the function to
"copyContextFrom", documenting that version won't be copied.
The function is still private API, so actually make it private;
QMessageLogContext already befriended the only user.
Finally, make it return *this (so that it can be chained,
if necessary) and noexcept.
Change-Id: I3deb3c8edc863a88ac0c37467b144ec2e20db5ca
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
As borders are always painted for single cells any rounding errors that
occur when mapping from fixed point numbers to integers during raster
painting will cause ugly drawing artifacts like extra pixels between
cells or borders that overlap.
To avoid this the following values are being rounded:
- table offset
- column positions and widths
- row positions and cell heights
For the column positions and widths the distribution constraints (total
table width) are respected.
Task-number: QTBUG-43589
Change-Id: I6308c113f8f9be3db8e9267629f26b5d65d2d7c7
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
All calls to QINSTALL or QINSTALL_PROGRAM were written into Makefiles
with a preceding dash which lets make ignore the command's exit code.
Scripts (and users) calling 'make install' had no way to determine if an
installation completely succeeded, unless they inspected make's output
or the installation tree.
Remove the leading dash from those commands to stop 'make install' on
failure. Users who really want to ignore the exit codes can run 'make -k
install'.
[ChangeLog][qmake] Installation targets do not ignore the exit code of
QINSTALL and QINSTALL_PROGRAM anymore.
Fixes: QTBUG-18870
Change-Id: I7c072c896e6bd2b2ddba4b9c082c5bf627c90f50
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Debug/release install targets can potentially install the same files which
leads to errors on install when running make with -j > 1.
If build_all is set, make the 'install' dependent of the new target
'debug-release-install' which contains the commands of 'debug-install' and
'release-install'.
Of course, debug/release is not hard-coded, but the content of the BUILDS
variable is used.
Change-Id: I67b504a95b83daf43bc89dcc0e3391b67e19c027
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>