Skip to content
Closed
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2776,6 +2776,8 @@ if(QML)
src/qml/qmlplayerproxy.cpp
src/qml/qmlvisibleeffectsmodel.cpp
src/qml/qmlwaveformoverview.cpp
src/qml/mixxxcontroller.cpp
src/qml/mixxxcontroller.h
# The following sources need to be in this target to get QML_ELEMENT properly interpreted
src/control/controlmodel.cpp
src/control/controlsortfiltermodel.cpp
Expand Down
15 changes: 15 additions & 0 deletions res/controllers/Denon-DN-S3700.midi.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<MixxxControllerPreset mixxxVersion="2.4.0" schemaVersion="1">
<info>
<name>Denon DN-S3700 (QML)</name>
<author>christophehenry</author>
<description>Controller preset for Denon DN-S3700 turntable</description>
</info>
<controller id="DN-S3700">
<scriptfiles>
<file filename="Denon-DN-S3700.qml" functionprefix=""/>
</scriptfiles>
<controls />
<outputs/>
</controller>
</MixxxControllerPreset>
14 changes: 14 additions & 0 deletions res/controllers/Denon-DN-S3700.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import QtQml

import "Mixxx"

MixxxController {
id: controller

function init() {
console.error(controller.controllerId, controller.debugMode);
}
function shutdown() {
console.error(`Shutting down ${controller.controllerId} with debug mode ${controller.debugMode}`);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually… Is that even needed? In QML, there's Component.onCompleted and Component.onDestruction.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These hooks will be invoked on component instantiation and destruction. Assuming this was inspired from the existing screen rendering, init and shutdown are called at different time.

  • init is called once the controller has started. It is the direct equivalent to the same hook in Javascript. Unlike the constructor (equivalent to Component.onCompleted), it is invoked once the engine is running.
  • shutdown is called when the engine is about to shutdown. This allows the controller to perform some animation or screen clean up, which is required for some devices (e.g restoring the splash screen, playing a shutdown animation, clearing the screen to a static colour, ...). In case of Component.onDestruction, as the name suggest, you don't have a component to render anymore.

In case of "pure" controller (without UI rendering), I think it makes sense to ditch these function, but if we want to eventually merge the engines together, they will have to remain.
I believe you might be able to replace them with signals instead tho (e.g MixxxController::onStart, MixxxController::onShutdown)

}
2 changes: 2 additions & 0 deletions src/controllers/legacycontrollermapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "controllers/legacycontrollersettingslayout.h"
#include "defs_urls.h"
#include "preferences/usersettings.h"
#include "qml/mixxxcontroller.h"
#include "util/assert.h"

/// This class represents a controller mapping, containing the data elements that
Expand Down Expand Up @@ -374,6 +375,7 @@ class LegacyControllerMapping {
#ifdef MIXXX_USE_QML
QList<QMLModuleInfo> m_modules;
QList<ScreenInfo> m_screens;
QList<mixxx::qml::MixxxController> m_mixxxControllers;
#endif
QList<ScriptFileInfo> m_scripts;
DeviceDirections m_deviceDirection;
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/legacycontrollermappingfilehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ void LegacyControllerMappingFileHandler::addScriptFilesToMapping(
QFileInfo file = findScriptFile(mapping, filename, systemMappingsPath);
if (file.suffix() == "qml") {
#ifdef MIXXX_USE_QML
QString identifier = scriptFile.attribute("identifier", "");
QString identifier = scriptFile.attribute(
"identifier", scriptFile.attribute("functionprefix", ""));
Comment on lines +393 to +394

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of the screens, it makes no sense to default to functionprefix

mapping->addScriptFile(LegacyControllerMapping::ScriptFileInfo{
filename,
identifier,
Expand Down
Loading