aboutsummaryrefslogtreecommitdiffstats
path: root/qt-gui.cpp
AgeCommit message (Collapse)Author
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>
2013-09-09Code Cleanup, Tabs instead of Spaces.Gravatar Tomaz Canabrava
Just changing a bunch of space-indented block of code to tabs. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-18Ask Qt to use system proxies in SubsurfaceGravatar Thiago Macieira
This causes the Marble widget to use proxies automatically too. On Mac, this gets the global proxy settings; on Windows, it gets the IE settings; on Unix, it uses environment variables (set http_proxy and all_proxy). Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27Update main window title depending of current file stateGravatar Lubomir I. Ivanov
If a file has been opened from the command line or via the File menu the main window title becomes "Subsurface: filename.ext". Title also updates if 'File->Save As' is called. "Subsurface" only is displayed when no active file is present or post 'File->New' or 'File->Close'. To make this work a new public method is added - MainWindow::setTitle() and also an enum type MainWindowTitleFormat, which should allow more complicated formatting, such as showing the selected dives or the total number of dives (e.g. MWTF_FILENAME_N_DIVES). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18Improve display of yearly statisticsGravatar Dirk Hohndel
Display the units in the header, make the header more consistent looking, convert the values into the right units with appropriate precision. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18Converting the device_info list into a Qt data structureGravatar Dirk Hohndel
This data structure was quite fragile and made 'undo' when editing rather hard to implement. So instead I decided to turn this into a QMultiMap which seemed like the ideal data structure for it. This map holds all the dive computer related data indexed by the model. As QMultiMap it allows multiple entries per key (model string) and disambiguates between them with the deviceId. This commit turned out much larger than I wanted. But I didn't manage to find a clean way to break it up and make the pieces make sense. So this brings back the Ok / Cancel button for the dive computer edit dialog. And it makes those two buttons actually do the right thing (which is what started this whole process). For this to work we simply copy the map to a working copy and do all edits on that one - and then copy that over the 'real' map when we accept the changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-17Process dive computers as they are read inGravatar Dirk Hohndel
When doing the early port from the Gtk code to Qt this function was just stubbed out. Now we are correctly filling the internal data structures with ALL the dive computers that we see. Instead of the silly dialog asking the user for a nickname we simply create one from the deviceid. The user can then use the device name editing dialog to create more intuitive nicknames. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-07Removed the buttons on the Edit Dive computers.Gravatar Tomaz Canabrava
This edit dive computers thing doesn't really need buttons anyway. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-31Much better solution to avoid the gtk+ style on LinuxGravatar Dirk Hohndel
Thiago showed me how to find out which style is in use and if we see a user is running gtk+ we simply switch Subsurface to Oxygen (using the old plastique in the previous patch was a result of reading an old Qt book, I guess). Solved-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-31Hack to force plastique style on LinuxGravatar Dirk Hohndel
I'd much rather be able to check if it is using the Gnome style and only then force plastique but I haven't been able to figure out how to do that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-31Display the Subsurface manual in the help widgetGravatar Dirk Hohndel
This adds a helper function to determine the Subsurface data directory (are we running from build directory? installed on Linux? installed on Mac? - still need to add support for Windows). This same function is then used by both the setup for Marble and for the help browser. This assumes that the user-manual.html file has actually been built and installed (which we don't do by default with the current Makefile). Right now there are rendering issues with our manual in the help browser widget - I'm sure this can be fixed... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-29Connect preferences to the rest of the codeGravatar Dirk Hohndel
The biggest problem here was that bool has different sizes in C and C++ code. So using this in a structure shared between the two sides wasn't a smart idea. Instead I went with 'short', but that caused problems with Qt being to smart for its own good and not doing the right thing when dealing with 'boolean' settings and a short value. This may be something in the way I implemented things (as I doubt that something this fundamental would be broken) but the workaround implemented here (explicitly using 0 or 1 depending on the value of the boolean) seems to work. I also decided to get rid of the confusion of where gflow/gfhigh are floating point (0..1) and when they are integers (0..100). We now use integers anywhere outside of deco.c. I also applied some serious spelling corrections to the preferences dialog's ui file. Finally, this enables the code that selects which partial pressure graph to show. Still to do: font size, metric/imperial logic Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-24Fix usage of temporary QByteArraysGravatar Alberto Mardegan
This commit fixes three different things: - a memory leak in WeightModel::setData() - getSetting() calling strdup() on a QByteArray - a possible usage of memory after deallocation Here's an explanation of the last issue (taken from the mailing list, slightly adapted): toByteArray(), as well as others "toSomething()" methods, returns a new object which the compiler allocates on the stack. The compiler will consider it a temporary data, and destroy it on the next line. So, when one does char *text= value.toByteArray().data(); // line 1 if (strcmp(description, text)) { // line 2 the compiler creates a QByteArray on line 1, calls ::data() on it, which returns a valid char *, and assigns its value to "text". So far, so good. But before jumping to line 2, the compiler destroys the temporary QByteArray, and this will in turn invoke the QByteArray destructor, which will destroy the internal data. The result is that on line 2, "text" will point to some memory which has already been freed. One solution is to store a copy of the temporary QByteArray into a local variable: the compiler will still destroy the temporary QByteArray it created, but (thanks to the reference-counted data sharing built in QByteArray) now the destructor will see that the data is referenced by another instance of QByteArray (the local variable "ba") and will not free the internal data. In this way, the internal data will be available until the local variable is destroyed, which will happen at the end of the {} block where it is defined. Please note that when one uses the data in the same line, one doesn't need to worry about this issue. In fact, text = strdup(value.toString().toUtf8().data()); works just fine. Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-23Remove a compile warningGravatar Dirk Hohndel
It's cleaner to make this a QString, anyeway. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22Implement default dive computer and deviceGravatar Dirk Hohndel
The data is saved in the settings and the correct dive computer (vendor and product) and device are picked when the download dialog is openend. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-21Replace GError handling with a kMessageWidget based approachGravatar Dirk Hohndel
Instead of passing pointers to GError around we pass just pointers to error message texts around and use kMessageWidget to show those. Problem is that right now the close button on that doesn't do a thing - so the error stays around indefinitely. Oops. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-21Remove Gtk crudGravatar Dirk Hohndel
The DEBUGFILE logic isn't needed anymore. Nor are helpers dealing with model / datastructure updates. Nor conditional compiles to use Gtk instead of Qt. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-21Initialize QSettings earlier & change the Organization to "Subsurface"Gravatar Dirk Hohndel
The first change allows the default_filename to be found again. The second change switches us to .config/Subsurface/Subsurface.conf which I find much more useful. QtCreator also fixed a few indentation issues for me. How helpful. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-21Removing an kinky settings that I forgot to.Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-21Fixed the hide / show columns using the settings.Gravatar Tomaz Canabrava
This also changed a bit the behavior on how the QSettings are managed, till now, we used the QSettings constructor passing the name of the software and the 'company', but this is now default - so there's no need to pass anything by the QSettings contructor. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-20Populate the Vendor && Dive computer information.Gravatar Tomaz Canabrava
This uses the QStringListModel to populate the items of the QComboBoxes. I used a QHash to hold every Computer of a particular Vendor. so, products[vendor] gives me the full list of products from each vendor. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-10Tweaks to maintabGravatar Amit Chaudhuri
Align statistics tab labels as per infotab. Amend helper function to show degree symbol for temp measurements. Change order of member initialisation list to match order of decl (ProfileGraphicsView::ProfileGraphicsView) Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>