aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* DOM: Allow loading and parsing of .js filesDmitrii Akshintsev2023-12-078-7/+123
| | | | | | | | | | | This commit introduces a possibility of loading and parsing of .js files by DOM environment and universe. (Without JS DOM construction) This is made possible through the support of DomType::JsFile, employing existing JsFile abstraction and expanding it. Change-Id: I5cc1a8cb727220c8de6c4c2b475c31e08c3818fb Task-number: QTBUG-117849 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix documentation of QUICK_TEST_MAIN_WITH_SETUP()Friedemann Kleint2023-12-072-4/+4
| | | | | | | | It takes a type, not a QObject *. Pick-to: 6.6 6.5 Change-Id: I11141cd8d67de0dd7fa9c21e688c59d5f94648f6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Update dirty attributes before calling transformChangedTor Arne Vestbø2023-12-071-3/+2
| | | | | | | | | Clients of transformChanged may want to inspect the dirty attributes to determine what has changed. Change-Id: I6c2bd69ac77450841d08a615ff86aadec6ef6580 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Ensure ItemObservesViewport works when item is moved to new ancestorTor Arne Vestbø2023-12-073-11/+101
| | | | | | | | | | | | | | | | | | | | | | | | | When an item has ItemObservesViewport set, it will receive transformChanged callbacks when any of its ancestors changes their position, size, etc. This relies on every ancestor having the subtreeTransformChangedEnabled flag set, which was previously ensured when the item called setFlag(). But when the item then moved to a different ancestor hierarchy, we would only set subtreeTransformChangedEnabled on the new parent, but not any of its ancestors, which meant that the item would no longer pick up changes beyond the immediate parent. We would also not send a transformChanged in response to the reparenting itself, which is critical, as the item's clip or scene positions may have changed in response to the new parent. Both of these cases are now handled as part of the ItemChildAddedChange of the new parent. Change-Id: I5000fb46d7638ce9674d4879890cf4344e5ce538 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickItem: Call markSortedChildrenDirty before QQuickItemPrivate::dirty()Tor Arne Vestbø2023-12-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | Marking an item dirty will normally result in adding the item to the dirty list, and telling the window about it, via QQuickWindowPrivate's dirtyItem(), which in turn does QQuickWindow::maybeUpdate(). This results in an asynchronous update, where we then render the scene graph, including updating its paint nodes. But QQuickItemPrivate::dirty() may also involve synchronous actions, such as calling QQuickItemPrivate::transformChanged(). To be on the safe side, we markSortedChildrenDirty before dirtying, so that any synchronous logic that runs as part of the dirtying will observe the newly dirtied sorted children. We were already doing this for QQuickItemPrivate::ChildrenChanged, but not for QQuickItemPrivate::ChildrenStackingChanged. Change-Id: I47f0ee81e17ed766ead7c7644596e90d240482a2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* tst_weeknumbercolumn: fail on warningsVladimir Belyavsky2023-12-071-6/+8
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: I8c5b6827f788888e7397de6a6846623bc969bb41 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_tooltip: fail on warningsVladimir Belyavsky2023-12-071-3/+3
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: Iec998429de1349500f4de21107a184fece6273ac Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_toolseparator: fail on warningsVladimir Belyavsky2023-12-071-6/+8
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: I6fdb9513be598a83d78ade14880599ca4893dde3 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_toolbar: fail on warningsVladimir Belyavsky2023-12-071-5/+7
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: If020a39f907613fed936253b9296a4e6b75cbb8e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_toolbutton: fail on warningsVladimir Belyavsky2023-12-071-14/+16
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: I1b6b1675a322b446753585fdd3e3ca555798f3e5 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Use Qt::WindowNoState for child windowsTor Arne Vestbø2023-12-071-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Qt::WindowState enum is documented to specify the current state of top-level windows, and do not make sense for child windows. It's up to the client code to ensure any sizing of child windows/widgets, e.g. via layouts. Many of our QPA backends bail out on QPlatformWindow::setWindowState() for a child window. Ideally we would do this at a higher level, in QWindow, but that's a bigger task, and the semantics of what happens when a window is moved from being top level to child or back are not fully clear. As a first step, we ensure that the default window state when showing a child window is Qt::WindowNoState. Unfortunately, the QPlatformIntegration::defaultWindowState() API only takes the window flags into account, which sadly do not have a way to reflect whether the window is a child window or not (Qt::SubWindow is not a child window, see QTBUG-115729). We don't want to pass a QWindow to this API, as it would mean QWidget would need to create a window when requesting the default window state. Instead we hard-code the opt-out for child windows. Change-Id: I2bb9b0f3b9f42351e065a7802d647b613f624993 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Add setter and notifier for QQuickTextDocument's documentShawn Rutledge2023-12-0610-20/+228
| | | | | | | | | | | | | | | | | | | | | | | Users want to be able to provide their own "special" instances of QTextDocument, or custom subclasses. But so far we allow this only from C++, not from QML. QQuickTextDocument is created lazily in QQuickTextEdit::textDocument() so it's not possible to rely on it to hold the actual QTextDocument all the time. It's only a facade provided to the user. But QQuickTextEdit holds the QTextDocument, and is the only class that creates QQuickTextDocument, and sets the parent to itself; so QQuickTextDocument can rely on accessing the TextEdit's document rather than maintaining its own pointer. textEdit.dot is basically a collaboration diagram showing which objects creates which, the parents, and which objects get swapped out if the user calls setTextDocument(). Task-number: QTBUG-35688 Change-Id: Iac5000aa8027a75a000d4501190f3ee5f04e426e Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow enabling HDR per window via a private propertyTor Arne Vestbø2023-12-061-0/+3
| | | | | | | | | | | The property needs to be set before the scene graph sets up the RHI swap chain, either from main() when creating the QQuickView, or from QML by adding `property string _qt_sg_hdr_format: "<value>"` to the Window. Change-Id: I74df4596828083435bc159079be5322b1195b7f1 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
* qmlls: continue and break statement completionSami Shalayel2023-12-063-0/+121
| | | | | | | | | | | Support completion of continue and break statements. When the current statement is nested inside a labelledStatement, then continue and break can be used to jump to a label. Autocomplete that label name. Task-number: QTBUG-117445 Change-Id: Ia87ae2686a9a3ac8e7ddea58b001861fd370da9f Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlls: implement completions for labelled statementsSami Shalayel2023-12-067-1/+117
| | | | | | | | | | | Add a Dom representation for labelled statements, and use it to provide completions inside of labels after the ':' token, like `myLabel: <complete JS statements here>`. Task-number: QTBUG-117445 Change-Id: If0e5d8482b00b8e02f37652632fec67972bb17b6 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmldom: add support for continue and break statement representationsSami Shalayel2023-12-068-0/+117
| | | | | | | | | | | Continue and break statement completion requires knowing about the label inside the continue or break statement. Therefore, start by adding a Dom representation for continue and break statements. Task-number: QTBUG-117445 Change-Id: I5fd80ddb3e9b0f53312046b4022e678a0add8051 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlls: completions in throw statementsSami Shalayel2023-12-067-0/+69
| | | | | | | | | | | Create a Dom representation of throw statements in qqmldomastcreator that contains the location of the 'throw' keyword, and propose expressions after that throw keyword in the autocompletion. Task-number: QTBUG-117445 Change-Id: Iac75118cb9c8eca6ffff5490b78b75b2c5e71048 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* embeddedinwidgets: Use modern loadFromModule APIFabian Kosmale2023-12-066-13/+14
| | | | | | | | | | Replaces 4f4a915ded1ddfb91ed0062d7079f5566400f422 Fixes: QTBUG-119318 Change-Id: I3c508a8b5b7f060cdb2b0eac087c24dab0f552e2 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Introduce QQuickView loadFromModuleFabian Kosmale2023-12-066-4/+122
| | | | | | | | | | | | | | | | ...as well as its ctor equivalent. This unifies the API with what is provided in QQmlApplicationEngine and QQmlComponent. If the type is composite, we update source accordingly. C++ defined types don't have any source, so we leave source empty – this is fine as source only promises to return something if it has been set. Typename and URI can't be retrieved after they have been passed to QQuickView. This could be changed later if a use case for it arrives. Fixes: QTBUG-111727 Change-Id: I9f8a27a6bf9132a37a2d3d09f90fbea7803342ee Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* tst_tabbar: fail on warningsVladimir Belyavsky2023-12-061-34/+36
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: Ia94b739d2fe0df784e37f509ea53d172a0033e69 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_tabbutton: fail on warningsVladimir Belyavsky2023-12-061-10/+12
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: Iefddaee357232ac14d0300a0d3caf6b8c8f911b5 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_switchdelegate: fail on warningsVladimir Belyavsky2023-12-061-29/+31
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: I1778b249f0ddde379e93d060b1ad0686a351897f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_switch: fail on warningsVladimir Belyavsky2023-12-061-24/+26
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: Iad20cd376257fbdaa102f85aa9fd3f944dcb1203 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_swipeview: fail on warningsVladimir Belyavsky2023-12-061-34/+36
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: I7d03dfc4f8bdf8ab2af6a7c26cf9a24f94fd7e3b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_swipedelegate: fail on warningsVladimir Belyavsky2023-12-061-68/+70
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: Iccd5e7576fddb68d9c966509e61552b1a965f903 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* qmlls: completions in variable declarationsSami Shalayel2023-12-057-7/+376
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the equal token sourcelocation into a ScriptPattern. This is somewhat cumbersome because the parser has no direct access to it. Instead, create a new ExpressionNode type called InitializerExpression: it contains an ExpressionNode and an equaltoken, and is populated in the parser for Initializer and Initializer_In rules. It also implements some pure virtual methods to not be abstract, and has its own Kind_InitializerExpression. The PatternElement constructor extracts the location of the equaltoken from the InitializerExpression in its constructor, and saves it in its new member equaltoken. Later on, the Dom constructor will be able to add the location of the equal token to the Dom, such that qmlls's completion can decide whether or not completion is required in variable declaration statements. With this commit, qmlls will provide completions only after the above mentioned equal token. The explanation is in a comment in qqmllsutils, but the rough idea is that everything before the '=' is a variable name (so it should not be in use yet, to avoid shadowing and confusing QML programs) and that everything behind a '=' is a default value that can be any arbitrary expression in JS. This default value can be a method name, a property name, etc, so provide completion at this place. Also takes care of completions inside of deconstructions nested inside variable declarations. Task-number: QTBUG-117445 Change-Id: Ie58ffda4de9636796a9a690537affef85ede398d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix text decorations with software backend on fractional scaleEskil Abrahamsen Blomfeldt2023-12-051-0/+4
| | | | | | | | | | | | | | | | | | We were drawing the text decorations twice, once through the cross-backend mechanism in the text node and then on top with QPainter. However, when drawing it through QPainter the fractional scale was not handled correctly. There may be a bug in QPainter::drawGlyphRun(), but for the software backend in particular we should just rely on the cross-backend code for this, so we disable the decoration on the QGlyphRun as a quick fix. Fixes: QTBUG-99266 Change-Id: Ie19d3554fc03dae6a6cbf219e91d5bb46fb3f15c Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Vladimir Belyavsky <belyavskyv@gmail.com>
* Implement variable axes API in QMLEskil Abrahamsen Blomfeldt2023-12-056-0/+103
| | | | | | | | | [ChangeLog][QtQuick][Text] Added font.variableAxes property. Fixes: QTBUG-117836 Change-Id: Id35d346b8136d67054da404044ae80df8da61445 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Improve hash strategy for font cachesEskil Abrahamsen Blomfeldt2023-12-054-27/+48
| | | | | | | | | | | | We were using a string key for font lookups instead of creating a proper type for this. This was a quick fix which has grown over time and is inconvenient and slow. Instead we now introduce a FontKey type which uses Qt 6's qHashMulti() for this, also making it automatically adapt to changes in the FaceId as well. Change-Id: I32dfe3b809710e3d76896a5ddef03649bb4da0d5 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* JSEngine: Optimize QV4InternalClass for tests on MSVCOlivier De Cannière2023-12-052-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running tst_ecmascripttests on MSVC in debug mode has become very slow and times out the CI. Analysing the program reveals that most of the slowdown is due to extensive wait times caused by locks. The test is run on all threads by default and this constant synchronization tanks performance. A large amount of these locks come from the fact that, in debug mode, MSVC standard containers use locks for most operations on iterators. This patch changes the container of the internal class transitions from an std::vector to a QVarLengthArray. This eliminates the iterator lock problem. The QVarLengthArray is given one inline entry to store a value. From the tests, it seems that the transitions contain only 0 or 1 entries about 84% of the time. In the remaining cases, more allocations will be needed. The additional entry will also increase the size of the containing object by 24 bytes. This should be a worthwhile tradeoff. This change alone has a significant impact on the duration of the tests. tst_ecmascripttests on 13900k with 32 threads Debug MSVC Windows Debug GCC Linux baseline: 2267s 104s QVarLengthArray 569s (~ -73%) 102s (~ -2%) This should be enough to no longer timeout the CI but many issues still remain. Change-Id: I69fefabc0375d76c817ef7d2d3b2e97dc1ace5bc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tst_selectionrectangle: fail on warningsVladimir Belyavsky2023-12-051-12/+13
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: Id906e49e7b35e45efec20a644695163e4abc56b8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_scrollview: fail on warningsVladimir Belyavsky2023-12-051-46/+48
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: I48b69bfdb537bc414396b1eb32b3ab67fad133b9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_scrollindicator: fail on warningsVladimir Belyavsky2023-12-051-20/+22
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: I163e80e1affe9b7fa7862375016c847b4663821d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_scrollbar: fail on warningsVladimir Belyavsky2023-12-051-75/+77
| | | | | | | | | Enable fail on warnings for all tests in init() method. Also, as a drive-by change, replace 'var' with 'let' Task-number: QTBUG-98718 Change-Id: I7ee578b4cc0939c9bcd6ae0e7c52bd44ed0fef56 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QML: Use actual type for aliases of enum valuesUlf Hermann2023-12-053-9/+8
| | | | | | | | | | | | | | The metatype system and the compiler may disagree about the underlying type. It's generally better to pass the full type information. We can deal with it everywhere by now. Amends commit 3ea55bf398412d373daab9c92b1498f45de70e96 Pick-to: 6.6 Fixes: QTBUG-119531 Change-Id: I4744f5fb81fb5430ac040ec5877f7d0845a2ab12 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Drop the explicit ctor for QQmlScriptDataUlf Hermann2023-12-052-7/+2
| | | | | | | | A default one will do just fine. Coverity-Id: 428988 Change-Id: I58e52e3f9bdb6729cb5e81b5ef9653c7d2f2cafd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlls: Move file system watchers into placeUlf Hermann2023-12-051-2/+5
| | | | | | | Coverity-Id: 428981 Coverity-Id: 428979 Change-Id: I1380c284a51abfade1ae3cc7706778f37d47d146 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlDom: Avoid excessive copying of ctor argumentsUlf Hermann2023-12-056-48/+61
| | | | | | | | | | | Pass QString, QDateTime and Path as const references rather than as values. We might pass some of them as rvalue refs instead, but that requires more invasive changes. Coverity-Id: 428991 Change-Id: Ie35e068d9d2cc102d71c1ea7358bd3e7fc429aa9 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlformat: Don't add invalid default settings optionsJoshua Goins2023-12-051-1/+3
| | | | | | | | | | | | | | | | | When determining whether or not a qmlformat setting is set in the config file, QQmlToolingSettings::isSet is called. Having a default value for a setting is optional, so some settings have an invalid QVariant in the map already. This means the isSet call always returns true, which overrides a bunch of command line options. Now only valid QVariants are added to the initial default settings map, which prevents command line options from inadvertently being ignored even if they weren't even set in a config file. Pick-to: 6.5 6.6 Change-Id: Iea6968a9ced17970ff0b2d79907de32f41b235c2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
* Update dependencies on 'dev' in qt/qtdeclarativeQt Submodule Update Bot2023-12-051-5/+5
| | | | | Change-Id: I519f46e2600cc7d07892771e51d3e08f6a2487c1 Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
* QQuickItemGrabResult: Grab with window devicePixelRatioKai Uwe Broulik2023-12-042-6/+17
| | | | | | | | | | | | | Ensures the grabbed image has the same device pixel ratio as the original item. [ChangeLog][QtQuick][Item][Important Behavior Change] grabToImage now grabs the item taking into account its devicePixelRatio. Task-number: QTBUG-50693 Change-Id: I63518438c8c9a84c2feee82119c47ea4a6b4a88e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Include QML object id in QQuickItem debug outputTor Arne Vestbø2023-12-042-0/+14
| | | | | | | | | | Knowing which specific item you're dealing with is often useful during debugging. Having the identifier as part of the debug output saves having to add an objectName to each item you're debugging. Pick-to: 6.6 6.5 Change-Id: Id1b91725b961b790d80e28d6be9d084fe737af04 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlls: completions in switch/case/default statementsSami Shalayel2023-12-047-21/+403
| | | | | | | | | | | | | | | | | | Add completions for switch/case/default statements, add the needed locations and use those locations to provide the autocompletion Also fix the suggestion of case and default statements to not happen inside of statements nested inside a case or default statement. Instead, only suggest them inside the {} of a switch statement and at the end of a case or default statement. Add some tests in a separate file. Task-number: QTBUG-117445 Change-Id: Ib2c8e7a88b20d5c6360fa8a491585265f42c4146 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlDom: remove DomType::CaseClauses, introduce moreCaseClausesSami Shalayel2023-12-046-3/+15
| | | | | | | | | | | | | | | | | | In JS, switch statements can contain case clauses behind a default clause. This commit fixes the behavior where case clauses behind a default clause were overriding the case clauses before the default clause. Introduce Fields::moreCaseClauses to store case clauses behind a default clause, add a test for it. Also remove the unused DomType::CaseClauses: the Dom creator just creates a DomType::List for CaseClauses. Change-Id: I87e9dc9981b421220ff734d1fd8161354605dd75 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlls: rebuild when modifying QML elements in C++ for CMake projectsSami Shalayel2023-12-0423-2/+480
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | newDocForOpenFile() first checks if a rebuild is needed and triggers a rebuild before creating the Dom to incorporate the latest updates in the C++ files defining the QML elements. This also means that rebuilds are only triggered when the user types some code in a qml file (to avoid constantly running builds when a user is typing C++ code). Disable the special CMake behavior if CMake does not exist on the current system via the m_cmakeStatus flag in QQmlCodeModel. The assumption is that cmake exists if `cmake --version` returns with exitcode 0. To check if a rebuild is needed, we use QFileSystemWatch to watch the c++ files that defines the QML elements used in the .qml files. The QFileSystemWatch::fileChanged signal is connected to QQmlCodeModel::onCppFileChanged to trigger builds in the next newDocForOpenFile() call. Finally, addFileWatches() takes a DomItem and add watches for all C++ files needed by the passed QmlFile. For testing purposes, this method is split in two:tst_qmlls_qqmlcodemodel has tests for both halves. The first half, fileNamesToWatch(), uses the QQmlJSTypeResolver to find all C++ defined scopes and collects all their file names. The file name provided by the QQmlJSScope comes from the .qmltypes, that contains a relative path and therefore needs to be made absolute again. For this, the second half of the method is done by findFilePathsFromFileNames(), that uses the rootUri (populated in a commit below this one in the relation chain) as the root source directory to search all files having one of the names found previously in fileNamesToWatch(). This is an overapproximation and might find unrelated files with the same name, but that should be fine: in the worst case, a rebuild is done for a QML module not used by the current file. Add tests for fileNamesToWatch, buildFolderWasCleaned, findFilePathsFromFileNames. This implies creating a small directory structure in the tst_qmlls_qqmlcodemodel data test with stub C++, qml and unrelated files, to see if the correct files are found. Fixes: QTBUG-118708 Fixes: QTBUG-118709 Task-number: QTBUG-118705 Change-Id: Idae3c3917f4154dc8c21551f5bfc5ce050365d91 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* make tst_qmlls_qqmlcodemodel a QQmlDataTestSami Shalayel2023-12-043-2/+8
| | | | | | | | | This is needed to test the new automatic cmake rebuild functionality that will be added in a commit in the relation chain Task-number: QTBUG-118705 Change-Id: If65e0d5e6f7ef64500dd86e02e0435d7e3ca36cf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmllsutils: add CMake build commandSami Shalayel2023-12-044-0/+34
| | | | | | | | | | | | | | | | | | Add a method QQmlLSUtils::cmakeBuildCommand() that generates the CMake build command to run the all_qmltyperegistrations target. This target generates the .qmltypes, .qrc, .qmldir and copies the qml files into the build folders and generates everything that qmlls needs from the build folder, without compiling the users code, so it should be much faster than a complete build. This method is hard to test (I do not believe you can call cmake just like this in the CI), so instead just test that cmakeBuildCommand() returns the correct cmake command. Task-number: QTBUG-118705 Change-Id: Ia29748d8fa9b38c3d4766d250e0ee9a15da7b09e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Simplify logic in QSGInternalTextNode::addGlyphs()Shawn Rutledge2023-12-041-14/+6
| | | | | | | Amends 5ffd0d8be35cea57acbf1e8d7a740d3fab5cbe43 Change-Id: I56dc36472e703d5aa49cfb63310fffbe0f5995d2 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Get rid of QQuickTextDocumentWithImageResourcesShawn Rutledge2023-12-0418-229/+322
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Users want to be able to provide their own QTextDocument instances to TextEdit; but we had been creating a subclass called QQuickTextDocumentWithImageResources, which was an obstacle for that. QTextDocumentPrivate has two QMaps to hold resources, but QQuickTextDocumentWithImageResources existed for the purpose of caching remote resources, which only QQuickPixmap knows how to fetch. (This design was apparently invented as a workaround to the lack of virtual-filesystem functionality in Qt Core. If QtCore already knew how to fetch web resources from URLs in the background, QTextDocument could use it to do its own fetching of remote resources.) What we want instead of subclassing QTextDocument is to keep doing the fetching in Qt Quick (because there's no other choice for now), but get the images into the same QTextDocumentPrivate::cachedResources map where local-file resources are cached. As it turns out, since qtbase ac300a166f801a6f6c0b15278e6893720a5726f8 QTextDocument::loadResource() can use QMetaMethod::invoke() to call a method with the signature QVariant loadResource(int,QUrl) if such a method is found in QTD's parent object; so since QQuickTextEdit creates its own document by default, and is the document's parent, we can keep remote resource fetching functionality working by 1) providing the QQuickTextEdit::loadResource() method to be invoked, and 2) moving the document to the QML thread so that it can be invoked directly. (QMetaMethod::invoke() doesn't work across a queued connection, because we need to return a value: the QVariant.) QTD will already cache the images as soon as the call to loadResource() returns a valid QVariant. We ask for the QQuickPixmap not to be cached by passing an empty QQuickPixmap::Option enum to its ctor, which gets passed through to the load() function. When we consider fetching resources from a web server, it's unfortunate that the signature of QTextDocument::resource() sets the expectation that resources can be loaded immediately. But as long as QQuickTextEdit::loadResource() is waiting for fetching to be done, it keeps returning a default-constructed QVariant, which won't be cached; and it will be called again later, repeatedly, until it eventually succeeds. To ensure that it is called again when fetching is done, we call QTextDocument::resource() again, to provoke it to call our QQuickTextEdit::loadResource() one last time. If the returned image wasn't cached before, it will be after that. Then it's ok to delete the QQuickPixmap, and invalidate the TextEdit so that layout will be updated to include the image, now that we have it. But most of the time it's relatively boring: QTextDocument knows how to load local files on its own, and caches them. So we no longer need QQuickTextDocumentWithImageResources. But we still needed to replace QTextImageHandler with a custom implementation, as explained in bab2eaf3da299c471dd898c89cf356984b077412: we need QQuickPixmap for its QML-specific URL resolution relative to the Text item's context. And it turns out that in case the document contains only a missing image, the minimum size is 16x16 pixels, to reserve space to display a "broken image" icon as browsers sometimes do... we have never actually done that in Qt Quick AFAICT, but autotests have been enforcing the 16x16 minimum size all along. This is done in QQuickTextImageHandler::intrinsicSize() now. The same approach is taken with Text (when textFormat is RichText or MarkdownText. In case of StyledText, there is no QTextDocument instance, and resource loading is taken care of entirely within QQuickText.) For the autotests, friendly use of QQuickPixmapCache::m_cache requires QT_BEGIN_NAMESPACE. Task-number: QTBUG-35688 Change-Id: I8ad8142b3b3790254dd56d6cfe5209d641465f08 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickPopup: Fix crash in createOverlayCarl Schwan2023-12-043-0/+44
| | | | | | | | | | | | Amend ef8bde838ec708ff45ad68c5db899a86116b4e94. createDimmer may return a nullptr and so we should handle this case without crashing. Include a test case that crashes without the fix. Done-with: Nicolas Fella <nicolas.fella@kde.org> Pick-to: 6.6 Change-Id: Ibeec486c6f874f9d373b0e7209033ffd17e6bde7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>