summaryrefslogtreecommitdiffstats
path: root/main.cpp
AgeCommit message (Collapse)Author
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-03-31Fix crash with libgit when it's compiled with GIT_THREADSGravatar Linus Torvalds
Call git_threads_init() before using libgit functions. The documentation says: "If libgit2 has been built with GIT_THREADS on, this function must be called once before any other library functions. If libgit2 has been built without GIT_THREADS support, this function is a no-op" Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-25Add optional Win32 console allocationGravatar Lubomir I. Ivanov
This patch adds the optional --win32console command line option. It does nothing on OSx and Linux, while is only useable on Win32. On Win32 if the application was built as GUI (not console), there is no way to view stdout and stderr. With windows.c's subsurface_console_init() we are able to either redirect stdout and stderr to the terminal from which subsurface.exe was started (always happens; --win32console does nothing in this case) or if --win32console is explicitly added to a shortcut, create a dedicated console window and monitor the output there. if set, WIN32_CONSOLE_APP is a condition that will make the subsurface_console_init() and subsurface_console_exit() functions NOP on Windows. The definition will be created if the user passes 'CONFIG += console' to qmake. Fixes #436 Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-20Do not use default dive filename before setting itGravatar Jan Mulder
Changeset ee2e43f introduced a small bug. The default dive file as set in the Prefences is not opened, requiring manual opening. This patch reshuffles a little code, allowing first the preferences being set, and than using it. Signed-off-by: Jan Mulder <jlmulder@planet.nl> 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-11Only anim if not first dive when openning subsurface with a divelog.Gravatar Tomaz Canabrava
The animation appeared when the user started subsurface with a default file, wich was a little annoying since it didn't had a 'from' position to go and it was also increasing it's size on some window managers that do subtle windows animations when a program starts. This patch treats the first dive opened when the program loads with a divelog pa rameter differently as the following ones storing the velocity value on a temporary, and reassigning it later. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07Fix colors on the new profile.Gravatar Tomaz Canabrava
This patch fixes the colors on the new profile, the init of the colors map was not being done. This fixes it. A few problems were spotted on the new profile dealing with the ruler graph and a newly added dive, when using the dive add dialog. I'll be on it later. 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-12Replace mainWindow() with MainWindow::instance()Gravatar Boris Barbulovski
C++ style of accessing single instance class object. Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-02Speed up XML loadingGravatar Linus Torvalds
This tries to speed up XML loading for large XML files (and thus subsurface startup times) by trimming the fat off our own matching code. The actual libxml overhead (particularly string allocation) tends to be the dominant part, so this only speeds up a big load by about 12% for me, but hey, it can be noticeable. Dirk's example nasty 175MB xml file with ~5200 dives takes "only' 7.7 seconds to load, when it used to take 8.8s. And that's on a fast machine. For smaller xml files, the dynamic loading costs etc startup costs tend to be big enough that the xml parsing costs aren't as noticeable. Aside from switching the node names around to "little endian" (ie least significant name first) format to avoid some unnecessary strlen() calls, this makes the nodename generation use a non-locale 'tolower()', and only decodes up to two levels of names (since that's the maximum we ever match against anyway). It also introduces a "-q" argument to make startup timing easier. Passing in "-q" just makes subsurface quit imediately after doing all necessary startup code. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-02Replaced the tag implementationGravatar Maximilian Güntner
The new implementation supports custom tags which are provided by the user as well as default tags which are provided by subsurface. Default tags can be translated and will be written to XML in their non-localized form. Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
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-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-08main.cpp: remove usage of subsurface_command_line_*Gravatar Lubomir I. Ivanov
subsurface_command_line_* are now redundant as Qt should handle the command line argument parsing on Windows for which these functions where mainly used and where NOP for other OS. main.cpp also receives a couple of small changes to use: QCoreApplication::arguments() to obtain the list of expanded arguments and parse those instead. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Changes to make the glib-removal-hack branch build on MacOSXGravatar Henrik Brautaset Aronsen
Tested with the Homebrew packaging system Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> 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-04Fix the first load of Subsurface - "File not found" error.Gravatar Tomaz Canabrava
The first time the user loads subsurface, the default_filename is not configured yet, but yet the software tries to load "", sending an error message that this file doesn't exists. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Taiane Ramos <exhora.tat@gmail.com>
2013-10-03Better fix for the compile problemsGravatar Dirk Hohndel
Still don't like the order dependency - but at least this seems to work and correctly build after make confclean. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03Build fixGravatar Dirk Hohndel
Reported-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-22Only load default file if no file is given on the command lineGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-09Removed WarningsGravatar Tomaz Canabrava
This patch removes a warning and a function call that shouldn't be there. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.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>