aboutsummaryrefslogtreecommitdiffstats
path: root/qt-gui.cpp
AgeCommit message (Collapse)Author
2014-10-29qt-qui.cpp: set the locale codec to UTF-8 on Win32Gravatar Lubomir I. Ivanov
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-21Fix dc nickname helper functionGravatar Linus Torvalds
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-08-22We should never show decimals on depth in feetGravatar Dirk Hohndel
That's 3cm resolution - just unrealistic Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-16Don't show seconds for dive start time in the UIGravatar Dirk Hohndel
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-06Attempt to hack around the problems with Swedish date localizationGravatar Dirk Hohndel
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-06Remove left overs from time zone designation in Windows/SpanishGravatar Dirk Hohndel
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-03Use Qt date localization instead of translated stringsGravatar Dirk Hohndel
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-01Fix time zone issues in 32bit buildsGravatar Dirk Hohndel
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-07-16Pick the correct timezoneoffset for the day in questionGravatar Dirk Hohndel
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-16Date picker l10n for profile and plannerGravatar Sergey Starosek
- 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-06-28Calendar Widget: set the locale appropriate first day of the weekGravatar Dirk Hohndel
Also adjust the minimum size, given I changed this in commit 26855234acef ("Make date widget easier to read"). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-28Fix date and time l10nGravatar Sergey Starosek
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-27Better date localizationGravatar Dirk Hohndel
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-12Fix tank size displayGravatar Dirk Hohndel
In commit 11380a5deb07 ("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-12Delay loading of some settings until laterGravatar Dirk Hohndel
This early in init_ui() the settings may not be available, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09qt-gui.cpp: add another QT_VERSION checkGravatar Lubomir I. Ivanov
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-08Change character for liter in SAC values as wellGravatar Dirk Hohndel
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-08Really display liters with script elGravatar Dirk Hohndel
In commit 125ddd955c04 ("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-06User manual: show a localized version of the manual if it existsGravatar Dirk Hohndel
So far we only have Spanish, but it always pays to plan ahead. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29Don't assume that pressures are always positiveGravatar Dirk Hohndel
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-22Gratuitous whitespace changesGravatar Dirk Hohndel
I keep trying to get to consistenct. Completely hopeless. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13Do not check for null before free.Gravatar Tomaz Canabrava
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-11Correct the usage of std::string and QStringGravatar Tomaz Canabrava
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-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>