Skip to content

Commit

Permalink
- Fix endless loop on DMX view : Getters should not emit change if no…
Browse files Browse the repository at this point in the history
…t changed.

- Force OpenGL for Qt6/QML.
- Fixes some binding loops (QML).
- Fixes some deprecated callback uses (QML).
- Fixes missing namespace (QML).
- Fixes warnings on potential null values (QML).
  • Loading branch information
Ledjlale committed Sep 11, 2024
1 parent 5d8b035 commit f7bc046
Show file tree
Hide file tree
Showing 21 changed files with 86 additions and 59 deletions.
41 changes: 27 additions & 14 deletions qmlui/fixturemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1431,8 +1431,8 @@ QVariantList FixtureManager::fixturesMap()
* Fixture ID | DMX address | isOdd | channel type (a lookup for icons)
*/

m_fixturesMap.clear();
m_fixtureNamesMap.clear();
QVariantList fixturesMap;
QVariantList fixtureNamesMap;

QList<Fixture*> origList = m_doc->fixtures();
// sort the fixture list by address and not by ID
Expand All @@ -1449,32 +1449,45 @@ QVariantList FixtureManager::fixturesMap()
quint32 startAddress = fx->address();
for (quint32 cn = 0; cn < fx->channels(); cn++)
{
m_fixturesMap.append(fx->id());
m_fixturesMap.append(startAddress + cn);
fixturesMap.append(fx->id());
fixturesMap.append(startAddress + cn);

if (odd)
m_fixturesMap.append(1);
fixturesMap.append(1);
else
m_fixturesMap.append(0);
fixturesMap.append(0);

QLCChannel::Group group = fx->channel(cn)->group();
if (group == QLCChannel::Intensity)
m_fixturesMap.append(fx->channel(cn)->colour());
fixturesMap.append(fx->channel(cn)->colour());
else
m_fixturesMap.append(group);
fixturesMap.append(group);
}
odd = !odd;

m_fixtureNamesMap.append(fx->id());
m_fixtureNamesMap.append(fx->address());
m_fixtureNamesMap.append(fx->channels());
m_fixtureNamesMap.append(fx->name());
fixtureNamesMap.append(fx->id());
fixtureNamesMap.append(fx->address());
fixtureNamesMap.append(fx->channels());
fixtureNamesMap.append(fx->name());
}
setFixturesMap(fixturesMap);
setFixtureNamesMap(fixtureNamesMap);

return fixturesMap;
}

void FixtureManager::setFixturesMap(QVariantList fixturesMap){
if(fixturesMap == m_fixturesMap)
return;
m_fixturesMap = fixturesMap;
emit fixturesMapChanged();
emit fixtureNamesMapChanged();
}

return m_fixturesMap;
void FixtureManager::setFixtureNamesMap(QVariantList fixtureNamesMap){
if(fixtureNamesMap == m_fixtureNamesMap)
return;
m_fixtureNamesMap = fixtureNamesMap;
emit fixtureNamesMapChanged();
}

int FixtureManager::pasteFromClipboard(QVariantList fixtureIDs)
Expand Down
2 changes: 2 additions & 0 deletions qmlui/fixturemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,14 @@ public slots:
public:
/** Returns a list of fixture names for representation in a GridEditor QML component */
QVariantList fixtureNamesMap();
void setFixtureNamesMap(QVariantList fixtureNamesMap);

/** Get a string to be displayed as tooltip for a fixture at $address */
Q_INVOKABLE QString getTooltip(quint32 address);

/** Returns data for representation in a GridEditor QML component */
QVariantList fixturesMap();
void setFixturesMap(QVariantList fixturesMap);

Q_INVOKABLE int pasteFromClipboard(QVariantList fixtureIDs);

Expand Down
5 changes: 5 additions & 0 deletions qmlui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ void printVersion()
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
// Since Qt6, the default rendering backend is Rhi. QLC doesn't support it yet so OpenGL have to be forced.
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
qputenv("QT3D_RENDERER", "opengl");
#endif

QApplication::setOrganizationName("qlcplus");
QApplication::setOrganizationDomain("org");
Expand Down
2 changes: 2 additions & 0 deletions qmlui/qml/ActionsMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Popup
CustomPopupDialog
{
id: saveFirstPopup
width: menuRoot.width // Set width to avoid binding loops on implicit sizes
title: qsTr("Your project has changes")
message: qsTr("Do you wish to save the current project first?\nChanges will be lost if you don't save them.")
standardButtons: Dialog.Yes | Dialog.No | Dialog.Cancel
Expand Down Expand Up @@ -581,6 +582,7 @@ Popup
PopupAbout
{
id: infoPopup
width: menuRoot.width // Set width to avoid binding loops on implicit sizes
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion qmlui/qml/CustomComboBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ ComboBox
delegate:
ItemDelegate
{
width: parent.width
width: parent?.width
implicitHeight: delegateHeight
highlighted: control.highlightedIndex === index
hoverEnabled: control.hoverEnabled
Expand Down
2 changes: 1 addition & 1 deletion qmlui/qml/GenericButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Rectangle
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: btnRoot.clicked(mouse.button)
onClicked: (mouse) => btnRoot.clicked(mouse.button)
onPressAndHold:
{
if (repetition == true)
Expand Down
8 changes: 5 additions & 3 deletions qmlui/qml/fixtureeditor/FixtureEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ Rectangle
id: openDialog
visible: false
title: qsTr("Open a fixture definition")
currentFolder: "file://" + fixtureEditor.workingPath
// fixtureEditor may be null on exit
currentFolder: "file://" + fixtureEditor?.workingPath
nameFilters: [ qsTr("Fixture definition files") + " (*.qxf)", qsTr("All files") + " (*)" ]

onAccepted:
Expand All @@ -70,7 +71,8 @@ Rectangle
id: saveDialog
visible: false
title: qsTr("Save definition as...")
currentFolder: "file://" + fixtureEditor.workingPath
// fixtureEditor may be null on exit
currentFolder: "file://" + fixtureEditor?.workingPath
fileMode: FileDialog.SaveFile
nameFilters: [ qsTr("Fixture definition files") + " (*.qxf)", qsTr("All files") + " (*)" ]
defaultSuffix: "qxf"
Expand Down Expand Up @@ -266,7 +268,7 @@ Rectangle
id: editorsRepeater
model: fixtureEditor ? fixtureEditor.editorsList : null

onItemAdded: item.clicked()
onItemAdded: (index,item) => item.clicked()

delegate:
MenuBarEntry
Expand Down
8 changes: 4 additions & 4 deletions qmlui/qml/fixturesfunctions/2DView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Rectangle
property int initialXPos
property int initialYPos

onPressed:
onPressed: (mouse) =>
{
console.log("button: " + mouse.button + ", mods: " + mouse.modifiers)
var itemID = View2D.itemIDAtPos(Qt.point(mouse.x, mouse.y))
Expand Down Expand Up @@ -256,7 +256,7 @@ Rectangle
}
}

onPositionChanged:
onPositionChanged: (mouse) =>
{
if (selectionRect.visible == true)
{
Expand Down Expand Up @@ -294,7 +294,7 @@ Rectangle
}
}

onReleased:
onReleased: (mouse) =>
{
if (selectionRect.visible === true && selectionRect.width && selectionRect.height)
{
Expand All @@ -317,7 +317,7 @@ Rectangle
}
}

onWheel:
onWheel: (wheel)=>
{
//console.log("Wheel delta: " + wheel.angleDelta.y)
if (wheel.angleDelta.y > 0)
Expand Down
10 changes: 5 additions & 5 deletions qmlui/qml/fixturesfunctions/3DView/3DView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ Rectangle

projectionType: CameraLens.PerspectiveProjection
fieldOfView: 45
aspectRatio: viewSize.width / viewSize.height
aspectRatio: viewCamera.width / viewCamera.height
nearPlane: 1.0
farPlane: 1000.0
position: View3D.cameraPosition
Expand Down Expand Up @@ -360,15 +360,15 @@ Rectangle
property int selGenericCount: View3D.genericSelectedCount

sourceDevice: mDevice
onPressed:
onPressed: (mouse) =>
{
directionCounter = 0
dx = 0
dy = 0
startPoint = Qt.point(mouse.x, mouse.y)
}

onPositionChanged:
onPositionChanged: (mouse) =>
{
if (directionCounter < 3)
{
Expand Down Expand Up @@ -444,7 +444,7 @@ Rectangle
if (!mouse.modifiers || (mouse.modifiers & Qt.ShiftModifier && direction == Qt.Horizontal))
viewCamera.panAboutViewCenter(-xDelta, Qt.vector3d(0, 1, 0))
if (!mouse.modifiers || (mouse.modifiers & Qt.ShiftModifier && direction == Qt.Vertical))
viewCamera.tiltAboutViewCenter(yDelta, Qt.vector3d(1, 0, 0))
viewCamera.tiltAboutViewCenter(yDelta)

View3D.cameraPosition = viewCamera.position
View3D.cameraUpVector = viewCamera.upVector
Expand All @@ -464,7 +464,7 @@ Rectangle
startPoint = Qt.point(mouse.x, mouse.y)
}

onWheel:
onWheel: (wheel) =>
{
if (wheel.angleDelta.y > 0)
viewCamera.setZoom(-1)
Expand Down
8 changes: 4 additions & 4 deletions qmlui/qml/fixturesfunctions/3DView/Fixture3DItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ Entity
{
id: panAnim
running: false
easing.type: Easing.Linear
easing.type: QQ2.Easing.Linear
}

QQ2.NumberAnimation on tiltRotation
{
id: tiltAnim
running: false
easing.type: Easing.Linear
easing.type: QQ2.Easing.Linear
}

property Texture2D depthTex:
Expand Down Expand Up @@ -292,7 +292,7 @@ Entity
id: goboAnim
running: false
duration: 0
easing.type: Easing.Linear
easing.type: QQ2.Easing.Linear
from: 0
to: 360
loops: QQ2.Animation.Infinite
Expand Down Expand Up @@ -323,7 +323,7 @@ Entity
{
id: eSceneLoader

onStatusChanged:
onStatusChanged: (status) =>
{
if (status === SceneLoader.Ready)
View3D.initializeFixture(itemID, fixtureEntity, eSceneLoader)
Expand Down
2 changes: 0 additions & 2 deletions qmlui/qml/fixturesfunctions/3DView/SelectionGeometry.qml
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ GeometryRenderer
Buffer
{
id: vertexBuffer
type: Buffer.VertexBuffer
data: vertexBufferData()
}

Buffer
{
id: indexBuffer
type: Buffer.IndexBuffer
data: indexBufferData()
}

Expand Down
12 changes: 6 additions & 6 deletions qmlui/qml/fixturesfunctions/3DView/StageBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Entity
effect: stage.effect

parameters: [
Parameter { name: "diffuse"; value: "lightgray" },
Parameter { name: "specular"; value: "black" },
Parameter { name: "diffuse"; value: Qt.color("lightgray") },
Parameter { name: "specular"; value: Qt.color("black") },
Parameter { name: "shininess"; value: 1.0 },
Parameter { name: "bloom"; value: 0 }
]
Expand Down Expand Up @@ -76,7 +76,7 @@ Entity
ObjectPicker
{
id: groundPicker
onClicked: contextManager.setPositionPickPoint(pick.worldIntersection)
onClicked: (pick) => contextManager.setPositionPickPoint(pick.worldIntersection)
}

components: [
Expand All @@ -98,7 +98,7 @@ Entity
ObjectPicker
{
id: leftPicker
onClicked: contextManager.setPositionPickPoint(pick.worldIntersection)
onClicked: (pick) => contextManager.setPositionPickPoint(pick.worldIntersection)
}

components: [
Expand All @@ -119,7 +119,7 @@ Entity
ObjectPicker
{
id: rightPicker
onClicked: contextManager.setPositionPickPoint(pick.worldIntersection)
onClicked: (pick) => contextManager.setPositionPickPoint(pick.worldIntersection)
}

components: [
Expand All @@ -140,7 +140,7 @@ Entity
ObjectPicker
{
id: backPicker
onClicked: contextManager.setPositionPickPoint(pick.worldIntersection)
onClicked: (pick) => contextManager.setPositionPickPoint(pick.worldIntersection)
}

components: [
Expand Down
6 changes: 3 additions & 3 deletions qmlui/qml/fixturesfunctions/3DView/StageRock.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Entity
effect: stage.effect

parameters: [
Parameter { name: "diffuse"; value: "lightgray" },
Parameter { name: "specular"; value: "black" },
Parameter { name: "diffuse"; value: Qt.color("lightgray") },
Parameter { name: "specular"; value: Qt.color("black") },
Parameter { name: "shininess"; value: 1.0 },
Parameter { name: "bloom"; value: 0 }
]
Expand Down Expand Up @@ -203,7 +203,7 @@ Entity
ObjectPicker
{
id: stagePicker
onClicked: contextManager.setPositionPickPoint(pick.worldIntersection)
onClicked: (pick) => contextManager.setPositionPickPoint(pick.worldIntersection)
}

components: [
Expand Down
6 changes: 3 additions & 3 deletions qmlui/qml/fixturesfunctions/3DView/StageSimple.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Entity
{
effect: stage.effect
parameters: [
Parameter { name: "diffuse"; value: "lightgray" },
Parameter { name: "specular"; value: "black" },
Parameter { name: "diffuse"; value: Qt.color("lightgray") },
Parameter { name: "specular"; value: Qt.color("black") },
Parameter { name: "shininess"; value: 1.0 },
Parameter { name: "bloom"; value: 0 }
]
Expand All @@ -56,7 +56,7 @@ Entity
ObjectPicker
{
id: stagePicker
onClicked: contextManager.setPositionPickPoint(pick.worldIntersection)
onClicked: (pick) => contextManager.setPositionPickPoint(pick.worldIntersection)
}

components: [
Expand Down
6 changes: 3 additions & 3 deletions qmlui/qml/fixturesfunctions/3DView/StageTheatre.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Entity
{
effect: stage.effect
parameters: [
Parameter { name: "diffuse"; value: "lightgray" },
Parameter { name: "specular"; value: "black" },
Parameter { name: "diffuse"; value: Qt.color("lightgray") },
Parameter { name: "specular"; value: Qt.color("black") },
Parameter { name: "shininess"; value: 1.0 },
Parameter { name: "bloom"; value: 0 }
]
Expand Down Expand Up @@ -167,7 +167,7 @@ Entity
ObjectPicker
{
id: stagePicker
onClicked: contextManager.setPositionPickPoint(pick.worldIntersection)
onClicked: (pick) => contextManager.setPositionPickPoint(pick.worldIntersection)
}

components: [
Expand Down
Loading

0 comments on commit f7bc046

Please sign in to comment.