[KeySequenceItem] Fix code style, bump QML imports, make keySequence non-null
Part one: Fix code style and bump QML imports
Fixed whitespaces and formatting; renamed _helper id to just helper; replaced some == checks with strict ===, and replaced dynamic/indirect parent.keySequence lookup with root.keySequence access (because parent is a generic Item, which doesn't have keySequence property).
Among other things, according to MDN docs1 +
and +=
are the
preferred ways of string concatenation in JavaScript.
Part two: Make keySequence «non-null», «non-undefined» and «non-""»
This property should always be of type QKeySequence and nothing else.
Unfortunately though,
-
QKeySequence is not exported in QML, and even if it were, being a QGadget makes it virtually impossible to use as a property type because of mind-blowing variety of internal errors from QML engine, such as:
Invalid property assignment: unsupported type "QKeySequence*" TypeError: Property 'KeySequence' of object [null] is not a function TypeError: Type error Error: Cannot assign QKeySequence to QKeySequence*
-
Qt factory methods of QKeySequence are not marked to be Q_INVOKABLE from QML side, I had to introduce one in helper class, so that we can always construct a valid object (gadget) with an empty sequence instead of messing with null / undefined / empty string values as before.
I was looking for the origins of the Jumpy Button Problem2, and even though it turned out this particular component has nothing to do with the bug itself, its code still had some ways to improve.
I don't really understand why is this KQuickControlsPrivate.TranslationContext
ever needed, so I didn't even bother to rename its id.