Whereas extraction of the dive-duration is trivial, AVIs don't seem
to have a standardized way of saving the creation time. This commit
implements support for two versions randomly found on the internet.
Additional version will follow if need arises. AVI seems not to be
a particular popular format for either vacation or professional
videographers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We want the duration of videos for two reasons:
- To display the duration of the video in the profile plot.
- To be able to determine which dive a video is closer to if the
start is not during a dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Gracefully handle drag & drop to the profile, which changes the
offset of the pictures. To do this, keep the pictures in the
DivePictureModel and the ProfileWidget2 sorted by offset and
re-arrange if needed to keep the list sorted. This needs some
code reshuffling.
Introduce a helper-function that moves ranges in arrays.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Disables the WindowContextHelpButtonHint by default on Qt::Sheet and
Qt::Dialog widgets. This hides the ? button on Windows, which only
makes sense if you use QWhatsThis functionality.
This value has been added in Qt 5.10.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
When I switched over from our own custom IO implementation to the new
upstream custom IO model in libdivecomputer, I completely missed the
fact that the libdivecomputer custom IO model also does a custom _sleep_
function.
I'm not entirely sure what the point was, and it broke things even in
libdivecopmputer itself when some of the new sleep functions were
broken.
Anyway, we didn't export any sleep functions at all for the bluetooth,
BLE and FTDI cases, the the libdivecomputer code didn't fall back to any
sane default sleep implementation either, so the end result was no
sleeping at all.
Which didn't matter for most divecomputers.
But it seems like at least some OSTC dive computers did care, at least
in certain situations, and both Miika and Anton had trouble downloading
with their OSTC Sport dive computers. Using the serial line protocol
and the legacy /dev/rfcomm model worked fine, because then it used the
sleeping functions in the POSIX serial code inside libdivecomputer.
This just adds trivial sleeping functions for the affected download
protocols. Maybe I should have just made libdivecomputer have a sane
default instead, but this wasn't hard either (the hard part was trying
to figure out why the downloads worked for some people and not for
others).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
add subsurface-helper.cpp to share functions between mobile and desktop
move mobile qml registrations to a shared function (avoiding differences in registrations)
Target is to replace current subsurface-desktop-main + subsurface-desktop-helper and
subsurface-mobile-main + subsurface-mobile-helper with
subsurface-*-main + subsurface-helper
Signed-off-by: Jan Iversen <jani@apache.org>
As per discussion in #1460 there is no point in showing decimal values
for pressures in the equipment tab on desktop or in the dive edit view on
mobile.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
add canonical_version and mobile_version to qPref
Having a property in qPref, allows the use in qml, and prepare the
interface for qml testing.
Signed-off-by: Jan Iversen <jani@apache.org>
add enum to qPref and remove elsewhere
update source core to reference qPref.
the enum cannot be in pref.h because it is to be used in qml and Q_ENUM
need the enum to be defined as part of the class
Signed-off-by: Jan Iversen <jani@apache.org>
Show different images for IO-error and unknow file format.
Use file-extensions to recognize video files if we couldn't
parse them.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
As long as ProfileWidget2 and DivePictureModel showed the same set of
pictures and any change would lead to a full recalculation of the set,
it made sense to let ProfileWidget2 use DivePictureModel's data.
Recently, keeping the two lists in sync become more and more of a
burden. Therefore, disconnect ProfileWidget2 and DivePictureModel. This
will lead to some code-duplication and perhaps a temporary drop in
UI-performance, but in the end the code is distinctly simpler and also
more flexible.
Thus, for example the DivePhotoTab could be changed to support headings
without having to touch ProfileWidget2 at all.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When generating thumbnails, test for video files. If it is, use
a dummy-thumbnail. Write only the type (video), but no image to
the thumbnail cache, for forward-compatibility.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
subsurface_user_info() only works on Linux (linux.c),
but it doesn't allocate values on the heap.
Solve this ownership problem by always allocating
.name and .email on the heap in subsurface_user_info()
and freeing in the caller.
If subsurface_user_info() did not modify any of the
values from NULL, use default ones, but allocate them
on the heap too.
Ref #1346
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
change qPrefDisplay.cpp to use qPref_private macros, for each variable. The macros
used depend on how standard the variable is handled.
Remark: this commit is production code, but qPrefDisplay is NOT integrated into
SettingsObjectWrapper and thus not active in the live system
Signed-off-by: Jan Iversen <jani@apache.org>
Add macros to handle get/set/loadsync function set functions in qPref
These macros are only convinience functions to write less for all those
variables who are traited standardized.
Signed-off-by: Jan Iversen <jani@apache.org>
Add macros to handle full function set functions in qPref
Remark: the function name is fixed to be "set_<name>" where name is
identical to the variable in struct preferences
This is not our standard naming, but is consistent with struct
preferences (that also use different name schemes).
Signed-off-by: Jan Iversen <jani@apache.org>
Add macros to handle full getter functions
Remark: it is assumed the name of getter function is identical to
the name in struct preferences.
Signed-off-by: Jan Iversen <jani@apache.org>
Use a private QSettings variable, instead of declaring it each time
Add macros to handle full disk* functions
Signed-off-by: Jan Iversen <jani@apache.org>
copy Display from SettingsObjectWrapper to qPref as its own class
file. Update Display to use a common load/sync scheme.
Update set/get functions to follow common name scheme:
- get function have same name as in struct preferences
- set function have set_<name in struct preferences>
- signal function have <name in struct preferences>_changed
one class one .h/.cpp is the C++ idiom. Having load/sync of each
variable in 1 functions (in contrast to the distributed way SettingsObjectWrapper
handles it) secures the same storage name is used. Having the set/get/load/sync
functions grouped together makes it easier to get an overview.
REMARK: this commit are made to show the use of the low level LOADSYNC macros, which will
be used for special cases. This class is NOT linked into the live system.
Signed-off-by: Jan Iversen <jani@apache.org>
In commit f3ef38ca0d ("Dive pictures: remove hashes") we removed picture
hashes, but removing them from the git parser causes an ugly red warning when
opening an existing cloud storage repo. With this patch we just silently ignore
the hash.
Fixes#1473
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While we shouldn't have a dive that references a dive site that doesn't exist,
if we do, we shouldn't crash. And a dive site that doesn't exist is most
definitely 'empty'.
Reported-by: Benjamin Fogel <nystire@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
commit ec0511e824 ("ios: concentrate build dirs") moved the translations around
without updating the way they are accessed, causing our release 2.1.0 on iOS to
not be localized.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Only the first computer is taken into account to find
surface intervals. All further dive computers are split
according to time.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
There were two catch-all classes for translations outside of class
context. gettextFromC was used exclusively from C, but C++ used
both, gettextFromC and QObject. Some of the string were even present
in both. Therefore, unify to gettextFromC throughout the code base.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Remove cloud_storage_status from qmlprefs.h.
usage to qPref::
enum cloud_storage_status is not used from C, but only from C++, and
having the same structure defined multiple times is a maintenance
challenge.
Signed-off-by: Jan Iversen <jani@apache.org>
add 2 header files and 1 cpp file (qPrefPrivate does not have an implementation)
The rewrite/consoliadation of SettingsObjectWrapper, qmlmanager, qmlpref and planner
needs a place to put common private parts (qPrefPrivate) and 1 common class (qPref).
Signed-off-by: Jan Iversen <jani@apache.org>
sort .c and .cpp files in CMakeLists.txt
The .c and .cpp files in CMakeLists.txt had no obvious sequence,
sorting it at least gives one understandable sequence
Signed-off-by: Jan Iversen <jani@apache.org>
PP_GRAPHS_ENABLED is only used in profilewidget2.cpp
make local to profilewidget.cpp
Signed-off-by: Jan Iversen <jani@apache.org>core/profile: move PP_GRAPHS_ENABLED from pref.h
Move the find-moved-images functions into a new translation unit
and present the user with the identified matches before applying
them.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the last commits, the canonical-to-local filename map was made
independent from the image hashes and the location of moved images
was based on filename not hashes. The hashes are now in principle
unused (except for conversion of old-style local filename lookups).
Therefore, remove the hashes in this commit. This makes addition
of images distinctly faster.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Users might have edited their pictures. Therefore, instead of identifying
pictures by the hash of the file-content, use the file path. The match
between original and new filename is graded by a score. Currently, this
is the number of path components that match, starting from the filename.
Camparison is case-insensitive.
After having identified the matching images, write the caches so that they
are saved even if the user doesn't cleanly quit the application.
Since the new code uses significantly less resources, it can be run in a
single background thread. Thus, the multi-threading can be simplified.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The connection canonical filename to local filename was done via
two maps:
1) canonical filename -> hash
2) hash -> local filename
But the local filename was always queried from the canonical filename.
Therefore, directly index the former with the latter.
On startup, convert the old map to the new one.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Some OSTC 2 and OSTC Plus variants show 'OSTC+ xxxxx' as BLE name and we
recognized this as OSTC 3 (but that one doesn't support BLE). With this
we recognize these models as OSTC 2 (which is identical from a download
perspective to the OSTC Plus) and both of those support BLE.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When we split a dive in two, we keep the dive computer ID for the dive,
but we should update the actual _time_ of the split dive to match the
split.
And when we look for "are these the exact same dives", we should check
not only that the dive computer dive ID matches, but also that the dive
computer time matches, so that we don't consider two parts of a dive
that has been split to be obviously the same dive.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The dive splitting was completely wrong, because we checked the time of
the previous sample by doing
sample[i - 1].time.seconds
which is entirely wrong. The 'sample' variable is the *current* sample,
so the time of the previous sample is simply
sample[-1].time.seconds
Alternatively, we could have started from the first sample, and done
dc->sample[i - 1].time.seconds
but mixing the two concepts up just gets you a random sample pointer
that is likely not a valid sample at all, and obviously does not have
the right time at all.
As a result, dive splitting was pretty much random. Sometimes it worked
purely by mistake, because the rest of the logic was right (ie we _had_
found the right point where we reached the surface in the dive etc, the
"previous sample time" was simply used to decide if the surface interval
was sufficient to split the dive up).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
move #include prefs-macros from SettingsObjectWrapper.h to SettingsObjectWrapper.cpp
include dive.h directly (only part of prefs-macros.h used) in preference classes
Signed-off-by: Jan Iversen <jani@apache.org>
The SVG icons for failed / still-loading pictures were rendered with an
alpha channel. This lead to strange behavior when hovering over the
icon in the profile plot: When hitting a "hole" the icon would be
minimized again.
Therefore, render the SVGs onto a white background.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Adding Cressi Giotto, Newton and Drake to the list of devices
that can be selected on Android devices.
Signed-off-by: Stephen Goodall <stephen.goodall88@googlemail.com>
This got disabled as unintended (I hope) side effect of commit
807571a588 ("core: update deviceData default from qml").
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Adding Cressi Leonardo to the list of devices that can be selected
on Android devices.
Signed-off-by: Stephen Goodall <stephen.goodall88@googlemail.com>
The old trGettext() was not thread-safe and the returned C-strings
could be freed in the case of empty translations strings. Therefore:
1) Introduce a mutex protecting access to the cache.
2) Never change existing entries, even if the translation string is empty.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>