Commit graph

16870 commits

Author SHA1 Message Date
jan Iversen
35de9c49a4 mobile-widgets: switch to new subsurfaceTheme
Remove subsurfaceTheme from main.qml
Replace ThemeNew -> subsurfaceTheme
change registration ThemeNew -> subsurfaceTheme

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-02-03 17:30:35 -08:00
jan Iversen
38120d555f mobile-widgets/qml: secure subsurfaceTheme.initial*
move initialWidth/initialHeight out of subsurfaceTheme to placeHolder,
this secures no change in behaviour.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-02-03 17:30:29 -08:00
jan Iversen
c3be85fbd9 mobile-widgets/qml/settings.qml: show all colors
Show all colors in a theme, allowing user to change theme.

This is preparation for allowing users to click on the individual
colors and change them.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-02-03 17:30:20 -08:00
jan Iversen
15fbcb655a mobile-widgets/themeinterface: make most part static
Make variables and functions static where possible, this is done
to prevent different versions of theme with different values.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-02-03 17:30:15 -08:00
jan Iversen
f16dc72556 mobile-widgets/qml: use new templates in converted pages
Use the TemplatePage and TemplateButton in the converted pages.

In order to avoid a bigger search/replace all other pages are left
untouched (for now).

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-02-03 17:30:06 -08:00
jan Iversen
3aa43f3ea5 mobile-widgets/qml: add TemplateButton
Do "git mv SsrfButton TemplateButton", and search/replace
all uses.

The general idea of the templates are to secure common layout,
but also to isolate the Kirigami parts (slowly) in the templates.

Signed-off-by: Jan Iversen <jani@apache.org>
2020-02-03 17:29:58 -08:00
jan Iversen
fb7920ef58 mobile-widgets/qml: add TemplatePage
Signed-off-by: Jan Iversen <jani@apache.org>
2020-02-03 17:29:51 -08:00
Berthold Stoeger
3fc2da567b Dive site: ignore dive sites without location in proximity search
When editing a dive site, the user can search for close dive sites
to merge duplicates. Dive sites without location are treated as
being located at 0N0E. This makes no sense, because:

When selecting a dive site without location, we shouldn't list
dive sites close to 0N0E.

Likewise when having a dive site close to 0N0E, we shouldn't list
dive sites that have no location.

Therefore, ignore these cases.

This also means that now dive sites without location are not
considered as close to other dive sites without location. That
might be a debatable point.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04 02:18:58 +01:00
Berthold Stoeger
670a5bd55a Dive sites: select each dive site only once
After selecting dives, the selected dive sites are collected.
This was done using the selectionModel()->selection().indexes(),
which is wrong, because it gives one index per row *and* column.
Accordingly, every dive site was added numerous times to the
array of dive sites to be selected. Change this to
selectionModel()->selectedRows(), which gives one entry per row.

Moreover, if multiple dives with the same site were selected,
this site was also added to the array multiple times. Therefore,
check the array before adding sites.

Note that all this should not change the user experience in
any way, it is only a code-hygiene thing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04 02:18:28 +01:00
Berthold Stoeger
65df9ca7b0 Coding style: PascalCase for classes
Codify our unspoken practice in the coding style document.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04 02:17:52 +01:00
Berthold Stoeger
d27b6805f3 Cleanup: rename plannerShared to PlannerShared
Usually, we use PascalCase (i.e. camelCase with a capital
letter at the start) for class names. For consistency, let's
do it here as well.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04 02:17:52 +01:00
Berthold Stoeger
317ee2f104 Dive site: inform map of selection in DiveFilter::setFilterDiveSite
When starting / changing the dive-site filter, inform the map of
the changed dive site selection by calling
	MapWidget::instance()->selectionChanged();
This fixes a bug, where on clicking dive sites in the dive site
tab the dive sites from the *previous* click were highlighted.

Perhaps the selectionChanged() call should be put into the
setSelected() call. But the data flow between the different
parts of the dive-site and map code are so convoluted that I
don't want to risk anything!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04 02:17:36 +01:00
Berthold Stoeger
9ed886e4be Cleanup: lower-case filenames in core/subsurface-qt/
We tend to use lower-case filenames. Let's do it for these files
as well. Simple search & replace.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04 02:16:46 +01:00
Dirk Hohndel
3ad1a5c7c7 GitHub Actions: use the official Ubuntu 18.04 container
Something is seriously wrong with the default Ubuntu 18.04 environment
on GitHub Actions. C++ builds fail with very confusing messages about
C++11 support.

Switching to building in a Ubuntu 18.04 based container - that seems
redundant, but it fixes the problem.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-03 17:14:28 -08:00
Dirk Hohndel
a686be07f9 android: use non-broken version of qt-android-cmake
A recent merge upstream causes build faiilures because the
PROJECT_VERSION variiable isn't defined. I can't figure out how to make
sure that it is defined correctly, so hack around that by using the
version prior to that merge.

See https://github.com/LaurentGomila/qt-android-cmake/issues/33

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-03 17:13:49 -08:00
Berthold Stoeger
8396b4bf01 Remove plannerShared::instance()
This class contains only static functions (i.e. it does not contain
any state). There does not seem to be a reason to have an instance
of that class. Therefore, remove the instance() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-31 21:31:26 +01:00
Berthold Stoeger
3b42de66dc Cleanup: remove QMLInterface::instance()
QMLInterface::instance() is only used in one single place. This
makes the whole notion of having a global instance of the object
moot, isn't it?

Simply make the object static to the function that uses it, which
guarantees that the object will be created when the function is
called. I.e. the same behavior is retained with less complexity.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-31 21:28:45 +01:00
Berthold Stoeger
188e513761 Cleanup: connect QMLInterface signals in constructor
It appears weird to connect the QMLInterface signal/slot combination
in a static helper function. This generates a bunch of lambdas that
call the instance() function.

Instead, simply do the connections in the constructor as we do it
in numerous other places.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-31 21:28:45 +01:00
jan Iversen
9452a78b1d divesummary: fix potential division by zero
[Dirk Hohndel: extracted from a larger commit from Jan]

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 19:55:47 +02:00
jan Iversen
a65ec77263 mobile-widgets/qml/divesummary.qml: detect change in units
When either length or volume unit is changed, the text needs to be
changed.

Let signal lengthChanged and volumeChanged cause a recalcation and therefore
new text.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-30 19:51:50 +02:00
Dirk Hohndel
636af40897 mobile: increment version number
In order to be able to roll out new betas, we need to first increment the
version number. Given the magnitude of the changes, incrementing the minor
version (not that we have ever been really consistent with how we do the
numbering in the first place).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 19:51:50 +02:00
Berthold Stoeger
15a4142839 Cleanup: remove redundant(?) comment
We don't have such a comment anywhere in the code base.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-30 19:33:21 +02:00
Berthold Stoeger
997e7fe1d2 Profile: fill gas change context menu from current dive
The gas change context menu was filled from the CylindersModel.
This means that even before saving new cylinders, the user could
add a gas change event to these cylinders.

Instead, fill from the current dive.

Fixes #2552.

Reported-by: Doug Junkins <junkins@foghead.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-30 19:33:21 +02:00
Berthold Stoeger
03f9e29146 Profile: transport gas id and timestamp via lambda
When adding a gas change event via a context menu, the gas-id and
timestamp were passed in two distinct ways.

1) The gas id was extracted from the text of the action. This meant
   doing rather complicated parsing.
2) The timestamp was passed via the "user data" of the action, which
   means transporting via "QVariant".

There is a much simpler way to pass arbitrary data, that is strongly
typed: lambdas. Instead of shoehorning the data onto the action in
an archaic way, we can simply connect to a stateful lambda. That's
what they're for after all.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-30 19:33:21 +02:00
Berthold Stoeger
62b869b24a CylindersModel: don't crash if accessing non-existing cylinder
It shouldn't happen, but currently we overwrite the displayed_dive
without updating the CylindersModel. Thus, CylindersModel may now
crash when the new displayed_dive has less cylinders than the old
one.

For now, catch this condition. Treat the root cause later.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-30 19:33:21 +02:00
jan Iversen
906cce9e88 mobile-widgets: emit signals for each color
Emit signals for each standard color when theme changes.

The iconStyle property was changed from being a constant, because it can
change, and thus a signal was added.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:53:34 +02:00
jan Iversen
5a7ebe15a5 mobile-widgets: correct empty lines
Remove extra empty lines in themeinterface.cpp just a cleanup, no functionality
change.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:53:12 +02:00
jan Iversen
8339384eeb mobile-widgets/qml: move fontMetrics to ThemeTest
fontMetrics is no longer used in production code, but still in the theme test
page.

Isolate fontMetrics in ThemeTest page.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:52:57 +02:00
jan Iversen
3d871ef0de mobile-widgets: do not use fontmetric for height
In order to remove fontMetrics from QML, replace references (height)
in DownloadFromDiveComputer and Settings

Add include kirigami as needed

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:52:31 +02:00
jan Iversen
2cc215d3f2 mobile-widgets: move font property to themeInterface
Move setting of font properties used throughout to themeInterface.
Add new settings "currentScale".

The properties are kept in main (subsurfaceTheme) in order not to do
a big search/replace.

Update settings to use currectScale and signal changes in themeinterface.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:52:14 +02:00
jan Iversen
a3e3a30b70 mobile-widgets: move basePointSize to themeinterface
Check defaultfont and calculate basepointsize in themeinterface instead
of in QML.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:51:05 +02:00
Dirk Hohndel
08e39f9d2d mobile/dive summary: rewrite statistics code
There were quite a few issues with the code - clearly a complete failure of
code review.

- all values were '??' if a period contained no dives
- imperial units were not calculated at all
- significant truncation and data loss in the way totals were added as meters
  and minutes instead of the higher precision data that is available
- several issues in striing conversion methodology, e.g. missing zero padding
  for minutes
- missing maxSac
- incorrectly calculated avgSac
- incorrectly claculated number of EANx dives
- hard to read code with most variables named 'temp'

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-30 07:45:25 +02:00
jan Iversen
a534f1a25c mobile-widgets/qml: Fix Kirigami error.
Solve kirigami error:
INFO: qrc:/org/kde/kirigami/ScrollablePage.qml:187: TypeError: Cannot assign to read-only property "parent".

Kirigami.scrollPage does not allow a ListModel be defined, even though it is allowed in QtQuick.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-29 06:19:25 -08:00
jan Iversen
eec1511218 divesummary: correct SAC calculation
Do not count dives where SAC == 0.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-28 15:34:54 -08:00
jan Iversen
303b5865cd mobile-widgets/qml: add icon to dive summary entry
Add sigma icon to menu entry "dive summary".

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-28 15:34:34 -08:00
jan Iversen
7ebfdd6232 mobile icons: add sigma svg
Add svg sigma to be used for dive summary.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-28 15:34:14 -08:00
jan Iversen
2d8af34016 mobile-widgets: add dive_mode variable to QML
Add dive_move variable to qmlinterface, to make it aviable to QML.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-28 11:28:30 -08:00
Dirk Hohndel
d54c26e627 GitHub Actions: remove outdated libdivecomputer header files
We never noticed this before, but during the build of the Trusty Qt5.12
container itself we create libdivecomputer include files and we ship them with
the container. And as the recent build failures after an incompatible API
change in libdivecomputer show, those include files are apparently used in this
build, not the ones that are newly created during the build.

Obviously the build container needs to be fixed, but as a quick workaround,
this should do.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-28 11:21:10 -08:00
jan Iversen
f424f9292e mobile-widget/qml/Settings.qml: correct theme switches
Replace subsurfaceTheme with ThemeNew, since there are still 2 objects
subsurfaceTheme in main.qml and ThemeNew in themeinterface.*

Replace theme color references with ThemeNew, as they are no longer available
in main.qml (subsurfaceTheme).

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-28 11:05:45 -08:00
jan Iversen
1d35942249 themeinterface: move registration to themeinterface
Move setup call and registration from subsurface-helper
to themeInterface, in order to keep the registration where the code
are.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-28 11:05:45 -08:00
jan Iversen
f69e1e31f0 documentation: add line to CHANGELOG.md
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-27 14:25:03 -08:00
jan Iversen
97e2890990 mobile-widgets/qml: integrate DiveSummary in menu.
Add DiveSummary to globalDrawer

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-27 14:25:03 -08:00
jan Iversen
b6e86a1c70 mobile-widgets/qml: add DiveSummary.qml
Add DivePlannerSummary, a page to show in dive centers.

Allow user to select period for the 2 colums in DiveSummary.

Default is "Total" and "3 month", but allowing the user to change
these, make it a very simple tool to view how the user progresses.

Variables are taken from Backend.

[Dirk Hohndel: adjusted text strings as these aren't really months]

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-27 14:25:03 -08:00
jan Iversen
6cd46bee06 divesummary: add DiveSummary class to shared and backend
Create DiveSummary class in backend-shared and make the DiveSummary calculation
results available to QML.

This adds a loop over all dives (could have been done with a model, but the
models available to mobile are very limited, so use the basic way).

[Dirk Hohndel: renamed the results variable and combined a couple of commits]

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-27 14:25:03 -08:00
jan Iversen
bb13065a75 mobile-widgets/qml: add background color property
Add property "colorBackground" to allow instances of templateLabel to have
background color overwritten.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-27 14:25:03 -08:00
jan Iversen
0920adf40f mobile-widgets/qml: correct spelling error
Correct spelling error in TemplateTitle.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-27 14:25:03 -08:00
Lubomir I. Ivanov
e69f5c4e28 core/qtserialbluetooth.cpp: use QEventLoop for polling
The Qt docs here:
https://doc.qt.io/qt-5/qbluetoothsocket.html#details
and here:
https://doc.qt.io/qt-5/qabstractsocket.html#waitForReadyRead

say that waitForReadyRead() does not work for QBluetoothSocket
and that it's flaky on Windows for the underlying QAbstractSocket.

Use a QEventLoop and a QTimer to poll the readyRead() signal.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2020-01-27 09:51:31 -08:00
Linus Torvalds
aceb8a547f rfcomm: make Windows use QtBluetooth too
Windows had it's own direct socket implementation for rfcomm (ie legacy
BT), while all the other platforms used QtBluetooth.

This makes Windows do the same thing.  Hopefully modern Qt libraries now
work well enough on the Windows platform for this to work, but I can't
test it.

We can make a test build that Windows people can try, though.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-01-27 09:51:31 -08:00
Linus Torvalds
9543f53150 Update to new libdivecomputer version
Jef has changed the libdivecomputer iostream layer and extended it in
two different ways:

 - iostram's now have a 'poll()' method, which does what the name
   implies: waits for data to be available with a timeout.

 - iostreams now have a 'ioctl()' method, which can be used to implement
   miscellaneous operations. Right now the two ones that you can do are
   "set latency" (this replaces the old 'set_latency()' method) and "get
   BLE name" (this replaces our 'get_name()' method that was never part
   of the upstream libdivecomputer interfaces)

Neither of these is all that complicated, and the transition is fairly
obvious.

HOWEVER.

I have absolutely no idea how to do 'poll()' on Windows sockets, and I
have no intention of figuring it out.  We use a direct socket interface
to implement the (non-BLE) RFCOMM bluetooth serial protocol, and I'm not
sure why Windows is so special here.  I suspect - but cannot test - that
we should just switch the Windows RFCOMM implementation over to the use
the same QtBluetooth code that we use on other platforms.

I assume that the Windows Bluetooth support was originally not
sufficiently good for that, but these days we depend on Qt doing BLE for
us even on Windows, so presumably FRCOMM works too.

That would be a nice cleanup, and would make 'poll()' work on RFCOMM
under Windows too.  However, since I can't test it, I've not done that,
but instead just made the Windows RFCOMM 'poll()' method always return
success.  That may or may not get the thing limping along.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-01-27 09:51:31 -08:00
Dirk Hohndel
5b81997459 code cleanup: whitespace cleanup
A lot of whitespace issues have snuck in recently, this just cleans those up so
that I don't need to hand-edit patches every time I touch this file (since
QtCreator automatically fixes whitespace when I make changes).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-26 16:51:05 -08:00