Commit graph

132 commits

Author SHA1 Message Date
Grace Karanja
b0df506a8c QML UI: Sort dives by date
Sort the dives by date, with the latest one appearing before the
others.

Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
2015-07-22 19:09:49 +03:00
Grace Karanja
0c9756c5d7 QML UI: Implement showing of the dive profile on QML
Link the QMLProfile class to the DiveList.qml file. The profile is
displayed above the dive details.

Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
2015-07-17 12:00:38 -07:00
Dirk Hohndel
15de7f0b71 QML UI: implement a message area to show information to the user
This is just a quick first stab to do this, but it at least allows us to
share some information with the user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12 17:39:13 -07:00
Dirk Hohndel
4491c91b93 Whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12 17:36:49 -07:00
Dirk Hohndel
4088f9f652 QML UI: set window size on desktop devices
On Android the app figures out the size by itself.

Also change the name to match our naming scheme (Subsurface mobile for the
QML UI).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12 10:52:15 -07:00
Dirk Hohndel
27f55cb964 Use mobile icon for subsurface-mobile
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-09 20:47:16 -07:00
Grace Karanja
b7e4b35cde Add DiveListModel
This model will be used to show the dives in QML. This commit adds
the model, and the means to link it to QML.

Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20 14:26:56 -07:00
Grace Karanja
bf882416f9 Only include Qt Quick when on mobile
In qt-gui.cpp, move the Qt Quick includes so that they will only
be used when on cmake SUBSURFACE_MOBILE is True.

Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20 14:25:09 -07:00
Grace Karanja
315a245868 Link QMLManager to the main.qml file
Add a link between the C++ and QML parts of the app using the
qmlRegisterType function.

[Dirk Hohndel: changed the name to org.subsurfacedivelog.mobile]

Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20 14:24:25 -07:00
Grace Karanja
b09975f46a Hide MainWindow when running under mobile
When compiling the mobile version, hide the Qt MainWindow.

Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20 14:18:48 -07:00
Grace Karanja
6ef082a4a2 Load main.qml on startup for mobile builds
When cmake is run with -DSUBSURFACE_MOBILE=True, the initial window
will be main.qml, instead of the MainWindow used when cmake is run
with -DSUBSURFACE_MOBILE=False

Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20 14:18:32 -07:00
Dirk Hohndel
0692e24036 Separate initializing Qt from initializing the UI
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16 14:05:09 -07:00
Tomaz Canabrava
e744fc5bba Remove support for Qt4 (part 7)
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-24 09:37:23 -07:00
Lubomir I. Ivanov
ea00fdb36a qt-gui.cpp: fix imcomplete type error
qt-gui.cpp:44:2: error: incomplete type 'QTextCodec' used
in nested name specifier

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-26 11:30:04 +01:00
Dirk Hohndel
ddc01e39e7 Move helper functions around
We had a ton of helper functions in qt-gui.cpp which really didn't make
much sense. So I moved them all into qthelper.cpp.

Also moved the UserAgent helper that didn't belong in the UpdateHandler to
begin with - that's a generic helper used in many places...

With this we can successfully build using cmake again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-23 09:31:08 -08:00
Tomaz Canabrava
cf4d55c470 Remove the DiveList from the mainwindow.ui
It's now set up from the mainwindow.cpp file.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10 10:45:45 -08:00
Dirk Hohndel
cab320201b Facebook integration: improve the confirmation UI experience
Date and time needs to be a string, not a time_t.
Duration should be called that (and not time) and wasn't hooked up.
Also added a helper to get the duration string.
Finally reordered the components of the text that is shown to make it more
natural (or I should say, more in line with the order we use elsewhere).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-29 11:14:34 -08:00
Anton Lundin
65a988a232 Free more struped prefs
These ones are strduped prefs, but not stored in the prefs structure.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-18 08:34:00 -08:00
Lubomir I. Ivanov
9e4cc81068 qt-qui.cpp: set the locale codec to UTF-8 on Win32
This makes QFile::encodeName() work and filenames
with special chars on Win32 can be opened again.

Fixes #740

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-29 09:28:11 -07:00
Linus Torvalds
0d30d2f064 Fix dc nickname helper function
This helper function is used to get a nickname for a dive computer, when
the model information on its own may be ambiguous (ie there may be
multiple dive computers of the same model, and we've nicknamed them by
owner).

However, the helper did completely the wrong thing if it didn't find a
dive computer entry at all due to a missing device ID - it would just
return empty.  Which is bogus: it should return the model name, the same
way it does if the nickname is missing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-21 09:54:31 -07:00
Dirk Hohndel
c47594417a We should never show decimals on depth in feet
That's 3cm resolution - just unrealistic

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-22 14:37:21 -07:00
Dirk Hohndel
3766f57392 Don't show seconds for dive start time in the UI
Some divecomputers only report at minute granularity, anyway. And when
diving with multiple dive computers they will never agree on the exact
time. And anyway, what's the point of second granularity when it comes to
the start time of a dive?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-16 15:56:38 -06:00
Dirk Hohndel
8092c0fdcd Attempt to hack around the problems with Swedish date localization
When trying to shorten the long date format into a "medium" length date
format we are messing up Swedish dates. This should fix the issue. Not a
great solution but should be good enough for 4.2

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-06 10:48:01 -07:00
Dirk Hohndel
158a853d97 Remove left overs from time zone designation in Windows/Spanish
We remove the time zone designation when showing times (as all our times
have no timezone). But the Spanish localization on Windows shows the time
zone in parenthesis - and the existing code then left those parenthesis
behind which looked very strange.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-06 10:23:33 -07:00
Dirk Hohndel
2ad433671f Use Qt date localization instead of translated strings
This gets us consistent date format everywhere. The reordering of month
name and day of the month didn't work correctly on Windows, anyway.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-03 13:02:32 -07:00
Dirk Hohndel
e2271f50ad Fix time zone issues in 32bit builds
The bug is obvious, tracking it down wasn't.
A simple thinko brought us time_t instead of timestamp_t - which doesn't
matter on 64bit builds, but makes things fail in weird ways on 32bit
builds - like our Windows binaries.
In this case instead of checking today's date to detect the timezone
offset we happened to be using a date in December 1969, so no dailight
savings, so the times were off.

Fixes #655
Fixes #667
See #670

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-01 15:25:53 -07:00
Dirk Hohndel
b3e662a895 Pick the correct timezoneoffset for the day in question
Calculating the timezoneoffset for the current date really makes no sense
whatsoever when displaying a time that isn't "now".

Fixes #605

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16 20:24:56 -07:00
Sergey Starosek
14cc59898a Date picker l10n for profile and planner
- set application-wide locale from preferences
- use custom date format for display

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16 13:58:06 -07:00
Dirk Hohndel
0ea86d83c1 Calendar Widget: set the locale appropriate first day of the week
Also adjust the minimum size, given I changed this in commit
26855234ac ("Make date widget easier to read").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-28 08:38:16 -07:00
Sergey Starosek
2a8f32b87e Fix date and time l10n
QDateTime::toString(const QString & format) uses system locale
for month and day names.

In order to get localized month and day names for user-choosen locale
use QLocale::toString(const QDateTime & datetime, const QString & format)
instead.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-28 06:34:13 -07:00
Dirk Hohndel
a8a9deb262 Better date localization
Instead on relying on the translators to correctly format date and time we
should be able to get all we need from QLocale. Sadly this takes a bit of
hacky post-processing, but in my limited testing the results look good.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-27 12:07:47 -07:00
Dirk Hohndel
ed5a805929 Fix tank size display
In commit 11380a5deb ("Really display liters with script el")
I inadvertantly broke the display of cylinder sizes in the imperial case.
This patch restores that and also tries to give slightly more useful
guidance on the number of decimals to display.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-12 15:39:42 -07:00
Dirk Hohndel
21be237b0e Delay loading of some settings until later
This early in init_ui() the settings may not be available, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-12 11:52:59 -07:00
Lubomir I. Ivanov
16dd110a09 qt-gui.cpp: add another QT_VERSION check
encodeUtf8() and decodeUtf8() are only used for Q_OS_WIN in init_ui(),
but also that branch is wrapped in a "#if QT_VERSION < 0x050000"

we do the same for the actual function declarations.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 16:55:18 -07:00
Dirk Hohndel
bbe62f756a Change character for liter in SAC values as well
And fix the bug that in the info overlay SAC was always given in metric
values. And try to reduce the number of places in which we calculate the
unit conversions...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 21:00:56 -07:00
Dirk Hohndel
11380a5deb Really display liters with script el
In commit 125ddd955c ("Display liters with script el") Robert only fixed
the C routine we use to show units. Strangely, we had a separately
implemented C++ function as well. Instead of implementing this in two
spots I now simply have the C++ function use the C function to do the
actual work and then wrap this into an easier to use (from UI code)
QString output.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 20:39:46 -07:00
Dirk Hohndel
a0a6759d93 User manual: show a localized version of the manual if it exists
So far we only have Spanish, but it always pays to plan ahead.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-06 12:10:34 -07:00
Dirk Hohndel
56395b3894 Don't assume that pressures are always positive
When planning a dive, the dive could use more gas than is in the cylinder.
So getting a negative end pressure is a useful indication to the user that
there plan might not be a good one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 13:18:13 -07:00
Dirk Hohndel
5ba573240f Gratuitous whitespace changes
I keep trying to get to consistenct.
Completely hopeless.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 11:40:22 -07:00
Tomaz Canabrava
c86d055db7 Do not check for null before free.
C specs says that we can safelly free a NULL pointer, so there's no reason
to check if it's null before freeing it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13 09:26:50 +09:00
Tomaz Canabrava
cf848e5233 Correct the usage of std::string and QString
QStrings shouldn't be == "" to check for empty string, use .isEmpty()
QStrings shouldn't be != "" to check for non empty, use .size()
std::string shouldn't be cleared with = "", use .clear()

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-11 01:57:00 -07:00
Dirk Hohndel
7797926329 Tell Qt4 that we really meant Utf8 when we said Utf8
How strange. Telling Qt4 to assume that all C strings are Utf8 apparently
isn't enough to convince tr() that the C strings we pass to it are Utf8.
You need to set that codec separately.

Fixes #503

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-30 10:39:28 -07:00
Dirk Hohndel
084c2c04db Make Subsurface with a British accent work
Our workaround for the lack of a US-English translation breaks en-GB. With
this the British version of Subsurface should work as well.

Reported-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-30 09:46:54 -07:00
Tomaz Canabrava
55d010bad8 Moved code around to make possible to compile the C part alone.
The C code should be compilable without the need to compile the Gui part,
too. This is expecially good for unit testing as we can test all the
algorithms without a window appearing out of nowhere.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17 08:46:29 -07:00
Lubomir I. Ivanov
ee2e43f11a Main: separate the QApplication and UI creation
When some arguments like --help and --version are passed to the
executable, we don't need to create the UI at all.

This patch separates the QApplication creation which is at first
only needed to parse the arguments and then if exit() is not
called from subsurfacestartup.c, we can call some of the
"init" methods such as setup_system_prefs(), fill_profile_color()
etc.

At this point init_ui() can be called which no longer needs
to accept the command line argument list.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-19 09:37:49 -07:00
Tomaz Canabrava
b758210c19 Defer mainwindow->show()
The mainwindow->show(); was being called before we parsed
the dives, so in the case of a large dive file, we got a
very quick, but spottable, gray background on the profile.

The mainwindow->show(); now is called just before the
Qt main-loop starts.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-11 17:41:41 -07:00
Dirk Hohndel
76e6420f6b Massive automated whitespace cleanup
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 20:09:57 -08:00
Boris Barbulovski
51220f26ef Add recent files to main menu.
Add(up to four) recent files to File main menu.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-13 22:05:05 -08:00
Linus Torvalds
96a4fd1bb2 Save XML files into a memory buffer rather than directly into a file
This introduces a "struct membuffer" abstraction that you can write
things into, and makes the XML saving code write to the memory buffer
rather than a file.

The UDDF export already really wanted this: it used to write to a file,
only to then read that file back into memory, delete the file, and then
*rewrite* the file after doing the magic xslt transform.

But the longer-term reason for this is that I want to try to write other
formats, and I want to try to share most helpers.  And those other
formats will need this memory buffer model.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 12:51:23 +07:00
Dirk Hohndel
fdf8c905d6 Save the divecomputer entries in a consistent order
This is the list of DCs in the settings. This way they don't keep
changing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-14 20:54:34 +07:00