summaryrefslogtreecommitdiffstats
path: root/qt-gui.cpp
AgeCommit message (Collapse)Author
2014-04-30Tell Qt4 that we really meant Utf8 when we said Utf8Gravatar Dirk Hohndel
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-30Make Subsurface with a British accent workGravatar Dirk Hohndel
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-17Moved code around to make possible to compile the C part alone.Gravatar Tomaz Canabrava
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-03-19Main: separate the QApplication and UI creationGravatar Lubomir I. Ivanov
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-11Defer mainwindow->show()Gravatar Tomaz Canabrava
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-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
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-13Add recent files to main menu.Gravatar Boris Barbulovski
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-01-16Save XML files into a memory buffer rather than directly into a fileGravatar Linus Torvalds
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-14Save the divecomputer entries in a consistent orderGravatar Dirk Hohndel
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-02Fix imperial cylinder sizes in equipment tabGravatar Linus Torvalds
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 f9b7c5dfe9d0 ("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>
2013-12-20Use QFile::{encode,decode}Name for file namesGravatar Thiago Macieira
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-16Remove the xslt_path now that all XSLT files are kept in a resourceGravatar Thiago Macieira
Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-16Move the XSLT files into a Qt resourceGravatar Thiago Macieira
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-13Look in one more place for our files on a MacGravatar Dirk Hohndel
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-12Fix the logic when to display the "language changed" warningGravatar Dirk Hohndel
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-10Don't rely on current path when searching for support filesGravatar Dirk Hohndel
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-06Don't change working directory when looking for tranlationsGravatar Dirk Hohndel
And only replace 'bin' if there is a bin in the path... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06Added 'English' and 'Use System Default' options.Gravatar Tomaz Canabrava
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-06Added a language preference to the Settings.Gravatar Tomaz Canabrava
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-11-30Weight and length units need translationGravatar Sergey Starosek
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-28Fix editing of negative temperaturesGravatar Linus Torvalds
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-21Try to get Windwos to find the pluginsGravatar Dirk Hohndel
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-21Refactoring of the configuration handling.Gravatar Patrick Valsecchi
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-10-16Helpers: move some date related function to qt-gui.cppGravatar Lubomir I. Ivanov
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-15Dependencies are too aggressive for version.hGravatar Dirk Hohndel
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-13Use QDir::currentPath to get the current directoryGravatar Miika Turkia
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-11Better diagnostic message when not finding translationsGravatar Dirk Hohndel
This way we know where the program was looking for the files. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-10Try harder to find the translation filesGravatar Dirk Hohndel
They could be below the data directory ("share") or next to it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-10Work around a Qt Locale bug on MacGravatar Dirk Hohndel
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-10Dismbiguate gettextGravatar Dirk Hohndel
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-09Next step towards working translationsGravatar Dirk Hohndel
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-09Make sure we handle untranslated Subsurface correctlyGravatar Dirk Hohndel
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-09Remove unnecessary moc includeGravatar Sergey Starosek
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-08Load translations at run timeGravatar Dirk Hohndel
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-08Fix edit + cancel = absolute zeroGravatar Patrick Valsecchi
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-06Remove lots of ifdef'ed out code from GTK/glib versionGravatar Dirk Hohndel
There's still a ton more left, but this is a start. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Trying to switch to Qt translationGravatar Dirk Hohndel
This compiles and looks about right, but it doesn't appear to work, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06First steps towards removing glib dependenciesGravatar Dirk Hohndel
- 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-04Use helper function to find xslt folderGravatar Dirk Hohndel
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-04Add a helper function to calculate weight display stringGravatar Benjamin
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-04Use the same conversion grams->lbs in dive and equipment listGravatar Benjamin
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-03Helpers: add get_cylinder_used_gas_string()Gravatar Lubomir I. Ivanov
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-09-27Hack to make the subsurface work on Gnome3 shellGravatar Tomaz Canabrava
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-26Only set documentMode on tab if in Oxygen style.Gravatar Tomaz Canabrava
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-26Cleanup the prettyness of subsurface on Gtk+ style.Gravatar Tomaz Canabrava
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-22Support imperial measurements in dive planner / add diveGravatar Dirk Hohndel
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-21Allow editing of date & time and air & water temperaturesGravatar Dirk Hohndel
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-18Destroy the main window before exiting the applicationGravatar Thiago Macieira
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-09Use the same code for command line and gui for file handling.Gravatar Tomaz Canabrava
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-09Fix QString UsageGravatar Tomaz Canabrava
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>