aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
Commit message (Collapse)AuthorAgeFilesLines
* QQuickTableView: refactor cancelOvershoot()Richard Moe Gustavsen2022-03-072-55/+19
| | | | | | | | | | | | | Since Flickable already has horizontalOvershoot() and verticalOvershoot() functions, there is no reason to calculate this again in TableView. This patch will refactor the overshoot code to use the already available API in Flickable. Task-number: QTBUG-100696 Change-Id: Ifc666e079b0147c3e1cfc6bba2beb287977b303e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Make logicalSize consistent in QQuickWindowAlvin Wong2022-03-071-12/+6
| | | | | | | | | | | | The logicalSize should always be calculated as `QSizeF(pixelSize) / devicePixelRatio`, so that it accurately reflects the actual size of the rendering surface. Extends 17a280995ab546074fa7e9a009642fec5f23c64e. Task-number: QTBUG-101269 Change-Id: Idd1b2337b6ef3456b570c0e619d5b9365ac93495 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* QQuickTableView: change cellAtPos() so that any loaded cell is foundRichard Moe Gustavsen2022-03-051-11/+13
| | | | | | | | | | | | | The current implementation would only find cells that were inside the bounding rect of the view. By changing the function so that it also find cells that are halfway outside the view (as long as they are loaded), it becomes useful also for implementing selection support (finding cells under the current selection, even those cells that are halfway outside the viewport). Task-number: QTBUG-100696 Change-Id: Ie54dc9b8773e7295ead0c9644dbbc5052b8e40fc Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: implement private helper function: atTableEnd()Richard Moe Gustavsen2022-03-052-34/+14
| | | | | | | | | | The pattern of checking if there are more rows or columns that can be loaded around the currently loaded table, is a reoccuring pattern. So factor it out into a more readable function. Task-number: QTBUG-100696 Change-Id: Ia0117a6db0495f3ac1173e24084d074581ff5e7d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: refactor mapping functions from QQuickTreeViewRichard Moe Gustavsen2022-03-054-99/+115
| | | | | | | | | | | | | | | | It turns out we need the modelIndex() and cellAtIndex() mapping functions in QQuickTableView as well, and not only in QQuickTreeView. The reason is that functionality for moving the current index around need to use them in order for the logic to end up correctly for both QQuickTreeView and QQuickTableView. [ChangeLog][QtQuick][TableView] Added a set of functions to get the model index for a cell, and vice versa. Task-number: QTBUG-100696 Change-Id: Ifd2cd3e42bf8141a51c48635e57fb3a22358f1f6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickAnchorChanges: Keep geometry bindings on reverse() and rewind()Ulf Hermann2022-03-022-15/+45
| | | | | | | | | | | This is in line with what we do in other reverse() and rewind() methods. Unfortunately we need to dig deep into the QQuickItem internals in order to get all the flags and callbacks right. Pick-to: 6.2 6.3 Fixes: QTBUG-101186 Change-Id: Icde1a1b2dab1b9cab5adcbc28485a7526a8ac2b7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* A11Y: make QQuickText focusable for A11YIvan Solovev2022-03-021-2/+3
| | | | | | | | | | | | | | | | | | | | | | A QtQuick Text element is used to represent a separate block of text in a window. Normally, when TalkBack is enabled, the user expects to be able to navigate between separate blocks of text with regular A11Y gestures. However before this patch the Text elements were not focusable by default, so all the Text elements in the Window were read by the TalkBack successively, as if it was one element. This could be solved by explicitly adding Accessible.focusable: true to the properties of every Text element. This patch enables A11Y focus on Text elements by default. Fixes: QTBUG-77371 Pick-to: 6.3 6.2 5.15 Change-Id: Icfcef6ee301b9218bb9ace97a05432c9fc2ffb0a Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QQuickText: fix fractional pointSize rounding error bugOliver Eftevaag2022-03-021-20/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The layout is initialized with a copy of the current font before the laying out begins. In cases when setupTextLayout() iterates through the main loop multiple times, it will update the layout font, if it differs. (See code below) if (!once) { if (pixelSize) scaledFont.setPixelSize(scaledFontSize); else scaledFont.setPointSizeF(scaledFontSize); if (layout.font() != scaledFont) layout.setFont(scaledFont); } The whole reason why we might update the font in the first place, is because the QQuickText has a fontSizeMode property which can be set to e.g. HorizontalFit, which will cause the layouting to downscale the font in order to fit (assuming the text doesn't fit the space available), instead of eliding. The problem here is that QFont internally uses a float to store the point size, and we would convert that value to an int when temporarily storing it on the stack. This would modify the pointSize value in cases where the pointSize is fractional, and cause a mismatch between the QQuickText and QTextLayout. The lineWidth is set only during the first loop iteration. During successive iterations of the main loop, the layout's font would be updated to one that has either a floored or ceiled pointSize. If the pointSize is a fractional value, and is ceiled when being updated during the second loop iteration, the layout would use a larger font value, which would cause the QTextLayout::naturalTextWidth() to return a larger value than that of the lineWidth, triggering eliding. Solution: Keep the font precision, by storing the values as floats instead of ints. Fixes: QTBUG-92006 Pick-to: 6.2 6.3 Change-Id: Ibf64ac2dfbf262c6aae05b8eb8251d2f5a869b69 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QQuickTableView: implement getEffectiveRowY/ColumnX()Richard Moe Gustavsen2022-03-022-0/+16
| | | | | | | | | There two functions will be used in subsequent patches to be able to determine the geometry of loaded rows and columns. Task-number: QTBUG-100696 Change-Id: I8619957bcfeafe11b3965e9179a4b7e8c612bbd4 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: be able to specify incubation mode to ↵Richard Moe Gustavsen2022-03-022-3/+3
| | | | | | | | | | | | | | loadAndUnloadVisibleEdges() Later patches that implements animation support for moving the currentIndex around will need to load edges synchronously, even if it can theoretically be inside an asynchronous loader. Add an extra argument to loadAndUnloadVisibleEdges() to be able to specify this from the caller. Task-number: QTBUG-100696 Change-Id: I3dc8e2c137ba0223cd820b7b7286829942f79821 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: make some functions constRichard Moe Gustavsen2022-03-022-21/+21
| | | | | Change-Id: Ib552f25b5bdb252a5447cb49681a8fc9b72953cf Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickLoader: Check for QQmlEngine before using itUlf Hermann2022-03-011-3/+9
| | | | | | | | | | The loader's context may have been removed from the context hierarchy or it may not have a context in the first place. We should not crash then. Pick-to: 5.15 6.2 6.3 Fixes: QTBUG-67950 Change-Id: I1058d5b1f978aa040f8b2f018c4357dd7a3ef333 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickStateOperations: updateGeometry() when setting x/y/w/hUlf Hermann2022-03-011-5/+5
| | | | | | | | | | | Failing to call updateGeometry() and setting the various dirty flags leads to inconsistent state. Pick-to: 6.2 6.3 Fixes: QTBUG-99436 Fixes: QTBUG-98857 Change-Id: I15240b1670947da29e2f05e7ea41c7586f0b987a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix tracking of sg initialized state in rendercontrolLaszlo Agocs2022-02-221-0/+1
| | | | | | | | | | | | | | The initialized = true statement either went missing or it never was there. This has zero effect on the common usage where the client does not bother with invalidate(), but rather destroys the QQuickRenderControl. However, more complex usages, such as in QQuickWidget do need to invalidate for various reasons, without destroying the entire QQuickRenderControl. Pick-to: 6.3 6.2 Change-Id: Iaabc6309cb42cfdd624321863a5504cdeb01275d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* QQuickTreeView: refactor 'setRequiredProperty()' into QQuickTableViewRichard Moe Gustavsen2022-02-224-69/+57
| | | | | | | | | | | | | Both TableView and TreeView needs to be able to set and update required properties. So move this helper function from QQuickTreeView into QQuickTableView, so that they both can use it. This will also make it easier to update how we deal with required properties in TableView/TreeView once QMetaProperty::isRequired() works. Task-number: QTBUG-100696 Change-Id: Iff0a86fe46cecdc4db8d307787fe148c7e71bbf6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Cleanup QQmlGuard and related classesFabian Kosmale2022-02-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An investigation of uses of QQmlGuard (+ related classes) yielded the following results: - objectDestroyed is the only virtual method of QQmlGuard (besides the dtor) - we never have an owning pointer of type QQmlGuard * to one of its subclasess => Therefore, we can replace the use of virtual methods with a function pointer, which avoids the issue of duplicated vtables. None of the objectDestroyed actually cares about the object we pass to them, so we can leave it out in the function pointer. As everything is private API, we could easily bring it back if the need arises in the future. By moving the function pointer into QQmlGuardImpl we also avoid UB in qqmlengine.cpp, which cast any QQmlGuardImpl pointer to QQmlGuard<QObject>. This, however, is wrong as QQmlGuard<T> does not inherit from QQmlGuard<QObject>, even if T inherits from QObject. As we now can sipmly access the pointer from QQmlGuardImpl, we can side-step any casting woes alltogether. Moreover, we use this opportunity to let QQmlStrongJSObjectReference drectly inherit from QQmlGuardImpl. This requires duplicating some of the QQmlGuard API, but on the other hand avoids busy-work to hide no longer desired API. Unfortunately, we can no longer inherit privately from QQmlGuardImpl, as otherwise the various subclasses can no longer cast the QQmlGuardImpl we pass to them to their own type in the objectDestroyed(Impl) methods. QQmlGuard(Impl) still could benefit from a move ctor/assignment operator; those will be added in a later commit. Task-number: QTBUG-45582 Change-Id: I995148a428e541ced5c79b3a61d91c4bb7e03308 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQuick: Reduce number of V4 includesFabian Kosmale2022-02-214-8/+11
| | | | | Change-Id: I801d2489e447309f25883e313cba13050fce20a4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQuickWindow: improve docs for activeFocusItemRichard Moe Gustavsen2022-02-181-0/+2
| | | | | | Pick-to: 6.3 6.2 5.15 Change-Id: I6e107095a7dbd074e076ac6762f18cecf484691f Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* QQuickTreeView: add expandToIndex()Richard Moe Gustavsen2022-02-182-0/+70
| | | | | | | | | | | Add a function that lets you expand the tree recursively from an index in the model, and all the way up to the root. [ChangeLog][QtQuick] New function "expandToIndex()" has been added to TreeView. Change-Id: I063ef698e37f44730438e1638d3b7c1b4edaa0d0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTreeView: add missing \since 6.4 linesRichard Moe Gustavsen2022-02-181-0/+2
| | | | | Change-Id: I5cec24e231c9dc22d384afa5716a1758f59c0311 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTreeView: add collapseRecursively()Richard Moe Gustavsen2022-02-142-4/+65
| | | | | | | | | | | | Add a new function collapseRecursively() to TreeView that lets you collapse a node all the way down to the leaves. [ChangeLog][QtQuick] New function "collapseRecursively()" has been added to TreeView. Change-Id: Ic82def1e45b7d9c2be4c5e7b04d1001e75452ba0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTreeView: add expandRecursively()Richard Moe Gustavsen2022-02-142-12/+68
| | | | | | | | | | | | Add a new function expandRecursively() to TreeView that lets you expand a node all the way down to the leaves. [ChangeLog][QtQuick] New function "expandRecursively()" has been added to TreeView. Change-Id: I665cad48e2a76e2f50ae559f1623ac9427c98fad Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: don't position the table contents outside the viewportRichard Moe Gustavsen2022-02-142-0/+71
| | | | | | | | | | | | | | | | | | | If you call positionViewAtCell(row, Qt.AlignTop) for the last row in the table, the row will be aligned to the top of the view, as requested. But this looks really wrong , since it will cause the table to be flicked to a position that causes it to overshoot by a distance close to the height of the whole view, effectively leaving a big empty gap at the bottom. This looks really buggy. This patch will correct this behavior by ensuring that we never flick the table to an "invalid" position while positioning table at a cell using the requested alignment. Instead we clamp the table to the edges of the viewport. Fixes: QTBUG-100680 Pick-to: 6.3 6.2 Change-Id: Id3003df784a0128df28ee2e78e2456e1fa1e11e8 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Mark QQuickRenderControl constructor explicitShawn Rutledge2022-02-121-1/+1
| | | | | | Pick-to: 6.3 Change-Id: I2adfaa21e5bb446a5ee373f70c3b16c103f4878d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Clean up an incorrect dpr query in QQWLaszlo Agocs2022-02-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | Not incorrect for on-screen windows per se, but all queries must go through QQuickWindow::effectiveDevicePixelRatio(), otherwise nothing handles the redirected cases, i.e. when a QQuickRenderControl subclass reports another QWindow as the "true" window (from which the dpr can be queried), or when a QQuickRenderTarget provides its own custom device pixel ratio. The listeners of the ItemDevicePixelRatioChange notification seem all correct already, for example, QQuickIconImage, upon the item change notification calls effectiveDevicePixelRatio() from QQuickIconImagePrivate::calculateDevicePixelRatio(), and it (very wisely) does not trust the value in the item change notification itself. Same goes for QQuickPaintedItem. But ideally should make the notification report the true value. Change-Id: I1a8cd438abbe63cac93ec20f166c40c2e36239d3 Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Simplify dpr handling when rendering is redirectedLaszlo Agocs2022-02-112-38/+32
| | | | | | | | | | | | | | | | | | We should make effectiveDevicePixelRatio(), i.e. the central point of truth, to take also the QQuickRenderTarget's user-provided dpr value into account, if there is one. QQuickRenderControl::renderWindowFor(), if reimplemented, still takes priority. This allows simplifying the logic in the sync and render steps. The end result is exactly the same, but now with fewer tests and branching, which for instance allows sharing a single code path in places that were split up to three branches before. Amends ddff1591fb5f966826bdc6d54d8c1145c7c260a7 (sort of). Change-Id: I27d801c5fd83b73c2a661532d6780812144aeb44 Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Rename private dev.pix.ratio member var in QQuickWindowLaszlo Agocs2022-02-112-5/+5
| | | | | | | | | | | | | | Calling this devicePixelRatio is fairly confusing: it merely serves as storage for the last notified value for itemChange(), enabling to decide if ItemDevicePixelRatioHasChanged needs to be sent. It has nothing to do with the QQuickWindow's effectiveDevicePixelRatio, QWindow's devicePixelRatio, or the device pixel ratio that is used for rendering, those have their own ways to retrieve the scale factor. Rename it to prevent further confusion. Change-Id: Ibaf3d1a9b4f97f6e4e8cc9ce87c90e170715f632 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* quick: only forward declare QQmlV4FunctionFabian Kosmale2022-02-084-1/+4
| | | | | | | | | In preparation of deprecating/purging it from QQuickItem. As a drive-by, remove a superfluous qquickpainteditem include, and move it to the place where it is needed. Change-Id: I42cda0a34bd5fd7b543790f75eb513303829139f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Stop using QGuiApplicationPrivate::lastCursorPosition.toPoint()Shawn Rutledge2022-02-041-3/+3
| | | | | | | | | | | | | QGuiApplicationPrivate::lastCursorPosition is initialized with qInf(); so before the mouse cursor has moved, attempting to convert to QPoint is an error. QWindow::mapFromGlobal(const QPointF &) exists in Qt 6 so hopefully there's no reason to convert it anyway. Task-number: QTBUG-45045 Task-number: QTBUG-52472 Pick-to: 6.2 6.3 Change-Id: I6ab651e874ed0af2f18735f8bd8eb374a4781bcb Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* TreeView: add missing QML_ADDED_IN_VERSIONShawn Rutledge2022-02-041-0/+1
| | | | | | | | | We don't want it showing up as available in 6.0 and 6.2 in plugins.qmltypes. Amends 18da655b77de70273e1aad7b9c2c4be74f5de91e Pick-to: 6.3 Change-Id: I5f65f031d03af2fa7203deb8d81f3c2a00586dec Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTableView: replace two QFlatMaps with ordered QListsMarc Mutz2022-01-292-56/+40
| | | | | | | | | | | | | The mapped_type of the QFlatMaps wasn't used at all, so don't maintain a separate QList full of zeroes shuffled around with the keys, just use an ordered QList of the keys. Write a minimal wrapper around said ordered QList, because it might come in handy elsewhere. Change-Id: I502b0628d492da792db343ed6ef81b537c258007 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* doc: Fix a typo in a See Also link from QQuickText::boundingRect()Shawn Rutledge2022-01-281-1/+1
| | | | | | Pick-to: 6.3 Change-Id: I2209e43206258e8b3a118e011a9d1eb8e7a61bd5 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* qquickwindowmodule: Properly expose Visibility enumMaximilian Goldstein2022-01-271-2/+3
| | | | | | | | | | Previously the foreign Visibility enum was not properly exposed leading to it not being represented in qmltypes. Pick-to: 6.2 6.3 Fixes: QTBUG-99311 Change-Id: I20d865328af6fe4d807e611cf69d496b3b574551 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Query the redirect rt size only once in renderSceneGraphLaszlo Agocs2022-01-261-3/+3
| | | | | | | | | | | ...because this is not just a simple getter but has to perform checks about the validity of the QRhiTextureRenderTarget with regards to the referenced texture and renderbuffer objects. Therefore, calling it once is better than twice. Pick-to: 6.3 Change-Id: I3e442c601d3a1ee3591d05c9a1dfe6ba4957e1ff Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* QQuickRenderControl ctor: fix style and let parent default to nullptrShawn Rutledge2022-01-261-1/+1
| | | | | | | | Amends 8c0b1e06d9679676d12ff92db981198077eeda76 Pick-to: 6.3 Change-Id: I82e0e10aece2870cc99144db6ba93a831919730e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add revision to QQuickItem::ensurePolished()Shawn Rutledge2022-01-261-1/+1
| | | | | | | | It's new in 6.3. Amends 18794487a5bf303a60bda7047550048f7d38a86a Pick-to: 6.3 Change-Id: I903b3e04091d7bce3217b90c23b823575bd9097b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QQuickWindow: rename argument of a 200+loc function e → eventMarc Mutz2022-01-251-20/+20
| | | | | | | | | | | | Variable name lengths should be proptortional to their scope. QEvent *e is ok for a 10-liner, but not for a 200+loc function. Adding to that, e is a very generic variable name, and like i or it, often used as the loop variable (_e_lement), incl. in this function, so rename the argument to event. Change-Id: Ic39ff0bf339343cbbe2bc0ff0b48052fcece2f14 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QQuickWindow: simplify convoluted code using QFlatMapMarc Mutz2022-01-251-11/+4
| | | | | | | | | | | | | | | | | | | | | | | The old code used the if (!find()) insert() anti-pattern, which performs two lookups. Since the old code appended pt only if no equivalent QEventPoint was already in the mapped_type, itself a QList<QEventPoint>, we don't actually need to care about find() - just use the index operator and do the search for equivalent points in both cases. It won't find one in a default-constructed mapped_type, so will append(pt) just like the old code did, before insert()ing. As a drive-by, name the lambda and use std::none_of. The code now says what it does in almost plain English, and is more efficient to boot. I love it when a plan comes together™. Task-number: QTBUG-100091 Task-number: QTBUG-100092 Change-Id: I8837cae5391a4fe3967a9328d449890f5d9bed72 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QQuickTreeView: be able to expand rows that are not yet visible in the viewRichard Moe Gustavsen2022-01-241-6/+8
| | | | | | | | | | | | | | | | | If the app expands a row in TreeView, that row will for a brief moment be expanded in the proxy model, but not in the view, until the view is polished. For that reason, when determining if a row can be expanded or not, we should check the state of the proxy model, and not the view. Note: if the application needs the state of the view to reflect the state of the proxy model immediataly after a call to expand, forcePolish() is always possible. Task-number: QTBUG-91374 Pick-to: 6.3 Change-Id: I5b85e0b5c3b32d17f93409153041df3fc2437424 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* QQuickListView: Stop overlap for section and firstItem delegatesOliver Eftevaag2022-01-202-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: The first delegate after a section delegate would have the same position as the section delegate, if the section delegate is invisible during initialization. In case the section delegates become visible later on during program execution, the delegates would be re-positioned again in the QQuickListViewPrivate::layoutVisibleItems function. But this would not call setPosition for the first item (delegate). It would only call setPosition for all delegates after the first one. This would mean that the position for the first delegate would never be updated, after the delegate was first created. Solution: Call FxListItemSG::setPosition() for the first item in QQuickListViewPrivate::layoutVisibleItems, just like we're already doing for all the items after the first one in the for-loop. Fixes: QTBUG-94848 Pick-to: 6.3 Change-Id: I34a5ada336ab507b31e3675a1c11eba066fa139a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add QObject::isQuickItemType() for convenienceYuhang Zhao2022-01-192-0/+19
| | | | | | | | Follow up commit for QtBase 054b814daacdd0cd7ac470da73c8307a6edcd89e Change-Id: I276f6be4bddee13f5979a16d5dc15f4eb01861d9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Move QJSEnginePrivate::cache() to QQmlMetaTypeUlf Hermann2022-01-181-4/+1
| | | | | | | | | It is just in line with the other propertyCache() methods, and should be treated the same way. The comment made no sense anymore. This allows us to drop more engine pointers. Change-Id: I2e9b479b555c7f771b619e4693d59cbfcf244df6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port users of QMutableEventPoint::from() to new static settersMarc Mutz2022-01-153-11/+9
| | | | | | | | | In QQuickItem, added an opportunistic std::move() as a drive-by. Task-number: QTBUG-99615 Pick-to: 6.3 Change-Id: Ib9426ae7e749036541d5f97824800636b5ccfb5e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Don't rely on transitive include of qeventpoint_p.hMarc Mutz2022-01-134-2/+5
| | | | | | | | | | It will be dropped from qevent_p.h. Task-number: QTBUG-99615 Pick-to: 6.3 6.2 Change-Id: Id4eee3036a873f0e021b30a8d43b2c4df25dc53c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QQuickPalette: replace a QFlatMap with std::array<.,3>Marc Mutz2022-01-132-13/+27
| | | | | | | | | | | | | | | | Using a QFlatMap for an enum-to-object mapping when the valid enum values are {0, 1, 2} is complete overkill. A std::array<T,3> has both a more convenient API, and much more efficiency. Add some assertions. Pick-to: 6.3 Change-Id: I6958302d1a7d0fd591e38efeea8291b3e9cc7212 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Remove uses of QMutableSinglePointEvent::mutablePoint()Marc Mutz2022-01-131-3/+3
| | | | | | | | | Use the static setters of QMutableEventPoint instead. Task-number: QTBUG-99615 Pick-to: 6.3 Change-Id: Ibdaf485aff2c1638f500b708d61eeabd79836486 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* TextEdit: hide cursor outside viewport if ItemObservesViewportShawn Rutledge2022-01-061-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Given a TextEdit in a Flickable, when someone scrolls the text such that the text cursor is completely outside the viewport, we want the text cursor to be hidden. It is clipped if Flickable has clip: true, which is better for "pixel-perfect" clipping, but has a performance penalty. Anyway it still looked ridiculous in the case when clipping is not turned on, to have a stray text cursor appearing on top of some neighbor items, even though the text wasn't visible. To have awareness of the viewport (such as Flickable) within which it's shown, TextEdit has to opt-in with the ItemObservesViewport flag so that QQuickTextEditPrivate::transformChanged() will be called; the question is under what conditions. We already opt-in when the text is large; otherwise we don't really want to have updatePaintNode() called so often, unless other code opts in by setting that flag; because for short texts, the old way is more efficient (populate all the glyphs from the document into the scenegraph one time, and no need to update until editing happens). Task-number: QTBUG-83069 Pick-to: 6.3 Change-Id: Idd7cc9d2369d67b967eec50fe81964e6abe84e9c Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* TextEdit: deal with scrolling backwards in rich textShawn Rutledge2022-01-062-5/+22
| | | | | | | | | | | | | | | | | | | | | | A bug was introduced in 9db23e0e04906cf9ea33e23fa41f34955e5e6fe0 : when scrolling backwards in some kinds of rich text, updatePaintNode() failed to re-populate the nodes that had been scrolled out above the viewport. That was because those nodes had been removed from textNodeMap, and then firstDirtyPos was set from the first node in textNodeMap. For some reason this didn't happen with the markdown document that I was testing (maybe because it had a table and an image near the beginning), but showed up when viewing an html document similar to the one we ship with the rich text example. So now we iterate backwards from textNodeMap.begin() when this happens, to find all nodes in the current frame that intersect the viewport as rendered. In the autotest we now use font.pixelSize in an attempt to make the rendered text ranges more consistent across platforms in CI; and we need to wait for the rendering to be redone after scrolling. Pick-to: 6.3 Change-Id: I70ef54c8d8facc439b9a6f8b5cb8e3a4a1c37e16 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Flickable: make overshoot distance velocity-sensitive; limit velocityShawn Rutledge2022-01-052-16/+22
| | | | | | | | | | | | | | | | | | | | QQuickFlickablePrivate::overShootDistance() was documented to take velocity, but actually took the size (content width or height) instead. When animated flicking occurs while handling wheel events, and we hit the end-stop, we want the springy overshoot behavior to be proportional to velocity, not always go to the max of 150 pixels. But then the calculated velocity needs to be kept reasonable; so we avoid updating the value if the time between updates is less than 2 ms. This code is bypassed when the user is actually drag-flicking the content, i.e. when the wheel events have phase() or when dragging via mouse or touch. Pick-to: 6.2 6.3 Fixes: QTBUG-99529 Change-Id: Ia9278c6fb14654d0a05b9679824ee7bdef4e219b Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Fix edge cases in arcToDelf Neumärker2022-01-052-18/+13
| | | | | | | | | | | | The implementation is mathematically sound, but due to floating point arithmetic the code would sometimes call acos with values very slightly out of the valid [-1..1] interval. Using hypot and atan2 instead gives the correct result. Fixes: QTBUG-49049 Pick-to: 5.15 6.2 6.3 Change-Id: I0185514a63dc2c99cb67e1f9951aac0ac32b5fd8 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>