diff --git a/src/core/core.cpp b/src/core/core.cpp index 51dbf21..f85dd5a 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -2724,6 +2724,12 @@ void Api::processResponseDocks(int reqId, int code, QVariant msgData) { dock.state = Util::convertStringToEnum(map.value("state").toString()); dock.learningActive = map.value("learning_active").toBool(); dock.description = map.value("descriptions").toString(); + if (map.contains("led_brightness")) { + dock.ledBrightness = map.value("led_brightness").toInt(); + } + if (map.contains("eth_led_brightness")) { + dock.ethLedBrightness = map.value("eth_led_brightness").toInt(); + } respList.append(dock); } @@ -2747,6 +2753,12 @@ void Api::processResponseDock(int reqId, int code, QVariant msgData) { dock.state = Util::convertStringToEnum(map.value("state").toString()); dock.learningActive = map.value("learning_active").toBool(); dock.description = map.value("descriptions").toString(); + if (map.contains("led_brightness")) { + dock.ledBrightness = map.value("led_brightness").toInt(); + } + if (map.contains("eth_led_brightness")) { + dock.ethLedBrightness = map.value("eth_led_brightness").toInt(); + } emit respDock(reqId, code, dock); } @@ -2850,6 +2862,12 @@ void Api::processDockChange(QVariant msgData) { dock.state = Util::convertStringToEnum(newState.value("state").toString()); dock.learningActive = newState.value("learning_active").toBool(); dock.description = newState.value("description").toString(); + if (newState.contains("led_brightness")) { + dock.ledBrightness = newState.value("led_brightness").toInt(); + } + if (newState.contains("eth_led_brightness")) { + dock.ethLedBrightness = newState.value("eth_led_brightness").toInt(); + } switch (eventType) { case MsgEventTypes::NEW: diff --git a/src/core/structs.h b/src/core/structs.h index fc92fe1..a10198e 100644 --- a/src/core/structs.h +++ b/src/core/structs.h @@ -260,6 +260,8 @@ struct DockConfiguration { DockEnums::DockState state; bool learningActive; QString description; + int ledBrightness = -1; + int ethLedBrightness = -1; }; struct DockDiscovery { diff --git a/src/dock/configuredDocks.cpp b/src/dock/configuredDocks.cpp index 5ee897d..92491af 100644 --- a/src/dock/configuredDocks.cpp +++ b/src/dock/configuredDocks.cpp @@ -10,7 +10,7 @@ namespace dock { ConfiguredDock::ConfiguredDock(const QString &id, const QString &name, const QString &customWsUrl, bool active, const QString &model, const QString &connectionType, const QString &version, State state, - bool learningActive, const QString &description, QObject *parent) + bool learningActive, const QString &description, int ledBrightness, QObject *parent) : QObject(parent), m_id(id), m_name(name), @@ -21,7 +21,8 @@ ConfiguredDock::ConfiguredDock(const QString &id, const QString &name, const QSt m_version(version), m_state(state), m_learningActive(learningActive), - m_description(description) {} + m_description(description), + m_ledBrightness(ledBrightness) {} ConfiguredDock::~ConfiguredDock() { qCDebug(lcDockController()) << "Configured dock destructor" << m_id; @@ -67,6 +68,12 @@ void ConfiguredDock::setDescription(const QString &description) { emit descriptionChanged(); } +void ConfiguredDock::setLedBrgithess(int brightness) +{ + m_ledBrightness = brightness; + emit ledBrightnessChanged(); +} + ConfiguredDocks::ConfiguredDocks(QObject *parent) : QAbstractListModel(parent), m_count(0) {} int ConfiguredDocks::count() const { @@ -123,6 +130,8 @@ QVariant ConfiguredDocks::data(const QModelIndex &index, int role) const { return item->getLearningActive(); case DescriptionRole: return item->getDescription(); + case LedBrightnessRole: + return item->getLedBrightness(); } return QVariant(); } @@ -139,6 +148,7 @@ QHash ConfiguredDocks::roleNames() const { roles[StateRole] = "dockState"; roles[LearningActiveRole] = "dockLearningActive"; roles[DescriptionRole] = "dockDescription"; + roles[LedBrightnessRole] = "dockLedBrightness"; return roles; } @@ -286,5 +296,15 @@ void ConfiguredDocks::updateDescription(const QString &key, const QString &descr } } +void ConfiguredDocks::updateLedBrightness(const QString &key, int brightness) +{ + auto dock = get(key); + + if (dock) { + dock->setLedBrgithess(brightness); + emit dataChanged(getModelIndexByKey(key), getModelIndexByKey(key)); + } +} + } // namespace dock } // namespace uc diff --git a/src/dock/configuredDocks.h b/src/dock/configuredDocks.h index f38a2e6..645c309 100644 --- a/src/dock/configuredDocks.h +++ b/src/dock/configuredDocks.h @@ -23,6 +23,7 @@ class ConfiguredDock : public QObject { Q_PROPERTY(State state READ getState NOTIFY stateChanged) Q_PROPERTY(bool learningActive READ getLearningActive NOTIFY learningActiveChanged) Q_PROPERTY(QString description READ getDescription NOTIFY descriptionChanged) + Q_PROPERTY(int ledBrightness READ getLedBrightness NOTIFY ledBrightnessChanged) public: enum State { @@ -36,7 +37,7 @@ class ConfiguredDock : public QObject { explicit ConfiguredDock(const QString& id, const QString& name, const QString& customWsUrl, bool active, const QString& model, const QString& connectionType, const QString& version, State state, - bool learningActive, const QString& description, QObject* parent = nullptr); + bool learningActive, const QString& description, int ledBrightness, QObject* parent = nullptr); ~ConfiguredDock(); QString getId() const { return m_id; } @@ -57,6 +58,8 @@ class ConfiguredDock : public QObject { void setLearningActive(bool learningActive); QString getDescription() const { return m_description; } void setDescription(const QString& description); + int getLedBrightness() const { return m_ledBrightness; } + void setLedBrgithess(int brightness); signals: void nameChanged(); @@ -67,6 +70,7 @@ class ConfiguredDock : public QObject { void stateChanged(); void learningActiveChanged(); void descriptionChanged(); + void ledBrightnessChanged(); private: QString m_id; @@ -79,6 +83,7 @@ class ConfiguredDock : public QObject { State m_state; bool m_learningActive; QString m_description; + int m_ledBrightness; }; class ConfiguredDocks : public QAbstractListModel { @@ -98,6 +103,7 @@ class ConfiguredDocks : public QAbstractListModel { StateRole, LearningActiveRole, DescriptionRole, + LedBrightnessRole, }; explicit ConfiguredDocks(QObject* parent = nullptr); @@ -137,6 +143,7 @@ class ConfiguredDocks : public QAbstractListModel { void updateState(const QString& key, ConfiguredDock::State state); void updateLearningActive(const QString& key, bool learningActive); void updateDescription(const QString& key, const QString& description); + void updateLedBrightness(const QString &key, int brightness); int totalPages = 0; int lastPageLoaded = 0; diff --git a/src/dock/dockController.cpp b/src/dock/dockController.cpp index 6bb51aa..6da638c 100644 --- a/src/dock/dockController.cpp +++ b/src/dock/dockController.cpp @@ -46,6 +46,52 @@ QObject *DockController::getConfiguredDock(const QString &dockId) { return m_configuredDocks.get(dockId); } +void DockController::getConfiguredDockFromCore(const QString &dockId) +{ + int id = m_core->getDock(dockId); + + m_core->onResponseWithErrorResult( + id, &core::Api::respDock, [=](core::DockConfiguration dock){ + qCDebug(lcDockController()) << "Got dock from core with id:" << dock.id; + + if (m_configuredDocks.contains(dockId)) { + m_configuredDocks.updateActive(dockId, dock.active); + m_configuredDocks.updateLearningActive(dockId, dock.learningActive); + + if (!dock.name.isEmpty()) { + m_configuredDocks.updateName(dockId, dock.name); + } + if (!dock.customWsUrl.isEmpty()) { + m_configuredDocks.updateCustomWsUrl(dockId, dock.customWsUrl); + } + if (!dock.connectionType.isEmpty()) { + m_configuredDocks.updateConnectionType(dockId, dock.connectionType); + } + if (!dock.version.isEmpty()) { + m_configuredDocks.updateVersion(dockId, dock.version); + } + if (!dock.description.isEmpty()) { + m_configuredDocks.updateDescription(dockId, dock.description); + } + if (dock.ledBrightness != -1) { + m_configuredDocks.updateLedBrightness(dockId, dock.ledBrightness); + } + + qCDebug(lcDockController()) << "Dock updated:" << dockId; + emit dockChanged(dockId); + emit gotDock(true, dockId); + } else { + qCWarning(lcDockController()) << "The dock with id" << dockId << "does not exists"; + emit gotDock(false, dockId); + } + + },[=](int code, QString message) { + // fail + qCWarning(lcDockController()) << "Failed to get dock from core with id:" << dockId << code << message; + emit gotDock(false, dockId); + }); +} + void DockController::startDiscovery() { m_discoveredDocks.clear(); @@ -263,7 +309,7 @@ void DockController::getDocks(int limit, int page) { if (!m_configuredDocks.contains(i->id)) { m_configuredDocks.append(new ConfiguredDock( i->id, i->name, i->customWsUrl, i->active, i->model, i->connectionType, i->version, - static_cast(i->state), i->learningActive, i->description, this)); + static_cast(i->state), i->learningActive, i->description, i->ledBrightness, this)); qCDebug(lcDockController()) << "Dock created:" << i->name << i->id; } } @@ -382,7 +428,7 @@ void DockController::onDockAdded(QString dockId, core::DockConfiguration dock) { if (!m_configuredDocks.contains(dockId)) { m_configuredDocks.append(new ConfiguredDock( dockId, dock.name, dock.customWsUrl, dock.active, dock.model, dock.connectionType, dock.version, - static_cast(dock.state), dock.learningActive, dock.description, this)); + static_cast(dock.state), dock.learningActive, dock.description, dock.ledBrightness, this)); qCDebug(lcDockController()) << "Dock added:" << dockId; emit dockAdded(dockId); @@ -409,6 +455,9 @@ void DockController::onDockChanged(QString dockId, core::DockConfiguration dock) if (!dock.description.isEmpty()) { m_configuredDocks.updateDescription(dockId, dock.description); } + if (dock.ledBrightness != -1) { + m_configuredDocks.updateLedBrightness(dockId, dock.ledBrightness); + } qCDebug(lcDockController()) << "Dock updated:" << dockId; emit dockChanged(dockId); diff --git a/src/dock/dockController.h b/src/dock/dockController.h index 6ab473c..ceb8726 100644 --- a/src/dock/dockController.h +++ b/src/dock/dockController.h @@ -32,6 +32,7 @@ class DockController : public QObject { Q_INVOKABLE QObject* getDiscoveredDock(const QString& dockId); Q_INVOKABLE QObject* getConfiguredDock(const QString& dockId); + Q_INVOKABLE void getConfiguredDockFromCore(const QString &dockId); Q_INVOKABLE void startDiscovery(); Q_INVOKABLE void stopDiscovery(); @@ -70,6 +71,8 @@ class DockController : public QObject { void dockPasswordChanged(QString dockId); void error(QString messsage); + void gotDock(bool success, QString id); + private: static DockController* s_instance; core::Api* m_core; diff --git a/src/qml/components/ButtonNavigation.qml b/src/qml/components/ButtonNavigation.qml index 7f1c155..d9c9218 100644 --- a/src/qml/components/ButtonNavigation.qml +++ b/src/qml/components/ButtonNavigation.qml @@ -25,16 +25,16 @@ Item { function takeControl() { ui.inputController.takeControl(String(buttonNavigation.parent)); - console.debug("Button control enabled for: " + String(buttonNavigation.parent)); + console.info("Button control enabled for: " + String(buttonNavigation.parent)); } function releaseControl(newNavigation = "") { ui.inputController.releaseControl(newNavigation); - console.debug("Button control disabled for: " + String(buttonNavigation.parent)); + console.info("Button control disabled for: " + String(buttonNavigation.parent)); } function extendDefaultConfig(config, overWrite = false) { - console.debug("Extending default config for: " + String(buttonNavigation.parent)); + console.info("Extending default config for: " + String(buttonNavigation.parent)); buttonNavigation.defaultConfigOriginal = buttonNavigation.defaultConfig; for (const [key, value] of Object.entries(config)) { @@ -47,12 +47,12 @@ Item { } function restoreDefaultConfig() { - console.debug("Restoring default config for: " + String(buttonNavigation.parent)); + console.info("Restoring default config for: " + String(buttonNavigation.parent)); buttonNavigation.defaultConfig = buttonNavigation.defaultConfigOriginal; } function extendOverrideConfig(config, overWrite = false) { - console.debug("Extending override config for: " + String(buttonNavigation.parent)); + console.info("Extending override config for: " + String(buttonNavigation.parent)); buttonNavigation.overrideConfigOriginal = buttonNavigation.overrideConfig; for (const [key, value] of Object.entries(config)) { @@ -65,7 +65,7 @@ Item { } function restoreOverrideConfig() { - console.debug("Restoring override config for: " + String(buttonNavigation.parent)); + console.info("Restoring override config for: " + String(buttonNavigation.parent)); buttonNavigation.overrideConfig = buttonNavigation.overrideConfigOriginal; } @@ -77,14 +77,14 @@ Item { if (overrideConfig[key]) { // execute override config if (overrideConfig[key].pressed) { - console.debug("OVERRIDE PRESSED: " + key + " " + buttonNavigation.parent); + console.info("OVERRIDE PRESSED: " + key + " " + buttonNavigation.parent); overrideConfig[key].pressed(); } } else if (defaultConfig[key]) { // execute default config if (defaultConfig[key].pressed) { - console.debug("DEFAULT PRESSED: " + key + " " + buttonNavigation.parent); + console.info("DEFAULT PRESSED: " + key + " " + buttonNavigation.parent); defaultConfig[key].pressed(); } } @@ -94,14 +94,14 @@ Item { if (overrideConfig[key]) { // execute override config if (overrideConfig[key].long_press) { - console.debug("OVERRIDE LONG_PRESS: " + key + " " + buttonNavigation.parent); + console.info("OVERRIDE LONG_PRESS: " + key + " " + buttonNavigation.parent); overrideConfig[key].long_press(); } } else if (defaultConfig[key]) { // execute default config if (defaultConfig[key].long_press) { - console.debug("DEFAULT LONG_PRESS: " + key + " " + buttonNavigation.parent); + console.info("DEFAULT LONG_PRESS: " + key + " " + buttonNavigation.parent); defaultConfig[key].long_press(); } } @@ -111,14 +111,14 @@ Item { if (overrideConfig[key]) { // execute override config if (overrideConfig[key].released) { - console.debug("OVERRIDE RELEASED: " + key + " " + buttonNavigation.parent); + console.info("OVERRIDE RELEASED: " + key + " " + buttonNavigation.parent); overrideConfig[key].released(); } } else if (defaultConfig[key]) { // execute default config if (defaultConfig[key].released) { - console.debug("DEFAULT RELEASED: " + key + " " + buttonNavigation.parent); + console.info("DEFAULT RELEASED: " + key + " " + buttonNavigation.parent); defaultConfig[key].released(); } } diff --git a/src/qml/components/docks/Info.qml b/src/qml/components/docks/Info.qml index 87e0579..bfff7f7 100644 --- a/src/qml/components/docks/Info.qml +++ b/src/qml/components/docks/Info.qml @@ -22,6 +22,7 @@ Item { property string name property int state property string connectionType + property int ledBrightness } property string dockId @@ -32,7 +33,13 @@ Item { onDockIdChanged: { if (dockId) { - dockObj = DockController.getConfiguredDock(dockId); + DockController.getConfiguredDockFromCore(dockId); + connectSignalSlot(DockController.gotDock, function(success, dockIdFromCore) { + dockObj = DockController.getConfiguredDock(dockIdFromCore); + if (!success) { + ui.createNotification("There was an error while getting the latest dock data", true); + } + }); } else { dockObj = dockObjDummy; } @@ -287,7 +294,7 @@ Item { Components.AboutInfo { Layout.bottomMargin: 10 - key: qsTr("Connection") + key: qsTr("Connection type") value: dockObj.connectionType ? dockObj.connectionType : qsTr("N/A") } @@ -347,10 +354,10 @@ Item { Components.Slider { height: 60 - from: 10 + from: 0 to: 100 stepSize: 1 - value: 60 + value: dockObj.ledBrightness live: true onUserInteractionEnded: { diff --git a/src/qml/components/entities/BaseDetail.qml b/src/qml/components/entities/BaseDetail.qml index 871cc0d..c54c413 100644 --- a/src/qml/components/entities/BaseDetail.qml +++ b/src/qml/components/entities/BaseDetail.qml @@ -52,7 +52,7 @@ Rectangle { } PropertyAnimation { target: iconClose; properties: "opacity"; easing.type: Easing.OutExpo; duration: entityBaseDetailContainer.skipAnimation ? 0 : 300 } PauseAnimation { duration: 500 } - ScriptAction { script: ui.inputController.blockInput(false); } +// ScriptAction { script: ui.inputController.blockInput(false); } } }, Transition { @@ -83,7 +83,7 @@ Rectangle { function open(skipAnimation = false) { buttonNavigation.takeControl(); - ui.inputController.blockInput(true); +// ui.inputController.blockInput(true); entityBaseDetailContainer.skipAnimation = skipAnimation; entityBaseDetailContainer.state = "open"; } @@ -96,7 +96,7 @@ Rectangle { buttonNavigation.releaseControl(); } - ui.inputController.blockInput(false); +// ui.inputController.blockInput(false); } Components.ButtonNavigation { diff --git a/src/qml/components/entities/activity/LoadingScreen.qml b/src/qml/components/entities/activity/LoadingScreen.qml index 4c9257f..38bcd74 100644 --- a/src/qml/components/entities/activity/LoadingScreen.qml +++ b/src/qml/components/entities/activity/LoadingScreen.qml @@ -7,6 +7,7 @@ import QtGraphicalEffects 1.0 import Entity.Controller 1.0 import Entity.Activity 1.0 +import Entity.Macro 1.0 import SequenceStep.Type 1.0 import "qrc:/components" as Components @@ -68,24 +69,26 @@ Popup { return; } - let stateString = entityObj.stateAsString + console.info((activityLoading.isMacro ? "Macro" : "Activity") + " state changed to: " + entityObj.stateAsString); - if (activityLoading.prevStateString != "Running" && stateString === "Off") { + if (activityLoading.prevState !== (activityLoading.isMacro ? MacroStates.Running : ActivityStates.Running) && entityObj.state === ActivityStates.Off) { activityLoading.end(false); return; } - if ((stateString === "Completed") || stateString === "On" || stateString === "Off" ) { + if ((entityObj.state === (activityLoading.isMacro ? MacroStates.Completed : ActivityStates.Completed)) || entityObj.state === ActivityStates.On || entityObj.state === ActivityStates.Off ) { activityLoading.end(false); - } else if (stateString === "Error") { + } else if (entityObj.state === (activityLoading.isMacro ? MacroStates.Error : ActivityStates.Error)) { activityLoading.end(true); errorText.text = entityObj.currentStep.error; } - activityLoading.prevStateString = stateString; + activityLoading.prevState = entityObj.state; } function onCurrentStepChanged() { + console.info("Current step changed: " + entityObj.currentStep.command); + let stepEntityObj = EntityController.get(entityObj.currentStep.entityId); activityLoading.stepIcon = stepEntityObj ? stepEntityObj.icon : ""; activityLoading.stepName = stepEntityObj ? stepEntityObj.name : ""; @@ -154,7 +157,7 @@ Popup { property bool isMacro: false property string entityId - property string prevStateString: "unknown" + property int prevState: ActivityStates.Unknown property QtObject entityObj property string stepIcon: "" property string stepName: "" diff --git a/src/qml/components/entities/activity/deviceclass/Activity.qml b/src/qml/components/entities/activity/deviceclass/Activity.qml index f305556..3817052 100644 --- a/src/qml/components/entities/activity/deviceclass/Activity.qml +++ b/src/qml/components/entities/activity/deviceclass/Activity.qml @@ -88,6 +88,7 @@ EntityComponents.BaseDetail { } Component.onCompleted: { + console.info("Setting up button mappings for activity: " + entityObj.name); entityObj.buttonMapping.forEach((buttonMap) => { if (buttonMap.short_press) { overrideConfig[buttonMap.button] = ({}); @@ -100,6 +101,8 @@ EntityComponents.BaseDetail { const cmdString = String(buttonMap.short_press.cmd_id); const canRepeat = !cmdString.includes("remote."); + console.info(entityObj.name + " button mapping: " + buttonMap.button + " -> " + JSON.stringify(buttonMap.short_press)); + overrideConfig[buttonMap.button]["pressed"] = function() { if (e) { switch (e.type) { @@ -108,8 +111,8 @@ EntityComponents.BaseDetail { if (buttonMap.button === "VOLUME_UP" || buttonMap.button === "VOLUME_DOWN") { volume.start(e, buttonMap.button === "VOLUME_UP"); } - activityBase.triggerCommand(buttonMap.short_press.entity_id, buttonMap.short_press.cmd_id, buttonMap.short_press.params); } + activityBase.triggerCommand(buttonMap.short_press.entity_id, buttonMap.short_press.cmd_id, buttonMap.short_press.params); break; case EntityTypes.Remote: { if (!activityBase.buttonLongPressStep1[buttonMap.button]) { @@ -168,6 +171,8 @@ EntityComponents.BaseDetail { activityBase.triggerCommand(buttonMap.short_press.entity_id, buttonMap.short_press.cmd_id, buttonMap.short_press.params); break; } + } else { + console.warn("Entity " + entityId + " is not loaded. Button mapping failed for press: " + buttonMap.button); } } @@ -198,8 +203,12 @@ EntityComponents.BaseDetail { "remote.stop_send", {}); } + } else { + console.warn("Entity " + entityId + " is not loaded. Button mapping failed for release: " + buttonMap.button); } } + } else { + console.warn("Entity " + entityId + " is not loaded. Button mapping failed."); } }) } diff --git a/src/ui/entity/activity.cpp b/src/ui/entity/activity.cpp index 775a474..bb8fb90 100644 --- a/src/ui/entity/activity.cpp +++ b/src/ui/entity/activity.cpp @@ -125,8 +125,7 @@ bool Activity::updateAttribute(const QString &attribute, QVariant data) { m_state = newState; ok = true; - m_stateAsString = - Util::convertEnumToString(static_cast(m_state)); + m_stateAsString = ActivityStates::getTranslatedString(static_cast(m_state)); m_stateInfo = getStateAsString(); emit stateAsStringChanged(); @@ -195,6 +194,18 @@ bool Activity::updateOptions(QVariant data) { return ok; } +void Activity::onLanguageChangedTypeSpecific() +{ + QTimer::singleShot(500, [=]() { + m_stateAsString = ActivityStates::getTranslatedString(static_cast(m_state)); + m_stateInfo = getStateAsString(); + + emit stateAsStringChanged(); + emit stateInfoChanged(); + emit stateChanged(m_id, m_state); + }); +} + void Activity::sendButtonMappingCommand(const QString &buttonName, bool shortPress) { QString command, entityId; QString press = shortPress ? "short_press" : "long_press"; diff --git a/src/ui/entity/activity.h b/src/ui/entity/activity.h index 90030b3..1e226de 100644 --- a/src/ui/entity/activity.h +++ b/src/ui/entity/activity.h @@ -25,10 +25,31 @@ class ActivityAttributes : public QObject { }; class ActivityStates : public QObject { - Q_GADGET + Q_OBJECT public: enum Enum { Unavailable = 0, Unknown, On, Off, Running, Error, Completed }; Q_ENUM(Enum) + + static QString getTranslatedString(Enum state) { + switch (state) { + case Enum::Unavailable: + return QCoreApplication::translate("Activity state", "Unavailable"); + case Enum::Unknown: + return QCoreApplication::translate("Activity state", "Unknown"); + case Enum::On: + return QCoreApplication::translate("Activity state", "On"); + case Enum::Off: + return QCoreApplication::translate("Activity state", "Off"); + case Enum::Running: + return QCoreApplication::translate("Activity state", "Running"); + case Enum::Error: + return QCoreApplication::translate("Activity state", "Error"); + case Enum::Completed: + return QCoreApplication::translate("Activity state", "Completed"); + default: + return Util::convertEnumToString(state); + } + } }; class ActivityCommands : public QObject { @@ -88,6 +109,8 @@ class Activity : public Base { bool updateAttribute(const QString &attribute, QVariant data) override; bool updateOptions(QVariant data) override; + void onLanguageChangedTypeSpecific() override; + signals: void totalStepsChanged(); void currentStepChanged(); diff --git a/src/ui/entity/button.cpp b/src/ui/entity/button.cpp index 238dedc..bd0914f 100644 --- a/src/ui/entity/button.cpp +++ b/src/ui/entity/button.cpp @@ -73,8 +73,7 @@ bool Button::updateAttribute(const QString &attribute, QVariant data) { ok = true; emit stateChanged(m_id, m_state); - m_stateAsString = - Util::convertEnumToString(static_cast(m_state)); + m_stateAsString = ButtonStates::getTranslatedString(static_cast(m_state)); emit stateAsStringChanged(); m_stateInfo = getStateAsString(); @@ -87,6 +86,17 @@ bool Button::updateAttribute(const QString &attribute, QVariant data) { return ok; } +void Button::onLanguageChangedTypeSpecific() +{ + QTimer::singleShot(500, [=]() { + m_stateAsString = ButtonStates::getTranslatedString(static_cast(m_state)); + emit stateAsStringChanged(); + + m_stateInfo = getStateAsString(); + emit stateInfoChanged(); + }); +} + } // namespace entity } // namespace ui } // namespace uc diff --git a/src/ui/entity/button.h b/src/ui/entity/button.h index 272c7ad..e7ae82c 100644 --- a/src/ui/entity/button.h +++ b/src/ui/entity/button.h @@ -28,10 +28,25 @@ class ButtonAttributes : public QObject { }; class ButtonStates : public QObject { - Q_GADGET + Q_OBJECT public: enum Enum { Unavailable = 0, Unknown, Available, On }; Q_ENUM(Enum) + + static QString getTranslatedString(Enum state) { + switch (state) { + case Enum::Unavailable: + return QCoreApplication::translate("Button state", "Unavailable"); + case Enum::Unknown: + return QCoreApplication::translate("Button state", "Unknown"); + case Enum::Available: + return QCoreApplication::translate("Button state", "Available"); + case Enum::On: + return QCoreApplication::translate("Button state", "On"); + default: + return Util::convertEnumToString(state); + } + } }; class ButtonCommands : public QObject { @@ -63,6 +78,8 @@ class Button : public Base { void sendCommand(ButtonCommands::Enum cmd, QVariantMap params); void sendCommand(ButtonCommands::Enum cmd); bool updateAttribute(const QString &attribute, QVariant data) override; + + void onLanguageChangedTypeSpecific() override; }; } // namespace entity diff --git a/src/ui/entity/climate.cpp b/src/ui/entity/climate.cpp index 24fc212..a84f480 100644 --- a/src/ui/entity/climate.cpp +++ b/src/ui/entity/climate.cpp @@ -232,8 +232,7 @@ bool Climate::updateAttribute(const QString &attribute, QVariant data) { ok = true; emit stateChanged(m_id, m_state); - m_stateAsString = - Util::convertEnumToString(static_cast(m_state)); + m_stateAsString = ClimateStates::getTranslatedString(static_cast(m_state)); emit stateAsStringChanged(); m_stateInfo1 = getStateAsString(); @@ -299,6 +298,17 @@ bool Climate::updateAttribute(const QString &attribute, QVariant data) { return ok; } +void Climate::onLanguageChangedTypeSpecific() +{ + QTimer::singleShot(500, [=]() { + m_stateAsString = ClimateStates::getTranslatedString(static_cast(m_state)); + emit stateAsStringChanged(); + + m_stateInfo1 = getStateAsString(); + emit stateInfoChanged(); + }); +} + void Climate::onUnitSystemChanged(Config::UnitSystems unitSystem) { if (!m_useSystemUnit) { return; diff --git a/src/ui/entity/climate.h b/src/ui/entity/climate.h index c2b9919..ad137b6 100644 --- a/src/ui/entity/climate.h +++ b/src/ui/entity/climate.h @@ -36,10 +36,33 @@ class ClimateAttributes : public QObject { }; class ClimateStates : public QObject { - Q_GADGET + Q_OBJECT public: enum Enum { Unavailable = 0, Unknown, Off, Heat, Cool, Heat_cool, Fan, Auto }; Q_ENUM(Enum) + + static QString getTranslatedString(Enum state) { + switch (state) { + case Enum::Unavailable: + return QCoreApplication::translate("Climate state", "Unavailable"); + case Enum::Unknown: + return QCoreApplication::translate("Climate state", "Unknown"); + case Enum::Off: + return QCoreApplication::translate("Climate state", "Off"); + case Enum::Heat: + return QCoreApplication::translate("Climate state", "Heat"); + case Enum::Cool: + return QCoreApplication::translate("Climate state", "Cool"); + case Enum::Heat_cool: + return QCoreApplication::translate("Climate state", "Heat/Cool"); + case Enum::Fan: + return QCoreApplication::translate("Climate state", "Fan"); + case Enum::Auto: + return QCoreApplication::translate("Climate state", "Auto"); + default: + return Util::convertEnumToString(state); + } + } }; class ClimateCommands : public QObject { @@ -118,6 +141,8 @@ class Climate : public Base { void sendCommand(ClimateCommands::Enum cmd); bool updateAttribute(const QString &attribute, QVariant data) override; + void onLanguageChangedTypeSpecific() override; + signals: void currentTemperatureChanged(); void targetTemperatureChanged(); diff --git a/src/ui/entity/cover.cpp b/src/ui/entity/cover.cpp index 88206ed..0f6df1e 100644 --- a/src/ui/entity/cover.cpp +++ b/src/ui/entity/cover.cpp @@ -124,7 +124,7 @@ bool Cover::updateAttribute(const QString &attribute, QVariant data) { ok = true; emit stateChanged(m_id, m_state); - m_stateAsString = Util::convertEnumToString(static_cast(m_state)); + m_stateAsString = CoverStates::getTranslatedString(static_cast(m_state)); emit stateAsStringChanged(); m_stateInfo1 = getStateAsString(); @@ -159,6 +159,17 @@ bool Cover::updateAttribute(const QString &attribute, QVariant data) { return ok; } +void Cover::onLanguageChangedTypeSpecific() +{ + QTimer::singleShot(500, [=]() { + m_stateAsString = CoverStates::getTranslatedString(static_cast(m_state)); + emit stateAsStringChanged(); + + m_stateInfo1 = getStateAsString(); + emit stateInfoChanged(); + }); +} + } // namespace entity } // namespace ui } // namespace uc diff --git a/src/ui/entity/cover.h b/src/ui/entity/cover.h index ed9a0ba..535b4b9 100644 --- a/src/ui/entity/cover.h +++ b/src/ui/entity/cover.h @@ -28,10 +28,29 @@ class CoverAttributes : public QObject { }; class CoverStates : public QObject { - Q_GADGET + Q_OBJECT public: enum Enum { Unavailable = 0, Unknown, Opening, Open, Closing, Closed }; Q_ENUM(Enum) + + static QString getTranslatedString(Enum state) { + switch (state) { + case Enum::Unavailable: + return QCoreApplication::translate("Cover state", "Unavailable"); + case Enum::Unknown: + return QCoreApplication::translate("Cover state", "Unknown"); + case Enum::Opening: + return QCoreApplication::translate("Cover state", "Opening"); + case Enum::Open: + return QCoreApplication::translate("Cover state", "Open"); + case Enum::Closing: + return QCoreApplication::translate("Cover state", "Closing"); + case Enum::Closed: + return QCoreApplication::translate("Cover state", "Closed"); + default: + return Util::convertEnumToString(state); + } + } }; class CoverCommands : public QObject { @@ -81,6 +100,8 @@ class Cover : public Base { void sendCommand(CoverCommands::Enum cmd); bool updateAttribute(const QString &attribute, QVariant data) override; + void onLanguageChangedTypeSpecific() override; + signals: void positionChanged(); void tiltPositionChanged(); diff --git a/src/ui/entity/entity.cpp b/src/ui/entity/entity.cpp index eae71c7..6b1bb1c 100644 --- a/src/ui/entity/entity.cpp +++ b/src/ui/entity/entity.cpp @@ -157,6 +157,8 @@ void Base::onLanguageChanged(QString language) { emit nameChanged(); m_sorting = m_name.toLower() + m_integration.toLower() + m_id.toLower() + m_area.toLower(); + + onLanguageChangedTypeSpecific(); } void Base::onStateChanged(QString entityId, int newState) { diff --git a/src/ui/entity/entity.h b/src/ui/entity/entity.h index df17269..f8d4786 100644 --- a/src/ui/entity/entity.h +++ b/src/ui/entity/entity.h @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "../../util.h" @@ -100,6 +102,8 @@ class Base : public QObject { bool getSelected() { return m_selected; } void setSelected(bool selected) { m_selected = selected; } + virtual void onLanguageChangedTypeSpecific() {} + public: static Type typeFromString(const QString &key, bool *ok = nullptr) { return Util::convertStringToEnum(key, ok); diff --git a/src/ui/entity/light.cpp b/src/ui/entity/light.cpp index 12c0a45..2faa8d7 100644 --- a/src/ui/entity/light.cpp +++ b/src/ui/entity/light.cpp @@ -121,7 +121,7 @@ bool Light::updateAttribute(const QString &attribute, QVariant data) { ok = true; emit stateChanged(m_id, m_state); - m_stateAsString = Util::convertEnumToString(static_cast(m_state)); + m_stateAsString = LightStates::getTranslatedString(static_cast(m_state)); emit stateAsStringChanged(); m_stateInfo1 = getStateAsString(); @@ -180,6 +180,17 @@ bool Light::updateAttribute(const QString &attribute, QVariant data) { return ok; } +void Light::onLanguageChangedTypeSpecific() +{ + QTimer::singleShot(500, [=]() { + m_stateAsString = LightStates::getTranslatedString(static_cast(m_state)); + emit stateAsStringChanged(); + + m_stateInfo1 = getStateAsString(); + emit stateInfoChanged(); + }); +} + void Light::calculateQColor() { QColor color; color.setHsv(m_hue, m_saturation, 255); diff --git a/src/ui/entity/light.h b/src/ui/entity/light.h index 48a9c22..0e71872 100644 --- a/src/ui/entity/light.h +++ b/src/ui/entity/light.h @@ -56,14 +56,29 @@ class LightAttributes : public QObject { }; class LightStates : public QObject { - Q_GADGET + Q_OBJECT public: enum Enum { Unavailable = 0, Unknown, On, Off }; Q_ENUM(Enum) + + static QString getTranslatedString(Enum state) { + switch (state) { + case Enum::Unavailable: + return QCoreApplication::translate("Light state", "Unavailable"); + case Enum::Unknown: + return QCoreApplication::translate("Light state", "Unknown"); + case Enum::On: + return QCoreApplication::translate("Light state", "On"); + case Enum::Off: + return QCoreApplication::translate("Light state", "Off"); + default: + return Util::convertEnumToString(state); + } + } }; class LightCommands : public QObject { - Q_GADGET + Q_OBJECT public: enum Enum { On, Off, Toggle }; Q_ENUM(Enum) @@ -99,7 +114,7 @@ class Light : public Base { // options int getColorTempSteps() { return m_colorTempSteps; } - QString getStateInfo() override { return m_stateInfo1 + " " + m_state == LightStates::On ? m_stateInfo2 : ""; } + QString getStateInfo() override { return m_stateInfo1 + " " + (m_state == LightStates::On ? m_stateInfo2 : ""); } Q_INVOKABLE void turnOn() override; Q_INVOKABLE void turnOff() override; @@ -112,11 +127,14 @@ class Light : public Base { void sendCommand(LightCommands::Enum cmd); bool updateAttribute(const QString &attribute, QVariant data) override; + void onLanguageChangedTypeSpecific() override; + signals: void brightnessChanged(); void colorChanged(); void colorTempChanged(); + private: int m_hue; int m_saturation; diff --git a/src/ui/entity/macro.cpp b/src/ui/entity/macro.cpp index 172858f..65477ba 100644 --- a/src/ui/entity/macro.cpp +++ b/src/ui/entity/macro.cpp @@ -56,6 +56,12 @@ void Macro::stop() { sendCommand(MacroCommands::Stop); } +void Macro::clearCurrentStep() +{ + m_totalSteps = 0; + emit totalStepsChanged(); +} + void Macro::sendCommand(MacroCommands::Enum cmd, QVariantMap params) { Base::sendCommand(QVariant::fromValue(cmd).toString(), params); } @@ -78,7 +84,7 @@ bool Macro::updateAttribute(const QString &attribute, QVariant data) { m_state = newState; ok = true; - m_stateAsString = Util::convertEnumToString(static_cast(m_state)); + m_stateAsString = MacroStates::getTranslatedString(static_cast(m_state)); emit stateAsStringChanged(); emit stateChanged(m_id, m_state); } @@ -109,6 +115,15 @@ bool Macro::updateAttribute(const QString &attribute, QVariant data) { return ok; } +void Macro::onLanguageChangedTypeSpecific() +{ + QTimer::singleShot(500, [=]() { + m_stateAsString = MacroStates::getTranslatedString(static_cast(m_state)); + emit stateAsStringChanged(); + emit stateChanged(m_id, m_state); + }); +} + } // namespace entity } // namespace ui } // namespace uc diff --git a/src/ui/entity/macro.h b/src/ui/entity/macro.h index 523dbe4..066a960 100644 --- a/src/ui/entity/macro.h +++ b/src/ui/entity/macro.h @@ -25,10 +25,27 @@ class MacroAttributes : public QObject { }; class MacroStates : public QObject { - Q_GADGET + Q_OBJECT public: enum Enum { Unavailable = 0, Unknown, Running, Error, Completed }; Q_ENUM(Enum) + + static QString getTranslatedString(Enum state) { + switch (state) { + case Enum::Unavailable: + return QCoreApplication::translate("Macro state", "Unavailable"); + case Enum::Unknown: + return QCoreApplication::translate("Macro state", "Unknown"); + case Enum::Running: + return QCoreApplication::translate("Macro state", "Running"); + case Enum::Error: + return QCoreApplication::translate("Macro state", "Error"); + case Enum::Completed: + return QCoreApplication::translate("Macro state", "Completed"); + default: + return Util::convertEnumToString(state); + } + } }; class MacroCommands : public QObject { @@ -64,11 +81,14 @@ class Macro : public Base { Q_INVOKABLE void run(); Q_INVOKABLE void stop(); + Q_INVOKABLE void clearCurrentStep(); void sendCommand(MacroCommands::Enum cmd, QVariantMap params); void sendCommand(MacroCommands::Enum cmd); bool updateAttribute(const QString &attribute, QVariant data) override; + void onLanguageChangedTypeSpecific() override; + signals: void totalStepsChanged(); void currentStepChanged(); diff --git a/src/ui/entity/mediaPlayer.cpp b/src/ui/entity/mediaPlayer.cpp index 4f9c510..facb4ad 100644 --- a/src/ui/entity/mediaPlayer.cpp +++ b/src/ui/entity/mediaPlayer.cpp @@ -259,13 +259,11 @@ bool MediaPlayer::updateAttribute(const QString &attribute, QVariant data) { switch (attributeEnum) { case MediaPlayerAttributes::State: { int newState = Util::convertStringToEnum(uc::Util::FirstToUpper(data.toString())); - if (m_state != newState && newState != -1) { m_state = newState; ok = true; emit stateChanged(m_id, m_state); - m_stateAsString = - Util::convertEnumToString(static_cast(m_state)); + m_stateAsString = MediaPlayerStates::getTranslatedString(static_cast(m_state)); emit stateAsStringChanged(); // enable/disable media position timer @@ -302,7 +300,6 @@ bool MediaPlayer::updateAttribute(const QString &attribute, QVariant data) { emit removeFromActivities(m_id); } - } break; } case MediaPlayerAttributes::Volume: { @@ -438,8 +435,19 @@ bool MediaPlayer::updateAttribute(const QString &attribute, QVariant data) { return ok; } +void MediaPlayer::onLanguageChangedTypeSpecific() +{ + QTimer::singleShot(500, [=]() { + m_stateAsString = MediaPlayerStates::getTranslatedString(static_cast(m_state)); + emit stateAsStringChanged(); + }); +} + void MediaPlayer::onPositionTimerTimeout() { m_mediaPosition++; + if (m_mediaPosition >= m_mediaDuration) { + m_mediaPosition = m_mediaDuration; + } emit mediaPositionChanged(); } diff --git a/src/ui/entity/mediaPlayer.h b/src/ui/entity/mediaPlayer.h index 0d4769c..46a99ba 100644 --- a/src/ui/entity/mediaPlayer.h +++ b/src/ui/entity/mediaPlayer.h @@ -86,11 +86,34 @@ class MediaPlayerAttributes : public QObject { }; class MediaPlayerStates : public QObject { - Q_GADGET + Q_OBJECT public: enum Enum { Unavailable = 0, Unknown, On, Off, Playing, Paused, Standby, Buffering }; Q_ENUM(Enum) + + static QString getTranslatedString(Enum state) { + switch (state) { + case Enum::Unavailable: + return QCoreApplication::translate("Media platyer state", "Unavailable"); + case Enum::Unknown: + return QCoreApplication::translate("Media platyer state", "Unknown"); + case Enum::On: + return QCoreApplication::translate("Media platyer state", "On"); + case Enum::Off: + return QCoreApplication::translate("Media platyer state", "Off"); + case Enum::Playing: + return QCoreApplication::translate("Media platyer state", "Playing"); + case Enum::Paused: + return QCoreApplication::translate("Media platyer state", "Paused"); + case Enum::Standby: + return QCoreApplication::translate("Media platyer state", "Standby"); + case Enum::Buffering: + return QCoreApplication::translate("Media platyer state", "Buffering"); + default: + return Util::convertEnumToString(state); + } + } }; class MediaPlayerCommands : public QObject { @@ -258,6 +281,8 @@ class MediaPlayer : public Base { void sendCommand(MediaPlayerCommands::Enum cmd); bool updateAttribute(const QString &attribute, QVariant data) override; + void onLanguageChangedTypeSpecific() override; + signals: void volumeChanged(); void mutedChanged(); diff --git a/src/ui/entity/remote.cpp b/src/ui/entity/remote.cpp index 6dbf2a2..97b22f2 100644 --- a/src/ui/entity/remote.cpp +++ b/src/ui/entity/remote.cpp @@ -82,8 +82,7 @@ bool Remote::updateAttribute(const QString &attribute, QVariant data) { ok = true; emit stateChanged(m_id, m_state); - m_stateAsString = - Util::convertEnumToString(static_cast(m_state)); + m_stateAsString = RemoteStates::getTranslatedString(static_cast(m_state)); emit stateAsStringChanged(); m_stateInfo = getStateAsString(); @@ -115,6 +114,17 @@ bool Remote::updateOptions(QVariant data) { return ok; } +void Remote::onLanguageChangedTypeSpecific() +{ + QTimer::singleShot(500, [=]() { + m_stateAsString = RemoteStates::getTranslatedString(static_cast(m_state)); + emit stateAsStringChanged(); + + m_stateInfo = getStateAsString(); + emit stateInfoChanged(); + }); +} + } // namespace entity } // namespace ui } // namespace uc diff --git a/src/ui/entity/remote.h b/src/ui/entity/remote.h index e05263a..60f9d22 100644 --- a/src/ui/entity/remote.h +++ b/src/ui/entity/remote.h @@ -24,10 +24,25 @@ class RemoteAttributes : public QObject { }; class RemoteStates : public QObject { - Q_GADGET + Q_OBJECT public: enum Enum { Unavailable = 0, Unknown, On, Off }; Q_ENUM(Enum) + + static QString getTranslatedString(Enum state) { + switch (state) { + case Enum::Unavailable: + return QCoreApplication::translate("Remote state", "Unavailable"); + case Enum::Unknown: + return QCoreApplication::translate("Remote state", "Unknown"); + case Enum::On: + return QCoreApplication::translate("Remote state", "On"); + case Enum::Off: + return QCoreApplication::translate("Remote state", "Off"); + default: + return Util::convertEnumToString(state); + } + } }; class RemoteCommands : public QObject { @@ -70,6 +85,8 @@ class Remote : public Base { bool updateAttribute(const QString &attribute, QVariant data) override; bool updateOptions(QVariant data) override; + void onLanguageChangedTypeSpecific() override; + signals: void buttonMappingChanged(); void uiConfigChanged(); diff --git a/src/ui/entity/sensor.cpp b/src/ui/entity/sensor.cpp index 2636af2..b858153 100644 --- a/src/ui/entity/sensor.cpp +++ b/src/ui/entity/sensor.cpp @@ -109,8 +109,7 @@ bool Sensor::updateAttribute(const QString &attribute, QVariant data) { ok = true; emit stateChanged(m_id, m_state); - m_stateAsString = - Util::convertEnumToString(static_cast(m_state)); + m_stateAsString = SensorStates::getTranslatedString(static_cast(m_state)); emit stateAsStringChanged(); } break; @@ -133,6 +132,14 @@ bool Sensor::updateAttribute(const QString &attribute, QVariant data) { return ok; } + +void Sensor::onLanguageChangedTypeSpecific() +{ + QTimer::singleShot(500, [=]() { + m_stateAsString = SensorStates::getTranslatedString(static_cast(m_state)); + emit stateAsStringChanged(); + }); +} } // namespace entity } // namespace ui } // namespace uc diff --git a/src/ui/entity/sensor.h b/src/ui/entity/sensor.h index bc40631..a4d0d6b 100644 --- a/src/ui/entity/sensor.h +++ b/src/ui/entity/sensor.h @@ -21,10 +21,23 @@ class SensorAttributes : public QObject { }; class SensorStates : public QObject { - Q_GADGET + Q_OBJECT public: enum Enum { Unavailable = 0, Unknown, On }; Q_ENUM(Enum) + + static QString getTranslatedString(Enum state) { + switch (state) { + case Enum::Unavailable: + return QCoreApplication::translate("Sensor state", "Unavailable"); + case Enum::Unknown: + return QCoreApplication::translate("Sensor state", "Unknown"); + case Enum::On: + return QCoreApplication::translate("Sensor state", "On"); + default: + return Util::convertEnumToString(state); + } + } }; class SensorCommands : public QObject { @@ -76,6 +89,8 @@ class Sensor : public Base { QString getStateInfo() override { return m_value.toString() + " " + m_unit; } + void onLanguageChangedTypeSpecific() override; + signals: void valueChanged(); void unitChanged(); diff --git a/src/ui/entity/switch.cpp b/src/ui/entity/switch.cpp index 7a4ef13..9976bba 100644 --- a/src/ui/entity/switch.cpp +++ b/src/ui/entity/switch.cpp @@ -84,8 +84,7 @@ bool Switch::updateAttribute(const QString &attribute, QVariant data) { ok = true; emit stateChanged(m_id, m_state); - m_stateAsString = - Util::convertEnumToString(static_cast(m_state)); + m_stateAsString = SwitchStates::getTranslatedString(static_cast(m_state)); emit stateAsStringChanged(); m_stateInfo = getStateAsString(); @@ -98,6 +97,17 @@ bool Switch::updateAttribute(const QString &attribute, QVariant data) { return ok; } +void Switch::onLanguageChangedTypeSpecific() +{ + QTimer::singleShot(500, [=]() { + m_stateAsString = SwitchStates::getTranslatedString(static_cast(m_state)); + emit stateAsStringChanged(); + + m_stateInfo = getStateAsString(); + emit stateInfoChanged(); + }); +} + } // namespace entity } // namespace ui } // namespace uc diff --git a/src/ui/entity/switch.h b/src/ui/entity/switch.h index 1ff22b5..1453217 100644 --- a/src/ui/entity/switch.h +++ b/src/ui/entity/switch.h @@ -28,10 +28,25 @@ class SwitchAttributes : public QObject { }; class SwitchStates : public QObject { - Q_GADGET + Q_OBJECT public: enum Enum { Unavailable = 0, Unknown, On, Off }; Q_ENUM(Enum) + + static QString getTranslatedString(Enum state) { + switch (state) { + case Enum::Unavailable: + return QCoreApplication::translate("Switch state", "Unavailable"); + case Enum::Unknown: + return QCoreApplication::translate("Switch state", "Unknown"); + case Enum::On: + return QCoreApplication::translate("Switch state", "On"); + case Enum::Off: + return QCoreApplication::translate("Switch state", "Off"); + default: + return Util::convertEnumToString(state); + } + } }; class SwitchCommands : public QObject { @@ -65,6 +80,8 @@ class Switch : public Base { void sendCommand(SwitchCommands::Enum cmd); bool updateAttribute(const QString &attribute, QVariant data) override; + void onLanguageChangedTypeSpecific() override; + // Options private: bool m_readable; diff --git a/src/ui/inputController.cpp b/src/ui/inputController.cpp index 6b442fc..0db6bae 100644 --- a/src/ui/inputController.cpp +++ b/src/ui/inputController.cpp @@ -50,7 +50,7 @@ void InputController::takeControl(const QString &activeObject) { // we need to delay this a bit, otherwise it happens so fast that both old and new objects will trigger QTimer::singleShot(200, [=] { emit activeObjectChanged(); - qCDebug(lcInput()) << "TAKE CONTROL FROM" << m_prevActiveObject << "->" << m_activeObject; + qCInfo(lcInput()) << "TAKE CONTROL FROM" << m_prevActiveObject << "->" << m_activeObject; }); m_mutex.unlock(); @@ -68,7 +68,7 @@ void InputController::releaseControl(const QString &activeObject) { // we need to delay this a bit, otherwise it happens so fast that both old and new objects will trigger QTimer::singleShot(200, [=] { emit activeObjectChanged(); - qCDebug(lcInput()) << "RELEASE CONTROL BACK TO ->" << m_activeObject; + qCInfo(lcInput()) << "RELEASE CONTROL BACK TO ->" << m_activeObject; }); m_mutex.unlock(); @@ -118,7 +118,7 @@ bool InputController::eventFilter(QObject *obj, QEvent *event) { timer->setInterval(m_longPressTimeOut); QObject::connect(timer, &QTimer::timeout, this, [=]() { - qCDebug(lcInput()) << "Key press and hold:" << m_keyCodeMapping.value(key) << m_activeObject; + qCInfo(lcInput()) << "Key press and hold:" << m_keyCodeMapping.value(key) << m_activeObject; m_longPressTriggered.insert(key, true); emit keyLongPressed(m_keyCodeMapping.value(key)); }); @@ -126,7 +126,7 @@ bool InputController::eventFilter(QObject *obj, QEvent *event) { m_longPressTimers.insert(key, timer); emit keyPressed(m_keyCodeMapping.value(key)); - qCDebug(lcInput()) << "Key pressed:" << m_keyCodeMapping.value(key) << m_activeObject; + qCInfo(lcInput()) << "Key pressed:" << m_keyCodeMapping.value(key) << m_activeObject; break; } case QEvent::KeyRelease: { @@ -144,7 +144,7 @@ bool InputController::eventFilter(QObject *obj, QEvent *event) { // if (!m_longPressTriggered.value(key)) { emit keyReleased(m_keyCodeMapping.value(key)); - qCDebug(lcInput()) << "Key released:" << m_keyCodeMapping.value(key) << m_activeObject; + qCInfo(lcInput()) << "Key released:" << m_keyCodeMapping.value(key) << m_activeObject; // } break; } diff --git a/src/ui/uiController.cpp b/src/ui/uiController.cpp index 758c0a4..f7e5273 100644 --- a/src/ui/uiController.cpp +++ b/src/ui/uiController.cpp @@ -95,7 +95,7 @@ Controller::Controller(HardwareModel::Enum model, int width, int height, QQmlApp QObject::connect(m_config, &Config::soundVolumeChanged, this, [=](int volume) { m_soundEffects->setVolume(volume); }); - QObject::connect(m_config, &Config::languageChanged, this, &Controller::onLanguageChanged); + QObject::connect(m_config, &Config::languageChanged, m_entityController, &EntityController::onLanguageChanged); QObject::connect(m_config, &Config::unitSystemChanged, m_entityController, &EntityController::onUnitSystemChanged); QObject::connect(m_config, &Config::displayBrightnessChanged, this, &Controller::onBrightnessChanged); @@ -666,11 +666,6 @@ void Controller::onWarning(core::MsgEventTypes::WarningEvent event, bool shutdow } } -void Controller::onLanguageChanged(QString language) { - // TODO(Marton) why is this a manual call and not setup with a signal / slot? - m_entityController->onLanguageChanged(language); -} - void Controller::onBrightnessChanged(int brightness) { if (m_model == HardwareModel::UCR2) { m_globalBrightness = (100 - brightness) / 100.0; diff --git a/src/ui/uiController.h b/src/ui/uiController.h index 2f1a1b0..bfcb5ea 100644 --- a/src/ui/uiController.h +++ b/src/ui/uiController.h @@ -181,7 +181,6 @@ class Controller : public QObject { void onCoreProblem(); void onWarning(core::MsgEventTypes::WarningEvent event, bool shutdown, QString message); - void onLanguageChanged(QString language); void onBrightnessChanged(int brightness); void onProfileIdChanged();