Skip to content

Conversation

keithel-qt
Copy link
Contributor

Changes to allow the toolbox to move forward to using PySide6 (Qt 6) instead of staying back on PySide2 (5.15).

  • Recursive layouts were fixed - Qt R&D recommended these be fixed to improve performance.
  • ColorOverlay no longer present in Qt 6, removed in favor of using a Qt Quick Controls private type IconImage that allows one to specify a color for the image, and for buttons, using the color property on Qt Quick Controls buttons.
  • Formalized slot parameters (more optimized codepaths)
  • Use QStringListModel in the LoggingBar
  • Fix recursive rearrange errors in the connection dialog needed for Qt 6.
  • Updated SwiftNav style modified Material components with Qt 6 variants.
  • Remove QML versioning.

Some particular gotchas:
Some changes are necessary to get the SwiftNav Qt Quick Controls style to
properly load in Qt 6.

* New to Qt 6 is that the the style needs to have a `qmldir` file declared to
  make it a QML module.
* Since the style is now a module, we need to add a qml import path to the
  engine so that it can find the module.
* Care needs to be taken on style imports. Importing `QtQuick.Controls` will
  trigger the dynamic style loading mechanism that parses the
  `qtquickcontrols2.conf` file. If you just import one of the specific
  QtQuick.Controls styles (like QtQuick.Controls.Material), then the
  `qtquickcontrols2.conf` file is ignored and no dynamic style loading will
  occur. Material will be the style then. Any accent colors or themes specified
  in the config file will be ignored, and those will need to be manually
  specified in the qml using attached properties.
* For some reason, when Material is selected as the fallback style, the style
  customizations specified in qtquickcontrols2.conf are ignored.
  To get around this, I import QtQuick.Controls to get the dynamic style
  loading, and then right after import the QtQuick.Controls.Material style, then
  in the base item, I set the Material.accentColor attached property to the
  desired accent color. This seems like a bug, and I may report this.
* Import of the QtQuick.Controls.Material style was done in Constants.qml - this
  was unnecessary, as it was not used, and it also prevented the dynamic style
  loading to work properly, as the static style was imported first.

https://doc.qt.io/qt-6/qtquickcontrols2-customize.html#creating-a-custom-style
https://doc.qt.io/qt-6/qtqml-syntax-imports.html#qml-import-path
https://doc.qt.io/qt-6/qtqml-modules-qmldir.html
QML_IMPORT_TRACE https://doc.qt.io/qt-6/qtquick-debugging.html#debugging-module-imports

Qt 6 QML doesn't need QML versioning, so remove it.
* This adds a vscode launch.json to debug the python code in VSCode.
* The dependencies of the `run` target were split off into a single task
  that bundled all of the dependencies into a single task - called
  prepare-run - that vscode can run prior to starting the debugger, as
  it could only issue one command.
* remove the -v option to tar to silence it when unpacking.
* This updates the modified Material controls with the changes made to
  them for Qt 6, leaving in the modifications desired for the console.
This fixes an error in laying out buttons in the connection dialog.
References to the parent layout's width while defining the button widths
is recursive - as the preferred widths of the buttons would affect the
the width of the parent, so referencing the parent width to determine
the width of the buttons is no good.
Replace instead with referencing the width of the parent's width - as
the parent layout fills its parent.

An alternative fix that was not chosen was to instead define the
minimumWidth of the buttons instead of the preferredWidth.
LoggingBarData included a couple of properties that were passing lists
of strings from Python to QML, and storing these in javascript arrays.

To improve efficiency, and what was an attempt to migrate away from
using QVariantLists across the Python QML boundary, the QVariantLists
were abandoned here, and the properties were exposed using
QStringListModels. Here I derived a new custom type from them, just so I
could provide a convenience method to return the index of a particular
string in the model. As these are QAbstractItemModels, they can be used
directly as the model property in the QComboBoxes that show them.
Qt will quit if it receives SIG_DFL, but not if SIGINT is received. To
allow handling of SIGINT, trigger a SIG_DFL when a SIGINT is received.
* ColorOverlay no longer exists in Qt 6, so it had to be removed.
  This uses a Button icon's color property to achieve the same effect.
* This fixes recursive layouting issues in the Settings and Solution
  tabs. Prior to this fix, the width of some buttons in a layout were
  dependent on the width of the layout, which was dependent on the width
  of those buttons - thus cyclic dependency. This achieves the same
  effect without the recursion.
Formalized parameters to slots is recommended in Qt 6, and issues a
warning if you do not do this. Doing this allows the code to be
optimized better.
* This adds a SwiftImage colorizable image type that we use in the
  remaining places where ColorOverlay was used. This allows one to color
  images with a simple color in a way that will work with Qt 6.
* This fixes a recursive layouting issue in
  AdvancedSpectrumAnalyzerTabChannelBar.
Some changes are necessary to get the SwiftNav Qt Quick Controls style to
properly load in Qt 6.

* New to Qt 6 is that the the style needs to have a `qmldir` file declared to
  make it a QML module.
* Since the style is now a module, we need to add a qml import path to the
  engine so that it can find the module.
* Care needs to be taken on style imports. Importing `QtQuick.Controls` will
  trigger the dynamic style loading mechanism that parses the
  `qtquickcontrols2.conf` file. If you just import one of the specific
  QtQuick.Controls styles (like QtQuick.Controls.Material), then the
  `qtquickcontrols2.conf` file is ignored and no dynamic style loading will
  occur. Material will be the style then. Any accent colors or themes specified
  in the config file will be ignored, and those will need to be manually
  specified in the qml using attached properties.
* For some reason, when Material is selected as the fallback style, the style
  customizations specified in qtquickcontrols2.conf are ignored.
  To get around this, I import QtQuick.Controls to get the dynamic style
  loading, and then right after import the QtQuick.Controls.Material style, then
  in the base item, I set the Material.accentColor attached property to the
  desired accent color. This seems like a bug, and I may report this.
* Import of the QtQuick.Controls.Material style was done in Constants.qml - this
  was unnecessary, as it was not used, and it also prevented the dynamic style
  loading to work properly, as the static style was imported first.

https://doc.qt.io/qt-6/qtquickcontrols2-customize.html#creating-a-custom-style
https://doc.qt.io/qt-6/qtqml-syntax-imports.html#qml-import-path
https://doc.qt.io/qt-6/qtqml-modules-qmldir.html
QML_IMPORT_TRACE https://doc.qt.io/qt-6/qtquick-debugging.html#debugging-module-imports
@keithel-qt
Copy link
Contributor Author

Makefile.toml installs PySide6 from pip instead of wheel. We may wish to keep installation from wheel if patches are needed or or commercial wheels are used.

@keithel-qt
Copy link
Contributor Author

The way Python classes are registered with QML is done the "old" way. In Qt 6, the qmlRegister... calls can go away, and instead the registrations are handled with annotations in the classes being registered themselves. It is much cleaner. This hasn't been done yet.

john-michaelburke added a commit that referenced this pull request Aug 30, 2022
Co-authored-by: Keith Kyzivat <[email protected]>
Co-authored-by: [email protected] <jm>
@silverjam silverjam closed this Aug 30, 2022
@silverjam
Copy link
Contributor

Closing this, but we'll leave the branch around for posterity/reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants