add mqtt control
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
2026-01-31 16:50:34 +11:00
parent 7cc6056e7e
commit a9c5139d55
13 changed files with 385 additions and 7 deletions

View File

@@ -3,6 +3,7 @@
#include "imageswitcher.h"
#include "pathtraverser.h"
#include "immichpathtraverser.h"
#include "mqttcontroller.h"
#include "overlay.h"
#include "appconfig.h"
#include "logger.h"
@@ -275,6 +276,24 @@ int main(int argc, char *argv[])
w.setImageSwitcher(&switcher);
std::function<void(MainWindow &w, ImageSwitcher *switcher)> reloader = [&appConfig](MainWindow &w, ImageSwitcher *switcher) { ReloadConfigIfNeeded(appConfig, w, switcher); };
switcher.setConfigFileReloader(reloader);
std::unique_ptr<MqttController> mqttController;
if (appConfig.mqtt.enabled)
{
mqttController = std::unique_ptr<MqttController>(new MqttController(appConfig.mqtt, &a));
QObject::connect(mqttController.get(), &MqttController::play, [&switcher]() { switcher.resume(); });
QObject::connect(mqttController.get(), &MqttController::pause, [&switcher]() { switcher.pause(); });
QObject::connect(mqttController.get(), &MqttController::nextImage, [&switcher]() { switcher.stepOnce(); });
QObject::connect(mqttController.get(), &MqttController::nextFolder, [&switcher]() {
if (!switcher.skipToNextFolder())
switcher.stepOnce();
});
QObject::connect(mqttController.get(), &MqttController::restart, [&appConfig, &switcher]() {
std::unique_ptr<ImageSelector> newSelector = GetSelectorForApp(appConfig);
switcher.restart(newSelector);
});
mqttController->start();
}
switcher.start();
return a.exec();
}