summaryrefslogtreecommitdiffstats
path: root/subsurface-desktop-main.cpp
AgeCommit message (Collapse)Author
2018-08-15ssrf: call sync() when exiting appl.Gravatar jan Iversen
In order to ensure preferences are saved, sync() is called when leaving the program. Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-26Whitespace cleanup main/helper filesGravatar Dirk Hohndel
Again, entirely script based. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-18Cleanups to core/color.[c|hpp]Gravatar Berthold Stoeger
A number of small cleanups to the color-table: 1) Make the profile_color map of static linkage - it is not used outside of this file. 2) Remove the third color, which originally was planned for printing. It was not accessed anywhere. 3) Replace QVector<QColor> by std::array<QColor, 2>. Using a reference-counted, copy-on-write, dynamic container for static data seems like overkill. std::array<QColor, 2> has exactly the same run-time impact as QColor[2], but allows for assignment. 4) Use brace-initialization and remove the unneeded COLOR macro. 5) Remove the fill_profile_color function. Simply use static initialization. 6) Move #includes from .h to .cpp file. 7) Remove text_render_options(_t), which were not used anywhere. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-24mobile: application variable unused in mainGravatar jan Iversen
Simplify starting application. instead of declaring var. application, and the setting unused, simple do the "new QApplication" without a variable. Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21subsurface: Change Q_UNUSED to no parameter nameGravatar jan Iversen
C++ permits use of parameters without name, which signals unused Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-14Core: remove dive.h from files that don't need itGravatar Dirk Hohndel
Of course, quite a few of them indirectly get it through other header files. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-14Cleanup: consistently use toUtf8() instead of toLocal8Bit()Gravatar Berthold Stoeger
These do the same, since the text-codex is set to UTF-8 on startup. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14Cleanup: consistently use qPrintable()Gravatar Berthold Stoeger
Replace constructs of the kind s.toUtf8().data(), s.toUtf8().constData(), s.toLocal8Bit().data(), s.toLocal8Bit.constData() or qUtf8Printable(s) by qPrintable(s). This is concise, consistent and - in principle - more performant than the .data() versions. Sadly, owing to a suboptimal implementation, qPrintable(s) currently is a pessimization compared to s.toUtf8().data(). A fix is scheduled for new Qt versions: https://codereview.qt-project.org/#/c/221331/ Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-17Unify float calulations: use doubleGravatar Berthold Stoeger
Internal floating point (FP) calculations should be performed using double unless there is a very good reason. This avoids headaches with conversions. Indeed, the vast majority of FP calculations were already done using double. This patch adapts most remaining calculations. Not converted where things that were based on binary representations and variables which weren't used anyway. An analysis of all instances follows: core/plannernotes.c, l.404: This was a comparison between two floats. On the left side, first an integer was cast to float then multiplied with and integer and divided by a constant double. The right hand side was an integer cast to a float. Simply divide by 1000.0 first to convert to double and continue with calculations. On the right hand side, remove the cast, because the integer will be implicitely cast to double for comparison. This conversion actually emits less instructions, because no conversion to double and back is performed. core/planner.c, l.613: Same analysis as previous case. subsurface-desktop-main.cpp, l.155: A local variable representing the version OpenGL version. Turn this into integer logic. Not only does this avoid dreaded FP rounding issues, it also works correctly for minor version > 10 (not that such a thing is to be expected anytime soon). abstractpreferenceswidget.[h/cpp]: A widget where the position is described as a float. Turn into double. desktop-widgets/divelogexportdialog.cpp, l.313: total_weight is described as float. Use double arithmetics instead. This instance fixes a truncation warning emitted by gcc.
2017-11-16subsurface-startup: expose print_version() in the headerGravatar Lubomir I. Ivanov
The Windows auto-verbose + log file creation if starting from a non-terminal has the problem that the print_version() call is never made becase 'verbose' is updated programatically in windows.c and not by the user (by passing -v). To work around the issue: - move the windows console creation call before *everything* else - then immediatelly install the message handler - then see if 'verbose' is set and explicitly call print_version() print_version() now also has a flag (version_printed), to avoid printing the version multiple times, if the user decided to add an extra -v to the Desktop shortcut. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-16dekstop-main.cpp: install a message handlerGravatar Lubomir I. Ivanov
This way the Windows binaries can properly write to log files. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-09Add details about key libraries when showing versionGravatar Dirk Hohndel
Also fixed a spelling error and apparently some whitespace issue. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-03win32: optimize the console and logging logicGravatar Lubomir I. Ivanov
Currently one has to explicitly use --win32console and/or --win32log to enable a dedicated console (a console window that opens next to the Subsurface window) or to enable file logging on Win32. This patch makes the following changes: - removes the --win32* command line arguments - removes the dedicated console window support - if the app starts from a shortcut and not from a console, always redirect stderr and stdout to _err & _out log files - if the app starts from a console redirect stderr and stdout to that console Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-02desktop-main.cpp: round the fractional part of the GL versionGravatar Lubomir I. Ivanov
When verMinor is extracted with the glGetString() method, use roundf() to round the GL MINOR version to an integer. 2.1 is split in 2 and 1. Without this patch rounding issues are present as for 32bit IEEE the default rounding makes (0.1f * 10.f) into 0.999999f. Given the MINOR is a single digit for GL, calling roundf() on 0.999999 gives the expected result 1 for the MINOR. Reported-by: Murillo Fernandes Bernardes <notifications@github.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-01desktop-main.cpp: further improve the GL version detectionGravatar Lubomir I. Ivanov
First, attempt to use glGetString(GL_VERSION), which works on legacy profiles but has to be parsed (unsafe and vendor specific?). If the above fails attempt to use the newer version API from glGetIntegerv(). If both fail, fall back to a software renderer or exit. If GLES is detected from glGetString() (for some odd reason - e.g. emulated driver) show a warning and return early as we don't handle it's versioning. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-30desktop-main.cpp: don't validate for custom backendsGravatar Lubomir I. Ivanov
Without this patch the user can pass a custom backend like 'software' and the validation will still be performed. In a case where the validation fails Subsurface will still exit. With this patch the validation is performed *only* for the standard backend which is OpenGL (or an empty QT_QUICK_BACKEND) env. variable. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-29desktop-main.cpp: add verbose output to validateGL()Gravatar Lubomir I. Ivanov
Amend validateGL() with verbose output. Also use QDebug instead of fprintf(). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-29desktop-main.cpp: add validateGL()Gravatar Lubomir I. Ivanov
Add a new static function to validate the availability of OpenGL on this particular desktop system. It makes some calls to create a platform agnostic GL context that renders to a offscreen surface. Then it makes a couple of glGetIntegerv((GL_xxx_VERSION, ...) calls to see if the GL profile version is at least 2.1. In case any of the steps fail, a stderr message is shown and all QtQuick based widgets would be rendered using a software renderer. Testing was done in the case of the Google maps plugin and the fallback seems to work on Windows, but further testing will be required on all OS. For the time being, the automatic fallback is only supported on Qt 5.8.0 or later. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-26Report which files were opened / imported at startGravatar Dirk Hohndel
We only do this in verbose mode to make sure a report contains the information about the existing files used. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26desktop UI: no longer attempt to manually show error notificationsGravatar Dirk Hohndel
report_error() now does this automatically. So all these odd places in which we tried to make sure that we show errors are no longer needed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-01Print Qt version when started in verbose modeGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27Move the fill_computer_list() out of widgetsGravatar Tomaz Canabrava
fill_computer_list() creates a Qt friendly structure that contains all of the necessary information about dive computers and it's devices, and it's needed both in Qml and Widgets to allow the user to download their dives. This patch makes it possible to use the code in QML without duplication. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29Add SPDX header to top level filesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-06Break down MainTab into smaller classesGravatar Tomaz Canabrava
Maintab is one of our most complex classes, and it's something I'm not actually proud of. But it currently works and the idea of splitting it was in my head for quite a while. This is the third or fourth tentative of splitting it, and this time I let the most complex part of it untouched, the Notes and Equipment tab are way too complex to untangle right now on my limited time. A new class 'TabBase' should be used for any new tab that we may create, and added on the MainTab (see the new lines on the MainTab constructor). Also, Extra Info, Information, Photos and Statistics where ported to this new way helping reduce the number of lines and functions on the MainTab quite a bit. Overall this is a step in the right direction for the future. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03Win32: add the --win32log option to log stdout and stderr to filesGravatar Lubomir I. Ivanov
Adding --win32log as the first command line option on Windows will now log all stdout and stderr output to the files subsurface_err.log and subsurface_out.log in the working directory. This change required a new argument 'bool logfile' to be added to: subsurface_console_init() which is defined in all platform files (linux.c, macos.c, etc.) Example usage: subsurface.exe --win32log -v -v -v Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2016-05-02Move the qtTranslator and ssrfTranslator pointers to qt-init.cppGravatar Thiago Macieira
No point in having it defined in each main program's .cpp. Especially since the unit tests don't define them. Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-26Prevent unintentionally running as rootGravatar Robert C. Helling
Some users try to run Subsurface as root for example to get around permission problems with dive computer devices. This is a bad idea since config files get touched as root and then cannot be read as normal user anymore. This patch allows running as root only with verbose option on. We can assume if somebody manages to start subsurface as root this happens from the command line. For some reason, I couldn't get translation working at this stage. Windows version is a stub. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-25Initialize the random number generatorGravatar Miika Turkia
We use random numbers for file names, both temporary filename when creating a zip for divelogs.de upload and for filename on form data for facebook upload. This does not require for true randomness but we still want these to not be constant on each run of Subsurface. Thus we need to initialize the random number generator. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25Start to use the QSettings ObjectWrapperGravatar Tomaz Canabrava
start of the QSettinsg Object Wrapper usage on the code this first patch removes two macros that generated around 200 lines in runtime for something like a quarter of it Basically, whenever we changed anything we called the PreferencesDialog::settingsChanged and connected everythign to that signal, now each setting has it's own changed signal and we can call it directly. The best thing about this approach is that we don't trigger repaints for things that are not directly profile related. ( actually we still do, but the plan is to remove them in due time) this commit breaks correct atualization of the profile (because everything was connected to PreferencesDialog::settingsChanged) and now I need to hunt a bit for the correct connections Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-07desktop-main.cpp: fix unused 'application' variableGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-11-05Untangle Profile from MainTabGravatar Dirk Hohndel
This one was easy. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-05Untangle Profile from MainWindow: edit current profileGravatar Dirk Hohndel
And action can't not just trigger a slot, it can also send a signal. With this there is no reference to the MainWindow left in the profile. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-05Untangle Profile from MainWindow: update main tab via signalGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-05Untangle Profile from MainWindow: refresh displayGravatar Dirk Hohndel
Instead of directly calling into the MainWindow, redirect this via a signal so Subsurface mobile can hook it up as needed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-05Untangle Profile from MainWindow: shortcutsGravatar Dirk Hohndel
This, too, should be done with signals. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-05Untangle Profile from MainWindow: turn off tts/ndl calculationGravatar Dirk Hohndel
I'm not sure we can ever run into this issue anymore since we stop calculating TTS / NDL past 2 hours, but I guess on a fairly slow CPU this still could take too long. But instead of calling into MainWindow let's just change the setting right here and add a signal to show the notification - that way we can use the appropriate way to make such notifications on the mobile app. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-05Untangle Profile from MainWindow: files on command lineGravatar Dirk Hohndel
There's no reason why this should be on the MainWindow widget. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-05Profile: begin untangling from MainWindowGravatar Dirk Hohndel
Use a signal to turn the toolbar on or off. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-30main.cpp -> {android-main, desktop-main}Gravatar Tomaz Canabrava
This is needed to compile both in a single call to make. Also it will help removing some of the mistakes in the current android version: it always created the mainwindow, even without using it for anything, so tons of memory will be freed now for the android version, making it snappier and smoother. This is a necessary move so we don't need to #ifdef all over the place for the two different versions, and imo the changes needed to keep both versions will not be that huge if we keep things in subsurface-core sane. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>