Skip to content

Commit 1c2881e

Browse files
committed
qml: update visual QML debug helper feature (DebugRect.qml) for qt6
1 parent 4c5d6b2 commit 1c2881e

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
lines changed

src/lib_app/qml/DebugRect.qml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ Item {
2222
visible: {
2323
// If the environment variable configured the ACCENT color to match our sentinel,
2424
// then every instance of DebugRect will become visible:
25-
Material.accent == sentinelColor
25+
var detectionInQt5 = (Material.accent == sentinelColor);
26+
// See the `runscene` script in this repo. Qt6 requires a new approach:
27+
var detectionInQt6 = ('-myqmldebug' == Qt.application.arguments.find((element) => element =='-myqmldebug'));
28+
29+
// Either detection mechanism can enable the DebugRect(s):
30+
detectionInQt5 || detectionInQt6
2631
}
2732

2833
// Limiting ourselves to this palette helps us unambiguously grep for color names

src/lib_app/qml/DebugRectangle.qml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ Rectangle {
1515
// or under qmlscene), then just do this before launch:
1616
// export QT_QUICK_CONTROLS_MATERIAL_ACCENT="#0B610B"
1717
readonly property color sentinelColor: "#0B610B"
18-
visible: Material.accent == sentinelColor
18+
visible: {
19+
// If the environment variable configured the ACCENT color to match our sentinel,
20+
// then every instance of DebugRect will become visible:
21+
var detectionInQt5 = (Material.accent == sentinelColor);
22+
// See the `runscene` script in this repo. Qt6 requires a new approach:
23+
var detectionInQt6 = ('-myqmldebug' == Qt.application.arguments.find((element) => element =='-myqmldebug'));
24+
25+
// Either detection mechanism can enable the DebugRect(s):
26+
detectionInQt5 || detectionInQt6
27+
}
1928

2029
anchors.fill: toFill
2130
z: 200

src/lib_app/qml/main.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ ApplicationWindow {
160160
text: "SPACEBAR (on logo): rotates logo"
161161

162162
DebugRect {
163-
// To make the DebugRect show up in the GUI, change your environment:
164-
// export QT_QUICK_CONTROLS_MATERIAL_ACCENT="#0B610B"
163+
// This shows a "visual debug" border, but when only when you
164+
// enable the feature.
165165
// (See comments in DebugRect.qml for more information.)
166166
color: red
167167
}

src/lib_app/qml/runscene

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ source "${DIR}/../../../tools/ci/rootdirhelper.bash"
77

88
source $CUR_GUICODE_ROOT/path_to_qmake.bash # path to qmake is also path to qmlscene
99

10-
# In order to cause our DebugRectangle instances to become visible, uncomment:
10+
# In order to cause our DebugRectangle instances to become visible, do the following
11+
# in your terminal before you call `runscene`:
1112
# export QT_QUICK_CONTROLS_MATERIAL_ACCENT="#0B610B"
1213

14+
RUNSCENE_EXTRA_CONF=()
15+
if [[ ${QT_QUICK_CONTROLS_MATERIAL_ACCENT-} == "#0B610B" ]]; then
16+
# The 'material accent' hack only worked in Qt5.
17+
# Here is our adaptation for Qt6:
18+
RUNSCENE_EXTRA_CONF=('-myqmldebug')
19+
fi
20+
1321
# In order that all the qml 'import' statements for our supporting libraries can
1422
# successfully load, you must feed some additional paths to qmlscene like so:
1523

16-
qmlscene -I ../../libstyles/imports/ "$@"
24+
qmlscene -I ../../libstyles/imports/ ${RUNSCENE_EXTRA_CONF[@]} "$@"

src/lib_app/qml/runstyledscene

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ source "${DIR}/../../../tools/ci/rootdirhelper.bash"
77

88
source $CUR_GUICODE_ROOT/path_to_qmake.bash # path to qmake is also path to qmlscene
99

10-
# In order to cause our DebugRectangle instances to become visible, uncomment:
10+
# In order to cause our DebugRectangle instances to become visible, do the following
11+
# in your terminal before you call `runscene`:
1112
# export QT_QUICK_CONTROLS_MATERIAL_ACCENT="#0B610B"
1213

14+
RUNSCENE_EXTRA_CONF=()
15+
if [[ ${QT_QUICK_CONTROLS_MATERIAL_ACCENT-} == "#0B610B" ]]; then
16+
# The 'material accent' hack only worked in Qt5.
17+
# Here is our adaptation for Qt6:
18+
RUNSCENE_EXTRA_CONF=('-myqmldebug')
19+
fi
20+
1321
# In order that all the qml 'import' statements for our supporting libraries can
1422
# successfully load, you must feed some additional paths to qmlscene like so:
1523

16-
qmlscene -I ../../libstyles/imports/ -style fusion "$@"
24+
qmlscene -I ../../libstyles/imports/ ${RUNSCENE_EXTRA_CONF[@]} -style fusion "$@"

0 commit comments

Comments
 (0)