Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support initializing language from argument or query parameter #458

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chriadam
Copy link
Contributor

@chriadam chriadam commented Sep 4, 2023

No description provided.

Copy link
Contributor

@blammit blammit left a comment

Choose a reason for hiding this comment

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

Would be nice if the language could be set from the BackendConnection or such before the rest of the UI was loaded (e.g. like how gui-v1 controls the temperature value in https://github.com/victronenergy/gui/blob/master/src/user.cpp) so that SystemSettings.qml wouldn't have to manage the startup case. But if that doesn't work out, then LGTM.

@chriadam
Copy link
Contributor Author

Need to reconsider this, as we don't really want the query parameter to overwrite the system setting. Instead, it should be more like: "what language should the error messages at startup time be, e.g. if it cannot connect to the MQTT broker?"
Not sure. If that's the case, merely setting the language in the singleton should be enough (and then it would automatically be overwritten once connection to MQTT succeeds, based on the system language setting received via MQTT).


QQmlEngine engine;
engine.setProperty("colorScheme", Victron::VenusOS::Theme::Dark);

/* Force construction of translator */
int languageSingletonId = qmlTypeId("Victron.VenusOS", 2, 0, "Language");
Q_ASSERT(languageSingletonId);
(void)engine.singletonInstance<Victron::VenusOS::Language*>(languageSingletonId);
Copy link
Contributor

Choose a reason for hiding this comment

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

This section seems out of date with main at the time of writing this comment, but it is noticed that the Victron::VenusOS::Language::create(&engine); does not specify QQmlEngine::setObjectOwnership(language, QQmlEngine::CppOwnership); and could cause multiple instances if the create() function was called multiple times. Suggest using Meyer's singleton pattern to prevent this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants