Commit graph

115 commits

Author SHA1 Message Date
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
Linus Torvalds
4cce5df7e2 Fix imperial cylinder sizes in equipment tab
The imperial cylinder sizes are not just in cubic feet: they are in
cubic feet of gas at STP. So the imperial/metric difference is not
just about converting blindly from liters to cubic feet, you also have
to take the working pressure of the cylinder into account.

This was broken by commit f9b7c5dfe9 ("Make units in cells
consistant in CylindersModel"), because those poor sheltered Swedish
people have never had to work with the wondrous imperial cylinder
sizing, and think that units should make _sense_. Hah.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-02 22:40:50 -08:00
Thiago Macieira
8eb6dfdb02 Use QFile::{encode,decode}Name for file names
And make them use UTF-8 on Windows instead of the local 8 bit encoding.
This will also get us the proper NFD encoding on OS X.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Thiago Macieira
397898434e Remove the xslt_path now that all XSLT files are kept in a resource
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-16 16:20:54 -08:00
Thiago Macieira
ca8aee4701 Move the XSLT files into a Qt resource
This means we no longer need to keep them on disk and worry about
installing / uninstalling them. They will always be kept in-memory
(compressed).

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-16 16:20:52 -08:00
Dirk Hohndel
b6338cc30d Look in one more place for our files on a Mac
Our directory structure is somewhat inconsistent on a Mac.
Instead of trying to mess with the qmake files and breaking other things this
late in the process, I simply decided to look in one more place for our files
(this time the translations).

Fixes #362

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-13 15:31:04 -08:00
Dirk Hohndel
76251c27da Fix the logic when to display the "language changed" warning
If the user had never set up the language selection they could end up
getting the "language changed, restart required" warning even if they
didn't touch the language setting at all.

This fixes that issue by assuming that UseSystemLanguage is true if the
setting is undefined and only comparing the selected language if that
selection actually matters (i.e., UseSystemLanguage is false).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 06:44:09 +01:00
Dirk Hohndel
13c9d2ad38 Don't rely on current path when searching for support files
The notion of current path changes as we open files in the file system.
What we really want is the directory from where Subsurface was started.
That covers both the case of Windows and running Subsurface from the
install directory.

This worked before because all support files were opened before the first
user interaction. But opening the manual showed the flaw in the previous
logic.

Fixes #348

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-10 07:29:06 +01:00
Dirk Hohndel
e015effb47 Don't change working directory when looking for tranlations
And only replace 'bin' if there is a bin in the path...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06 12:03:12 -08:00
Tomaz Canabrava
9b7b477d7c Added 'English' and 'Use System Default' options.
These complete the ability to select languages from the preferences panel.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06 11:58:29 -08:00
Tomaz Canabrava
4e263bae98 Added a language preference to the Settings.
When the user first opens the application the default language is
selected; this can be changed to a hardcoded one by going to system
preferences and choosing the one you want.

Restart required.

Fixes #136

[Dirk Hohndel: whitespace fixes, removed qDebug() call, rephrased the
               message displayed prompting the user to restart.]
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06 09:49:05 -08:00
Sergey Starosek
0caaaf3d31 Weight and length units need translation
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30 07:53:38 -08:00
Linus Torvalds
38179f49d4 Fix editing of negative temperatures
We tried to clean up the temperature string (to remove degree characters
and unit names etc) a bit too aggressively, and removed the sign
character too..

Fixes #306

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-28 12:11:29 -08:00
Dirk Hohndel
d4563e54a9 Try to get Windwos to find the plugins
This way the application path (i.e., install directory) will be searched
for plugin DLLs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-21 15:51:41 -08:00
Patrick Valsecchi
4c4a7a6d96 Refactoring of the configuration handling.
Before, when clicking the OK button on the preferences GUI, we were
updating in-memory preferences from the GUI, saving them to the
configuration file from the GUI, reloading from the file to the
in-memory preferences. Then, to add to the ducplication, when the
application was exiting, some fields were saved again.
Basically the first step and the last step were useless appart from
the fact the the other steps where missing a few fields here and there.

This patch removes the first step and fixes the missing fields.

Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
ACKed-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-21 08:11:40 -08:00
Lubomir I. Ivanov
861b524e7a Helpers: move some date related function to qt-gui.cpp
divelist.c:
get_dive_date_string()
get_short_dive_date_string()
get_trip_date_string()

MinGW support for *printf and parameter positions (e.g. %1$d)
is horribly broken. Instead of implementing *proper* support
for this feature Microsoft decide to ignore the standard (again)
and they implement new functions with the '_p' suffix,
such as 'sprintf_p', which seem to be available from a 2003 runtime.
To top that 'sprintf_p' is not really a 'sprintf' but rather
a 'snprintf'.

It seems that the MinGW people ignore the issue and do not provide
wrappers of any sort, or at least for the current recommended compiler
for Qt 4.8.5 on Windows - which is a 4.4.0. A note of warning;
inspecting how MinGW does certain things in headers such as stdio.h,
can ensue bad dreams or other negative effects on to the viewer.

This forces us to move the following functions from the 'back-end'
(divelist.c) to the 'front-end' (qt-gui.cpp) and use QString.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-16 15:04:44 -07:00
Dirk Hohndel
f96299ea94 Dependencies are too aggressive for version.h
Apparently qmake can't tell that #include "version.h" and #include
"libdivecomputer/version.h" are not the same thing. Instead of spending
another bunch of hours on fixing the buildsystem I decided to just cleanup
the spots where we actually use the version file and rename it to
ssrf-version.h.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15 19:54:15 -07:00
Miika Turkia
39d7ae5f3a Use QDir::currentPath to get the current directory
applicationDirPath() does not find the source directory (if build
directory differs from source directory). Using currentPath() allows one
to still run built Subsurface from the source directory and find e.g.
xslt_path.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-13 11:31:34 -07:00