Skip to content

Commit cb8c40e

Browse files
committed
demo_threading: provide proxies for Qt 5 and 6 with graphical effects
1 parent 3157ce7 commit cb8c40e

12 files changed

+79
-5
lines changed

examples/demo_threading/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ target_link_libraries(${CRATE} INTERFACE
4949
Qt::QuickControls2
5050
)
5151

52+
# Qt Graphical Effects imports changed in Qt 6 so provide proxies
53+
if(QT_VERSION LESS 6.0.0)
54+
set(QML_COMPAT_RESOURCES qml/compat/compat_qt5.qrc)
55+
else()
56+
set(QML_COMPAT_RESOURCES qml/compat/compat_qt6.qrc)
57+
endif()
58+
5259
add_executable(${APP_NAME}
5360
cpp/helpers/energyusageproxymodel.h
5461
cpp/helpers/energyusageproxymodel.cpp
@@ -57,6 +64,7 @@ add_executable(${APP_NAME}
5764
cpp/helpers/sensor.cpp
5865
images/images.qrc
5966
qml/qml.qrc
67+
${QML_COMPAT_RESOURCES}
6068
)
6169

6270
target_link_libraries(${APP_NAME} PRIVATE

examples/demo_threading/qml/MainWindow.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// SPDX-License-Identifier: MIT OR Apache-2.0
66
import QtQuick 2.12
77
import QtQuick.Window 2.12
8+
89
import com.kdab.energy 1.0
9-
import QtGraphicalEffects 1.10
1010

1111
Window {
1212
id: root

examples/demo_threading/qml/Panel.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//
44
// SPDX-License-Identifier: MIT OR Apache-2.0
55
import QtQuick 2.12
6-
import QtGraphicalEffects 1.10
76

87
Item {
98
id: root

examples/demo_threading/qml/SensorUI.qml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// SPDX-License-Identifier: MIT OR Apache-2.0
55

66
import QtQuick 2.12
7-
import QtGraphicalEffects 1.10
7+
8+
import "qrc:/compat" as Compat
89

910
Item {
1011
id: sensorUI
@@ -53,7 +54,7 @@ Item {
5354
}
5455
}
5556

56-
ConicalGradient {
57+
Compat.ConicalGradient {
5758
id: angle
5859
anchors.margins: -15
5960
anchors.fill: parent
@@ -67,7 +68,7 @@ Item {
6768
visible: false
6869
}
6970

70-
OpacityMask {
71+
Compat.OpacityMask {
7172
anchors.fill: efect
7273
maskSource: efect
7374
source: angle
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
2+
// SPDX-FileContributor: Andrew Hayzen <[email protected]>
3+
4+
// SPDX-License-Identifier: MIT OR Apache-2.0
5+
6+
import QtQuick 2.12
7+
8+
import QtGraphicalEffects 1.10
9+
10+
ConicalGradient {
11+
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
2+
// SPDX-FileContributor: Andrew Hayzen <[email protected]>
3+
4+
// SPDX-License-Identifier: MIT OR Apache-2.0
5+
6+
import QtQuick 2.12
7+
8+
import Qt5Compat.GraphicalEffects
9+
10+
ConicalGradient {
11+
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
2+
// SPDX-FileContributor: Andrew Hayzen <[email protected]>
3+
4+
// SPDX-License-Identifier: MIT OR Apache-2.0
5+
6+
import QtQuick 2.12
7+
8+
import QtGraphicalEffects 1.10
9+
10+
OpacityMask {
11+
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
2+
// SPDX-FileContributor: Andrew Hayzen <[email protected]>
3+
4+
// SPDX-License-Identifier: MIT OR Apache-2.0
5+
6+
import QtQuick 2.12
7+
8+
import Qt5Compat.GraphicalEffects
9+
10+
OpacityMask {
11+
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<RCC>
2+
<qresource prefix="/compat">
3+
<file alias="ConicalGradient">ConicalGradientQt5.qml</file>
4+
<file alias="OpacityMask">OpacityMaskQt5.qml</file>
5+
</qresource>
6+
</RCC>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
2+
# SPDX-FileContributor: Andrew Hayzen <[email protected]>
3+
# SPDX-License-Identifier: MIT OR Apache-2.0

0 commit comments

Comments
 (0)