Skip to content

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!

@leventelist
Copy link

leventelist commented Oct 12, 2025

+1 for this to be merged. It is really inconvenient to start a qlog from a terminal like this: LC_MEASUREMENT=cs_CZ.UTF-8 ./qlog.

@foldynl
Copy link
Owner

foldynl commented Oct 12, 2025

It is really inconvenient to start a qlog from a terminal

Your OS should have these variables set according to your preferences. What is the reason to change this before each QLog run?

@leventelist
Copy link

It is either you change the locale system wide, or start it from the command line as you suggested. Both options have drawbacks.

@foldynl
Copy link
Owner

foldynl commented Oct 12, 2025

I meant, why, if you have LC_MEASUREMENT set to, for example, miles, do you expect QLog to use kilometers? In other words, why is your system set to miles if you actually want kilometers (or vice versa)?

@leventelist
Copy link

For the exact same reason Date and Time format is there. They are also override a format coming from the locale.

@foldynl
Copy link
Owner

foldynl commented Oct 13, 2025

to be honest, I was waiting for this answer. Because it's easy to say why it's not for the unit, when it's for the time.

But I'm curious, what leads a person to the fact that he/she has the system in miles and it needs km?

@lima-limon-inc
Copy link
Author

But I'm curious, what leads a person to the fact that he/she has the system in miles and it needs km?

For instance, some DE don't configure said variables. I am using qtile which doesn't set them.

@lima-limon-inc
Copy link
Author

@foldynl I see you tagged this PR as part of the 0.47.0 release. If that's the case, I can work on fixing the conflicts.

If you have any thoughts/comments, do let me know 😊

Thanks in advance!

@foldynl
Copy link
Owner

foldynl commented Oct 14, 2025

I'll modify it. There are some things that QLog already does differently (ex. QSettings is not used etc).

@foldynl
Copy link
Owner

foldynl commented Oct 14, 2025

Sorry, QLog is still using QSettings here. There’ve been so many changes that I’m starting to lose track of what’s what.

@foldynl
Copy link
Owner

foldynl commented Oct 14, 2025

Reworked. Please, could you verify it - branch MeasurementUnit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants