aboutsummaryrefslogtreecommitdiffstats
path: root/qt-gui.cpp
AgeCommit message (Collapse)Author
2015-06-20Add DiveListModelGravatar Grace Karanja
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-20Only include Qt Quick when on mobileGravatar Grace Karanja
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-20Link QMLManager to the main.qml fileGravatar Grace Karanja
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-20Hide MainWindow when running under mobileGravatar Grace Karanja
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-20Load main.qml on startup for mobile buildsGravatar Grace Karanja
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-16Separate initializing Qt from initializing the UIGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-24Remove support for Qt4 (part 7)Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-26qt-gui.cpp: fix imcomplete type errorGravatar Lubomir I. Ivanov
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-23Move helper functions aroundGravatar Dirk Hohndel
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-10Remove the DiveList from the mainwindow.uiGravatar Tomaz Canabrava
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>
2014-12-29Facebook integration: improve the confirmation UI experienceGravatar Dirk Hohndel
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-18Free more struped prefsGravatar Anton Lundin
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-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>