Skip to content

feat: add unit system setting in gui tab #680

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

lima-limon-inc
Copy link

AFAIK, one's system's QLocale setting determines the unit system in which distances are displayed, i.e. Metric or Imperial.

This patch adds a new setting in the GUI tab to set a QLog specific preference, without having to modify the unit system used system-wide.

The current implementation looks like this:
image

Would love to get some feedback on this!

PS: QLog is awesome, thanks for all the work.

@lima-limon-inc
Copy link
Author

Some additional notes:

  • I have tested these changes and they seem to work on my machine.
  • I am most hesitant about this commit: 70c0c7e
    • I replicated the code used in other classes where the LogLocale class is simply declared inside the class. Do I need to initialize it anywhere? Is there any danger of a void pointer being used? I am not a CPP expert, so maybe there are some details that are going over my head.

Thanks in advance! Have a nice week 😊

@foldynl
Copy link
Owner

foldynl commented Jun 9, 2025

Thank you for you patch. As usual, I have to ask, what is the motivation? The units are automatically selected according to the settings in the OS. What is the motivation to have this setting different from the user's preferred settings in the OS?

@lima-limon-inc
Copy link
Author

Thank you for you patch. As usual, I have to ask, what is the motivation? The units are automatically selected according to the settings in the OS. What is the motivation to have this setting different from the user's preferred settings in the OS?

Hi Foldynl! My main motivation is that, when I opened QLog, it was using Imperial units and I wasn't able to change them. I wasn't able to find an easy way to change my system's QLocale. I'm running QLog on a Linux system with no Desktop Environment, only a Window Manager; so there is no global "System's setting".

With this patch, I was able to display the distance using the metric system without having to go into the Linux rabbit hole of "how do I change my system's QLocale without messing up the rest of my system".

As an added bonus, having this setting could serve useful when speaking with another ham that uses a different unit system.

Hope that explains my reasoning.

Cheers! 😊

PS: I'm more than willing to tune this PR with any modifications you see fit.

@foldynl
Copy link
Owner

foldynl commented Jun 10, 2025

Measurement unit is controlled by an environment variable LC_MEASUREMENT (more detail https://github.com/foldynl/QLog/wiki/Multi-language-Support#distance-unit). If you are seeing a unit that you are not using, it is necessary to set this correctly in the environment. Personally, I do not think it is necessary to have this setting in QLog.

I made an exception for the date and time but I wouldn’t want to replicate settings that are handled elsewhere in the operating system.

@lima-limon-inc
Copy link
Author

Oh I see! I was not aware of that env variable, I'll let you know if that works on my system. Thanks ^_^

@lima-limon-inc
Copy link
Author

Measurement unit is controlled by an environment variable LC_MEASUREMENT (more detail https://github.com/foldynl/QLog/wiki/Multi-language-Support#distance-unit). If you are seeing a unit that you are not using, it is necessary to set this correctly in the environment. Personally, I do not think it is necessary to have this setting in QLog.

I made an exception for the date and time but I wouldn’t want to replicate settings that are handled elsewhere in the operating system.

Hi @foldynl. I did manage to change the LC_MEASUREMENT env variable, and now the units are shown in meters correctly.

Although, I do get the following warning:

Qt depends on a UTF-8 locale, and has switched to "C.UTF-8" instead.
If this causes problems, reconfigure your locale. See the locale(1) manual
for more information.

Tbh, I don't think I'm the biggest fan of having to change the locale system-wide. Could that cause problems with other apps?

Regardless, thanks for the help!
I'll leave this patch here if you change your mind.

Cheers 😊

@lima-limon-inc
Copy link
Author

Update: It did mess up with some utilities, so customization of the LC_MEASUREMENTS env variable is not as seamless as one would think.

Context btw:

Traceback (most recent call last):
  File "/usr/lib/eselect-repo/eselect-repo-helper", line 163, in <module>
    main()
    ~~~~^^
  File "/usr/lib/eselect-repo/eselect-repo-helper", line 125, in main
    locale.setlocale(locale.LC_ALL, '')
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/locale.py", line 615, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
!!! Error: helper failed to run

This was raised by Gentoo's eselect utility, a system level configuration tool.

So I'd say changing that env variable is a no-go. Have you ever modified it successfully?

@foldynl
Copy link
Owner

foldynl commented Jun 11, 2025

If I run
LC_MEASUREMENT=cs_CZ.UTF-8 ./qlog
then I have the distance in the km

I'm not a Gentoo expert, but on Ubuntu, you need to have the required locale installed.

@lima-limon-inc
Copy link
Author

If I run LC_MEASUREMENT=cs_CZ.UTF-8 ./qlog then I have the distance in the km

I'm not a Gentoo expert, but on Ubuntu, you need to have the required locale installed.

Oh I see, I passed LC_MEASUREMENT=1, I'll give yours a try!

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.

2 participants