Commit graph

91 commits

Author SHA1 Message Date
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
Dirk Hohndel
344fc98bfc Better diagnostic message when not finding translations
This way we know where the program was looking for the files.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-11 13:50:35 -07:00
Dirk Hohndel
f5423c48b8 Try harder to find the translation files
They could be below the data directory ("share") or next to it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-10 14:52:30 -07:00
Dirk Hohndel
8bd26af44e Work around a Qt Locale bug on Mac
With Qt4.8.5 Locale::uiLanguages() sometimes doesn't return the country, just
the language. This works around this by recreating the locale if this has
happened.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-10 13:00:23 -07:00
Dirk Hohndel
86a80d37eb Dismbiguate gettext
Just to make sure there's no confusion - we are NOT calling gettext. We
are calling tr from a gettext like interface.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-10 00:18:26 -07:00
Dirk Hohndel
193d20c479 Next step towards working translations
This may seem like a really odd change - but with this change the Qt tools
can correctly parse the C files (and qt-gui.cpp) and get the context for
the translatable strings right.

It's not super-pretty (I'll admit that _("string literal") is much easier
on the eye than translate("gettextFromC", "string literal") ) but I think
this will be the price of success.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-09 22:51:59 -07:00
Dirk Hohndel
2d69d4a5ef Make sure we handle untranslated Subsurface correctly
At least on the Mac we otherwise switch to the next language which is not what
the user likely intended.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-09 17:55:31 -07:00
Sergey Starosek
4fee6077af Remove unnecessary moc include
This fixes compilation issues with the new build system.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-09 06:58:41 -07:00
Dirk Hohndel
7813ac86bf Load translations at run time
This doesn't enable translation switching, but at least we try and load
the correct translation at startup.

We create two global pointers for the currently active translations.

This also removes the remainders of the gettext()/glib based translation
system.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-08 23:11:25 -07:00
Patrick Valsecchi
d0e9d1f383 Fix edit + cancel = absolute zero
If a temperature in Kelvin is 0, I think we can safely assume it is
not set.

Fixes #207.

Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-08 06:23:49 -07:00
Dirk Hohndel
70352c3962 Remove lots of ifdef'ed out code from GTK/glib version
There's still a ton more left, but this is a start.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:55:18 -07:00
Dirk Hohndel
4d3e74a236 Trying to switch to Qt translation
This compiles and looks about right, but it doesn't appear to work, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:42:32 -07:00
Dirk Hohndel
4b12f28ca4 First steps towards removing glib dependencies
- remove the build flags and libraries from the Makefile / Configure.mk
- remove the glib types (gboolean, gchar, gint64, gint)
- comment out / hack around gettext
- replace the glib file helper functions
- replace g_ascii_strtod
- replace g_build_filename
- use environment variables instead of g_get_home_dir() & g_get_user_name()
- comment out GPS string parsing (uses glib utf8 macros)

This needs massive cleanup, but it's a snapshot of what I have right now, in
case people want to look at it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:41:44 -07:00
Dirk Hohndel
f8708e2921 Use helper function to find xslt folder
This seems much better than the different hard coded and semi-hard coded
paths we had before.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-04 13:21:31 -07:00
Benjamin
ae713763c7 Add a helper function to calculate weight display string
Add a helper function to unify the calculation of the
weight display string, instead of having the same calculation
in two places in the code.

Signed-off-by: Benjamin Fogel <nystire@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-04 11:57:28 -07:00
Benjamin
9961cf13b1 Use the same conversion grams->lbs in dive and equipment list
Subsurface stores weight values in grams. When displaying lbs,
the dive list was not rounding the converted weights up, but
rather truncating the value at the decimal place. The equipment
list was rounding the converted weights up. This gave two
different displayed values for the same weight value.

Signed-off-by: Benjamin Fogel <nystire@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-04 09:40:05 -07:00
Lubomir I. Ivanov
50e74f4565 Helpers: add get_cylinder_used_gas_string()
get_cylinder_used_gas_string() retrieves used gas per cylinder
with optional units display.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03 09:38:13 -07:00
Tomaz Canabrava
e81bbc1dab Hack to make the subsurface work on Gnome3 shell
The Gtk+ style on the Gnome shell is somewhat broken on Qt for
some reason. This hack pokes the system, checks if it's running
gnome-shell, and if the current style is gtk+ ( I couldn't just
check for gtk+ since it worked on XFCE and other Gtk based enviro
ments. so a double check is needed. ) then I changed the Pallete
of the affected widgets by hand.
not a pretty hack but worked.

[Dirk Hohndel: redid the patch to be simpler and more consistent]

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-27 09:22:19 -07:00
Tomaz Canabrava
57ebed9dd0 Only set documentMode on tab if in Oxygen style.
This is much better looking in the Oxygen style, and
on the other styles it looks like crap - so let`s not
use that.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-26 17:02:27 -03:00
Tomaz Canabrava
8f94b904dd Cleanup the prettyness of subsurface on Gtk+ style.
Fix some stuff concerning the pretyness of subsurface while running
on Gnome and XFCE enviroments. This is the kind of stuff that I
really didn`t want to put on the code but sometimes it`s for the
best. this makes the MainTab much more bearable. There are still
things to fix, like the size and positioning of some of the icons.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-26 16:51:11 -03:00
Dirk Hohndel
6ce5704435 Support imperial measurements in dive planner / add dive
This was not as hard as I assumed it would be. I may still change the
horizontal dimension to be the more logical seconds instead of minutes,
but for now this achieves the main goal.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-22 12:37:49 -07:00
Dirk Hohndel
a8888eaf26 Allow editing of date & time and air & water temperatures
Add two more rows to the widget - this is getting quite busy.
There still is some weirdness where the focus isn't returned where it
should be and a few other details, but overall getting there.

Added helper functions to parse a temperature and to deal with the
timezone offset - with that latter one I also fixed the time offset bug in
the planner.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-21 08:30:32 -07:00
Thiago Macieira
0afe576a50 Destroy the main window before exiting the application
This ensures all widgets inside the window get destroyed too.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-18 12:02:42 -05:00
Tomaz Canabrava
96d1cc570e Use the same code for command line and gui for file handling.
The Command line execution of Subsurface happened before the
GUI was created, this leaded to various bugs by me(tm) over
time. This patch seems to fix all of those, by reusing the
same code for GUI interaction and CommandLine interaction.

I had to rework how the main.c worked, it used to be C code
calling C++ code, and this is non desirable, since C doesn't
really understand C++.

I Moved all of C-related code to 'subsurfacestartup.c/h' and
created a tiny wrapper to call it, so all of the C code is still
C code, and the new main.cpp calls the mainwindow->loadFiles and
mainWindow->importFiles to get rid of the bugs that happened before.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-09 05:59:03 -03:00
Tomaz Canabrava
6a7256fdd5 Fix QString Usage
Fixes QString Usage. to return a Empty QString, one should
return a QString() and not a QString(""), and to check if
the string is empty, one should check for string.isEmpty()
instead of "string != "" ", because the latter will create
a new QString, then call the != operator, less function calls,
better code.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-09 04:48:03 -03:00