Commit graph

1662 commits

Author SHA1 Message Date
Berthold Stoeger
556ecd5a9b core: use C++-primitives for g_tag_list
The old code was leaking memory. Use std::unique_ptr<> for
ownership management.

This is still very primitive and divetags are kept during
application lifetime. There should probably be some form
of reference counting. And the taglist should not be global,
but attached to the divelog.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
ab7218d543 Use report_info() instead of qDebug in mobile code
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
c6cd10a43f core: make getCloudURL() return an std::string
Let's use std::string in the core. Notably, I'd like to make
the numerous main() functions mostly independent of Qt. Some
things will have to remain, such as argument parsing, of course.

This changes the API: instead of returning an error code and
taking a pointer to the actual return-value, return an
std::optional<std::string>> that is set if the function succeeds.

Returning an empty string in the error case might be simpler,
but oh well...

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
da7ea17b66 cleanup: replace fprintf to stderr by report_info()
Let's try to unify debugging output!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
a123589efb core: convert git_info to std::string
Quite a bit of fallout in users of this structure.

Conveniently, since git-access.cpp is now C++ we can move
some helpers from the monstrous qthelper.cpp to git-access.cpp.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
de313bd01a mobile: save changes from main event loop
When autosync to cloud was enabled, the old code would crash,
because it synced to cloud from a signal handler, which executed
the main loop when checking the cloud connection, which deleted
the object which was causing the original signal. Or something
like that. See discussion in #4119.

To avoid such problems, send a signal via a 'QueuedConnection'
from QMLManager to itself. The slot will be called once the
signal handler terminates and the main event loop retakes
control.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-04 13:57:00 +02:00
Berthold Stoeger
2172e18298 mobile: pull undo/redo notification text up
When changes need saving, the notification text was set quite
deep in the calltree in "saveChangesLocal()". I don't know why
this was put so deep in the call tree. In any case, it prevents
asynchronous saving of the data. Therefore, pull it up to
chnagesNeedSaving().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-04 13:57:00 +02:00
Berthold Stoeger
916c88ded9 mobile: fix undo/redo
The signals of the undo-stack can only be connected after it
was initialized. One of those cases where I would have preferred
a crash over a warning message. The mobile version is extremely
noisy!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-31 14:19:44 +02:00
Berthold Stoeger
2bf7432a94 cleanup: remove unused macros in qmlmanager.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-25 21:41:57 +01:00
Berthold Stoeger
5ac64ab2cd cleanup: replace Q_FOREACH and foreach by range base for
Q_FOREACH and foreach are anachronisms.

Range based for may cause a performance regression: it can
lead to a copy of shared containers (one reason why Qt's
COW containers are broken). However, as long as there is no
user noticeable delay, there is no point in analyzing each case.
And also no point in slapping an 'asConst' on every container
that is looped over.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-24 17:53:19 +01:00
Berthold Stoeger
41cb916060 core: turn existing_filename into std::string
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-24 17:53:19 +01:00
Berthold Stoeger
3a1122048b core: make logfile_name and dumpfile_name std::string
To avoid memory management woes. These shouldn't be global
variables, but let's fix that later.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-24 17:53:19 +01:00
Dirk Hohndel
d653cec7a4 ensure locale language info lands in the applog
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-03-11 11:30:14 -04:00
Dirk Hohndel
4b0fe3bc38 mobile: show incorrect cloud password state
While the startup flow should make it obvious when a user is not
correctly logged into the cloud, we still do see fairly frequent
situations where a user has an incorrect password on a mobile device and
is confused about why their data isn't syncing with their PC. Now this
is clearly shown in the main menu.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-02-23 20:12:12 -08:00
Michael Keller
a946dc323b Mobile: Add Input Validation and Conversion for Gradient Factors.
Add input validation and input conversion for the gradient factor
settings.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-02-17 12:36:15 +13:00
Dirk Hohndel
704b26ff1e Mobile: improve GFLow/High settings UI
- move the spinbox closer to the senter
- improve sizing and spacing of the spinbox
- hide it when we aren't showing the calculated ceiling

Also address an odd whitespace issue.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-02-14 18:57:41 +13:00
Michael Keller
31d1755efd Mobile: Fix Cloud Synch Status Management.
Fix how the cloud synch status is handled - currently the preference is
used incorrectly, switching cloud synch off when it should be on.
Also hide the 'Manual cloud synch' button when no cloud credentials are
stored, and don't show the 'manual synch' popup when auto synch is
enabled.

Signed-off-by: Michael Keller <github@ike.ch>
2024-02-12 16:47:46 -08:00
Michael Keller
345f0570a5 Mobile: Add 'Contribute' link.
Add a link to the 'Contribute' page to the mobile app.

Signed-off-by: Michael Keller <github@ike.ch>
2024-02-06 23:40:58 +13:00
Michael Keller
df1974a244 Mobile: Fix Configuration of Ceiling Display.
Fix the configuration of the deco ceilings in the mobile version:
- make the settings work;
- remove reading of the dive computer ceiling from git;
- hide the gradient factor in the profile when the calculated ceiling is
  not shown;
- when the calculated ceiling is disabled in the settings, disable
  editing of the gradient factor.

Signed-off-by: Michael Keller <github@ike.ch>
2024-02-06 11:58:49 +13:00
Michael Keller
aad0063c46 Mobile: Fix Link to the Online Manual.
Replace the link to the online manual to the post-website-revamp URL.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-02-04 14:59:55 -08:00
Michael Keller
fb41999c73 Mobile: Fix Gradient Factor Preference Setting.
Fix the persisting and use of gradient factor preferences for dive
profiles in the mobile version.
Also rename the mobile backend gradient factor settings to make it
obvious that they are used by the (not currently enabled) planner.

Signed-off-by: Michael Keller <github@ike.ch>
2024-01-27 20:55:32 -08:00
Dirk Hohndel
ef35c3e8cb update copyright year and version details
While the update to the copyright year really isn't required, it just looks
better.

By using the canonical instead of the git version in user visible strings we
are creating more consistency in how we refer to the version.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-01-07 16:01:55 -08:00
Michael Keller
5ad75e81c3 Mobile: Add Warning About Delay for Initial Synch.
Add a warning to the initial login screen telling the user that the
first synchronisation can take a few minutes.
Fixes a misunderstanding pointed out in a recent post in the Subsurface
mailing list.

Signed-off-by: Michael Keller <github@ike.ch>
2023-12-11 23:17:14 +13:00
Michael Keller
90e5de8357 Mobile: Make Cloud Auto Synch Status Easier to Understand.
Add an explicit checkbox to the 'cloud auto synch' status toggle in the
mobile 'Dive Management' menu in order to make it more intuitive to
understand.
This isn't super pretty, but I think it will improve the usability. A
prettier way to achieve this will be to redesign the `ic_cloud_off.svg`
/ `ic_cloud_done.svg` in order to make them intuitively recognisable as
unchecked / checked checkboxes.
Example of a support request caused by confusion from the current
implementation: https://groups.google.com/g/subsurface-divelog/c/9X-hTt9NFlE/m/ZcqtdOOhBQAJ

Signed-off-by: Michael Keller <github@ike.ch>
2023-06-26 07:54:48 -07:00
Michael Keller
a127c4ac63 Mobile: Make Gradient Factor Range Consistent with Desktop.
Change the range to be 10 to 150.

Signed-off-by: Michael Keller <github@ike.ch>
2023-05-30 16:21:41 +02:00
Michael Keller
50438b0456 Mobile: Fix Editing of Gradient Factors
Fix the issue that Gradient Factors cannot be set to 100 in the mobile
version. This is done by changing the edits from a text box to a spin
edit, which seems to be a better match for numerical values.
As a side effect this also solves the issue that the keyboard for the
text edit is not properly displayed when settings are opened when dive
details are already on the page stack.

Fixes #3911.

Reported-by: @gbetous
Signed-off-by: Michael Keller <github@ike.ch>
2023-05-30 16:21:41 +02:00
Berthold Stoeger
a7889d1f4e cleanup: fix typo: verboseEnabebled -> verboseEnabled
Not really relevant, because it only affects debugging output.

But shows why I dislike weakly typed, non-compiled languages.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-05-20 20:07:22 +02:00
Michael Keller
a38ea971a0 Import: Add option to sync time on dive computer download
Add an option for users to sync the dive computer time with the PC time
every time dives are downloaded.
Obviously this will only work on dive computers that have time
synchronisation support in libdivecomputer, for other computers a notice
is logged.
The selection for this option is persisted as a preference.

Signed-off-by: Michael Keller <github@ike.ch>
2023-04-17 07:56:02 -07:00
Berthold Stoeger
c5d6e0f44f core: make owning pointers a top-level features
The undo-code uses owning pointers based on std::unique_ptr to
manage lifetime of C-objects. Since these are generally useful,
move them from the undo-code to the core-code. In fact, this
eliminates one instance of code duplication.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
b61732da42 core: remove autogroup global
Use the flag in the divelog structure, since this will be saved
in the dive log.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-14 21:20:23 +02:00
Berthold Stoeger
9c253ee6c5 core: introduce divelog structure
The parser API was very annoying, as a number of tables
to-be-filled were passed in as pointers. The goal of this
commit is to collect all these tables in a single struct.
This should make it (more or less) clear what is actually
written into the divelog files.

Moreover, it should now be rather easy to search for
instances, where the global logfile is accessed (and it
turns out that there are many!).

The divelog struct does not contain the tables as substructs,
but only collects pointers. The idea is that the "divelog.h"
file can be included without all the other files describing
the numerous tables.

To make it easier to use from C++ parts of the code, the
struct implements a constructor and a destructor. Sadly,
we can't use smart pointers, since the pointers are accessed
from C code. Therfore the constructor and destructor are
quite complex.

The whole commit is large, but was mostly an automatic
conversion.

One oddity of note: the divelog structure also contains
the "autogroup" flag, since that is saved in the divelog.
This actually fixes a bug: Before, when importing dives
from a different log, the autogroup flag was overwritten.
This was probably not intended and does not happen anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-14 21:20:23 +02:00
Berthold Stoeger
261f07dfa4 core: add make_manually_added_dc() function
For reasons of symmetry (there is a is_manually_added_dc()
function), create a make_manually_added_dc() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-21 16:51:57 -07:00
Berthold Stoeger
f687e51d4b core: don't consider dives with many samples as manually added
This causes UI confusion. Notably we go into edit mode and
reduce the number of samples, leading to loss of information.

If someone really manually adds a dive with more than 50
samples, they should still be able to explicitly open the
dive in the planner.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-21 16:51:57 -07:00
Berthold Stoeger
7c8dc016b5 mobile: flip through dive computers on mobile
UI fixed by Dirk.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-10-01 18:47:16 +02:00
Dirk Hohndel
42da08df20 mobile: enable sharing via email
Instead of using the save file dialog (which creates a horrendous user
experience - and isn't even supported on Android), simply allow the user
to email the file in question to a recipient of their choice, e.g.,
themselves.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-31 13:58:22 -07:00
Dirk Hohndel
f144fa0a1b mobile: allow sharing files via email
This will allow the user of the mobile app to export dive and dive site
data from their mobile device without using the Subsurface cloud.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-31 13:58:22 -07:00
Dirk Hohndel
ead15f622a mobile: remove export as UDDF
The export functionality is horridly poorly implemented, and the UDDF export
isn't actually functional on mobile. And why would we support this in the first
place? That's not a reasonable expectation for the mobile app.

So let's just completely remove that and good riddance.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-31 13:58:22 -07:00
Berthold Stoeger
aa4b48f440 core: move floating point functions to own header file
This were in subsurface-string.h for unknown reasons.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-08-30 22:34:38 +02:00
Berthold Stoeger
61701509b0 core: replace IS_FP_SAME macro by inline function
No reason to keep this as a macro - a function is easier to
read, type safe and easier to debug. Moreover, give it the
more appropriate name "nearly_equal()". After all, it precisely
does NOT check floating points for equality.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-08-30 22:34:38 +02:00
Dirk Hohndel
2ae7f3cf6c Android: make support email API consistent with iOS
We have two different API endpoints. supportEmail() which adds the
default subject, recipient, and message body, and the generic
shareViaEmail() which takes all of these as arguments.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-30 11:55:54 -07:00
Dirk Hohndel
87387b7e7e mobile: send logfiles as attachments on iOS as well
This was added for Android a while ago, but now this works on iOS as well which
is a very welcome addition for the recipient of these support emails (i.e. me).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-30 09:18:06 -07:00
Dirk Hohndel
8c644547fb mobile: fix reading of cache dir
For some reason the flag to exclude . and .. breaks this functionality.
It works just fine without that flag, so let's just remove it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-28 19:51:03 -07:00
Dirk Hohndel
32bc034f41 mobile: add ability to delete cloud account
Apple store rules require this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-13 14:08:37 -07:00
Vlad A
30a964c508 Added option to choose between different depth grid quantization schema.
This allows having 3m depth grid for metric users.

* All original properties ( named diferently ) were renamed to three_m_based_grid everywhere to be consistent.
* Plus other small changes requested during review.

Signed-off-by: Vlad A. <elf128@gmail.com>
Signed-off-by: Vlad A <elf128@gmail.com>
2022-05-21 17:29:40 -07:00
Linus Torvalds
e33680c336 git access: add proper cleanup function for git_info
We had various random "free parts of the git info" left-overs from when
we passed down the git repo data ad-hoc.  Get rid of it, and replace it
with just doing a 'cleanup_git_info()' that does the final cleanup of it
all.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-04-22 08:28:17 -07:00
Linus Torvalds
96337dbbcf git access: rename 'check_git_sha()' function
That function name was incomprehensible.  What did it check? And what
did the return value mean?

So let's rename it to something that actually describes what it does,
and reverse the meaning of the return value while at it.

So now it's called 'remote_repo_uptodate()', and it returns true if the
remote repository branch has the same value as our 'saved_git_id'.

It's still a bit obscure, but at least within the context of the only
user, the code now makes _more_ sense than it used to:

        if (remote_repo_uptodate(fileNamePrt.data(), &info)) {
                appendTextToLog("Cloud sync shows local cache was current");

but maybe we could come up with even better semantics and naming, and
make it even clearer.

Requested-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-04-22 08:28:17 -07:00
Linus Torvalds
7e632173e0 Collect and convert git repo data to 'struct git_info'
We have this nasty habit of randomly passing down all the different
things that we use to look up the local and remote git repository, and
the information associated with it.

Start collecting the data into a 'struct git_info' instead, so that it
is easier to manage, and easier and more logical to just look up
different parts of the puzzle.

This is a fairly mechanical conversion, but has moved all the basic
information collection to the 'is_git_repository()' function.  That
function no longer actually opens the repository (so the 'dry_run'
argument is gone, and instead a successful 'is_git_repository()' is
followed by 'opn_git_repository()' if you actually want the old
non-dry_run semantics.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-04-17 22:14:34 -07:00
Dirk Hohndel
2886104b1d mobile: allow date only when adding/editing dives
Apparently some people try to manually enter older dives where they don't
have data about the dive time and therefore want to only capture the dive
date.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-03-18 08:57:55 -07:00
Dirk Hohndel
ccda4f557c mobile: fix broken undo stack initialization
We would dereference the undoAction before the command infrastructure
was initialized which led to a crash in the mobile app.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-03-18 08:57:55 -07:00
Berthold Stoeger
ba95edc2d2 statistics: switch themes on the mobile version
When changing the theme to a dark theme, also change the
statistics theme. The code is a mess, because it crashes
when setting the theme right at the beginning. Therefore,
there is a "theme has been set" flag. Also, this directly
accesses the ThemeInterface singleton object. I have no
time to fight QML, sorry.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-03-16 15:26:54 -07:00