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

Dialog for setting user-defined frequencies #1417

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jirimaier
Copy link
Contributor

@jirimaier jirimaier commented Apr 30, 2024

XCSoar can set the frequency of a radio. However, this is currently only possible for frequencies that are tied to an airfield (defined in a waypoints file). This PR proposes a dialog that shows a list of user-defined frequencies. the frequency list is editable via GUI and stored in user.freq file in XCSoar's root directory.

This will be particularly useful for frequencies like:

  • glider air-to-air
  • FIC
  • emergency

image

image

image

@jirimaier jirimaier force-pushed the FrequenciesDialog branch 2 times, most recently from 05e119a to 64f2cce Compare April 30, 2024 00:43
@lordfolken
Copy link
Contributor

Hey,
So i'm all for expanding the radio control situation, which is currently providing little advantage over entry directly on the device.

I think a favourites list like this, that can be activated by tapping on the radio infobox, or called up via a menu option, is a good thing.

What i would like to avoid, is yet another file that has to be managed by the user, outside of xcsoar.

So please consider:

  • User editable from the application
  • Saving stations in the profile

@DanD222
Copy link
Contributor

DanD222 commented Apr 30, 2024

@lordfolken Would you be OK with an incremental approach, i.e. get the functionality of reading from a file and sending the frequency to a radio done first, and then expand the XCSoar editing features?

Edit - incremental.. shouldn’t try to use fancy words.

@jirimaier
Copy link
Contributor Author

Hello,

This is a draft that is far from finished. I mainly wanted to have such a discussion about proper implementation, so thank you for sharing your ideas.

I already have an intention to add GUI controls for editing the list. New/Edit/Delete, maybe Copy would also be useful.

I also don't like storing it in a separate file; storing it in preferences may be a good option. However, I would like to have a way to load/transfer a larger amount of frequencies quickly rather than typing them manually (for example there are going to be 8 air-to-air frequencies for cross-country gliding in Czechia this year). Maybe I can store it in preferences and add some import/export button that would load/create the frequencies file.

Or I can think of a hybrid approach, where the frequencies will be loaded from both preferences and a file. In that case, it is questionable how to order them in the list (I'd like to let the user select the order rather than sorting them by name, but when they come from multiple sources, this is not so simple), and also whether the user should be able to edit the separate file (from GUI) or only those in preferences.

@lordfolken
Copy link
Contributor

@lordfolken Would you be OK with an incremental approach, i.e. get the functionality of reading from a file and sending the frequency to a radio done first, and then expand the XCSoar editing features?

Edit - incremental.. shouldn’t try to use fancy words.

The problem with that is, that you would have to code the migration path as well. As users expect "everything to just work". So i'd rather have the functionality first.

@lordfolken
Copy link
Contributor

I also don't like storing it in a separate file; storing it in preferences may be a good option. However, I would like to have a way to load/transfer a larger amount of frequencies quickly rather than typing them manually (for example there are going to be 8 air-to-air frequencies for cross-country gliding in Czechia this year). Maybe I can store it in preferences and add some import/export button that would load/create the frequencies file.

Potentially you could also create an import/export text field, where a csv or multiline file could be pasted/copied. The result of which would go to the profile.

An additional option would be to add a "to favorite" button in airspace and waypoint dialogs.

@DanD222
Copy link
Contributor

DanD222 commented Apr 30, 2024

On the other hand, thinking about it more, if we settle on where the frequencies will be stored (IMO a separate csv is better than in the preferences because if the frequencies are stored in the preferences then you'd need to ensure compatibility of preferences with frequencies / without frequencies), then the only difference would be handling reading from the csv file as the data source vs also writing to it.

Plus there would be a clear separation of functions, i.e. I don't believe XCSoar stores the checklist in the preferences either, and if you mess up editing the frequencies file, for example if you don't want to input all your initial frequencies through XCSoar, then you wouldn't potentially be left with a non-functioning preferences file.

But of course I could be missing something.

@kobedegeest
Copy link
Contributor

maybe you know but just in case #867 tried a similar thing i believe.

And about how to save/ store the data why not do something similar to how markers are saved? User never has to make or edit a file but if you want to you totaly could.

@jirimaier
Copy link
Contributor Author

What about taking the Waypoit Editor as a precedent?
The user would create/edit the list in GUI and it will get saved in a file (let's name it user.freq).
There is no need for the user to ever touch the file, but they can still copy it to another device if they want to.

@jirimaier jirimaier force-pushed the FrequenciesDialog branch 7 times, most recently from 736be21 to bfcbc48 Compare May 3, 2024 09:10
@jirimaier jirimaier marked this pull request as ready for review May 3, 2024 09:25
@jirimaier jirimaier requested a review from a team as a code owner May 3, 2024 09:25
Copy link
Contributor

@lordfolken lordfolken left a comment

Choose a reason for hiding this comment

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

When saving the frequencies on manage mode somehow the MessageBox blanks the background
image

Please make the frequencies dialog also accessible from the Active/Standby infoboxes via the touch menu.

src/Dialogs/Frequency/dlgFrequencyEdit.cpp Outdated Show resolved Hide resolved
src/Dialogs/Frequency/dlgUserFrequencyList.cpp Outdated Show resolved Hide resolved
@lordfolken
Copy link
Contributor

A numpad kind of keyboard entry widget for numbers/frequencies would be a welcome addtion.

set_standby_button = dialog.AddButton(_("Set Stand-by"), [this]()
{ SetClicked(false); });
edit_mode_button = dialog.AddButton(_("Edit"), [this]()
{ dlgUserFrequencyListWidgetShowModal(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace

if (dlgFrequencyEditShowModal(item) == FrequencyEditResult::MODIFIED)
{
list[GetList().GetCursorIndex()] = item;
listUpdated();
Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace

@lordfolken
Copy link
Contributor

Invalid lines in user.freq get erased when saving. The question is whether this should be handled or not.

@lordfolken
Copy link
Contributor

lordfolken commented May 6, 2024

Ive had several crashes when saving on android. Guess we more error handling.

05-06T00:26:34Z] cannot open /storage/emulated/0/Android/data/org.xcsoar/files/lua/init.lua: No such file or directory
./src/RadioFrequency.hpp:71: unsigned int RadioFrequency::GetKiloHertz() const: assertion "IsDefined()" failed

@jirimaier
Copy link
Contributor Author

jirimaier commented May 6, 2024

When saving the frequencies on manage mode somehow the MessageBox blanks the background

This behavior is same as in the Waypoint Editor. Perhaps it can't be avoided, because the message box is shown after the dialog is closed. I may show the message box after clicking Close button and closing the dialog after Yes/no is selected. However, the behavior would then be different for Close button and closing by escape key.

@jirimaier
Copy link
Contributor Author

Invalid lines in user.freq get erased when saving. The question is whether this should be handled or not.

I have an idea: if the file contains invalid line and user opens the edit/manage screen, show message box saying "There are invalid lines and they will be deleted if changes are saved" and immediately set the 'modified' flag to show the "save changes" prompt after closing even if no changes were made.

@jirimaier jirimaier force-pushed the FrequenciesDialog branch 3 times, most recently from b755b5a to c188422 Compare May 8, 2024 10:14
value = RadioFrequency(entry.GetRadioFrequency());

return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

missing newline

{
const RadioFrequencyDataField &df =
(const RadioFrequencyDataField &)GetDataField(i);
assert(df.GetType() == DataField::Type::RADIO_FREQUENCY);
Copy link
Contributor

Choose a reason for hiding this comment

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

Asserts are not on in non-debug mode. Can you add a check if invalid?

@lordfolken
Copy link
Contributor

Good work on the Frequency dialog. Really cool. :-)

@xtophe80
Copy link
Contributor

xtophe80 commented May 8, 2024

In case it is useful, I have pushed my rebased version of #867 mentioned last week in my repo: https://github.com/xtophe80/XCSoar/tree/FrequencyCard2

@jirimaier jirimaier force-pushed the FrequenciesDialog branch 6 times, most recently from 774c5eb to e41a353 Compare May 11, 2024 09:48
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.

None yet

5 participants