Commit graph

19345 commits

Author SHA1 Message Date
Berthold Stoeger
248976bf11 cleanup: factor out duplicate axis-initialization code
The axes of the profile are setup when switching into
the "ProfileState" and also when the preferences are
changed. The same code existed twice for both cases.

Let's factor it out into a single function to avoid
future divergence and confusion.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-27 19:05:20 +02:00
Dirk Hohndel
9eb10af68f build-system: updates to processes
This is mostly for my own use, but I think it makes sense to have it in
the repo.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-07 08:25:31 -07:00
Dirk Hohndel
bf363c016b Update translation source strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-07 08:23:48 -07:00
Berthold Stoeger
0b190243dd profile: remove internal event-copy (fix deleting/renaming events)
The DiveEventItem had an internal copy of the event. It passed
that copy to the undo-machinery, which of course didn't work.

Simply keep a pointer to the event. All changes to a dive no
pass via the undo-machinery, which causes a reload of the profile,
so this should be safe.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-05 11:29:00 -07:00
Berthold Stoeger
fd2862042b profile: pass axes and model to DiveEventItem on construction
Firstly, there is no point in supporting DiveEventItems without
model and axis. Secondly, this avoid pointless position-
recalculations.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-05 11:29:00 -07:00
Berthold Stoeger
c93fb83edf profile: pass event at construction time to DiveEventItem
There is no point in having a dive event without an event.
Let's pass the event at construction time to avoid having
to handle "invalid" events.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-05 11:29:00 -07:00
Mark Stiebel
e42fc1a1e9 desktop: add numerus translation for dive context menu
Add numerus translation lookup for the right-click context menu in the dive
list to show proper singular/plural text.

Fixes #3256

Signed-off-by: Mark Stiebel <mark@aretha.stiebel.me>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-04 09:35:16 -07:00
Dirk Hohndel
891805763e build-system: remove relative paths to icons
Asciidoc appears to insert './images' references when using the admonitionblock.
Clean that up in the post processing of the user manual for HTML.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-04 09:30:54 -07:00
Berthold Stoeger
4462ae5aee profile: remove unused function ProfileWidget2::getPrintMode()
The last user was removed in the previous commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-04 08:45:32 -07:00
Berthold Stoeger
1ddb55dcad profile: use printMode flag directly in DiveCartesianAxis
The axis has a print-mode flag. There is no point in querying
the widget.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-04 08:45:32 -07:00
Berthold Stoeger
b2b24665e7 profile: remove DiveCartesianAxis::maxChanged signal
The last listener was removed in 0104b0a915.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-04 08:45:32 -07:00
Dirk Hohndel
1762ad9472 documentation: update the included html manual
Forgot to do that when updating the user manual the last time.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-03 08:30:07 -07:00
Dirk Hohndel
49130150cd cleanup: don't use colons in file names
While Subsurface doesn't build on Windows, we shouldn't prevent people
from checking out the sources there...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-03 08:25:11 -07:00
Berthold Stoeger
9e391b4eea documentation: update installation instructions for Ubuntu
Apparently, with Ubuntu 21.04 the qt5-default package doesn't
exist anymore. Removing it from the list of installed packages
makes things still work on a freshly installed system.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-01 09:26:41 -07:00
Berthold Stoeger
622abc5afd cleanup: strongly type DepthAxis::unitSystem
This takes an enum of units::LENGTH, therefore declare it as
such. Yes, this is kind of superfluous bike shedding, but since
we have a strongly typed language, let's use it.

On a side note, the enum should probably not be named with
all-caps.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-01 09:25:32 -07:00
Berthold Stoeger
04d7c9b808 cleanup: remove DiveCartesianAxis::unitSystem
This was only used by the child class DepthAxis,
where it was defined separately. An oversight?

In any case, remove the unused member.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-01 09:25:32 -07:00
Ryan Gardner
87e203ea50 make whitespace in build script match existing whitespace
Signed-off-by: Ryan Gardner <ryan.gardner@coxautoinc.com>
2021-05-20 15:10:52 -07:00
Ryan Gardner
effd0dbae8 Make the Mac SDK detection in build.sh more robust
When trying to build on Big Sur, the xcode command-line tools
install are installed in /Library/Developer/CommandLineTools/SDKs,
and as of Xcode 12.5, it does not include a 10.x version
of SDK.

This changes it to search in the location of the command-line tools SDK
for a 10.x version, and if it can't find a 10.x version it will
find an explicit 11.x version of the SDK to use because it is
conceivable that in the near future Apple will stop installing any
10.x SDK's as part of the command-line tool installer.

If the SDK can't be found, the build script will exit now instead
of continuing with an unset BASESDK version that causes a later failure.

Signed-off-by: Ryan Gardner <ryan.gardner@coxautoinc.com>
2021-05-20 15:10:52 -07:00
mikeller
2d734c529b desktop: Add the capability to copy / paste dive number and date / time.
This is adding the capability to select 'Dive number' and 'Date / Time'
in the 'Copy dive components' dialog, and then copy them into the
clipboard.
When using 'Paste dive components, these values will then be pasted into
the selected dive(s).
This is intended to help with workflows that import dive information
from two different sources, like general information from another
logging program, and CCR ppO2 sensor readings from a unit log, and then
stitch them together into one cohesive entry with all data per dive.
Copied data is also output into formatted text when pasting the
clipboard outside of the application:

```
Dive number: 401
Date / time: Sun 2 May 2021 12:00 AM
```

No translations have been added as of now - I could not find any
information on how strings are translated for this project.

Signed-off-by: Michael Keller <github@ike.ch>
2021-05-19 15:15:34 -07:00
Berthold Stoeger
2264a5e166 cleanup: remove double layout name in statswidget.ui
This gave an annoying warning.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-05-17 11:58:59 -07:00
Robert C. Helling
41f87f3e77 Translate header strings for APD
We are matching translated header names. Thus, when composing
a header line for APD, make sure it contains translations.

This mechanism is quite brittle. Our German translations had
two different translations for "Sample time" and this already
broke it. This is why this patch also includes a fix for a
translation string (should be fixed in transiflex as well
of course).

Fixes #3246

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-05-13 12:28:38 -07:00
Robert C. Helling
5dfc183517 Planner: Update plan when deco parameters change
This makes sure that the dive plan is updated (including the
planner notes) when parameters of the dive or the planner
change.

This fixes a bug reported by Jay Anchor.

There is a chance that by partly undoing 77a6bc6d62, this
introduces too many recalculations of the plan. But without
this patch, there are definitely not enough recalculations.

Reported-by: Jay Anchor <jay.anchor-subsurface@e257.fi>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-05-12 10:02:47 +02:00
Berthold Stoeger
dc645ce8c6 profile: rename GF_LINE color to DURATION_LINE
The color was misnamed, since it has only been used for the
duration line for quite some time (since 893bea700c to be
exact).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-05-08 13:40:24 +02:00
Berthold Stoeger
a7002f4089 profile: remove DiveAmbPressureItem
This was replaced by the tissue map in 893bea700c.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-05-08 13:40:24 +02:00
Berthold Stoeger
8b0db14f64 profile: remove DiveGFLineItem
This was replaced by the tissue map in 893bea700c.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-05-08 13:40:24 +02:00
Dirk Hohndel
fd3ebf9b62 build-system: build for Ubuntu 21.04 / hirsute as well
This release drops the qt5-default package - which really wasn't needed since
focal. So just drop it on all of the builds after 18.04 (bionic).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-05-07 12:17:21 -07:00
Robert C. Helling
312b760c5b Planner: Update notes when not computing variations
A change not to compute plan variations when not needed
was too aggressive and eliminated also the signal to update
the notes. Bug fixed.

Reported-by: Jay Anchor <jay.anchor-subsurface@e257.fi>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-05-07 11:20:30 -07:00
Robert C. Helling
09bbd846da The planner should not always ascent from the depth of
the last manually entered waypoint but consider the
possibility that it should first top where we are
before the next stop depth has cleared.

Reported-by: David Carron

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-05-07 08:16:41 -07:00
Berthold Stoeger
3e1ade5206 cleanup: free print dialog in planner
When printing the plan, a print-dialog was created with "new",
but not freed later. Strictly speaking, this is not a leak,
because the dialog is attached to the main-window in Qt's
object hierarchy. Thus it is freed on application exit. On
the other hand, it is a leak in the sense that resources are
pointlessly hogged until application exit.

Let's just turn it into a stack-allocated object.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-05-06 08:46:57 -07:00
Dirk Hohndel
b95ab84226 build-system: fix AppImage build failure
It's debatable if it makes sense to continue building on Trusty. The AppImage
community moved on to Xenial for a reason. But for now let's just make sure the
CI builds don't all break.

Suggested-by: Simon Peter <probono@puredarwin.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-05-06 08:43:01 -07:00
Berthold Stoeger
38d0fac2d1 export: show progress dialog for profile exports
Simply reuse QProgressDialog interface for the TeX exports.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-05-06 08:21:04 -07:00
Berthold Stoeger
9ee8807af7 export: show progress dialog for TeX exports
The TeX exports may hang the UI for a long time.

Show a progress-dialog that is updated after every exported dive
and allows the user to cancel the export.

This is pretty lame, because it is synchronous (export still runs
in UI thread) and therefore the UI still is sluggish. But it
is an improvement.

Since the TeX-exporting code is in a shared directory (desktop and
mobile), this uses a slim interface class. Mobile does not
yet use TeX export, but you never know. Better than #ifdefs
sprinkled all around, I reckon.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-05-06 08:21:04 -07:00
Berthold Stoeger
573de51e48 export: remove redundant QString::isNull() checks
If QString::isEmpty() is false, QString::isNull() is likewise
false, so these tests are redundant.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-05-06 08:21:04 -07:00
Berthold Stoeger
c34f0b88a2 profile: move checking for DiveTextItem into its own function
When creating the context menu, a special menu is created for
the dive computer name.

This was checked in a loop, that set a flag and exited early.

This can all be simplified by moving the loop into its own
function. No more flag, less indentation. Overall better.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-04-26 08:24:28 -07:00
Berthold Stoeger
78f4d7b2b9 profile: simplify checking for DiveTextItem
When creating the context menu on the profile, the code has
to check whether the context menu is activated on the
dive computer name to show a special menu (delete / split
dive computer).

This was done by setting a special property on the item
and then checking for that property on the item that
the menu is invoked on or its parents.

The reason the code didn't simply check the pointer was
probably that DiveTextItem uses multiple inheritance:
It derives from QObject and QGraphicsItem. It has to derive
from QObject first, because (the ridiculously broken) MOC
needs it that way. The object added to the scene is a
QGraphicsItem. Thus, we get a pointer _into_ the DiveTextItem
object.

However, that's all completely unnecessary. We can simply
compare the pointers, as the compiler will understand that
QGraphicsItem is only the second base class of DiveTextItem.
Magic!

Let's remove the cruft and simply compare the pointers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-04-26 08:24:28 -07:00
Berthold Stoeger
e9dd1b150f cleanup: remove unnecessary includes from profilewidget2.cpp
These became unnecessary along the way. "qthelper.hpp" was
included twice and <QtWidget> was to broad and was replaced
by <QMimeData>.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-04-26 08:24:28 -07:00
Berthold Stoeger
159dc15f99 cleanup: make a few ToolTipItem member functions private
They were not used outside the class.

Moreover, mark ToolTipItem::persistPos() as const.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-04-25 12:33:20 -07:00
Berthold Stoeger
bd6b714be1 profile: ignore animation-speed setting when printing
When printing, the animation speed was set to 0 by the
caller and later reset to the original value. Instead of
modifying global state, set it internally (in the profile-code)
to zero when in print mode.

This is another small step in making the printing independent
from the shown profile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-04-25 12:33:20 -07:00
Dirk Hohndel
757eeced78 Update to latest libdivecomputer
Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9

Merge upstream updates from Jef:

 - add suppoort for various new variants of existing dive computers:

    + Suunto Eon Steel Black, and new variant of Zoop Novo

    + Sherwood Beacon

    + new Shearwater Perdix AI model number

 - add new Sporasub SP2 support

 - various minor fixes and updates

* 'master' of git://github.com/libdivecomputer/libdivecomputer: (22 commits)
  Add support for a new Suunto Zoop Novo variant
  Add support for the EON Steel Black
  Add support for the Sporasub SP2
  Fix an overflow in the progress events
  Use a common sleep implementation
  Fix the clang compiler flag detection
  Add Github Actions CI builds and releases
  Show a summary after configuration
  Extend the OS detection to non Windows platforms
  Implement the ndl/deco sample
  Fix the maximum depth
  Mark the McLean Extreme as supporting BLE
  Fix -Wcast-qual compiler warning
  Mark the new iX3M 2021 models as supporting BLE
  Add support for the Sherwood Beacon
  Remove the infinite timeout
  Simplify the loop for reading the packet header
  Add a new Perdix AI hardware type
  Fix the McLean Extreme fingerprint feature
  Perform the check for the NULL key earlier
  ...

Merge-done-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-04-23 10:34:03 -07:00
Berthold Stoeger
267c82d85f cleanup: remove MainWindow::turnOffNdlTts()
This flag is handled directly by the profile code
since 2015 (000c9cc21c).

The function therefore can be removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-04-21 10:04:26 -07:00
Linus Torvalds
a0a631122a xml parsing: add XML_PARSE_HUGE flag to xmlReadMemory()
It looks like libxml2 has some internal limitations by default that
causes parse failures in some situations.  Avoid them with
XML_PARSE_HUGE.

Without this, you get errors like

    test.xml:349250: parser error : internal error: Huge input lookup
    όμουν τουλάχιστον αλλά +2kg και ενδεχομένως +4
                                                                                   ^
when something in the xml file grows too large.

I don't know libxml2 internals, so I have no idea what exactly goes
wrong, but the docs say:

    XML_PARSE_HUGE = 524288 : relax any hardcoded limit from the parser

and that makes us successfully parse the Greek file from Kostas.

Reported-by: Kostas Katsioulis <kostaskatsioulis@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-04-21 08:39:29 -07:00
Dirk Hohndel
194fe28d50 cleanup: don't hardcode array length
Move the ARRAY_SIZE macro into a header file and use it to determine the
number of cloud servers that we need to check.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-04-19 12:51:01 -07:00
Dirk Hohndel
9620d11828 cloudstorage: update remote if cloud server changes
If we can't reach the cloud server in the URL (which might come from the
settings or be passed in by the user), we try the alternative server(s).
If we end up changing servers, we need to update the remote that we have
already parsed from the URL.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-04-19 12:51:01 -07:00
Dirk Hohndel
766f297bc4 cloudstorage: try alternative server if first connection fails
If we can't reach our preferred server, try using a different one.
The diff makes more sense when ignoring white space.

With this we check the connection to the cloud server much earlier and
in case of failure to connect try a different cloud_base_url.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-04-19 12:51:01 -07:00
Dirk Hohndel
fe074ccad1 cloudstorage: adapt tests
The code assumes that prefs.cloud_base_url is non NULL. Allowing that to
be NULL makes no sense during normal operation of the app. Yet, most of
the tests don't initialize the prefs at all.

Making things worse, if we do correctly initialize the prefs (so as to
reasonably approximate the behavior when running the app), things break
because some of the reference outputs assume that the prefs are unset.
This deserves fixing.

For now, simply make sure that cloud_base_url is set for all the tests
that try to parse files.

Additionally, the semantics how cloud_base_url is saved to disk have
changed, so adjust the test for those prefs accordingly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-04-19 12:51:01 -07:00
Dirk Hohndel
cfe20ee5f4 cloudstorage: create consistent local directory names
With the new names for the cloud server we'd get different local cache
directory names depending on which server gets used. In order to avoid
that, normalize the name before generating the hash that determines the
local directory name.

Additionally, the old code had an extra '/' in the URL, due to the way
the URL was assembled. Again, to match the existing hash for people
upgrading from older Subsurface versions, add that to our normalized
name as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-04-19 12:51:01 -07:00
Dirk Hohndel
7fa031b648 cloudstorage: try to pick between multiple cloud servers
The backend infrastructure will soon be able to support more than one
cloud server which automagically stay in sync with each other.

One critical requirement for that to work is that once a session was
started with one of the servers, the complete session happens with that
server - we must not switch from server to server while doing a git
transaction. To make sure that's the case, we aren't trying to use DNS
tricks to make this load balancing scheme work, but instead try to
determine at program start which server is the best one to use.

Right now this is super simplistic. Two servers, one in the US, one in
Europe. By default we use the European server (most of our users appear
to be in Europe), but if we can figure out that the client is actually
in the Americas, use the US server. We might improve that heuristic over
time, but as a first attempt it seems not entirely bogus.

The way this is implemented is a simple combination of two free
webservices that together appear to give us a very reliable estimate
which continent the user is located on.

api.ipify.org gives us our external IP address
ip-api.com gives us the continent that IP address is on

If any of this fails or takes too long to respond, we simply ignore it
since either server will work. One oddity is that if we decide to change
servers we only change the settings that are stored on disk, not the
runtime preferences. This goes back to the comment above that we have to
avoid changing servers in mid sync.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-04-19 12:51:01 -07:00
Dirk Hohndel
e22b33795b cloudstorage: add API to just update on-disk setting
This way we can change the host that we will use next time the app runs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-04-19 12:51:01 -07:00
Dirk Hohndel
c5eb806adb cloudstorage: some cleanup of cloud url handling
We know the preference is never empty, so stop testing for this. But
don't maintain two different preferences with basically the same
content. Instead add the '/git' suffix where needed and keep this all in
one place.

Simplify the extraction of the branch name from the cloud URL.

Also a typo fix and a new comment.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-04-19 12:51:01 -07:00
Dirk Hohndel
da6395a4a8 cloudstorage: remove ancient SSL hack
This was a hack for a very early SSL certificate that was rejected on
some platforms. We haven't used that one in ages, so let's just remove
the whole hack - but always show in the console output when there was an
SSL error.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-04-19 12:51:01 -07:00