diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-11-02 19:54:34 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-11-02 19:54:34 -0800 |
commit | 8ea7f404574c2ee571d2dde6bb6be3791e962150 (patch) | |
tree | 6a050178bfc71bf10558968f2a3bc0a12d8c525f | |
parent | b273c1b0ca7bfe933e7c83742f1610f6bbe3f4d3 (diff) | |
parent | df7818a9b8495285b4d9812e5d6d50d6f9c08813 (diff) | |
download | subsurface-8ea7f404574c2ee571d2dde6bb6be3791e962150.tar.gz |
Merge branch 'cmakeAndPreferences'
-rw-r--r-- | CMakeLists.txt | 316 | ||||
-rw-r--r-- | desktop-widgets/CMakeLists.txt | 93 | ||||
-rw-r--r-- | desktop-widgets/about.cpp (renamed from qt-ui/about.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/about.h (renamed from qt-ui/about.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/about.ui (renamed from qt-ui/about.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/btdeviceselectiondialog.cpp (renamed from qt-ui/btdeviceselectiondialog.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/btdeviceselectiondialog.h (renamed from qt-ui/btdeviceselectiondialog.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/btdeviceselectiondialog.ui (renamed from qt-ui/btdeviceselectiondialog.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/configuredivecomputerdialog.cpp (renamed from qt-ui/configuredivecomputerdialog.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/configuredivecomputerdialog.h (renamed from qt-ui/configuredivecomputerdialog.h) | 2 | ||||
-rw-r--r-- | desktop-widgets/configuredivecomputerdialog.ui (renamed from qt-ui/configuredivecomputerdialog.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/css/tableviews.css (renamed from qt-ui/css/tableviews.css) | 0 | ||||
-rw-r--r-- | desktop-widgets/divecomponentselection.ui (renamed from qt-ui/divecomponentselection.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/divecomputermanagementdialog.cpp (renamed from qt-ui/divecomputermanagementdialog.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/divecomputermanagementdialog.h (renamed from qt-ui/divecomputermanagementdialog.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/divecomputermanagementdialog.ui (renamed from qt-ui/divecomputermanagementdialog.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/divelistview.cpp (renamed from qt-ui/divelistview.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/divelistview.h (renamed from qt-ui/divelistview.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/divelogexportdialog.cpp (renamed from qt-ui/divelogexportdialog.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/divelogexportdialog.h (renamed from qt-ui/divelogexportdialog.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/divelogexportdialog.ui (renamed from qt-ui/divelogexportdialog.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/divelogimportdialog.cpp (renamed from qt-ui/divelogimportdialog.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/divelogimportdialog.h (renamed from qt-ui/divelogimportdialog.h) | 4 | ||||
-rw-r--r-- | desktop-widgets/divelogimportdialog.ui (renamed from qt-ui/divelogimportdialog.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/divepicturewidget.cpp (renamed from qt-ui/divepicturewidget.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/divepicturewidget.h (renamed from qt-ui/divepicturewidget.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/diveplanner.cpp (renamed from qt-ui/diveplanner.cpp) | 8 | ||||
-rw-r--r-- | desktop-widgets/diveplanner.h (renamed from qt-ui/diveplanner.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/diveplanner.ui (renamed from qt-ui/diveplanner.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/diveshareexportdialog.cpp (renamed from qt-ui/diveshareexportdialog.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/diveshareexportdialog.h (renamed from qt-ui/diveshareexportdialog.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/diveshareexportdialog.ui (renamed from qt-ui/diveshareexportdialog.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/downloadfromdivecomputer.cpp (renamed from qt-ui/downloadfromdivecomputer.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/downloadfromdivecomputer.h (renamed from qt-ui/downloadfromdivecomputer.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/downloadfromdivecomputer.ui (renamed from qt-ui/downloadfromdivecomputer.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/filterwidget.ui (renamed from qt-ui/filterwidget.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/globe.cpp (renamed from qt-ui/globe.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/globe.h (renamed from qt-ui/globe.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/groupedlineedit.cpp (renamed from qt-ui/groupedlineedit.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/groupedlineedit.h (renamed from qt-ui/groupedlineedit.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/kmessagewidget.cpp (renamed from qt-ui/kmessagewidget.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/kmessagewidget.h (renamed from qt-ui/kmessagewidget.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/listfilter.ui (renamed from qt-ui/listfilter.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/locationInformation.ui (renamed from qt-ui/locationInformation.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/locationinformation.cpp (renamed from qt-ui/locationinformation.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/locationinformation.h (renamed from qt-ui/locationinformation.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/maintab.cpp (renamed from qt-ui/maintab.cpp) | 4 | ||||
-rw-r--r-- | desktop-widgets/maintab.h (renamed from qt-ui/maintab.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/maintab.ui (renamed from qt-ui/maintab.ui) | 6 | ||||
-rw-r--r-- | desktop-widgets/mainwindow.cpp (renamed from qt-ui/mainwindow.cpp) | 34 | ||||
-rw-r--r-- | desktop-widgets/mainwindow.h (renamed from qt-ui/mainwindow.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/mainwindow.ui (renamed from qt-ui/mainwindow.ui) | 1 | ||||
-rw-r--r-- | desktop-widgets/marble/GeoDataTreeModel.h (renamed from qt-ui/marble/GeoDataTreeModel.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/modeldelegates.cpp (renamed from qt-ui/modeldelegates.cpp) | 2 | ||||
-rw-r--r-- | desktop-widgets/modeldelegates.h (renamed from qt-ui/modeldelegates.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/notificationwidget.cpp (renamed from qt-ui/notificationwidget.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/notificationwidget.h (renamed from qt-ui/notificationwidget.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/plannerDetails.ui (renamed from qt-ui/plannerDetails.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/plannerSettings.ui (renamed from qt-ui/plannerSettings.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/plugins/CMakeLists.txt | 1 | ||||
-rw-r--r-- | desktop-widgets/plugins/facebook/CMakeLists.txt | 6 | ||||
-rw-r--r-- | desktop-widgets/plugins/facebook/facebook_integration.cpp | 36 | ||||
-rw-r--r-- | desktop-widgets/plugins/facebook/facebook_integration.h | 21 | ||||
-rw-r--r-- | desktop-widgets/preferences.cpp | 173 | ||||
-rw-r--r-- | desktop-widgets/preferences.ui | 241 | ||||
-rw-r--r-- | desktop-widgets/preferences/CMakeLists.txt | 27 | ||||
-rw-r--r-- | desktop-widgets/preferences/abstractpreferenceswidget.cpp | 21 | ||||
-rw-r--r-- | desktop-widgets/preferences/abstractpreferenceswidget.h | 27 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_defaults.cpp | 103 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_defaults.h | 28 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_defaults.ui | 251 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_georeference.cpp | 45 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_georeference.h | 21 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_graph.cpp | 77 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_graph.h | 27 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_graph.ui | 268 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_language.cpp | 72 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_language.h | 21 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_network.cpp | 172 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_network.h | 28 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_network.ui | 293 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_units.cpp | 60 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_units.h | 21 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_units.ui | 251 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferencesdialog.cpp | 140 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferencesdialog.h | 35 | ||||
-rw-r--r-- | desktop-widgets/preferences/prefs_georeference.ui | 123 | ||||
-rw-r--r-- | desktop-widgets/preferences/prefs_language.ui | 260 | ||||
-rw-r--r-- | desktop-widgets/printdialog.cpp (renamed from qt-ui/printdialog.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/printdialog.h (renamed from qt-ui/printdialog.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/printer.cpp (renamed from printer.cpp) | 1 | ||||
-rw-r--r-- | desktop-widgets/printer.h (renamed from printer.h) | 1 | ||||
-rw-r--r-- | desktop-widgets/printoptions.cpp (renamed from qt-ui/printoptions.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/printoptions.h (renamed from qt-ui/printoptions.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/printoptions.ui (renamed from qt-ui/printoptions.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/qtwaitingspinner.cpp (renamed from qt-ui/qtwaitingspinner.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/qtwaitingspinner.h (renamed from qt-ui/qtwaitingspinner.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/renumber.ui (renamed from qt-ui/renumber.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/searchbar.ui (renamed from qt-ui/searchbar.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/setpoint.ui (renamed from qt-ui/setpoint.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/shiftimagetimes.ui (renamed from qt-ui/shiftimagetimes.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/shifttimes.ui (renamed from qt-ui/shifttimes.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/simplewidgets.cpp (renamed from qt-ui/simplewidgets.cpp) | 2 | ||||
-rw-r--r-- | desktop-widgets/simplewidgets.h (renamed from qt-ui/simplewidgets.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/socialnetworks.cpp (renamed from qt-ui/socialnetworks.cpp) | 2 | ||||
-rw-r--r-- | desktop-widgets/socialnetworks.h (renamed from qt-ui/socialnetworks.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/socialnetworksdialog.ui (renamed from qt-ui/socialnetworksdialog.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/starwidget.cpp (renamed from qt-ui/starwidget.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/starwidget.h (renamed from qt-ui/starwidget.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/statistics/monthstatistics.cpp (renamed from qt-ui/statistics/monthstatistics.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/statistics/monthstatistics.h (renamed from qt-ui/statistics/monthstatistics.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/statistics/statisticsbar.cpp (renamed from qt-ui/statistics/statisticsbar.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/statistics/statisticsbar.h (renamed from qt-ui/statistics/statisticsbar.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/statistics/statisticswidget.cpp (renamed from qt-ui/statistics/statisticswidget.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/statistics/statisticswidget.h (renamed from qt-ui/statistics/statisticswidget.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/statistics/yearstatistics.cpp (renamed from qt-ui/statistics/yearstatistics.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/statistics/yearstatistics.h (renamed from qt-ui/statistics/yearstatistics.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/subsurfacewebservices.cpp (renamed from qt-ui/subsurfacewebservices.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/subsurfacewebservices.h (renamed from qt-ui/subsurfacewebservices.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/tableview.cpp (renamed from qt-ui/tableview.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/tableview.h (renamed from qt-ui/tableview.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/tableview.ui (renamed from qt-ui/tableview.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/tagwidget.cpp (renamed from qt-ui/tagwidget.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/tagwidget.h (renamed from qt-ui/tagwidget.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/templateedit.cpp (renamed from qt-ui/templateedit.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/templateedit.h (renamed from qt-ui/templateedit.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/templateedit.ui (renamed from qt-ui/templateedit.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/templatelayout.cpp (renamed from templatelayout.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/templatelayout.h (renamed from templatelayout.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/undocommands.cpp (renamed from qt-ui/undocommands.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/undocommands.h (renamed from qt-ui/undocommands.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/updatemanager.cpp (renamed from qt-ui/updatemanager.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/updatemanager.h (renamed from qt-ui/updatemanager.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/urldialog.ui (renamed from qt-ui/urldialog.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/usermanual.cpp (renamed from qt-ui/usermanual.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/usermanual.h (renamed from qt-ui/usermanual.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/usersurvey.cpp (renamed from qt-ui/usersurvey.cpp) | 0 | ||||
-rw-r--r-- | desktop-widgets/usersurvey.h (renamed from qt-ui/usersurvey.h) | 0 | ||||
-rw-r--r-- | desktop-widgets/usersurvey.ui (renamed from qt-ui/usersurvey.ui) | 0 | ||||
-rw-r--r-- | desktop-widgets/webservices.ui (renamed from qt-ui/webservices.ui) | 0 | ||||
-rw-r--r-- | icons/satellite.svg (renamed from satellite.svg) | 0 | ||||
-rw-r--r-- | icons/subsurface-icon.svg (renamed from subsurface-icon.svg) | 0 | ||||
-rw-r--r-- | icons/subsurface-mobile-icon.svg (renamed from subsurface-mobile-icon.svg) | 0 | ||||
-rw-r--r-- | profile-widget/CMakeLists.txt | 19 | ||||
-rw-r--r-- | profile-widget/animationfunctions.cpp (renamed from qt-ui/profile/animationfunctions.cpp) | 0 | ||||
-rw-r--r-- | profile-widget/animationfunctions.h (renamed from qt-ui/profile/animationfunctions.h) | 0 | ||||
-rw-r--r-- | profile-widget/divecartesianaxis.cpp (renamed from qt-ui/profile/divecartesianaxis.cpp) | 2 | ||||
-rw-r--r-- | profile-widget/divecartesianaxis.h (renamed from qt-ui/profile/divecartesianaxis.h) | 2 | ||||
-rw-r--r-- | profile-widget/diveeventitem.cpp (renamed from qt-ui/profile/diveeventitem.cpp) | 0 | ||||
-rw-r--r-- | profile-widget/diveeventitem.h (renamed from qt-ui/profile/diveeventitem.h) | 0 | ||||
-rw-r--r-- | profile-widget/divelineitem.cpp (renamed from qt-ui/profile/divelineitem.cpp) | 0 | ||||
-rw-r--r-- | profile-widget/divelineitem.h (renamed from qt-ui/profile/divelineitem.h) | 0 | ||||
-rw-r--r-- | profile-widget/divepixmapitem.cpp (renamed from qt-ui/profile/divepixmapitem.cpp) | 2 | ||||
-rw-r--r-- | profile-widget/divepixmapitem.h (renamed from qt-ui/profile/divepixmapitem.h) | 0 | ||||
-rw-r--r-- | profile-widget/diveprofileitem.cpp (renamed from qt-ui/profile/diveprofileitem.cpp) | 4 | ||||
-rw-r--r-- | profile-widget/diveprofileitem.h (renamed from qt-ui/profile/diveprofileitem.h) | 1 | ||||
-rw-r--r-- | profile-widget/diverectitem.cpp (renamed from qt-ui/profile/diverectitem.cpp) | 0 | ||||
-rw-r--r-- | profile-widget/diverectitem.h (renamed from qt-ui/profile/diverectitem.h) | 0 | ||||
-rw-r--r-- | profile-widget/divetextitem.cpp (renamed from qt-ui/profile/divetextitem.cpp) | 3 | ||||
-rw-r--r-- | profile-widget/divetextitem.h (renamed from qt-ui/profile/divetextitem.h) | 4 | ||||
-rw-r--r-- | profile-widget/divetooltipitem.cpp (renamed from qt-ui/profile/divetooltipitem.cpp) | 0 | ||||
-rw-r--r-- | profile-widget/divetooltipitem.h (renamed from qt-ui/profile/divetooltipitem.h) | 0 | ||||
-rw-r--r-- | profile-widget/profilewidget2.cpp (renamed from qt-ui/profile/profilewidget2.cpp) | 2 | ||||
-rw-r--r-- | profile-widget/profilewidget2.h (renamed from qt-ui/profile/profilewidget2.h) | 1 | ||||
-rw-r--r-- | profile-widget/ruleritem.cpp (renamed from qt-ui/profile/ruleritem.cpp) | 2 | ||||
-rw-r--r-- | profile-widget/ruleritem.h (renamed from qt-ui/profile/ruleritem.h) | 0 | ||||
-rw-r--r-- | profile-widget/tankitem.cpp (renamed from qt-ui/profile/tankitem.cpp) | 0 | ||||
-rw-r--r-- | profile-widget/tankitem.h (renamed from qt-ui/profile/tankitem.h) | 0 | ||||
-rw-r--r-- | qt-models/CMakeLists.txt | 29 | ||||
-rw-r--r-- | qt-models/completionmodels.cpp | 3 | ||||
-rw-r--r-- | qt-models/diveplotdatamodel.cpp | 2 | ||||
-rw-r--r-- | qt-models/filtermodels.cpp | 15 | ||||
-rw-r--r-- | qt-models/models.h | 6 | ||||
-rw-r--r-- | qt-ui/graphicsview-common.h | 94 | ||||
-rw-r--r-- | qt-ui/preferences.cpp | 559 | ||||
-rw-r--r-- | qt-ui/preferences.h | 54 | ||||
-rw-r--r-- | qt-ui/preferences.ui | 1883 | ||||
-rw-r--r-- | subsurface-android-helper.cpp (renamed from qt-gui.cpp) | 21 | ||||
-rw-r--r-- | subsurface-android-main.cpp | 81 | ||||
-rw-r--r-- | subsurface-core/CMakeLists.txt | 84 | ||||
-rw-r--r-- | subsurface-core/android.cpp (renamed from android.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/checkcloudconnection.cpp (renamed from checkcloudconnection.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/checkcloudconnection.h (renamed from checkcloudconnection.h) | 0 | ||||
-rw-r--r-- | subsurface-core/cochran.c (renamed from cochran.c) | 0 | ||||
-rw-r--r-- | subsurface-core/cochran.h (renamed from cochran.h) | 0 | ||||
-rw-r--r-- | subsurface-core/color.cpp (renamed from qt-ui/graphicsview-common.cpp) | 2 | ||||
-rw-r--r-- | subsurface-core/color.h (renamed from color.h) | 85 | ||||
-rw-r--r-- | subsurface-core/configuredivecomputer.cpp (renamed from configuredivecomputer.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/configuredivecomputer.h (renamed from configuredivecomputer.h) | 0 | ||||
-rw-r--r-- | subsurface-core/configuredivecomputerthreads.cpp (renamed from configuredivecomputerthreads.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/configuredivecomputerthreads.h (renamed from configuredivecomputerthreads.h) | 0 | ||||
-rw-r--r-- | subsurface-core/datatrak.c (renamed from datatrak.c) | 0 | ||||
-rw-r--r-- | subsurface-core/datatrak.h (renamed from datatrak.h) | 0 | ||||
-rw-r--r-- | subsurface-core/deco.c (renamed from deco.c) | 0 | ||||
-rw-r--r-- | subsurface-core/deco.h (renamed from deco.h) | 0 | ||||
-rw-r--r-- | subsurface-core/device.c (renamed from device.c) | 0 | ||||
-rw-r--r-- | subsurface-core/device.h (renamed from device.h) | 0 | ||||
-rw-r--r-- | subsurface-core/devicedetails.cpp (renamed from devicedetails.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/devicedetails.h (renamed from devicedetails.h) | 0 | ||||
-rw-r--r-- | subsurface-core/display.h (renamed from display.h) | 0 | ||||
-rw-r--r-- | subsurface-core/dive.c (renamed from dive.c) | 0 | ||||
-rw-r--r-- | subsurface-core/dive.h (renamed from dive.h) | 0 | ||||
-rw-r--r-- | subsurface-core/divecomputer.cpp (renamed from divecomputer.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/divecomputer.h (renamed from divecomputer.h) | 0 | ||||
-rw-r--r-- | subsurface-core/divelist.c (renamed from divelist.c) | 0 | ||||
-rw-r--r-- | subsurface-core/divelist.h (renamed from divelist.h) | 0 | ||||
-rw-r--r-- | subsurface-core/divelogexportlogic.cpp (renamed from divelogexportlogic.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/divelogexportlogic.h (renamed from divelogexportlogic.h) | 0 | ||||
-rw-r--r-- | subsurface-core/divesite.c (renamed from divesite.c) | 0 | ||||
-rw-r--r-- | subsurface-core/divesite.cpp (renamed from divesite.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/divesite.h (renamed from divesite.h) | 0 | ||||
-rw-r--r-- | subsurface-core/divesitehelpers.cpp (renamed from divesitehelpers.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/divesitehelpers.h (renamed from divesitehelpers.h) | 0 | ||||
-rw-r--r-- | subsurface-core/equipment.c (renamed from equipment.c) | 0 | ||||
-rw-r--r-- | subsurface-core/exif.cpp (renamed from exif.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/exif.h (renamed from exif.h) | 0 | ||||
-rw-r--r-- | subsurface-core/file.c (renamed from file.c) | 0 | ||||
-rw-r--r-- | subsurface-core/file.h (renamed from file.h) | 0 | ||||
-rw-r--r-- | subsurface-core/gaspressures.c (renamed from gaspressures.c) | 0 | ||||
-rw-r--r-- | subsurface-core/gaspressures.h (renamed from gaspressures.h) | 0 | ||||
-rw-r--r-- | subsurface-core/gettext.h (renamed from gettext.h) | 0 | ||||
-rw-r--r-- | subsurface-core/gettextfromc.cpp (renamed from gettextfromc.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/gettextfromc.h (renamed from gettextfromc.h) | 0 | ||||
-rw-r--r-- | subsurface-core/git-access.c (renamed from git-access.c) | 0 | ||||
-rw-r--r-- | subsurface-core/git-access.h (renamed from git-access.h) | 0 | ||||
-rw-r--r-- | subsurface-core/helpers.h (renamed from helpers.h) | 1 | ||||
-rw-r--r-- | subsurface-core/isocialnetworkintegration.h | 72 | ||||
-rw-r--r-- | subsurface-core/libdivecomputer.c (renamed from libdivecomputer.c) | 0 | ||||
-rw-r--r-- | subsurface-core/libdivecomputer.h (renamed from libdivecomputer.h) | 0 | ||||
-rw-r--r-- | subsurface-core/linux.c (renamed from linux.c) | 0 | ||||
-rw-r--r-- | subsurface-core/liquivision.c (renamed from liquivision.c) | 0 | ||||
-rw-r--r-- | subsurface-core/load-git.c (renamed from load-git.c) | 0 | ||||
-rw-r--r-- | subsurface-core/macos.c (renamed from macos.c) | 0 | ||||
-rw-r--r-- | subsurface-core/membuffer.c (renamed from membuffer.c) | 0 | ||||
-rw-r--r-- | subsurface-core/membuffer.h (renamed from membuffer.h) | 0 | ||||
-rw-r--r-- | subsurface-core/metrics.cpp (renamed from qt-ui/metrics.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/metrics.h (renamed from qt-ui/metrics.h) | 0 | ||||
-rw-r--r-- | subsurface-core/ostctools.c (renamed from ostctools.c) | 0 | ||||
-rw-r--r-- | subsurface-core/parse-xml.c (renamed from parse-xml.c) | 0 | ||||
-rw-r--r-- | subsurface-core/planner.c (renamed from planner.c) | 0 | ||||
-rw-r--r-- | subsurface-core/planner.h (renamed from planner.h) | 0 | ||||
-rw-r--r-- | subsurface-core/pluginmanager.cpp | 51 | ||||
-rw-r--r-- | subsurface-core/pluginmanager.h | 19 | ||||
-rw-r--r-- | subsurface-core/pref.h (renamed from pref.h) | 5 | ||||
-rw-r--r-- | subsurface-core/prefs-macros.h (renamed from prefs-macros.h) | 0 | ||||
-rw-r--r-- | subsurface-core/profile.c (renamed from profile.c) | 0 | ||||
-rw-r--r-- | subsurface-core/profile.h (renamed from profile.h) | 0 | ||||
-rw-r--r-- | subsurface-core/qt-gui.h (renamed from qt-gui.h) | 0 | ||||
-rw-r--r-- | subsurface-core/qt-init.cpp (renamed from qt-init.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/qthelper.cpp (renamed from qthelper.cpp) | 65 | ||||
-rw-r--r-- | subsurface-core/qthelper.h (renamed from qthelper.h) | 0 | ||||
-rw-r--r-- | subsurface-core/qthelperfromc.h (renamed from qthelperfromc.h) | 0 | ||||
-rw-r--r-- | subsurface-core/qtserialbluetooth.cpp (renamed from qtserialbluetooth.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/save-git.c (renamed from save-git.c) | 0 | ||||
-rw-r--r-- | subsurface-core/save-html.c (renamed from save-html.c) | 0 | ||||
-rw-r--r-- | subsurface-core/save-html.h (renamed from save-html.h) | 0 | ||||
-rw-r--r-- | subsurface-core/save-xml.c (renamed from save-xml.c) | 0 | ||||
-rw-r--r-- | subsurface-core/serial_ftdi.c (renamed from serial_ftdi.c) | 0 | ||||
-rw-r--r-- | subsurface-core/sha1.c (renamed from sha1.c) | 0 | ||||
-rw-r--r-- | subsurface-core/sha1.h (renamed from sha1.h) | 0 | ||||
-rw-r--r-- | subsurface-core/statistics.c (renamed from statistics.c) | 0 | ||||
-rw-r--r-- | subsurface-core/statistics.h (renamed from statistics.h) | 0 | ||||
-rw-r--r-- | subsurface-core/strndup.h (renamed from strndup.h) | 0 | ||||
-rw-r--r-- | subsurface-core/strtod.c (renamed from strtod.c) | 0 | ||||
-rw-r--r-- | subsurface-core/subsurfacestartup.c (renamed from subsurfacestartup.c) | 3 | ||||
-rw-r--r-- | subsurface-core/subsurfacestartup.h (renamed from subsurfacestartup.h) | 0 | ||||
-rw-r--r-- | subsurface-core/subsurfacesysinfo.cpp (renamed from subsurfacesysinfo.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/subsurfacesysinfo.h (renamed from subsurfacesysinfo.h) | 0 | ||||
-rw-r--r-- | subsurface-core/taxonomy.c (renamed from taxonomy.c) | 0 | ||||
-rw-r--r-- | subsurface-core/taxonomy.h (renamed from taxonomy.h) | 0 | ||||
-rw-r--r-- | subsurface-core/time.c (renamed from time.c) | 0 | ||||
-rw-r--r-- | subsurface-core/uemis-downloader.c (renamed from uemis-downloader.c) | 0 | ||||
-rw-r--r-- | subsurface-core/uemis.c (renamed from uemis.c) | 0 | ||||
-rw-r--r-- | subsurface-core/uemis.h (renamed from uemis.h) | 0 | ||||
-rw-r--r-- | subsurface-core/units.h (renamed from units.h) | 0 | ||||
-rw-r--r-- | subsurface-core/version.c (renamed from version.c) | 0 | ||||
-rw-r--r-- | subsurface-core/version.h (renamed from version.h) | 0 | ||||
-rw-r--r-- | subsurface-core/webservice.h (renamed from webservice.h) | 0 | ||||
-rw-r--r-- | subsurface-core/windows.c (renamed from windows.c) | 0 | ||||
-rw-r--r-- | subsurface-core/windowtitleupdate.cpp (renamed from windowtitleupdate.cpp) | 0 | ||||
-rw-r--r-- | subsurface-core/windowtitleupdate.h (renamed from windowtitleupdate.h) | 0 | ||||
-rw-r--r-- | subsurface-core/worldmap-options.h (renamed from worldmap-options.h) | 0 | ||||
-rw-r--r-- | subsurface-core/worldmap-save.c (renamed from worldmap-save.c) | 0 | ||||
-rw-r--r-- | subsurface-core/worldmap-save.h (renamed from worldmap-save.h) | 0 | ||||
-rw-r--r-- | subsurface-desktop-helper.cpp | 65 | ||||
-rw-r--r-- | subsurface-desktop-main.cpp (renamed from main.cpp) | 6 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 28 |
287 files changed, 3678 insertions, 2922 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ae1e9b45..9d9cb1f60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ project(Subsurface) cmake_minimum_required(VERSION 2.8.11) + # global settings set(CMAKE_AUTOMOC ON) @@ -11,8 +12,8 @@ option(LIBGIT2_FROM_PKGCONFIG "use pkg-config to retrieve libgit2" OFF) option(LIBDC_FROM_PKGCONFIG "use pkg-config to retrieve libdivecomputer" OFF) option(LIBGRANTLEE_FROM_PKGCONFIG "use pkg-config to retrieve grantlee" OFF) option(LIBMARBLE_FROM_PKGCONFIG "use pkg-config to retrieve marble" OFF) +option(MAKE_TESTS "Make the tests" ON) option(NO_MARBLE "disable the marble widget" OFF) -option(NO_TESTS "disable the tests" OFF) option(NO_DOCS "disable the docs" OFF) option(NO_PRINTING "disable the printing support" OFF) option(NO_USERMANUAL "don't include a viewer for the user manual" OFF) @@ -23,6 +24,12 @@ option(FBSUPPORT "allow posting to Facebook" ON) option(BTSUPPORT "enable support for QtBluetooth (requires Qt5.4 or newer)" ON) option(FTDISUPPORT "enable support for libftdi based serial" OFF) +add_definitions(-DSUBSURFACE_SOURCE="${CMAKE_SOURCE_DIR}") + +if(BTSUPPORT) + add_definitions(-DBT_SUPPORT) +endif() + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${${PROJECT_NAME}_SOURCE_DIR}/cmake/Modules @@ -31,9 +38,11 @@ set(CMAKE_MODULE_PATH include_directories(. ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR} - qt-ui + ${CMAKE_BINARY_DIR}/desktop-widgets + desktop-widgets/ qt-models - qt-ui/profile + desktop-widgets/profile + subsurface-core/ ) # get the version string -- this is only used for Mac Bundle at this point @@ -47,9 +56,19 @@ execute_process( message(STATUS "Creating build files for Subsurface ${SSRF_VERSION_STRING}") -# compiler specific settings -if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 ") +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 ") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 ") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + # using Intel C++ +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + # using Visual Studio C++ endif() # pkgconfig for required libraries @@ -136,7 +155,6 @@ if(FTDISUPPORT) if (NOT LIBFTDI_FOUND) pkg_config_library(LIBFTDI libftdi1 REQUIRED) endif() - set(SERIAL_FTDI serial_ftdi.c) add_definitions(-DSERIAL_FTDI) endif() @@ -159,13 +177,6 @@ else() find_package(Grantlee5 REQUIRED) set(GRANTLEE_LIBRARIES Grantlee5::Templates) endif() - set(SUBSURFACE_PRINTING_SRCS - printer.cpp - templatelayout.cpp - qt-ui/templateedit.cpp - qt-ui/printdialog.cpp - qt-ui/printoptions.cpp - ) set(PRINTING_PKG PrintSupport) set(PRINTING_LIB Qt5::PrintSupport) endif() @@ -174,7 +185,6 @@ if(NO_USERMANUAL) message(STATUS "building without usermanual") add_definitions(-DNO_USERMANUAL) else() - set(USERMANUAL qt-ui/usermanual.cpp) set(WEBKIT_PKG WebKitWidgets) set(WEBKIT_LIB Qt5::WebKitWidgets) endif() @@ -273,22 +283,18 @@ add_custom_target( ) # set up the different target platforms -set(PLATFORM_SRC unknown_platform.c) if(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(SUBSURFACE_TARGET subsurface) - set(PLATFORM_SRC linux.c) # in some builds we appear to be missing libz for some strange reason... set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lz) endif() if(ANDROID) - set(PLATFORM_SRC android.cpp) set(SUBSURFACE_TARGET subsurface) # To allow us to debug log to logcat set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -llog) endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(SUBSURFACE_TARGET Subsurface) - set(PLATFORM_SRC macos.c) find_library(APP_SERVICES_LIBRARY ApplicationServices) find_library(HID_LIB HidApi) set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${HID_LIB}) @@ -307,200 +313,35 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() if(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(SUBSURFACE_TARGET subsurface) - set(PLATFORM_SRC windows.c) set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lwsock32 -lws2_32) remove_definitions(-DUNICODE) add_definitions(-mwindows -D_WIN32) endif() +qt5_add_resources(SUBSURFACE_RESOURCES subsurface.qrc) + # include translations add_subdirectory(translations) - -if(BTSUPPORT) - add_definitions(-DBT_SUPPORT) - set(BT_SRC_FILES qt-ui/btdeviceselectiondialog.cpp) - set(BT_CORE_SRC_FILES qtserialbluetooth.cpp) -endif() - -# compile the core library, in C. -set(SUBSURFACE_CORE_LIB_SRCS - cochran.c - datatrak.c - deco.c - device.c - dive.c - divesite.c - divesite.cpp # some new stuff that is not c code but belongs to divesite. - divelist.c - equipment.c - file.c - git-access.c - libdivecomputer.c - liquivision.c - load-git.c - membuffer.c - ostctools.c - parse-xml.c - planner.c - profile.c - gaspressures.c - worldmap-save.c - save-git.c - save-xml.c - save-html.c - sha1.c - statistics.c - strtod.c - subsurfacestartup.c - time.c - uemis.c - uemis-downloader.c - version.c - # gettextfrommoc should be added because we are using it on the c-code. - gettextfromc.cpp - # dirk ported some core functionality to c++. - qthelper.cpp - divecomputer.cpp - exif.cpp - subsurfacesysinfo.cpp - devicedetails.cpp - configuredivecomputer.cpp - configuredivecomputerthreads.cpp - divesitehelpers.cpp - taxonomy.c - checkcloudconnection.cpp - windowtitleupdate.cpp - divelogexportlogic.cpp - qt-init.cpp - ${BT_CORE_SRC_FILES} - ${SERIAL_FTDI} - ${PLATFORM_SRC} -) -source_group("Subsurface Core" FILES ${SUBSURFACE_CORE_LIB_SRCS}) +add_subdirectory(subsurface-core) +add_subdirectory(qt-models) +add_subdirectory(profile-widget) +add_subdirectory(desktop-widgets) if(FBSUPPORT) add_definitions(-DFBSUPPORT) - set(SOCIALNETWORKS qt-ui/socialnetworks.cpp) -endif() - -# the data models that will interface -# with the views. -set(SUBSURFACE_MODELS_LIB_SRCS - qt-models/cleanertablemodel.cpp - qt-models/cylindermodel.cpp - qt-models/diveplannermodel.cpp - qt-models/models.cpp - qt-models/filtermodels.cpp - qt-models/tankinfomodel.cpp - qt-models/weigthsysteminfomodel.cpp - qt-models/weightmodel.cpp - qt-models/divecomputermodel.cpp - qt-models/treemodel.cpp - qt-models/tableprintmodel.cpp - qt-models/yearlystatisticsmodel.cpp - qt-models/divetripmodel.cpp - qt-models/divecomputerextradatamodel.cpp - qt-models/completionmodels.cpp - qt-models/profileprintmodel.cpp - qt-models/divepicturemodel.cpp - qt-models/diveplotdatamodel.cpp - qt-models/divelocationmodel.cpp - qt-models/divesitepicturesmodel.cpp - qt-models/ssrfsortfilterproxymodel.cpp -) -source_group("Subsurface Models" FILES ${SUBSURFACE_MODELS}) - -# the interface, in C++ -set(SUBSURFACE_INTERFACE - qt-ui/updatemanager.cpp - qt-ui/about.cpp - qt-ui/divecomputermanagementdialog.cpp - qt-ui/divelistview.cpp - qt-ui/diveplanner.cpp - qt-ui/diveshareexportdialog.cpp - qt-ui/downloadfromdivecomputer.cpp - qt-ui/globe.cpp - qt-ui/graphicsview-common.cpp - qt-ui/kmessagewidget.cpp - qt-ui/maintab.cpp - qt-ui/mainwindow.cpp - qt-ui/modeldelegates.cpp - qt-ui/metrics.cpp - qt-ui/notificationwidget.cpp - qt-ui/preferences.cpp - qt-ui/simplewidgets.cpp - qt-ui/starwidget.cpp - qt-ui/subsurfacewebservices.cpp - qt-ui/tableview.cpp - qt-ui/divelogimportdialog.cpp - qt-ui/tagwidget.cpp - qt-ui/groupedlineedit.cpp - ${USERMANUAL} - qt-ui/divelogexportdialog.cpp - qt-ui/divepicturewidget.cpp - qt-ui/usersurvey.cpp - qt-ui/configuredivecomputerdialog.cpp - qt-ui/undocommands.cpp - qt-ui/locationinformation.cpp - qt-ui/qtwaitingspinner.cpp - ${SUBSURFACE_PRINTING_SRCS} - ${SOCIALNETWORKS} - ${BT_SRC_FILES} -) -source_group("Subsurface Interface" FILES ${SUBSURFACE_INTERFACE}) - -# the profile widget -set(SUBSURFACE_PROFILE_LIB_SRCS - qt-ui/profile/profilewidget2.cpp - qt-ui/profile/diverectitem.cpp - qt-ui/profile/divepixmapitem.cpp - qt-ui/profile/divelineitem.cpp - qt-ui/profile/divetextitem.cpp - qt-ui/profile/animationfunctions.cpp - qt-ui/profile/divecartesianaxis.cpp - qt-ui/profile/diveprofileitem.cpp - qt-ui/profile/diveeventitem.cpp - qt-ui/profile/divetooltipitem.cpp - qt-ui/profile/ruleritem.cpp - qt-ui/profile/tankitem.cpp -) -source_group("Subsurface Profile" FILES ${SUBSURFACE_PROFILE_LIB_SRCS}) - -# the yearly statistics widget. -set(SUBSURFACE_STATISTICS_LIB_SRCS - qt-ui/statistics/statisticswidget.cpp - qt-ui/statistics/yearstatistics.cpp - qt-ui/statistics/statisticsbar.cpp - qt-ui/statistics/monthstatistics.cpp -) -source_group("Subsurface Statistics" FILES ${SUBSURFACE_STATISTICS_LIB_SRCS}) +endif() + +if(BTSUPPORT) + add_definitions(-DBT_SUPPORT) +endif() # the main app. set(SUBSURFACE_APP - main.cpp - qt-gui.cpp - qthelper.cpp + subsurface-desktop-main.cpp + subsurface-desktop-helper.cpp ) -source_group("Subsurface App" FILES ${SUBSURFACE_APP}) -# create the libraries -file(GLOB SUBSURFACE_UI qt-ui/*.ui) -qt5_wrap_ui(SUBSURFACE_UI_HDRS ${SUBSURFACE_UI}) -qt5_add_resources(SUBSURFACE_RESOURCES subsurface.qrc) -source_group("Subsurface Interface Files" FILES ${SUBSURFACE_UI}) - -add_library(subsurface_corelib STATIC ${SUBSURFACE_CORE_LIB_SRCS} ) -target_link_libraries(subsurface_corelib ${QT_LIBRARIES}) -add_library(subsurface_models STATIC ${SUBSURFACE_MODELS_LIB_SRCS}) -target_link_libraries(subsurface_models ${QT_LIBRARIES}) -add_library(subsurface_profile STATIC ${SUBSURFACE_PROFILE_LIB_SRCS}) -target_link_libraries(subsurface_profile ${QT_LIBRARIES}) -add_library(subsurface_statistics STATIC ${SUBSURFACE_STATISTICS_LIB_SRCS}) -target_link_libraries(subsurface_statistics ${QT_LIBRARIES}) -add_library(subsurface_generated_ui STATIC ${SUBSURFACE_UI_HDRS}) -target_link_libraries(subsurface_generated_ui ${QT_LIBRARIES}) -add_library(subsurface_interface STATIC ${SUBSURFACE_INTERFACE}) -target_link_libraries(subsurface_interface ${QT_LIBRARIES} ${MARBLE_LIBRARIES}) +source_group("Subsurface App" FILES ${SUBSURFACE_APP}) # add pthread to the end of the library list on Linux # this is only needed on Ubuntu (why do these idiots break everything?) @@ -511,13 +352,19 @@ endif() # create the executables if(SUBSURFACE_MOBILE) - set(MOBILE_SRC qt-mobile/qmlmanager.cpp qt-mobile/qmlprofile.cpp qt-models/divelistmodel.cpp) + set(MOBILE_SRC + qt-mobile/qmlmanager.cpp + qt-mobile/qmlprofile.cpp + qt-models/divelistmodel.cpp + subsurface-android-main.cpp + subsurface-android-helper.cpp + ) add_definitions(-DSUBSURFACE_MOBILE) qt5_add_resources(MOBILE_RESOURCES qt-mobile/mobile-resources.qrc) if(ANDROID) - add_library(subsurface-mobile SHARED ${MOBILE_SRC} ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES}) + add_library(subsurface-mobile SHARED ${MOBILE_SRC} ${SUBSURFACE_PKG} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES}) else() - add_executable(subsurface-mobile ${MOBILE_SRC} ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES}) + add_executable(subsurface-mobile ${MOBILE_SRC} ${SUBSURFACE_PKG} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES}) endif() target_link_libraries( subsurface-mobile @@ -528,25 +375,26 @@ if(SUBSURFACE_MOBILE) subsurface_models subsurface_corelib ${SUBSURFACE_LINK_LIBRARIES}) +endif() + +if(ANDROID) + # Produce a shared-library instead of a program. + # Something that androiddeployqt can work with. + # this is the desktop version, running on android. + add_library(${SUBSURFACE_TARGET} SHARED ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES}) else() - if(ANDROID) - # Produce a shared-library instead of a program. - # Something that androiddeployqt can work with. - add_library(${SUBSURFACE_TARGET} SHARED ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES}) - else() - add_executable(${SUBSURFACE_TARGET} MACOSX_BUNDLE WIN32 ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES}) - endif() - target_link_libraries( - ${SUBSURFACE_TARGET} - subsurface_generated_ui - subsurface_interface - subsurface_profile - subsurface_statistics - subsurface_models - subsurface_corelib - ${SUBSURFACE_LINK_LIBRARIES} -) + add_executable(${SUBSURFACE_TARGET} MACOSX_BUNDLE WIN32 ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES}) endif() +target_link_libraries( + ${SUBSURFACE_TARGET} + subsurface_generated_ui + subsurface_interface + subsurface_profile + subsurface_statistics + subsurface_models + subsurface_corelib + ${SUBSURFACE_LINK_LIBRARIES} +) add_dependencies(subsurface_statistics subsurface_generated_ui) add_dependencies(subsurface_profile subsurface_generated_ui) @@ -568,32 +416,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows") endif() # build an automated html exporter -add_executable(export-html EXCLUDE_FROM_ALL export-html.cpp qt-init.cpp qthelper.cpp ${SUBSURFACE_RESOURCES}) +add_executable(export-html EXCLUDE_FROM_ALL export-html.cpp ${SUBSURFACE_RESOURCES}) target_link_libraries(export-html subsurface_corelib ${SUBSURFACE_LINK_LIBRARIES}) -# QTest based tests -macro(TEST NAME FILE) - add_executable(${NAME} EXCLUDE_FROM_ALL tests/${FILE} ${SUBSURFACE_RESOURCES}) - target_link_libraries(${NAME} subsurface_corelib ${QT_TEST_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES}) - add_test(NAME ${NAME}_build COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${NAME}) - add_test(NAME ${NAME}_run COMMAND ${NAME}) - set_tests_properties(${NAME}_run PROPERTIES DEPENDS ${NAME}_build) -endmacro() - -add_definitions(-DSUBSURFACE_SOURCE="${CMAKE_SOURCE_DIR}") -add_definitions(-g) -if(NOT NO_TESTS) - enable_testing() - TEST(TestUnitConversion testunitconversion.cpp) - TEST(TestProfile testprofile.cpp) - TEST(TestGpsCoords testgpscoords.cpp) - TEST(TestParse testparse.cpp) - TEST(TestPlan testplan.cpp) - TEST(TestDiveSiteDuplication testdivesiteduplication.cpp) - TEST(TestRenumber testrenumber.cpp) - TEST(TestGitStorage testgitstorage.cpp) -endif() - # install a few things so that one can run Subsurface from the build # directory if(NOT insource) @@ -804,7 +629,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") install(DIRECTORY marbledata/bitmaps DESTINATION share/subsurface/data) install(FILES subsurface.debug DESTINATION bin) install(FILES subsurface.desktop DESTINATION share/applications) - install(FILES subsurface-icon.svg DESTINATION share/icons/hicolor/scalable/apps) + install(FILES icons/subsurface-icon.svg DESTINATION share/icons/hicolor/scalable/apps) install(DIRECTORY Documentation/images DESTINATION share/subsurface/Documentation) install(FILES ${DOCFILES} DESTINATION share/subsurface/Documentation) install(DIRECTORY theme DESTINATION share/subsurface) @@ -822,7 +647,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") ) endif() endif() + # get_cmake_property(_variableNames VARIABLES) # foreach (_variableName ${_variableNames}) # message(STATUS "${_variableName}=${${_variableName}}") # endforeach() + +if (MAKE_TESTS) + add_subdirectory(tests) +endif() diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt new file mode 100644 index 000000000..0a0059ee3 --- /dev/null +++ b/desktop-widgets/CMakeLists.txt @@ -0,0 +1,93 @@ +# create the libraries +file(GLOB SUBSURFACE_UI *.ui) +qt5_wrap_ui(SUBSURFACE_UI_HDRS ${SUBSURFACE_UI}) +source_group("Subsurface Interface Files" FILES ${SUBSURFACE_UI}) + +if(BTSUPPORT) + set(BT_SRC_FILES btdeviceselectiondialog.cpp) +endif() + +include_directories(. + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} +) + +add_subdirectory(preferences) +add_subdirectory(plugins) + +# the interface, in C++ +set(SUBSURFACE_INTERFACE + updatemanager.cpp + about.cpp + divecomputermanagementdialog.cpp + divelistview.cpp + diveplanner.cpp + diveshareexportdialog.cpp + downloadfromdivecomputer.cpp + globe.cpp + kmessagewidget.cpp + maintab.cpp + mainwindow.cpp + modeldelegates.cpp + notificationwidget.cpp + simplewidgets.cpp + starwidget.cpp + subsurfacewebservices.cpp + tableview.cpp + divelogimportdialog.cpp + tagwidget.cpp + groupedlineedit.cpp + divelogexportdialog.cpp + divepicturewidget.cpp + usersurvey.cpp + configuredivecomputerdialog.cpp + undocommands.cpp + locationinformation.cpp + qtwaitingspinner.cpp +) + +if(NOT NO_USERMANUAL) + set(SUBSURFACE_INTERFACE ${SUBSURFACE_INTERFACE} + usermanual.cpp + ) +endif() + +if(NOT NO_PRINTING) + set(SUBSURFACE_INTERFACE ${SUBSURFACE_INTERFACE} + templateedit.cpp + printdialog.cpp + printoptions.cpp + printer.cpp + templatelayout.cpp + ) +endif() + +if (FBSUPPORT) + set(SUBSURFACE_INTERFACE ${SUBSURFACE_INTERFACE} + socialnetworks.cpp + ) +endif() + +if (BTSUPPORT) + set(SUBSURFACE_INTERFACE ${SUBSURFACE_INTERFACE} + btdeviceselectiondialog.cpp + ) +endif() + +source_group("Subsurface Interface" FILES ${SUBSURFACE_INTERFACE}) + +# the yearly statistics widget. +set(SUBSURFACE_STATISTICS_LIB_SRCS + statistics/statisticswidget.cpp + statistics/yearstatistics.cpp + statistics/statisticsbar.cpp + statistics/monthstatistics.cpp +) +source_group("Subsurface Statistics" FILES ${SUBSURFACE_STATISTICS_LIB_SRCS}) + +add_library(subsurface_statistics STATIC ${SUBSURFACE_STATISTICS_LIB_SRCS}) +target_link_libraries(subsurface_statistics ${QT_LIBRARIES}) +add_library(subsurface_generated_ui STATIC ${SUBSURFACE_UI_HDRS}) +target_link_libraries(subsurface_generated_ui ${QT_LIBRARIES}) +add_library(subsurface_interface STATIC ${SUBSURFACE_INTERFACE}) +target_link_libraries(subsurface_interface ${QT_LIBRARIES} ${MARBLE_LIBRARIES} subsurface_desktop_preferences) diff --git a/qt-ui/about.cpp b/desktop-widgets/about.cpp index e0df55980..e0df55980 100644 --- a/qt-ui/about.cpp +++ b/desktop-widgets/about.cpp diff --git a/qt-ui/about.h b/desktop-widgets/about.h index 47423aea2..47423aea2 100644 --- a/qt-ui/about.h +++ b/desktop-widgets/about.h diff --git a/qt-ui/about.ui b/desktop-widgets/about.ui index 0c1735e26..0c1735e26 100644 --- a/qt-ui/about.ui +++ b/desktop-widgets/about.ui diff --git a/qt-ui/btdeviceselectiondialog.cpp b/desktop-widgets/btdeviceselectiondialog.cpp index fb2cbc1f3..fb2cbc1f3 100644 --- a/qt-ui/btdeviceselectiondialog.cpp +++ b/desktop-widgets/btdeviceselectiondialog.cpp diff --git a/qt-ui/btdeviceselectiondialog.h b/desktop-widgets/btdeviceselectiondialog.h index 7651f164b..7651f164b 100644 --- a/qt-ui/btdeviceselectiondialog.h +++ b/desktop-widgets/btdeviceselectiondialog.h diff --git a/qt-ui/btdeviceselectiondialog.ui b/desktop-widgets/btdeviceselectiondialog.ui index 4aa83cf1c..4aa83cf1c 100644 --- a/qt-ui/btdeviceselectiondialog.ui +++ b/desktop-widgets/btdeviceselectiondialog.ui diff --git a/qt-ui/configuredivecomputerdialog.cpp b/desktop-widgets/configuredivecomputerdialog.cpp index ddb9450de..ddb9450de 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/desktop-widgets/configuredivecomputerdialog.cpp diff --git a/qt-ui/configuredivecomputerdialog.h b/desktop-widgets/configuredivecomputerdialog.h index be76644a9..9ad30ac67 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/desktop-widgets/configuredivecomputerdialog.h @@ -4,7 +4,7 @@ #include <QDialog> #include <QStringListModel> #include "ui_configuredivecomputerdialog.h" -#include "../libdivecomputer.h" +#include "subsurface-core/libdivecomputer.h" #include "configuredivecomputer.h" #include <QStyledItemDelegate> #include <QNetworkAccessManager> diff --git a/qt-ui/configuredivecomputerdialog.ui b/desktop-widgets/configuredivecomputerdialog.ui index 0986d71ca..0986d71ca 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/desktop-widgets/configuredivecomputerdialog.ui diff --git a/qt-ui/css/tableviews.css b/desktop-widgets/css/tableviews.css index e69de29bb..e69de29bb 100644 --- a/qt-ui/css/tableviews.css +++ b/desktop-widgets/css/tableviews.css diff --git a/qt-ui/divecomponentselection.ui b/desktop-widgets/divecomponentselection.ui index 8262a5c2a..8262a5c2a 100644 --- a/qt-ui/divecomponentselection.ui +++ b/desktop-widgets/divecomponentselection.ui diff --git a/qt-ui/divecomputermanagementdialog.cpp b/desktop-widgets/divecomputermanagementdialog.cpp index fd9273ffb..fd9273ffb 100644 --- a/qt-ui/divecomputermanagementdialog.cpp +++ b/desktop-widgets/divecomputermanagementdialog.cpp diff --git a/qt-ui/divecomputermanagementdialog.h b/desktop-widgets/divecomputermanagementdialog.h index d065a0208..d065a0208 100644 --- a/qt-ui/divecomputermanagementdialog.h +++ b/desktop-widgets/divecomputermanagementdialog.h diff --git a/qt-ui/divecomputermanagementdialog.ui b/desktop-widgets/divecomputermanagementdialog.ui index 0e5db2c41..0e5db2c41 100644 --- a/qt-ui/divecomputermanagementdialog.ui +++ b/desktop-widgets/divecomputermanagementdialog.ui diff --git a/qt-ui/divelistview.cpp b/desktop-widgets/divelistview.cpp index d2386ecf1..d2386ecf1 100644 --- a/qt-ui/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp diff --git a/qt-ui/divelistview.h b/desktop-widgets/divelistview.h index aaec37af5..aaec37af5 100644 --- a/qt-ui/divelistview.h +++ b/desktop-widgets/divelistview.h diff --git a/qt-ui/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp index 7a406b982..7a406b982 100644 --- a/qt-ui/divelogexportdialog.cpp +++ b/desktop-widgets/divelogexportdialog.cpp diff --git a/qt-ui/divelogexportdialog.h b/desktop-widgets/divelogexportdialog.h index a5b5cc770..a5b5cc770 100644 --- a/qt-ui/divelogexportdialog.h +++ b/desktop-widgets/divelogexportdialog.h diff --git a/qt-ui/divelogexportdialog.ui b/desktop-widgets/divelogexportdialog.ui index 02c8cf38b..02c8cf38b 100644 --- a/qt-ui/divelogexportdialog.ui +++ b/desktop-widgets/divelogexportdialog.ui diff --git a/qt-ui/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp index 025d181d1..025d181d1 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/desktop-widgets/divelogimportdialog.cpp diff --git a/qt-ui/divelogimportdialog.h b/desktop-widgets/divelogimportdialog.h index 03bb14029..2d12c7cac 100644 --- a/qt-ui/divelogimportdialog.h +++ b/desktop-widgets/divelogimportdialog.h @@ -9,8 +9,8 @@ #include <QAbstractTableModel> #include <QStyledItemDelegate> -#include "../dive.h" -#include "../divelist.h" +#include "subsurface-core/dive.h" +#include "subsurface-core/divelist.h" namespace Ui { class DiveLogImportDialog; diff --git a/qt-ui/divelogimportdialog.ui b/desktop-widgets/divelogimportdialog.ui index 6d154b7c6..6d154b7c6 100644 --- a/qt-ui/divelogimportdialog.ui +++ b/desktop-widgets/divelogimportdialog.ui diff --git a/qt-ui/divepicturewidget.cpp b/desktop-widgets/divepicturewidget.cpp index bed3d3bd1..bed3d3bd1 100644 --- a/qt-ui/divepicturewidget.cpp +++ b/desktop-widgets/divepicturewidget.cpp diff --git a/qt-ui/divepicturewidget.h b/desktop-widgets/divepicturewidget.h index 54f5bb826..54f5bb826 100644 --- a/qt-ui/divepicturewidget.h +++ b/desktop-widgets/divepicturewidget.h diff --git a/qt-ui/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index b4413d11a..fd14944f0 100644 --- a/qt-ui/diveplanner.cpp +++ b/desktop-widgets/diveplanner.cpp @@ -5,7 +5,7 @@ #include "helpers.h" #include "cylindermodel.h" #include "models.h" -#include "profile/profilewidget2.h" +#include "profile-widget/profilewidget2.h" #include "diveplannermodel.h" #include <QGraphicsSceneMouseEvent> @@ -104,7 +104,7 @@ void DiveHandler::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) { ui.setupUi(this); - ui.dateEdit->setDisplayFormat(getDateFormat()); + ui.dateEdit->setDisplayFormat(prefs.date_format); ui.tableWidget->setTitle(tr("Dive planner points")); ui.tableWidget->setModel(plannerModel); plannerModel->setRecalc(true); @@ -328,11 +328,11 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) modeMapper->setMapping(ui.recreational_deco, int(RECREATIONAL)); modeMapper->setMapping(ui.buehlmann_deco, int(BUEHLMANN)); modeMapper->setMapping(ui.vpmb_deco, int(VPMB)); - + connect(ui.recreational_deco, SIGNAL(clicked()), modeMapper, SLOT(map())); connect(ui.buehlmann_deco, SIGNAL(clicked()), modeMapper, SLOT(map())); connect(ui.vpmb_deco, SIGNAL(clicked()), modeMapper, SLOT(map())); - + connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, SLOT(setLastStop6m(bool))); connect(ui.verbatim_plan, SIGNAL(toggled(bool)), plannerModel, SLOT(setVerbatim(bool))); connect(ui.display_duration, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayDuration(bool))); diff --git a/qt-ui/diveplanner.h b/desktop-widgets/diveplanner.h index b2e03a97b..b2e03a97b 100644 --- a/qt-ui/diveplanner.h +++ b/desktop-widgets/diveplanner.h diff --git a/qt-ui/diveplanner.ui b/desktop-widgets/diveplanner.ui index adb44fad9..adb44fad9 100644 --- a/qt-ui/diveplanner.ui +++ b/desktop-widgets/diveplanner.ui diff --git a/qt-ui/diveshareexportdialog.cpp b/desktop-widgets/diveshareexportdialog.cpp index 9fe6eefd6..9fe6eefd6 100644 --- a/qt-ui/diveshareexportdialog.cpp +++ b/desktop-widgets/diveshareexportdialog.cpp diff --git a/qt-ui/diveshareexportdialog.h b/desktop-widgets/diveshareexportdialog.h index 85dadf5f1..85dadf5f1 100644 --- a/qt-ui/diveshareexportdialog.h +++ b/desktop-widgets/diveshareexportdialog.h diff --git a/qt-ui/diveshareexportdialog.ui b/desktop-widgets/diveshareexportdialog.ui index 2235740c8..2235740c8 100644 --- a/qt-ui/diveshareexportdialog.ui +++ b/desktop-widgets/diveshareexportdialog.ui diff --git a/qt-ui/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp index 4c8fa6b4a..4c8fa6b4a 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/desktop-widgets/downloadfromdivecomputer.cpp diff --git a/qt-ui/downloadfromdivecomputer.h b/desktop-widgets/downloadfromdivecomputer.h index 7acd49e95..7acd49e95 100644 --- a/qt-ui/downloadfromdivecomputer.h +++ b/desktop-widgets/downloadfromdivecomputer.h diff --git a/qt-ui/downloadfromdivecomputer.ui b/desktop-widgets/downloadfromdivecomputer.ui index b1f152034..b1f152034 100644 --- a/qt-ui/downloadfromdivecomputer.ui +++ b/desktop-widgets/downloadfromdivecomputer.ui diff --git a/qt-ui/filterwidget.ui b/desktop-widgets/filterwidget.ui index 1450d81b2..1450d81b2 100644 --- a/qt-ui/filterwidget.ui +++ b/desktop-widgets/filterwidget.ui diff --git a/qt-ui/globe.cpp b/desktop-widgets/globe.cpp index 135f195a1..135f195a1 100644 --- a/qt-ui/globe.cpp +++ b/desktop-widgets/globe.cpp diff --git a/qt-ui/globe.h b/desktop-widgets/globe.h index 8cc1265e4..8cc1265e4 100644 --- a/qt-ui/globe.h +++ b/desktop-widgets/globe.h diff --git a/qt-ui/groupedlineedit.cpp b/desktop-widgets/groupedlineedit.cpp index 9ce5e175c..9ce5e175c 100644 --- a/qt-ui/groupedlineedit.cpp +++ b/desktop-widgets/groupedlineedit.cpp diff --git a/qt-ui/groupedlineedit.h b/desktop-widgets/groupedlineedit.h index c9cd1a0e0..c9cd1a0e0 100644 --- a/qt-ui/groupedlineedit.h +++ b/desktop-widgets/groupedlineedit.h diff --git a/qt-ui/kmessagewidget.cpp b/desktop-widgets/kmessagewidget.cpp index 2e506af2d..2e506af2d 100644 --- a/qt-ui/kmessagewidget.cpp +++ b/desktop-widgets/kmessagewidget.cpp diff --git a/qt-ui/kmessagewidget.h b/desktop-widgets/kmessagewidget.h index 885d2a78f..885d2a78f 100644 --- a/qt-ui/kmessagewidget.h +++ b/desktop-widgets/kmessagewidget.h diff --git a/qt-ui/listfilter.ui b/desktop-widgets/listfilter.ui index 48d813d21..48d813d21 100644 --- a/qt-ui/listfilter.ui +++ b/desktop-widgets/listfilter.ui diff --git a/qt-ui/locationInformation.ui b/desktop-widgets/locationInformation.ui index 58d065648..58d065648 100644 --- a/qt-ui/locationInformation.ui +++ b/desktop-widgets/locationInformation.ui diff --git a/qt-ui/locationinformation.cpp b/desktop-widgets/locationinformation.cpp index aee0b7328..aee0b7328 100644 --- a/qt-ui/locationinformation.cpp +++ b/desktop-widgets/locationinformation.cpp diff --git a/qt-ui/locationinformation.h b/desktop-widgets/locationinformation.h index 243df939b..243df939b 100644 --- a/qt-ui/locationinformation.h +++ b/desktop-widgets/locationinformation.h diff --git a/qt-ui/maintab.cpp b/desktop-widgets/maintab.cpp index 0afb7b4c0..c7961735a 100644 --- a/qt-ui/maintab.cpp +++ b/desktop-widgets/maintab.cpp @@ -13,7 +13,7 @@ #include "diveplannermodel.h" #include "divelistview.h" #include "display.h" -#include "profile/profilewidget2.h" +#include "profile-widget/profilewidget2.h" #include "diveplanner.h" #include "divesitehelpers.h" #include "cylindermodel.h" @@ -43,7 +43,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), currentTrip(0) { ui.setupUi(this); - ui.dateEdit->setDisplayFormat(getDateFormat()); + ui.dateEdit->setDisplayFormat(prefs.date_format); memset(&displayed_dive, 0, sizeof(displayed_dive)); memset(&displayedTrip, 0, sizeof(displayedTrip)); diff --git a/qt-ui/maintab.h b/desktop-widgets/maintab.h index 20b4da690..20b4da690 100644 --- a/qt-ui/maintab.h +++ b/desktop-widgets/maintab.h diff --git a/qt-ui/maintab.ui b/desktop-widgets/maintab.ui index 2c515a225..7bc516b1a 100644 --- a/qt-ui/maintab.ui +++ b/desktop-widgets/maintab.ui @@ -525,8 +525,8 @@ <rect> <x>0</x> <y>0</y> - <width>70</width> - <height>16</height> + <width>445</width> + <height>754</height> </rect> </property> <layout class="QGridLayout" name="equipmentTabScrollAreaLayout"> @@ -1229,7 +1229,7 @@ <customwidget> <class>TagWidget</class> <extends>QPlainTextEdit</extends> - <header>qt-ui/tagwidget.h</header> + <header>tagwidget.h</header> </customwidget> <customwidget> <class>DivePictureWidget</class> diff --git a/qt-ui/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index e0476381f..dc45d1d8d 100644 --- a/qt-ui/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -11,17 +11,17 @@ #include <QSettings> #include <QShortcut> #include <QToolBar> + #include "version.h" #include "divelistview.h" #include "downloadfromdivecomputer.h" -#include "preferences.h" #include "subsurfacewebservices.h" #include "divecomputermanagementdialog.h" #include "about.h" #include "updatemanager.h" #include "planner.h" #include "filtermodels.h" -#include "profile/profilewidget2.h" +#include "profile-widget/profilewidget2.h" #include "globe.h" #include "divecomputer.h" #include "maintab.h" @@ -40,6 +40,7 @@ #include "divesitehelpers.h" #include "windowtitleupdate.h" #include "locationinformation.h" +#include "preferences/preferencesdialog.h" #ifndef NO_USERMANUAL #include "usermanual.h" @@ -50,6 +51,9 @@ #include <QUndoStack> #include <qthelper.h> #include <QtConcurrentRun> +#include "subsurface-core/color.h" +#include "subsurface-core/isocialnetworkintegration.h" +#include "subsurface-core/pluginmanager.h" #if defined(FBSUPPORT) #include "socialnetworks.h" @@ -250,6 +254,26 @@ MainWindow::MainWindow() : QMainWindow(), ui.actionFacebook->setEnabled(false); #endif + if(PluginManager::instance().socialNetworkIntegrationPlugins().count()) { + QMenu *connections = new QMenu(tr("Connect to")); + for(ISocialNetworkIntegration *plugin : PluginManager::instance().socialNetworkIntegrationPlugins()){ + QAction *toggle_connection = new QAction(this); + toggle_connection->setText(plugin->socialNetworkName()); + toggle_connection->setIcon(QIcon(plugin->socialNetworkIcon())); + toggle_connection->setData(QVariant::fromValue(plugin)); + + QAction *share_on = new QAction(this); + share_on->setText(plugin->socialNetworkName()); + share_on->setIcon(QIcon(plugin->socialNetworkIcon())); + share_on->setData(QVariant::fromValue(plugin)); + ui.menuShare_on->addAction(share_on); + connections->addAction(toggle_connection); + } + ui.menuShare_on->addSeparator(); + ui.menuShare_on->addMenu(connections); + } else { + ui.menubar->removeAction(ui.menuShare_on->menuAction()); + } ui.menubar->show(); set_git_update_cb(&updateProgress); @@ -1164,7 +1188,7 @@ void MainWindow::initialUiSetup() show(); } -const char *getSetting(QSettings &s, QString name) +const char *getSetting(const QSettings &s,const QString& name) { QVariant v; v = s.value(name); @@ -1758,6 +1782,7 @@ void MainWindow::editCurrentDive() } } +// TODO: Remove the dependency to the PreferencesDialog here. #define PREF_PROFILE(QT_PREFS) \ QSettings s; \ s.beginGroup("TecDetails"); \ @@ -1897,8 +1922,7 @@ void MainWindow::setApplicationState(const QByteArray& state) { void MainWindow::showProgressBar() { - if (progressDialog) - delete progressDialog; + delete progressDialog; progressDialog = new QProgressDialog(tr("Contacting cloud service..."), tr("Cancel"), 0, 100, this); progressDialog->setWindowModality(Qt::WindowModal); diff --git a/qt-ui/mainwindow.h b/desktop-widgets/mainwindow.h index 02ec2478c..02ec2478c 100644 --- a/qt-ui/mainwindow.h +++ b/desktop-widgets/mainwindow.h diff --git a/qt-ui/mainwindow.ui b/desktop-widgets/mainwindow.ui index 5e3200cfc..c62e1df7f 100644 --- a/qt-ui/mainwindow.ui +++ b/desktop-widgets/mainwindow.ui @@ -142,7 +142,6 @@ <string>Share on</string> </property> <addaction name="separator"/> - <addaction name="actionFacebook"/> </widget> <addaction name="menuFile"/> <addaction name="menu_Edit"/> diff --git a/qt-ui/marble/GeoDataTreeModel.h b/desktop-widgets/marble/GeoDataTreeModel.h index 39eff8388..39eff8388 100644 --- a/qt-ui/marble/GeoDataTreeModel.h +++ b/desktop-widgets/marble/GeoDataTreeModel.h diff --git a/qt-ui/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp index 881037a83..1b1a31c0b 100644 --- a/qt-ui/modeldelegates.cpp +++ b/desktop-widgets/modeldelegates.cpp @@ -5,7 +5,7 @@ #include "cylindermodel.h" #include "models.h" #include "starwidget.h" -#include "profile/profilewidget2.h" +#include "profile-widget/profilewidget2.h" #include "tankinfomodel.h" #include "weigthsysteminfomodel.h" #include "weightmodel.h" diff --git a/qt-ui/modeldelegates.h b/desktop-widgets/modeldelegates.h index 95701775a..95701775a 100644 --- a/qt-ui/modeldelegates.h +++ b/desktop-widgets/modeldelegates.h diff --git a/qt-ui/notificationwidget.cpp b/desktop-widgets/notificationwidget.cpp index 103c0d068..103c0d068 100644 --- a/qt-ui/notificationwidget.cpp +++ b/desktop-widgets/notificationwidget.cpp diff --git a/qt-ui/notificationwidget.h b/desktop-widgets/notificationwidget.h index 8a551a0b3..8a551a0b3 100644 --- a/qt-ui/notificationwidget.h +++ b/desktop-widgets/notificationwidget.h diff --git a/qt-ui/plannerDetails.ui b/desktop-widgets/plannerDetails.ui index 1f2790d85..1f2790d85 100644 --- a/qt-ui/plannerDetails.ui +++ b/desktop-widgets/plannerDetails.ui diff --git a/qt-ui/plannerSettings.ui b/desktop-widgets/plannerSettings.ui index 4db69f883..4db69f883 100644 --- a/qt-ui/plannerSettings.ui +++ b/desktop-widgets/plannerSettings.ui diff --git a/desktop-widgets/plugins/CMakeLists.txt b/desktop-widgets/plugins/CMakeLists.txt new file mode 100644 index 000000000..f424e172e --- /dev/null +++ b/desktop-widgets/plugins/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(facebook)
\ No newline at end of file diff --git a/desktop-widgets/plugins/facebook/CMakeLists.txt b/desktop-widgets/plugins/facebook/CMakeLists.txt new file mode 100644 index 000000000..8628bd070 --- /dev/null +++ b/desktop-widgets/plugins/facebook/CMakeLists.txt @@ -0,0 +1,6 @@ +set(FACEBOOK_PLUGIN_SRCS facebook_integration.cpp) + +add_library(facebook_integration SHARED ${FACEBOOK_PLUGIN_SRCS}) + +target_link_libraries(facebook_integration subsurface_corelib ${QT_LIBRARIES}) +add_dependencies(facebook_integration subsurface_corelib)
\ No newline at end of file diff --git a/desktop-widgets/plugins/facebook/facebook_integration.cpp b/desktop-widgets/plugins/facebook/facebook_integration.cpp new file mode 100644 index 000000000..e9b2297a0 --- /dev/null +++ b/desktop-widgets/plugins/facebook/facebook_integration.cpp @@ -0,0 +1,36 @@ +#include "facebook_integration.h" + +FacebookPlugin::FacebookPlugin(QObject* parent): QObject(parent) +{ + +} + +bool FacebookPlugin::isConnected() +{ + +} + +void FacebookPlugin::requestLogin() +{ + +} + +void FacebookPlugin::requestLogoff() +{ + +} + +QString FacebookPlugin::socialNetworkIcon() const +{ + return QString(); +} + +QString FacebookPlugin::socialNetworkName() const +{ + return tr("Facebook"); +} + +void FacebookPlugin::uploadCurrentDive() +{ + +} diff --git a/desktop-widgets/plugins/facebook/facebook_integration.h b/desktop-widgets/plugins/facebook/facebook_integration.h new file mode 100644 index 000000000..a9d212e7e --- /dev/null +++ b/desktop-widgets/plugins/facebook/facebook_integration.h @@ -0,0 +1,21 @@ +#ifndef FACEBOOK_INTEGRATION_H +#define FACEBOOK_INTEGRATION_H + +#include "subsurface-core/isocialnetworkintegration.h" +#include <QString> + +class FacebookPlugin : public QObject, public ISocialNetworkIntegration { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.subsurface.plugins.ISocialNetworkIntegration") + Q_INTERFACES(ISocialNetworkIntegration) +public: + explicit FacebookPlugin(QObject* parent = 0); + virtual bool isConnected(); + virtual void requestLogin(); + virtual void requestLogoff(); + virtual QString socialNetworkIcon() const; + virtual QString socialNetworkName() const; + virtual void uploadCurrentDive(); +}; + +#endif
\ No newline at end of file diff --git a/desktop-widgets/preferences.cpp b/desktop-widgets/preferences.cpp new file mode 100644 index 000000000..29e9d2458 --- /dev/null +++ b/desktop-widgets/preferences.cpp @@ -0,0 +1,173 @@ +#include "preferences.h" +#include "mainwindow.h" +#include "models.h" +#include "divelocationmodel.h" +#include "prefs-macros.h" +#include "qthelper.h" +#include "subsurfacestartup.h" + +#include <QSettings> +#include <QFileDialog> +#include <QMessageBox> +#include <QShortcut> +#include <QNetworkProxy> +#include <QNetworkCookieJar> + +#include "subsurfacewebservices.h" + +#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) +#include "socialnetworks.h" +#include <QWebView> +#endif + +PreferencesDialog *PreferencesDialog::instance() +{ + static PreferencesDialog *dialog = new PreferencesDialog(MainWindow::instance()); + return dialog; +} + +PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) +{ + ui.setupUi(this); + setAttribute(Qt::WA_QuitOnClose, false); + +#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) + FacebookManager *fb = FacebookManager::instance(); + facebookWebView = new QWebView(this); + ui.fbWebviewContainer->layout()->addWidget(facebookWebView); + if (fb->loggedIn()) { + facebookLoggedIn(); + } else { + facebookDisconnect(); + } + connect(facebookWebView, &QWebView::urlChanged, fb, &FacebookManager::tryLogin); + connect(fb, &FacebookManager::justLoggedIn, this, &PreferencesDialog::facebookLoggedIn); + connect(ui.fbDisconnect, &QPushButton::clicked, fb, &FacebookManager::logout); + connect(fb, &FacebookManager::justLoggedOut, this, &PreferencesDialog::facebookDisconnect); +#endif + + connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); + + // connect(ui.defaultSetpoint, SIGNAL(valueChanged(double)), this, SLOT(defaultSetpointChanged(double))); + QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); + connect(close, SIGNAL(activated()), this, SLOT(close())); + QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); + connect(quit, SIGNAL(activated()), parent, SLOT(close())); + loadSettings(); + setUiFromPrefs(); + rememberPrefs(); +} + +void PreferencesDialog::facebookLoggedIn() +{ +#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) + ui.fbDisconnect->show(); + ui.fbWebviewContainer->hide(); + ui.fbWebviewContainer->setEnabled(false); + ui.FBLabel->setText(tr("To disconnect Subsurface from your Facebook account, use the button below")); +#endif +} + +void PreferencesDialog::facebookDisconnect() +{ +#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) + // remove the connect/disconnect button + // and instead add the login view + ui.fbDisconnect->hide(); + ui.fbWebviewContainer->show(); + ui.fbWebviewContainer->setEnabled(true); + ui.FBLabel->setText(tr("To connect to Facebook, please log in. This enables Subsurface to publish dives to your timeline")); + if (facebookWebView) { + facebookWebView->page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar()); + facebookWebView->setUrl(FacebookManager::instance()->connectUrl()); + } +#endif +} + +void PreferencesDialog::showEvent(QShowEvent *event) +{ + setUiFromPrefs(); + rememberPrefs(); + QDialog::showEvent(event); +} + +void PreferencesDialog::setUiFromPrefs() +{ + +} + +void PreferencesDialog::restorePrefs() +{ + prefs = oldPrefs; + setUiFromPrefs(); +} + +void PreferencesDialog::rememberPrefs() +{ + oldPrefs = prefs; +} + +void PreferencesDialog::syncSettings() +{ +} + +void PreferencesDialog::loadSettings() +{ + // This code was on the mainwindow, it should belong nowhere, but since we didn't + // correctly fixed this code yet ( too much stuff on the code calling preferences ) + // force this here. + loadPreferences(); + QSettings s; + QVariant v; +} + +void PreferencesDialog::buttonClicked(QAbstractButton *button) +{ + switch (ui.buttonBox->standardButton(button)) { + case QDialogButtonBox::Discard: + restorePrefs(); + syncSettings(); + close(); + break; + case QDialogButtonBox::Apply: + syncSettings(); + break; + case QDialogButtonBox::FirstButton: + syncSettings(); + close(); + break; + default: + break; // ignore warnings. + } +} +#undef SB + +#if 0 +// TODO: Copy this later. +void PreferencesDialog::on_resetSettings_clicked() +{ + QSettings s; + QMessageBox response(this); + response.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + response.setDefaultButton(QMessageBox::Cancel); + response.setWindowTitle(tr("Warning")); + response.setText(tr("If you click OK, all settings of Subsurface will be reset to their default values. This will be applied immediately.")); + response.setWindowModality(Qt::WindowModal); + + int result = response.exec(); + if (result == QMessageBox::Ok) { + copy_prefs(&default_prefs, &prefs); + setUiFromPrefs(); + Q_FOREACH (QString key, s.allKeys()) { + s.remove(key); + } + syncSettings(); + close(); + } +} +#endif + +void PreferencesDialog::emitSettingsChanged() +{ + emit settingsChanged(); +} diff --git a/desktop-widgets/preferences.ui b/desktop-widgets/preferences.ui new file mode 100644 index 000000000..8d0b18900 --- /dev/null +++ b/desktop-widgets/preferences.ui @@ -0,0 +1,241 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PreferencesDialog</class> + <widget class="QDialog" name="PreferencesDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>835</width> + <height>698</height> + </rect> + </property> + <property name="windowTitle"> + <string>Preferences</string> + </property> + <property name="windowIcon"> + <iconset> + <normalon>:/subsurface-icon</normalon> + </iconset> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="leftMargin"> + <number>5</number> + </property> + <property name="topMargin"> + <number>5</number> + </property> + <property name="rightMargin"> + <number>5</number> + </property> + <property name="bottomMargin"> + <number>5</number> + </property> + <item> + <layout class="QHBoxLayout" name="mainHorizontalLayout"> + <item> + <widget class="QListWidget" name="listWidget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>120</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>120</width> + <height>16777215</height> + </size> + </property> + <property name="iconSize"> + <size> + <width>24</width> + <height>24</height> + </size> + </property> + <property name="textElideMode"> + <enum>Qt::ElideNone</enum> + </property> + <property name="movement"> + <enum>QListView::Static</enum> + </property> + <property name="isWrapping" stdset="0"> + <bool>true</bool> + </property> + <property name="layoutMode"> + <enum>QListView::Batched</enum> + </property> + <property name="spacing"> + <number>0</number> + </property> + <property name="gridSize"> + <size> + <width>110</width> + <height>40</height> + </size> + </property> + <property name="viewMode"> + <enum>QListView::ListMode</enum> + </property> + <property name="uniformItemSizes"> + <bool>true</bool> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="currentRow"> + <number>-1</number> + </property> + <item> + <property name="text"> + <string>Facebook</string> + </property> + <property name="icon"> + <iconset> + <normalon>:/facebook</normalon> + </iconset> + </property> + </item> + </widget> + </item> + <item> + <widget class="QStackedWidget" name="stackedWidget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="facebook_page"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QVBoxLayout" name="fbLayout" stretch="0"> + <property name="spacing"> + <number>5</number> + </property> + <property name="leftMargin"> + <number>5</number> + </property> + <property name="topMargin"> + <number>5</number> + </property> + <property name="rightMargin"> + <number>5</number> + </property> + <property name="bottomMargin"> + <number>5</number> + </property> + <item> + <widget class="QWidget" name="widget" native="true"> + <layout class="QVBoxLayout" name="verticalLayout_9"> + <item> + <widget class="QLabel" name="FBLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Connect to facebook text placeholder</string> + </property> + </widget> + </item> + <item> + <widget class="QWidget" name="fbWebviewContainer" native="true"> + <layout class="QVBoxLayout" name="verticalLayout_10"/> + </widget> + </item> + <item> + <widget class="QPushButton" name="fbDisconnect"> + <property name="text"> + <string>Disconnect</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Apply|QDialogButtonBox::Discard|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>PreferencesDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>264</x> + <y>720</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>PreferencesDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>332</x> + <y>720</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>listWidget</sender> + <signal>currentRowChanged(int)</signal> + <receiver>stackedWidget</receiver> + <slot>setCurrentIndex(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>37</x> + <y>97</y> + </hint> + <hint type="destinationlabel"> + <x>282</x> + <y>18</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt new file mode 100644 index 000000000..4e506ed73 --- /dev/null +++ b/desktop-widgets/preferences/CMakeLists.txt @@ -0,0 +1,27 @@ +# the profile widget +include_directories(. + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} +) + +file(GLOB SUBSURFACE_PREFERENCES_UI *.ui) +qt5_wrap_ui(SUBSURFACE_PREFERENCES_UI_HDRS ${SUBSURFACE_PREFERENCES_UI}) + +source_group("Subsurface Interface Files" FILES ${SUBSURFACE_PREFERENCES_UI}) + +set(SUBSURFACE_PREFERENCES_LIB_SRCS + abstractpreferenceswidget.cpp + preferencesdialog.cpp + preferences_language.cpp + preferences_georeference.cpp + preferences_defaults.cpp + preferences_units.cpp + preferences_graph.cpp + preferences_network.cpp +) + +source_group("Subsurface Preferences" FILES ${SUBSURFACE_PREFERENCES_LIB_SRCS}) + +add_library(subsurface_desktop_preferences STATIC ${SUBSURFACE_PREFERENCES_LIB_SRCS} ${SUBSURFACE_PREFERENCES_UI_HDRS}) +target_link_libraries(subsurface_desktop_preferences ${QT_LIBRARIES}) + diff --git a/desktop-widgets/preferences/abstractpreferenceswidget.cpp b/desktop-widgets/preferences/abstractpreferenceswidget.cpp new file mode 100644 index 000000000..9334c74ed --- /dev/null +++ b/desktop-widgets/preferences/abstractpreferenceswidget.cpp @@ -0,0 +1,21 @@ +#include "abstractpreferenceswidget.h" + +AbstractPreferencesWidget::AbstractPreferencesWidget(const QString& name, const QIcon& icon, float positionHeight) +: QWidget(), _name(name), _icon(icon), _positionHeight(positionHeight) +{ +} + +QIcon AbstractPreferencesWidget::icon() const +{ + return _icon; +} + +QString AbstractPreferencesWidget::name() const +{ + return _name; +} + +float AbstractPreferencesWidget::positionHeight() const +{ + return _positionHeight; +} diff --git a/desktop-widgets/preferences/abstractpreferenceswidget.h b/desktop-widgets/preferences/abstractpreferenceswidget.h new file mode 100644 index 000000000..2f607c4c9 --- /dev/null +++ b/desktop-widgets/preferences/abstractpreferenceswidget.h @@ -0,0 +1,27 @@ +#ifndef ABSTRACTPREFERENCESWIDGET_H +#define ABSTRACTPREFERENCESWIDGET_H + +#include <QIcon> +#include <QWidget> + +class AbstractPreferencesWidget : public QWidget { + Q_OBJECT +public: + AbstractPreferencesWidget(const QString& name, const QIcon& icon, float positionHeight); + QIcon icon() const; + QString name() const; + float positionHeight() const; + + /* gets the values from the preferences and should set the correct values in + * the interface */ + virtual void refreshSettings() = 0; + + /* gets the values from the interface and set in the preferences object. */ + virtual void syncSettings() = 0; + +private: + QIcon _icon; + QString _name; + float _positionHeight; +}; +#endif
\ No newline at end of file diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp new file mode 100644 index 000000000..45888ebec --- /dev/null +++ b/desktop-widgets/preferences/preferences_defaults.cpp @@ -0,0 +1,103 @@ +#include "preferences_defaults.h" +#include "ui_preferences_defaults.h" +#include "dive.h" +#include "subsurface-core/prefs-macros.h" + +#include <QSettings> +#include <QFileDialog> + +PreferencesDefaults::PreferencesDefaults(): AbstractPreferencesWidget(tr("Defaults"), QIcon(":defaults"), 0 ), ui(new Ui::PreferencesDefaults()) +{ + ui->setupUi(this); +} + +PreferencesDefaults::~PreferencesDefaults() +{ + delete ui; +} + +void PreferencesDefaults::on_chooseFile_clicked() +{ + QFileInfo fi(system_default_filename()); + QString choosenFileName = QFileDialog::getOpenFileName(this, tr("Open default log file"), fi.absolutePath(), tr("Subsurface XML files (*.ssrf *.xml *.XML)")); + + if (!choosenFileName.isEmpty()) + ui->defaultfilename->setText(choosenFileName); +} + +void PreferencesDefaults::on_btnUseDefaultFile_toggled(bool toggle) +{ + if (toggle) { + ui->defaultfilename->setText(system_default_filename()); + ui->defaultfilename->setEnabled(false); + } else { + ui->defaultfilename->setEnabled(true); + } +} + +void PreferencesDefaults::on_localDefaultFile_toggled(bool toggle) +{ + ui->defaultfilename->setEnabled(toggle); + ui->btnUseDefaultFile->setEnabled(toggle); + ui->chooseFile->setEnabled(toggle); +} + +void PreferencesDefaults::refreshSettings() +{ + ui->font->setCurrentFont(QString(prefs.divelist_font)); + ui->fontsize->setValue(prefs.font_size); + ui->defaultfilename->setText(prefs.default_filename); + ui->noDefaultFile->setChecked(prefs.default_file_behavior == NO_DEFAULT_FILE); + ui->cloudDefaultFile->setChecked(prefs.default_file_behavior == CLOUD_DEFAULT_FILE); + ui->localDefaultFile->setChecked(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); + + ui->default_cylinder->clear(); + for (int i = 0; tank_info[i].name != NULL; i++) { + ui->default_cylinder->addItem(tank_info[i].name); + if (prefs.default_cylinder && strcmp(tank_info[i].name, prefs.default_cylinder) == 0) + ui->default_cylinder->setCurrentIndex(i); + } + ui->displayinvalid->setChecked(prefs.display_invalid_dives); + ui->velocitySlider->setValue(prefs.animation_speed); + ui->btnUseDefaultFile->setChecked(prefs.use_default_file); + + if (prefs.cloud_verification_status == CS_VERIFIED) { + ui->cloudDefaultFile->setEnabled(true); + } else { + if (ui->cloudDefaultFile->isChecked()) + ui->noDefaultFile->setChecked(true); + ui->cloudDefaultFile->setEnabled(false); + } + + ui->defaultfilename->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); + ui->btnUseDefaultFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); + ui->chooseFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); +} + +void PreferencesDefaults::syncSettings() +{ + QSettings s; + s.beginGroup("GeneralSettings"); + s.setValue("default_filename", ui->defaultfilename->text()); + s.setValue("default_cylinder", ui->default_cylinder->currentText()); + s.setValue("use_default_file", ui->btnUseDefaultFile->isChecked()); + if (ui->noDefaultFile->isChecked()) + s.setValue("default_file_behavior", NO_DEFAULT_FILE); + else if (ui->localDefaultFile->isChecked()) + s.setValue("default_file_behavior", LOCAL_DEFAULT_FILE); + else if (ui->cloudDefaultFile->isChecked()) + s.setValue("default_file_behavior", CLOUD_DEFAULT_FILE); + s.endGroup(); + + s.beginGroup("Display"); + SAVE_OR_REMOVE_SPECIAL("divelist_font", system_divelist_default_font, ui->font->currentFont().toString(), ui->font->currentFont()); + SAVE_OR_REMOVE("font_size", system_divelist_default_font_size, ui->fontsize->value()); + s.setValue("displayinvalid", ui->displayinvalid->isChecked()); + s.endGroup(); + s.sync(); + + // Animation + s.beginGroup("Animations"); + s.setValue("animation_speed", ui->velocitySlider->value()); + s.endGroup(); +} diff --git a/desktop-widgets/preferences/preferences_defaults.h b/desktop-widgets/preferences/preferences_defaults.h new file mode 100644 index 000000000..c72be31a6 --- /dev/null +++ b/desktop-widgets/preferences/preferences_defaults.h @@ -0,0 +1,28 @@ +#ifndef PREFERENCES_DEFAULTS_H +#define PREFERENCES_DEFAULTS_H + +#include "abstractpreferenceswidget.h" +#include "subsurface-core/pref.h" + +namespace Ui { + class PreferencesDefaults; +} + +class PreferencesDefaults : public AbstractPreferencesWidget { + Q_OBJECT +public: + PreferencesDefaults(); + virtual ~PreferencesDefaults(); + virtual void refreshSettings(); + virtual void syncSettings(); +public slots: + void on_chooseFile_clicked(); + void on_btnUseDefaultFile_toggled(bool toggled); + void on_localDefaultFile_toggled(bool toggled); + +private: + Ui::PreferencesDefaults *ui; +}; + + +#endif
\ No newline at end of file diff --git a/desktop-widgets/preferences/preferences_defaults.ui b/desktop-widgets/preferences/preferences_defaults.ui new file mode 100644 index 000000000..632e82763 --- /dev/null +++ b/desktop-widgets/preferences/preferences_defaults.ui @@ -0,0 +1,251 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PreferencesDefaults</class> + <widget class="QWidget" name="PreferencesDefaults"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>555</width> + <height>558</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Lists and tables</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_11"> + <property name="margin"> + <number>5</number> + </property> + <item> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Font</string> + </property> + </widget> + </item> + <item> + <widget class="QFontComboBox" name="font"/> + </item> + <item> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Font size</string> + </property> + </widget> + </item> + <item> + <widget class="QDoubleSpinBox" name="fontsize"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_3"> + <property name="title"> + <string>Dives</string> + </property> + <layout class="QFormLayout" name="formLayout"> + <property name="horizontalSpacing"> + <number>5</number> + </property> + <property name="verticalSpacing"> + <number>5</number> + </property> + <property name="margin"> + <number>5</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="defaultDiveLogFileLabel"> + <property name="text"> + <string>Default dive log file</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <layout class="QHBoxLayout" name="defaultFileBehaviorLayout"> + <item> + <widget class="QRadioButton" name="noDefaultFile"> + <property name="text"> + <string>No default file</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="localDefaultFile"> + <property name="text"> + <string>&Local default file</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="cloudDefaultFile"> + <property name="text"> + <string>Clo&ud storage default file</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_9"> + <property name="text"> + <string>Local dive log file</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_3b"> + <item> + <widget class="QLineEdit" name="defaultfilename"/> + </item> + <item> + <widget class="QToolButton" name="btnUseDefaultFile"> + <property name="text"> + <string>Use default</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="chooseFile"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>Display invalid</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="displayinvalid"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_6"> + <property name="title"> + <string>Default cylinder</string> + </property> + <layout class="QFormLayout" name="formLayout_6"> + <property name="horizontalSpacing"> + <number>5</number> + </property> + <property name="verticalSpacing"> + <number>5</number> + </property> + <property name="margin"> + <number>5</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="label_11"> + <property name="text"> + <string>Use default cylinder</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QComboBox" name="default_cylinder"/> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_7"> + <property name="title"> + <string>Animations</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <property name="margin"> + <number>5</number> + </property> + <item> + <widget class="QLabel" name="label_15"> + <property name="text"> + <string>Speed</string> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="velocitySlider"> + <property name="maximum"> + <number>500</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="velocitySpinBox"> + <property name="maximum"> + <number>500</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_9"> + <property name="title"> + <string>Clear all settings</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_7b"> + <property name="spacing"> + <number>5</number> + </property> + <property name="margin"> + <number>5</number> + </property> + <item> + <widget class="QPushButton" name="resetSettings"> + <property name="text"> + <string>Reset all settings to their default value</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>195</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/desktop-widgets/preferences/preferences_georeference.cpp b/desktop-widgets/preferences/preferences_georeference.cpp new file mode 100644 index 000000000..7e8ccec9d --- /dev/null +++ b/desktop-widgets/preferences/preferences_georeference.cpp @@ -0,0 +1,45 @@ +#include "preferences_georeference.h" +#include "ui_prefs_georeference.h" +#include "prefs-macros.h" +#include "qthelper.h" +#include "qt-models/divelocationmodel.h" + +#include <ctime> +#include <QSettings> + +PreferencesGeoreference::PreferencesGeoreference() : AbstractPreferencesWidget(tr("Georeference"), QIcon(":/georeference"), 9) +{ + ui = new Ui::PreferencesGeoreference(); + ui->setupUi(this); + ui->first_item->setModel(GeoReferencingOptionsModel::instance()); + ui->second_item->setModel(GeoReferencingOptionsModel::instance()); + ui->third_item->setModel(GeoReferencingOptionsModel::instance()); +} + +PreferencesGeoreference::~PreferencesGeoreference() +{ + delete ui; +} + +void PreferencesGeoreference::refreshSettings() +{ + ui->enable_geocoding->setChecked(prefs.geocoding.enable_geocoding); + ui->parse_without_gps->setChecked(prefs.geocoding.parse_dive_without_gps); + ui->tag_existing_dives->setChecked(prefs.geocoding.tag_existing_dives); + ui->first_item->setCurrentIndex(prefs.geocoding.category[0]); + ui->second_item->setCurrentIndex(prefs.geocoding.category[1]); + ui->third_item->setCurrentIndex(prefs.geocoding.category[2]); +} + +void PreferencesGeoreference::syncSettings() +{ + QSettings s; + s.beginGroup("geocoding"); + s.setValue("enable_geocoding", ui->enable_geocoding->isChecked()); + s.setValue("parse_dives_without_gps", ui->parse_without_gps->isChecked()); + s.setValue("tag_existing_dives", ui->tag_existing_dives->isChecked()); + s.setValue("cat0", ui->first_item->currentIndex()); + s.setValue("cat1", ui->second_item->currentIndex()); + s.setValue("cat2", ui->third_item->currentIndex()); + s.endGroup(); +}
\ No newline at end of file diff --git a/desktop-widgets/preferences/preferences_georeference.h b/desktop-widgets/preferences/preferences_georeference.h new file mode 100644 index 000000000..5dd4bc445 --- /dev/null +++ b/desktop-widgets/preferences/preferences_georeference.h @@ -0,0 +1,21 @@ +#ifndef PREFERENCES_GEOREFERENCE_H +#define PREFERENCES_GEOREFERENCE_H + +#include "abstractpreferenceswidget.h" + +namespace Ui { + class PreferencesGeoreference; +} + +class PreferencesGeoreference : public AbstractPreferencesWidget { + Q_OBJECT +public: + PreferencesGeoreference(); + virtual ~PreferencesGeoreference(); + virtual void refreshSettings(); + virtual void syncSettings(); +private: + Ui::PreferencesGeoreference *ui; +}; + +#endif
\ No newline at end of file diff --git a/desktop-widgets/preferences/preferences_graph.cpp b/desktop-widgets/preferences/preferences_graph.cpp new file mode 100644 index 000000000..327557692 --- /dev/null +++ b/desktop-widgets/preferences/preferences_graph.cpp @@ -0,0 +1,77 @@ +#include "preferences_graph.h" +#include "ui_preferences_graph.h" +#include "subsurface-core/prefs-macros.h" + +#include <QSettings> +#include <QMessageBox> + +#include "qt-models/models.h" + +PreferencesGraph::PreferencesGraph() : AbstractPreferencesWidget(tr("Graph"), QIcon(":graph"), 5) +{ + ui = new Ui::PreferencesGraph(); + ui->setupUi(this); +} + +PreferencesGraph::~PreferencesGraph() +{ + delete ui; +} + +void PreferencesGraph::refreshSettings() +{ + ui->pheThreshold->setValue(prefs.pp_graphs.phe_threshold); + ui->po2Threshold->setValue(prefs.pp_graphs.po2_threshold); + ui->pn2Threshold->setValue(prefs.pp_graphs.pn2_threshold); + ui->maxpo2->setValue(prefs.modpO2); + ui->red_ceiling->setChecked(prefs.redceiling); + + ui->gflow->setValue(prefs.gflow); + ui->gfhigh->setValue(prefs.gfhigh); + ui->gf_low_at_maxdepth->setChecked(prefs.gf_low_at_maxdepth); + ui->show_ccr_setpoint->setChecked(prefs.show_ccr_setpoint); + ui->show_ccr_sensors->setChecked(prefs.show_ccr_sensors); + ui->defaultSetpoint->setValue((double)prefs.defaultsetpoint / 1000.0); + ui->psro2rate->setValue(prefs.o2consumption / 1000.0); + ui->pscrfactor->setValue(rint(1000.0 / prefs.pscr_ratio)); + + ui->display_unused_tanks->setChecked(prefs.display_unused_tanks); + ui->show_average_depth->setChecked(prefs.show_average_depth); +} + +void PreferencesGraph::syncSettings() +{ + QSettings s; + + s.beginGroup("GeneralSettings"); + s.setValue("defaultsetpoint", rint(ui->defaultSetpoint->value() * 1000.0)); + s.setValue("o2consumption", rint(ui->psro2rate->value() *1000.0)); + s.setValue("pscr_ratio", rint(1000.0 / ui->pscrfactor->value())); + s.endGroup(); + + s.beginGroup("TecDetails"); + SAVE_OR_REMOVE("phethreshold", default_prefs.pp_graphs.phe_threshold, ui->pheThreshold->value()); + SAVE_OR_REMOVE("po2threshold", default_prefs.pp_graphs.po2_threshold, ui->po2Threshold->value()); + SAVE_OR_REMOVE("pn2threshold", default_prefs.pp_graphs.pn2_threshold, ui->pn2Threshold->value()); + SAVE_OR_REMOVE("modpO2", default_prefs.modpO2, ui->maxpo2->value()); + SAVE_OR_REMOVE("redceiling", default_prefs.redceiling, ui->red_ceiling->isChecked()); + SAVE_OR_REMOVE("gflow", default_prefs.gflow, ui->gflow->value()); + SAVE_OR_REMOVE("gfhigh", default_prefs.gfhigh, ui->gfhigh->value()); + SAVE_OR_REMOVE("gf_low_at_maxdepth", default_prefs.gf_low_at_maxdepth, ui->gf_low_at_maxdepth->isChecked()); + SAVE_OR_REMOVE("show_ccr_setpoint", default_prefs.show_ccr_setpoint, ui->show_ccr_setpoint->isChecked()); + SAVE_OR_REMOVE("show_ccr_sensors", default_prefs.show_ccr_sensors, ui->show_ccr_sensors->isChecked()); + SAVE_OR_REMOVE("display_unused_tanks", default_prefs.display_unused_tanks, ui->display_unused_tanks->isChecked()); + SAVE_OR_REMOVE("show_average_depth", default_prefs.show_average_depth, ui->show_average_depth->isChecked()); + s.endGroup(); +} + +#define DANGER_GF (gf > 100) ? "* { color: red; }" : "" +void PreferencesGraph::on_gflow_valueChanged(int gf) +{ + ui->gflow->setStyleSheet(DANGER_GF); +} +void PreferencesGraph::on_gfhigh_valueChanged(int gf) +{ + ui->gfhigh->setStyleSheet(DANGER_GF); +} +#undef DANGER_GF
\ No newline at end of file diff --git a/desktop-widgets/preferences/preferences_graph.h b/desktop-widgets/preferences/preferences_graph.h new file mode 100644 index 000000000..ca40c0a92 --- /dev/null +++ b/desktop-widgets/preferences/preferences_graph.h @@ -0,0 +1,27 @@ +#ifndef PREFERENCES_GRAPH_H +#define PREFERENCES_GRAPH_H + +#include "abstractpreferenceswidget.h" + +namespace Ui { + class PreferencesGraph; +} + +class PreferencesGraph : public AbstractPreferencesWidget { + Q_OBJECT +public: + PreferencesGraph(); + virtual ~PreferencesGraph(); + virtual void refreshSettings(); + virtual void syncSettings(); + +private slots: + void on_gflow_valueChanged(int gf); + void on_gfhigh_valueChanged(int gf); + +private: + Ui::PreferencesGraph *ui; + +}; + +#endif
\ No newline at end of file diff --git a/desktop-widgets/preferences/preferences_graph.ui b/desktop-widgets/preferences/preferences_graph.ui new file mode 100644 index 000000000..bdbbc75d3 --- /dev/null +++ b/desktop-widgets/preferences/preferences_graph.ui @@ -0,0 +1,268 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PreferencesGraph</class> + <widget class="QWidget" name="PreferencesGraph"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>505</width> + <height>623</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox_4"> + <property name="title"> + <string>Show</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_12"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Threshold when showing pOâ‚‚</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QDoubleSpinBox" name="po2Threshold"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="singleStep"> + <double>0.100000000000000</double> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_13"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Threshold when showing pNâ‚‚</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QDoubleSpinBox" name="pn2Threshold"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="singleStep"> + <double>0.100000000000000</double> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_17"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Threshold when showing pHe</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QDoubleSpinBox" name="pheThreshold"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="singleStep"> + <double>0.100000000000000</double> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_18"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Max pOâ‚‚ when showing MOD</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QDoubleSpinBox" name="maxpo2"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="singleStep"> + <double>0.100000000000000</double> + </property> + </widget> + </item> + <item row="4" column="0" colspan="2"> + <widget class="QCheckBox" name="red_ceiling"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Draw dive computer reported ceiling red</string> + </property> + </widget> + </item> + <item row="5" column="0" colspan="2"> + <widget class="QCheckBox" name="display_unused_tanks"> + <property name="text"> + <string>Show unused cylinders in Equipment tab</string> + </property> + </widget> + </item> + <item row="6" column="0" colspan="2"> + <widget class="QCheckBox" name="show_average_depth"> + <property name="text"> + <string>Show average depth</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_5"> + <property name="title"> + <string>Misc</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="1"> + <widget class="QSpinBox" name="gflow"> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>150</number> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QDoubleSpinBox" name="defaultSetpoint"> + <property name="suffix"> + <string>bar</string> + </property> + <property name="decimals"> + <number>2</number> + </property> + <property name="maximum"> + <double>10.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.100000000000000</double> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_26"> + <property name="text"> + <string>Default CCR set-point for dive planning</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="pSCR"> + <property name="text"> + <string>pSCR Oâ‚‚ metabolism rate</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_19"> + <property name="text"> + <string>GFLow</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_20"> + <property name="text"> + <string>GFHigh</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="gfhigh"> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>150</number> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QDoubleSpinBox" name="psro2rate"> + <property name="suffix"> + <string>â„“/min</string> + </property> + <property name="decimals"> + <number>3</number> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_28"> + <property name="text"> + <string>pSCR ratio</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QSpinBox" name="pscrfactor"> + <property name="suffix"> + <string/> + </property> + <property name="prefix"> + <string>1:</string> + </property> + </widget> + </item> + <item row="7" column="0" colspan="2"> + <widget class="QCheckBox" name="show_ccr_sensors"> + <property name="text"> + <string>CCR: show individual Oâ‚‚ sensor values when viewing pOâ‚‚</string> + </property> + </widget> + </item> + <item row="6" column="0" colspan="2"> + <widget class="QCheckBox" name="show_ccr_setpoint"> + <property name="text"> + <string>CCR: show setpoints when viewing pOâ‚‚</string> + </property> + </widget> + </item> + <item row="5" column="0" colspan="2"> + <widget class="QCheckBox" name="gf_low_at_maxdepth"> + <property name="text"> + <string>GFLow at max depth</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp new file mode 100644 index 000000000..31bbd1c20 --- /dev/null +++ b/desktop-widgets/preferences/preferences_language.cpp @@ -0,0 +1,72 @@ +#include "preferences_language.h" +#include "ui_prefs_language.h" +#include "subsurface-core/helpers.h" + +#include <QApplication> +#include <QSettings> +#include <QMessageBox> +#include <QSortFilterProxyModel> + +#include "qt-models/models.h" + +PreferencesLanguage::PreferencesLanguage() : AbstractPreferencesWidget(tr("Language"), QIcon(":/language"), 4) +{ + ui = new Ui::PreferencesLanguage(); + ui->setupUi(this); + + QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(); + filterModel->setSourceModel(LanguageModel::instance()); + filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + ui->languageDropdown->setModel(filterModel); + filterModel->sort(0); + connect(ui->languageFilter, &QLineEdit::textChanged, + filterModel, &QSortFilterProxyModel::setFilterFixedString); +} + +PreferencesLanguage::~PreferencesLanguage() +{ + delete ui; +} + +void PreferencesLanguage::refreshSettings() +{ + QSettings s; + s.beginGroup("Language"); + ui->languageSystemDefault->setChecked(s.value("UseSystemLanguage", true).toBool()); + ui->timeFormatSystemDefault->setChecked(!s.value("time_format_override", false).toBool()); + ui->dateFormatSystemDefault->setChecked(!s.value("date_format_override", false).toBool()); + ui->timeFormatEntry->setText(s.value("time_format").toString()); + ui->dateFormatEntry->setText(s.value("date_format").toString()); + ui->shortDateFormatEntry->setText(s.value("date_format_short").toString()); + QAbstractItemModel *m = ui->languageDropdown->model(); + QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, s.value("UiLanguage").toString()); + if (languages.count()) + ui->languageDropdown->setCurrentIndex(languages.first().row()); + s.endGroup(); +} + +void PreferencesLanguage::syncSettings() +{ + QSettings s; + s.beginGroup("Language"); + bool useSystemLang = s.value("UseSystemLanguage", true).toBool(); + QAbstractItemModel *m = ui->languageDropdown->model(); + QString currentText = m->data(m->index(ui->languageDropdown->currentIndex(),0), Qt::UserRole).toString(); + if (useSystemLang != ui->languageSystemDefault->isChecked() || + (!useSystemLang && s.value("UiLanguage").toString() != currentText)) { + QMessageBox::warning(this, tr("Restart required"), + tr("To correctly load a new language you must restart Subsurface.")); + } + s.setValue("UiLanguage", currentText); + s.setValue("UseSystemLanguage", ui->languageSystemDefault->isChecked()); + s.setValue("time_format_override", !ui->timeFormatSystemDefault->isChecked()); + s.setValue("date_format_override", !ui->dateFormatSystemDefault->isChecked()); + if (!ui->timeFormatSystemDefault->isChecked()) + s.setValue("time_format", ui->timeFormatEntry->text()); + if (!ui->dateFormatSystemDefault->isChecked()) { + s.setValue("date_format", ui->dateFormatEntry->text()); + s.setValue("date_format_short", ui->shortDateFormatEntry->text()); + } + s.endGroup(); + uiLanguage(NULL); +} diff --git a/desktop-widgets/preferences/preferences_language.h b/desktop-widgets/preferences/preferences_language.h new file mode 100644 index 000000000..43014c0fd --- /dev/null +++ b/desktop-widgets/preferences/preferences_language.h @@ -0,0 +1,21 @@ +#ifndef PREFERENCES_LANGUAGE_H +#define PREFERENCES_LANGUAGE_H + +#include "abstractpreferenceswidget.h" + +namespace Ui { + class PreferencesLanguage; +} + +class PreferencesLanguage : public AbstractPreferencesWidget { + Q_OBJECT +public: + PreferencesLanguage(); + virtual ~PreferencesLanguage(); + virtual void refreshSettings(); + virtual void syncSettings(); +private: + Ui::PreferencesLanguage *ui; +}; + +#endif
\ No newline at end of file diff --git a/desktop-widgets/preferences/preferences_network.cpp b/desktop-widgets/preferences/preferences_network.cpp new file mode 100644 index 000000000..3780a6c91 --- /dev/null +++ b/desktop-widgets/preferences/preferences_network.cpp @@ -0,0 +1,172 @@ +#include "preferences_network.h" +#include "ui_preferences_network.h" +#include "dive.h" +#include "subsurfacewebservices.h" +#include "subsurface-core/prefs-macros.h" + +#include <QNetworkProxy> +#include <QSettings> + +PreferencesNetwork::PreferencesNetwork() : AbstractPreferencesWidget(tr("Network"),QIcon(":network"), 9), ui(new Ui::PreferencesNetwork()) +{ + ui->setupUi(this); + + ui->proxyType->clear(); + ui->proxyType->addItem(tr("No proxy"), QNetworkProxy::NoProxy); + ui->proxyType->addItem(tr("System proxy"), QNetworkProxy::DefaultProxy); + ui->proxyType->addItem(tr("HTTP proxy"), QNetworkProxy::HttpProxy); + ui->proxyType->addItem(tr("SOCKS proxy"), QNetworkProxy::Socks5Proxy); + ui->proxyType->setCurrentIndex(-1); + + connect(ui->proxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(proxyType_changed(int))); +} + +PreferencesNetwork::~PreferencesNetwork() +{ + delete ui; +} + +void PreferencesNetwork::refreshSettings() +{ + QSettings s; + + ui->proxyHost->setText(prefs.proxy_host); + ui->proxyPort->setValue(prefs.proxy_port); + ui->proxyAuthRequired->setChecked(prefs.proxy_auth); + ui->proxyUsername->setText(prefs.proxy_user); + ui->proxyPassword->setText(prefs.proxy_pass); + ui->proxyType->setCurrentIndex(ui->proxyType->findData(prefs.proxy_type)); + ui->cloud_storage_email->setText(prefs.cloud_storage_email); + ui->cloud_storage_password->setText(prefs.cloud_storage_password); + ui->save_password_local->setChecked(prefs.save_password_local); + ui->cloud_background_sync->setChecked(prefs.cloud_background_sync); + ui->save_uid_local->setChecked(prefs.save_userid_local); + ui->default_uid->setText(s.value("subsurface_webservice_uid").toString().toUpper()); + + cloudPinNeeded(); +} + +void PreferencesNetwork::syncSettings() +{ + QSettings s; + s.setValue("subsurface_webservice_uid", ui->default_uid->text().toUpper()); + set_save_userid_local(ui->save_uid_local->checkState()); + + s.beginGroup("Network"); + s.setValue("proxy_type", ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt()); + s.setValue("proxy_host", ui->proxyHost->text()); + s.setValue("proxy_port", ui->proxyPort->value()); + SB("proxy_auth", ui->proxyAuthRequired); + s.setValue("proxy_user", ui->proxyUsername->text()); + s.setValue("proxy_pass", ui->proxyPassword->text()); + s.endGroup(); + + s.beginGroup("CloudStorage"); + QString email = ui->cloud_storage_email->text(); + QString password = ui->cloud_storage_password->text(); + QString newpassword = ui->cloud_storage_new_passwd->text(); + if (prefs.cloud_verification_status == CS_VERIFIED && !newpassword.isEmpty()) { + // deal with password change + if (!email.isEmpty() && !password.isEmpty()) { + // connect to backend server to check / create credentials + QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$"); + if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) { + report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); + } else { + CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this); + connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded())); + connect(cloudAuth, SIGNAL(passwordChangeSuccessful()), this, SLOT(passwordUpdateSuccessfull())); + QNetworkReply *reply = cloudAuth->backend(email, password, "", newpassword); + ui->cloud_storage_new_passwd->setText(""); + free(prefs.cloud_storage_newpassword); + prefs.cloud_storage_newpassword = strdup(qPrintable(newpassword)); + } + } + } else if (prefs.cloud_verification_status == CS_UNKNOWN || + prefs.cloud_verification_status == CS_INCORRECT_USER_PASSWD || + email != prefs.cloud_storage_email || + password != prefs.cloud_storage_password) { + + // different credentials - reset verification status + prefs.cloud_verification_status = CS_UNKNOWN; + if (!email.isEmpty() && !password.isEmpty()) { + // connect to backend server to check / create credentials + QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$"); + if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) { + report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); + } else { + CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this); + connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded())); + QNetworkReply *reply = cloudAuth->backend(email, password); + } + } + } else if (prefs.cloud_verification_status == CS_NEED_TO_VERIFY) { + QString pin = ui->cloud_storage_pin->text(); + if (!pin.isEmpty()) { + // connect to backend server to check / create credentials + QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$"); + if (!reg.match(email).hasMatch() || !reg.match(password).hasMatch()) { + report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); + } + CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this); + connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded())); + QNetworkReply *reply = cloudAuth->backend(email, password, pin); + } + } + SAVE_OR_REMOVE("email", default_prefs.cloud_storage_email, email); + SAVE_OR_REMOVE("save_password_local", default_prefs.save_password_local, ui->save_password_local->isChecked()); + if (ui->save_password_local->isChecked()) { + SAVE_OR_REMOVE("password", default_prefs.cloud_storage_password, password); + } else { + s.remove("password"); + free(prefs.cloud_storage_password); + prefs.cloud_storage_password = strdup(qPrintable(password)); + } + SAVE_OR_REMOVE("cloud_verification_status", default_prefs.cloud_verification_status, prefs.cloud_verification_status); + SAVE_OR_REMOVE("cloud_background_sync", default_prefs.cloud_background_sync, ui->cloud_background_sync->isChecked()); + + // at this point we intentionally do not have a UI for changing this + // it could go into some sort of "advanced setup" or something + SAVE_OR_REMOVE("cloud_base_url", default_prefs.cloud_base_url, prefs.cloud_base_url); + s.endGroup(); +} + +void PreferencesNetwork::cloudPinNeeded() +{ + ui->cloud_storage_pin->setEnabled(prefs.cloud_verification_status == CS_NEED_TO_VERIFY); + ui->cloud_storage_pin->setVisible(prefs.cloud_verification_status == CS_NEED_TO_VERIFY); + ui->cloud_storage_pin_label->setEnabled(prefs.cloud_verification_status == CS_NEED_TO_VERIFY); + ui->cloud_storage_pin_label->setVisible(prefs.cloud_verification_status == CS_NEED_TO_VERIFY); + ui->cloud_storage_new_passwd->setEnabled(prefs.cloud_verification_status == CS_VERIFIED); + ui->cloud_storage_new_passwd->setVisible(prefs.cloud_verification_status == CS_VERIFIED); + ui->cloud_storage_new_passwd_label->setEnabled(prefs.cloud_verification_status == CS_VERIFIED); + ui->cloud_storage_new_passwd_label->setVisible(prefs.cloud_verification_status == CS_VERIFIED); + if (prefs.cloud_verification_status == CS_VERIFIED) { + ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (credentials verified)")); + } else { + ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage")); + } + //TODO: Do not call mainWindow here. Verify things on SettingsChanged. + //MainWindow::instance()->enableDisableCloudActions(); +} + +void PreferencesNetwork::proxyType_changed(int idx) +{ + if (idx == -1) { + return; + } + + int proxyType = ui->proxyType->itemData(idx).toInt(); + bool hpEnabled = (proxyType == QNetworkProxy::Socks5Proxy || proxyType == QNetworkProxy::HttpProxy); + ui->proxyHost->setEnabled(hpEnabled); + ui->proxyPort->setEnabled(hpEnabled); + ui->proxyAuthRequired->setEnabled(hpEnabled); + ui->proxyUsername->setEnabled(hpEnabled & ui->proxyAuthRequired->isChecked()); + ui->proxyPassword->setEnabled(hpEnabled & ui->proxyAuthRequired->isChecked()); + ui->proxyAuthRequired->setChecked(ui->proxyAuthRequired->isChecked()); +} + +void PreferencesNetwork::passwordUpdateSuccessfull() +{ + ui->cloud_storage_password->setText(prefs.cloud_storage_password); +}
\ No newline at end of file diff --git a/desktop-widgets/preferences/preferences_network.h b/desktop-widgets/preferences/preferences_network.h new file mode 100644 index 000000000..3e17d51b0 --- /dev/null +++ b/desktop-widgets/preferences/preferences_network.h @@ -0,0 +1,28 @@ +#ifndef PREFERENCES_NETWORK_H +#define PREFERENCES_NETWORK_H + +#include "abstractpreferenceswidget.h" + +namespace Ui { + class PreferencesNetwork; +} + +class PreferencesNetwork : public AbstractPreferencesWidget { + Q_OBJECT + +public: + PreferencesNetwork(); + virtual ~PreferencesNetwork(); + virtual void refreshSettings(); + virtual void syncSettings(); + +public slots: + void proxyType_changed(int i); + +private: + Ui::PreferencesNetwork *ui; + void cloudPinNeeded(); + void passwordUpdateSuccessfull(); +}; + +#endif
\ No newline at end of file diff --git a/desktop-widgets/preferences/preferences_network.ui b/desktop-widgets/preferences/preferences_network.ui new file mode 100644 index 000000000..8bb9bf9a0 --- /dev/null +++ b/desktop-widgets/preferences/preferences_network.ui @@ -0,0 +1,293 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PreferencesNetwork</class> + <widget class="QWidget" name="PreferencesNetwork"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>713</width> + <height>558</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox_10"> + <property name="title"> + <string>Proxy</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="1" column="2"> + <widget class="QLabel" name="label_23"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Port</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_22"> + <property name="text"> + <string>Host</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_21"> + <property name="text"> + <string>Proxy type</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_24"> + <property name="text"> + <string>Username</string> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QSpinBox" name="proxyPort"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximum"> + <number>65535</number> + </property> + <property name="value"> + <number>80</number> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="proxyHost"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maxLength"> + <number>64</number> + </property> + </widget> + </item> + <item row="0" column="1" colspan="3"> + <widget class="QComboBox" name="proxyType"/> + </item> + <item row="2" column="1" colspan="3"> + <widget class="QCheckBox" name="proxyAuthRequired"> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="text"> + <string>Requires authentication</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="proxyUsername"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maxLength"> + <number>32</number> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLabel" name="label_25"> + <property name="text"> + <string>Password</string> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QLineEdit" name="proxyPassword"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maxLength"> + <number>32</number> + </property> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="cloudStorageGroupBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>129</height> + </size> + </property> + <property name="title"> + <string>Subsurface cloud storage</string> + </property> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="0" column="0"> + <widget class="QLabel" name="label_16b"> + <property name="toolTip"> + <string extracomment="Email address used for the Subsurface cloud storage infrastructure"/> + </property> + <property name="text"> + <string>Email address</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_16c"> + <property name="text"> + <string>Password</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="cloud_storage_pin_label"> + <property name="text"> + <string>Verification PIN</string> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QLabel" name="cloud_storage_new_passwd_label"> + <property name="text"> + <string>New password</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLineEdit" name="cloud_storage_email"> + <property name="toolTip"> + <string extracomment="Email address used for the Subsurface cloud storage infrastructure"/> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="cloud_storage_password"> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="cloud_storage_pin"> + <property name="toolTip"> + <string extracomment="One time verification PIN for Subsurface cloud storage infrastructure"/> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QLineEdit" name="cloud_storage_new_passwd"> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QCheckBox" name="cloud_background_sync"> + <property name="text"> + <string>Sync to cloud in the background?</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="save_password_local"> + <property name="text"> + <string>Save Password locally?</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_8"> + <property name="title"> + <string>Subsurface web service</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <property name="spacing"> + <number>5</number> + </property> + <property name="leftMargin"> + <number>5</number> + </property> + <property name="topMargin"> + <number>5</number> + </property> + <property name="rightMargin"> + <number>5</number> + </property> + <property name="bottomMargin"> + <number>5</number> + </property> + <item> + <widget class="QLabel" name="label_16"> + <property name="text"> + <string>Default user ID</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="default_uid"/> + </item> + <item> + <widget class="QCheckBox" name="save_uid_local"> + <property name="text"> + <string>Save user ID locally?</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/desktop-widgets/preferences/preferences_units.cpp b/desktop-widgets/preferences/preferences_units.cpp new file mode 100644 index 000000000..cc77e51bb --- /dev/null +++ b/desktop-widgets/preferences/preferences_units.cpp @@ -0,0 +1,60 @@ +#include "preferences_units.h" +#include "ui_preferences_units.h" +#include "prefs-macros.h" +#include "qthelper.h" + +#include <QSettings> + +PreferencesUnits::PreferencesUnits(): AbstractPreferencesWidget(tr("Units"),QIcon(":units"),1), ui(new Ui::PreferencesUnits()) +{ + ui->setupUi(this); +} + +PreferencesUnits::~PreferencesUnits() +{ + +} + +void PreferencesUnits::refreshSettings() +{ + switch(prefs.unit_system) { + case METRIC: ui->metric->setChecked(true); break; + case IMPERIAL: ui->imperial->setChecked(true); break; + default: ui->personalize->setChecked(true); break; + } + + ui->gpsTraditional->setChecked(prefs.coordinates_traditional); + ui->gpsDecimal->setChecked(!prefs.coordinates_traditional); + + ui->celsius->setChecked(prefs.units.temperature == units::CELSIUS); + ui->fahrenheit->setChecked(prefs.units.temperature == units::FAHRENHEIT); + ui->meter->setChecked(prefs.units.length == units::METERS); + ui->feet->setChecked(prefs.units.length == units::FEET); + ui->bar->setChecked(prefs.units.pressure == units::BAR); + ui->psi->setChecked(prefs.units.pressure == units::PSI); + ui->liter->setChecked(prefs.units.volume == units::LITER); + ui->cuft->setChecked(prefs.units.volume == units::CUFT); + ui->kg->setChecked(prefs.units.weight == units::KG); + ui->lbs->setChecked(prefs.units.weight == units::LBS); + ui->units_group->setEnabled(ui->personalize->isChecked()); + + ui->vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES); + ui->vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS); +} + +void PreferencesUnits::syncSettings() +{ + QSettings s; + s.beginGroup("Units"); + QString unitSystem[] = {"metric", "imperial", "personal"}; + short unitValue = ui->metric->isChecked() ? METRIC : (ui->imperial->isChecked() ? IMPERIAL : PERSONALIZE); + SAVE_OR_REMOVE_SPECIAL("unit_system", default_prefs.unit_system, unitValue, unitSystem[unitValue]); + s.setValue("temperature", ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS); + s.setValue("length", ui->feet->isChecked() ? units::FEET : units::METERS); + s.setValue("pressure", ui->psi->isChecked() ? units::PSI : units::BAR); + s.setValue("volume", ui->cuft->isChecked() ? units::CUFT : units::LITER); + s.setValue("weight", ui->lbs->isChecked() ? units::LBS : units::KG); + s.setValue("vertical_speed_time", ui->vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS); + s.setValue("coordinates", ui->gpsTraditional->isChecked()); + s.endGroup(); +} diff --git a/desktop-widgets/preferences/preferences_units.h b/desktop-widgets/preferences/preferences_units.h new file mode 100644 index 000000000..21a7f4404 --- /dev/null +++ b/desktop-widgets/preferences/preferences_units.h @@ -0,0 +1,21 @@ +#ifndef PREFERENCES_UNITS_H +#define PREFERENCES_UNITS_H + +#include "abstractpreferenceswidget.h" + +namespace Ui { + class PreferencesUnits; +} + +class PreferencesUnits : public AbstractPreferencesWidget { + Q_OBJECT +public: + PreferencesUnits(); + virtual ~PreferencesUnits(); + virtual void refreshSettings(); + virtual void syncSettings(); +private: + Ui::PreferencesUnits *ui; +}; + +#endif
\ No newline at end of file diff --git a/desktop-widgets/preferences/preferences_units.ui b/desktop-widgets/preferences/preferences_units.ui new file mode 100644 index 000000000..bb1ffba66 --- /dev/null +++ b/desktop-widgets/preferences/preferences_units.ui @@ -0,0 +1,251 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PreferencesUnits</class> + <widget class="QWidget" name="PreferencesUnits"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>374</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox_units"> + <property name="title"> + <string>Unit system</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>System</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="metric"> + <property name="text"> + <string>&Metric</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="imperial"> + <property name="text"> + <string>Imperial</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="personalize"> + <property name="text"> + <string>Personali&ze</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="units_group"> + <property name="title"> + <string>Individual settings</string> + </property> + <property name="checkable"> + <bool>false</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Depth</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QRadioButton" name="meter"> + <property name="text"> + <string>meter</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QRadioButton" name="feet"> + <property name="text"> + <string>feet</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Pressure</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QRadioButton" name="bar"> + <property name="text"> + <string>bar</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QRadioButton" name="psi"> + <property name="text"> + <string>psi</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Volume</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QRadioButton" name="liter"> + <property name="text"> + <string>&liter</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QRadioButton" name="cuft"> + <property name="text"> + <string>cu ft</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Temperature</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QRadioButton" name="celsius"> + <property name="text"> + <string>celsius</string> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QRadioButton" name="fahrenheit"> + <property name="text"> + <string>fahrenheit</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Weight</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QRadioButton" name="kg"> + <property name="text"> + <string>kg</string> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QRadioButton" name="lbs"> + <property name="text"> + <string>lbs</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Time units</string> + </property> + <layout class="QGridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label13"> + <property name="text"> + <string>Ascent/descent speed denominator</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QRadioButton" name="vertical_speed_minutes"> + <property name="text"> + <string>Minutes</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QRadioButton" name="vertical_speed_seconds"> + <property name="text"> + <string>Seconds</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_11"> + <property name="title"> + <string>GPS coordinates</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_12"> + <item> + <widget class="QLabel" name="label_27"> + <property name="text"> + <string>Location Display</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="gpsTraditional"> + <property name="text"> + <string>traditional (dms)</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="gpsDecimal"> + <property name="text"> + <string>decimal</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp new file mode 100644 index 000000000..d8798879a --- /dev/null +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -0,0 +1,140 @@ +#include "preferencesdialog.h" + +#include "abstractpreferenceswidget.h" +#include "preferences_language.h" +#include "preferences_georeference.h" +#include "preferences_defaults.h" +#include "preferences_units.h" +#include "preferences_graph.h" +#include "preferences_network.h" + +#include "subsurface-core/qthelper.h" + +#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QListWidget> +#include <QStackedWidget> +#include <QDialogButtonBox> +#include <QAbstractButton> +#include <QDebug> + +PreferencesDialog* PreferencesDialog::instance() +{ + static PreferencesDialog *self = new PreferencesDialog(); + return self; +} + +void PreferencesDialog::emitSettingsChanged() +{ + emit settingsChanged(); +} + +PreferencesDialog::PreferencesDialog() +{ + loadPreferences(); //TODO: Move this code out of the qthelper.cpp + + pagesList = new QListWidget(); + pagesStack = new QStackedWidget(); + buttonBox = new QDialogButtonBox( + QDialogButtonBox::Save | + QDialogButtonBox::Apply | + QDialogButtonBox::Cancel); + + pagesList->setMinimumWidth(120); + pagesList->setMaximumWidth(120); + + QHBoxLayout *h = new QHBoxLayout(); + h->addWidget(pagesList); + h->addWidget(pagesStack); + QVBoxLayout *v = new QVBoxLayout(); + v->addLayout(h); + v->addWidget(buttonBox); + + setLayout(v); + + addPreferencePage(new PreferencesLanguage()); + addPreferencePage(new PreferencesGeoreference()); + addPreferencePage(new PreferencesDefaults()); + addPreferencePage(new PreferencesUnits()); + addPreferencePage(new PreferencesGraph()); + addPreferencePage(new PreferencesNetwork()); + refreshPages(); + + connect(pagesList, &QListWidget::currentRowChanged, + pagesStack, &QStackedWidget::setCurrentIndex); + connect(buttonBox, &QDialogButtonBox::clicked, + this, &PreferencesDialog::buttonClicked); +} + +PreferencesDialog::~PreferencesDialog() +{ +} + +void PreferencesDialog::buttonClicked(QAbstractButton* btn) +{ + QDialogButtonBox::ButtonRole role = buttonBox->buttonRole(btn); + switch(role) { + case QDialogButtonBox::ApplyRole : applyRequested(false); return; + case QDialogButtonBox::AcceptRole : applyRequested(true); return; + case QDialogButtonBox::RejectRole : cancelRequested(); return; + case QDialogButtonBox::ResetRole : defaultsRequested(); return; + } +} + +bool abstractpreferenceswidget_lessthan(AbstractPreferencesWidget *p1, AbstractPreferencesWidget *p2) +{ + return p1->positionHeight() <= p2->positionHeight(); +} + +void PreferencesDialog::addPreferencePage(AbstractPreferencesWidget *page) +{ + pages.push_back(page); + qSort(pages.begin(), pages.end(), abstractpreferenceswidget_lessthan); +} + +void PreferencesDialog::refreshPages() +{ + // Remove things + pagesList->clear(); + while(pagesStack->count()) { + QWidget *curr = pagesStack->widget(0); + pagesStack->removeWidget(curr); + curr->setParent(0); + } + + // Readd things. + Q_FOREACH(AbstractPreferencesWidget *page, pages) { + QListWidgetItem *item = new QListWidgetItem(page->icon(), page->name()); + pagesList->addItem(item); + pagesStack->addWidget(page); + page->refreshSettings(); + } +} + +void PreferencesDialog::applyRequested(bool closeIt) +{ + Q_FOREACH(AbstractPreferencesWidget *page, pages) { + page->syncSettings(); + } + emit settingsChanged(); + if (closeIt) + accept(); +} + +void PreferencesDialog::cancelRequested() +{ + Q_FOREACH(AbstractPreferencesWidget *page, pages) { + page->refreshSettings(); + } + reject(); +} + +void PreferencesDialog::defaultsRequested() +{ + prefs = default_prefs; + Q_FOREACH(AbstractPreferencesWidget *page, pages) { + page->refreshSettings(); + } + emit settingsChanged(); + accept(); +} diff --git a/desktop-widgets/preferences/preferencesdialog.h b/desktop-widgets/preferences/preferencesdialog.h new file mode 100644 index 000000000..5f7f5f979 --- /dev/null +++ b/desktop-widgets/preferences/preferencesdialog.h @@ -0,0 +1,35 @@ +#ifndef PREFERENCES_WIDGET_H +#define PREFERENCES_WIDGET_H + +#include <QDialog> +#include "pref.h" + +class AbstractPreferencesWidget; +class QListWidget; +class QStackedWidget; +class QDialogButtonBox; +class QAbstractButton; + +class PreferencesDialog : public QDialog { + Q_OBJECT +public: + static PreferencesDialog* instance(); + virtual ~PreferencesDialog(); + void addPreferencePage(AbstractPreferencesWidget *page); + void refreshPages(); + void emitSettingsChanged(); +signals: + void settingsChanged(); +private: + PreferencesDialog(); + void cancelRequested(); + void applyRequested(bool closeIt); + void defaultsRequested(); + void buttonClicked(QAbstractButton *btn); + QList<AbstractPreferencesWidget*> pages; + QListWidget *pagesList; + QStackedWidget *pagesStack; + QDialogButtonBox *buttonBox; +}; + +#endif diff --git a/desktop-widgets/preferences/prefs_georeference.ui b/desktop-widgets/preferences/prefs_georeference.ui new file mode 100644 index 000000000..7d4f0907e --- /dev/null +++ b/desktop-widgets/preferences/prefs_georeference.ui @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PreferencesGeoreference</class> + <widget class="QWidget" name="PreferencesGeoreference"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox_Geocoding"> + <property name="title"> + <string>Dive site geo lookup</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_8"> + <item> + <widget class="QCheckBox" name="enable_geocoding"> + <property name="text"> + <string>Enable geocoding for dive site management</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="parse_without_gps"> + <property name="text"> + <string>Parse site without GPS data</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="tag_existing_dives"> + <property name="text"> + <string>Same format for existing dives</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_12"> + <property name="title"> + <string>Dive Site Layout</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_10"> + <item> + <widget class="QComboBox" name="first_item"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_29"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>/</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="second_item"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_30"> + <property name="text"> + <string>/</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="third_item"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer_6"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>109</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/desktop-widgets/preferences/prefs_language.ui b/desktop-widgets/preferences/prefs_language.ui new file mode 100644 index 000000000..af3a0ad87 --- /dev/null +++ b/desktop-widgets/preferences/prefs_language.ui @@ -0,0 +1,260 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PreferencesLanguage</class> + <widget class="QWidget" name="PreferencesLanguage"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>621</width> + <height>523</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="language_group"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>UI language</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QCheckBox" name="languageSystemDefault"> + <property name="text"> + <string>Use system default</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="languageDropdown"/> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>203</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label_14"> + <property name="text"> + <string>Filter</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="languageFilter"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="dateformat_group"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Date format</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="1"> + <widget class="QLineEdit" name="dateFormatEntry"> + <property name="toolTip"> + <string><html><head/><body><p>Preferred date format. Commonly used fields are</p><p>d (day of month)</p><p>ddd (abbr. day name)</p><p>M (month number)</p><p>MMM (abbr. month name)</p><p>yy/yyyy (2/4 digit year)</p></body></html></string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QCheckBox" name="dateFormatSystemDefault"> + <property name="text"> + <string>Use UI language default</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="shortDateFormatEntry"/> + </item> + <item row="1" column="3"> + <widget class="QLabel" name="label"> + <property name="toolTip"> + <string>This is used in places where there is less space to show the full date</string> + </property> + <property name="text"> + <string>Short format</string> + </property> + </widget> + </item> + <item row="0" column="3"> + <spacer name="horizontalSpacer2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>203</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="timeformat_group"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Time format</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout3"> + <item> + <widget class="QCheckBox" name="timeFormatSystemDefault"> + <property name="text"> + <string>Use UI language default</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="timeFormatEntry"> + <property name="toolTip"> + <string><html><head/><body><p>Preferred time format</p><p>Commonly used format specifiers are</p><p>h (hours in 12h format)</p><p>H (hours in 24h format)</p><p>mm (2 digit minutes)</p><p>ss (2 digit seconds)</p><p>t/tt (a/p or am/pm)</p></body></html></string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>203</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>languageSystemDefault</sender> + <signal>toggled(bool)</signal> + <receiver>languageDropdown</receiver> + <slot>setDisabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>73</x> + <y>273</y> + </hint> + <hint type="destinationlabel"> + <x>179</x> + <y>273</y> + </hint> + </hints> + </connection> + <connection> + <sender>languageSystemDefault</sender> + <signal>toggled(bool)</signal> + <receiver>languageFilter</receiver> + <slot>setDisabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>73</x> + <y>273</y> + </hint> + <hint type="destinationlabel"> + <x>539</x> + <y>273</y> + </hint> + </hints> + </connection> + <connection> + <sender>dateFormatSystemDefault</sender> + <signal>toggled(bool)</signal> + <receiver>dateFormatEntry</receiver> + <slot>setDisabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>79</x> + <y>132</y> + </hint> + <hint type="destinationlabel"> + <x>264</x> + <y>132</y> + </hint> + </hints> + </connection> + <connection> + <sender>timeFormatSystemDefault</sender> + <signal>toggled(bool)</signal> + <receiver>timeFormatEntry</receiver> + <slot>setDisabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>79</x> + <y>210</y> + </hint> + <hint type="destinationlabel"> + <x>264</x> + <y>210</y> + </hint> + </hints> + </connection> + <connection> + <sender>dateFormatSystemDefault</sender> + <signal>toggled(bool)</signal> + <receiver>shortDateFormatEntry</receiver> + <slot>setDisabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>99</x> + <y>132</y> + </hint> + <hint type="destinationlabel"> + <x>293</x> + <y>169</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/qt-ui/printdialog.cpp b/desktop-widgets/printdialog.cpp index cf08062d2..cf08062d2 100644 --- a/qt-ui/printdialog.cpp +++ b/desktop-widgets/printdialog.cpp diff --git a/qt-ui/printdialog.h b/desktop-widgets/printdialog.h index a00c4c5d9..a00c4c5d9 100644 --- a/qt-ui/printdialog.h +++ b/desktop-widgets/printdialog.h diff --git a/printer.cpp b/desktop-widgets/printer.cpp index f0197d446..33ee71b55 100644 --- a/printer.cpp +++ b/desktop-widgets/printer.cpp @@ -8,6 +8,7 @@ #include <QPainter> #include <QWebElementCollection> #include <QWebElement> +#include "profile-widget/profilewidget2.h" Printer::Printer(QPaintDevice *paintDevice, print_options *printOptions, template_options *templateOptions, PrintMode printMode) { diff --git a/printer.h b/desktop-widgets/printer.h index 979cacd6a..e5f16d77d 100644 --- a/printer.h +++ b/desktop-widgets/printer.h @@ -6,7 +6,6 @@ #include <QRect> #include <QPainter> -#include "profile/profilewidget2.h" #include "printoptions.h" #include "templateedit.h" diff --git a/qt-ui/printoptions.cpp b/desktop-widgets/printoptions.cpp index 769c89ff4..769c89ff4 100644 --- a/qt-ui/printoptions.cpp +++ b/desktop-widgets/printoptions.cpp diff --git a/qt-ui/printoptions.h b/desktop-widgets/printoptions.h index 9c50b10f3..9c50b10f3 100644 --- a/qt-ui/printoptions.h +++ b/desktop-widgets/printoptions.h diff --git a/qt-ui/printoptions.ui b/desktop-widgets/printoptions.ui index 1c2523d39..1c2523d39 100644 --- a/qt-ui/printoptions.ui +++ b/desktop-widgets/printoptions.ui diff --git a/qt-ui/qtwaitingspinner.cpp b/desktop-widgets/qtwaitingspinner.cpp index 14e8669b0..14e8669b0 100644 --- a/qt-ui/qtwaitingspinner.cpp +++ b/desktop-widgets/qtwaitingspinner.cpp diff --git a/qt-ui/qtwaitingspinner.h b/desktop-widgets/qtwaitingspinner.h index 254b52ec7..254b52ec7 100644 --- a/qt-ui/qtwaitingspinner.h +++ b/desktop-widgets/qtwaitingspinner.h diff --git a/qt-ui/renumber.ui b/desktop-widgets/renumber.ui index 00e7b84bb..00e7b84bb 100644 --- a/qt-ui/renumber.ui +++ b/desktop-widgets/renumber.ui diff --git a/qt-ui/searchbar.ui b/desktop-widgets/searchbar.ui index 22bce39c6..22bce39c6 100644 --- a/qt-ui/searchbar.ui +++ b/desktop-widgets/searchbar.ui diff --git a/qt-ui/setpoint.ui b/desktop-widgets/setpoint.ui index d96488a31..d96488a31 100644 --- a/qt-ui/setpoint.ui +++ b/desktop-widgets/setpoint.ui diff --git a/qt-ui/shiftimagetimes.ui b/desktop-widgets/shiftimagetimes.ui index 0478a62b4..0478a62b4 100644 --- a/qt-ui/shiftimagetimes.ui +++ b/desktop-widgets/shiftimagetimes.ui diff --git a/qt-ui/shifttimes.ui b/desktop-widgets/shifttimes.ui index 486b1f43b..486b1f43b 100644 --- a/qt-ui/shifttimes.ui +++ b/desktop-widgets/shifttimes.ui diff --git a/qt-ui/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp index 62a9cc646..43ad1ddc0 100644 --- a/qt-ui/simplewidgets.cpp +++ b/desktop-widgets/simplewidgets.cpp @@ -14,7 +14,7 @@ #include "libdivecomputer/parser.h" #include "divelistview.h" #include "display.h" -#include "profile/profilewidget2.h" +#include "profile-widget/profilewidget2.h" #include "undocommands.h" class MinMaxAvgWidgetPrivate { diff --git a/qt-ui/simplewidgets.h b/desktop-widgets/simplewidgets.h index 595c4cd4b..595c4cd4b 100644 --- a/qt-ui/simplewidgets.h +++ b/desktop-widgets/simplewidgets.h diff --git a/qt-ui/socialnetworks.cpp b/desktop-widgets/socialnetworks.cpp index 6e191267a..0794c764e 100644 --- a/qt-ui/socialnetworks.cpp +++ b/desktop-widgets/socialnetworks.cpp @@ -16,7 +16,7 @@ #include <QMessageBox> #include <QInputDialog> #include "mainwindow.h" -#include "profile/profilewidget2.h" +#include "profile-widget/profilewidget2.h" #include "pref.h" #include "helpers.h" #include "ui_socialnetworksdialog.h" diff --git a/qt-ui/socialnetworks.h b/desktop-widgets/socialnetworks.h index 2f63915ca..2f63915ca 100644 --- a/qt-ui/socialnetworks.h +++ b/desktop-widgets/socialnetworks.h diff --git a/qt-ui/socialnetworksdialog.ui b/desktop-widgets/socialnetworksdialog.ui index e8953d1c7..e8953d1c7 100644 --- a/qt-ui/socialnetworksdialog.ui +++ b/desktop-widgets/socialnetworksdialog.ui diff --git a/qt-ui/starwidget.cpp b/desktop-widgets/starwidget.cpp index d959ed3b9..d959ed3b9 100644 --- a/qt-ui/starwidget.cpp +++ b/desktop-widgets/starwidget.cpp diff --git a/qt-ui/starwidget.h b/desktop-widgets/starwidget.h index 989aa527d..989aa527d 100644 --- a/qt-ui/starwidget.h +++ b/desktop-widgets/starwidget.h diff --git a/qt-ui/statistics/monthstatistics.cpp b/desktop-widgets/statistics/monthstatistics.cpp index e69de29bb..e69de29bb 100644 --- a/qt-ui/statistics/monthstatistics.cpp +++ b/desktop-widgets/statistics/monthstatistics.cpp diff --git a/qt-ui/statistics/monthstatistics.h b/desktop-widgets/statistics/monthstatistics.h index e69de29bb..e69de29bb 100644 --- a/qt-ui/statistics/monthstatistics.h +++ b/desktop-widgets/statistics/monthstatistics.h diff --git a/qt-ui/statistics/statisticsbar.cpp b/desktop-widgets/statistics/statisticsbar.cpp index e69de29bb..e69de29bb 100644 --- a/qt-ui/statistics/statisticsbar.cpp +++ b/desktop-widgets/statistics/statisticsbar.cpp diff --git a/qt-ui/statistics/statisticsbar.h b/desktop-widgets/statistics/statisticsbar.h index e69de29bb..e69de29bb 100644 --- a/qt-ui/statistics/statisticsbar.h +++ b/desktop-widgets/statistics/statisticsbar.h diff --git a/qt-ui/statistics/statisticswidget.cpp b/desktop-widgets/statistics/statisticswidget.cpp index 3e91fa317..3e91fa317 100644 --- a/qt-ui/statistics/statisticswidget.cpp +++ b/desktop-widgets/statistics/statisticswidget.cpp diff --git a/qt-ui/statistics/statisticswidget.h b/desktop-widgets/statistics/statisticswidget.h index ae988292d..ae988292d 100644 --- a/qt-ui/statistics/statisticswidget.h +++ b/desktop-widgets/statistics/statisticswidget.h diff --git a/qt-ui/statistics/yearstatistics.cpp b/desktop-widgets/statistics/yearstatistics.cpp index e69de29bb..e69de29bb 100644 --- a/qt-ui/statistics/yearstatistics.cpp +++ b/desktop-widgets/statistics/yearstatistics.cpp diff --git a/qt-ui/statistics/yearstatistics.h b/desktop-widgets/statistics/yearstatistics.h index e69de29bb..e69de29bb 100644 --- a/qt-ui/statistics/yearstatistics.h +++ b/desktop-widgets/statistics/yearstatistics.h diff --git a/qt-ui/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp index ee079cc48..ee079cc48 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/desktop-widgets/subsurfacewebservices.cpp diff --git a/qt-ui/subsurfacewebservices.h b/desktop-widgets/subsurfacewebservices.h index 2b454ebc7..2b454ebc7 100644 --- a/qt-ui/subsurfacewebservices.h +++ b/desktop-widgets/subsurfacewebservices.h diff --git a/qt-ui/tableview.cpp b/desktop-widgets/tableview.cpp index 40d5199ec..40d5199ec 100644 --- a/qt-ui/tableview.cpp +++ b/desktop-widgets/tableview.cpp diff --git a/qt-ui/tableview.h b/desktop-widgets/tableview.h index f72b256ea..f72b256ea 100644 --- a/qt-ui/tableview.h +++ b/desktop-widgets/tableview.h diff --git a/qt-ui/tableview.ui b/desktop-widgets/tableview.ui index 73867231e..73867231e 100644 --- a/qt-ui/tableview.ui +++ b/desktop-widgets/tableview.ui diff --git a/qt-ui/tagwidget.cpp b/desktop-widgets/tagwidget.cpp index 3b61b492a..3b61b492a 100644 --- a/qt-ui/tagwidget.cpp +++ b/desktop-widgets/tagwidget.cpp diff --git a/qt-ui/tagwidget.h b/desktop-widgets/tagwidget.h index 6a16129f3..6a16129f3 100644 --- a/qt-ui/tagwidget.h +++ b/desktop-widgets/tagwidget.h diff --git a/qt-ui/templateedit.cpp b/desktop-widgets/templateedit.cpp index 4964016b9..4964016b9 100644 --- a/qt-ui/templateedit.cpp +++ b/desktop-widgets/templateedit.cpp diff --git a/qt-ui/templateedit.h b/desktop-widgets/templateedit.h index 5e548ae19..5e548ae19 100644 --- a/qt-ui/templateedit.h +++ b/desktop-widgets/templateedit.h diff --git a/qt-ui/templateedit.ui b/desktop-widgets/templateedit.ui index 60a0fc7e6..60a0fc7e6 100644 --- a/qt-ui/templateedit.ui +++ b/desktop-widgets/templateedit.ui diff --git a/templatelayout.cpp b/desktop-widgets/templatelayout.cpp index a376459a6..a376459a6 100644 --- a/templatelayout.cpp +++ b/desktop-widgets/templatelayout.cpp diff --git a/templatelayout.h b/desktop-widgets/templatelayout.h index a2868e7ff..a2868e7ff 100644 --- a/templatelayout.h +++ b/desktop-widgets/templatelayout.h diff --git a/qt-ui/undocommands.cpp b/desktop-widgets/undocommands.cpp index 0fd182cb3..0fd182cb3 100644 --- a/qt-ui/undocommands.cpp +++ b/desktop-widgets/undocommands.cpp diff --git a/qt-ui/undocommands.h b/desktop-widgets/undocommands.h index 8e359db51..8e359db51 100644 --- a/qt-ui/undocommands.h +++ b/desktop-widgets/undocommands.h diff --git a/qt-ui/updatemanager.cpp b/desktop-widgets/updatemanager.cpp index 0760d6407..0760d6407 100644 --- a/qt-ui/updatemanager.cpp +++ b/desktop-widgets/updatemanager.cpp diff --git a/qt-ui/updatemanager.h b/desktop-widgets/updatemanager.h index f91c82dc8..f91c82dc8 100644 --- a/qt-ui/updatemanager.h +++ b/desktop-widgets/updatemanager.h diff --git a/qt-ui/urldialog.ui b/desktop-widgets/urldialog.ui index 397f90a64..397f90a64 100644 --- a/qt-ui/urldialog.ui +++ b/desktop-widgets/urldialog.ui diff --git a/qt-ui/usermanual.cpp b/desktop-widgets/usermanual.cpp index 6b676f16b..6b676f16b 100644 --- a/qt-ui/usermanual.cpp +++ b/desktop-widgets/usermanual.cpp diff --git a/qt-ui/usermanual.h b/desktop-widgets/usermanual.h index 5101a3c3b..5101a3c3b 100644 --- a/qt-ui/usermanual.h +++ b/desktop-widgets/usermanual.h diff --git a/qt-ui/usersurvey.cpp b/desktop-widgets/usersurvey.cpp index 05da582a1..05da582a1 100644 --- a/qt-ui/usersurvey.cpp +++ b/desktop-widgets/usersurvey.cpp diff --git a/qt-ui/usersurvey.h b/desktop-widgets/usersurvey.h index 1dd5aaab3..1dd5aaab3 100644 --- a/qt-ui/usersurvey.h +++ b/desktop-widgets/usersurvey.h diff --git a/qt-ui/usersurvey.ui b/desktop-widgets/usersurvey.ui index c118fe89d..c118fe89d 100644 --- a/qt-ui/usersurvey.ui +++ b/desktop-widgets/usersurvey.ui diff --git a/qt-ui/webservices.ui b/desktop-widgets/webservices.ui index bcca35f1e..bcca35f1e 100644 --- a/qt-ui/webservices.ui +++ b/desktop-widgets/webservices.ui diff --git a/satellite.svg b/icons/satellite.svg index 10b2ee5db..10b2ee5db 100644 --- a/satellite.svg +++ b/icons/satellite.svg diff --git a/subsurface-icon.svg b/icons/subsurface-icon.svg index 29410c8ee..29410c8ee 100644 --- a/subsurface-icon.svg +++ b/icons/subsurface-icon.svg diff --git a/subsurface-mobile-icon.svg b/icons/subsurface-mobile-icon.svg index e4cf8aea2..e4cf8aea2 100644 --- a/subsurface-mobile-icon.svg +++ b/icons/subsurface-mobile-icon.svg diff --git a/profile-widget/CMakeLists.txt b/profile-widget/CMakeLists.txt new file mode 100644 index 000000000..f0a1d8439 --- /dev/null +++ b/profile-widget/CMakeLists.txt @@ -0,0 +1,19 @@ +# the profile widget +set(SUBSURFACE_PROFILE_LIB_SRCS + profilewidget2.cpp + diverectitem.cpp + divepixmapitem.cpp + divelineitem.cpp + divetextitem.cpp + animationfunctions.cpp + divecartesianaxis.cpp + diveprofileitem.cpp + diveeventitem.cpp + divetooltipitem.cpp + ruleritem.cpp + tankitem.cpp +) +source_group("Subsurface Profile" FILES ${SUBSURFACE_PROFILE_LIB_SRCS}) + +add_library(subsurface_profile STATIC ${SUBSURFACE_PROFILE_LIB_SRCS}) +target_link_libraries(subsurface_profile ${QT_LIBRARIES})
\ No newline at end of file diff --git a/qt-ui/profile/animationfunctions.cpp b/profile-widget/animationfunctions.cpp index a19d50c9d..a19d50c9d 100644 --- a/qt-ui/profile/animationfunctions.cpp +++ b/profile-widget/animationfunctions.cpp diff --git a/qt-ui/profile/animationfunctions.h b/profile-widget/animationfunctions.h index 3cfcff563..3cfcff563 100644 --- a/qt-ui/profile/animationfunctions.h +++ b/profile-widget/animationfunctions.h diff --git a/qt-ui/profile/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp index bf5a5380c..f40e1c3e5 100644 --- a/qt-ui/profile/divecartesianaxis.cpp +++ b/profile-widget/divecartesianaxis.cpp @@ -1,7 +1,7 @@ #include "divecartesianaxis.h" #include "divetextitem.h" #include "helpers.h" -#include "preferences.h" +#include "preferences/preferencesdialog.h" #include "diveplotdatamodel.h" #include "animationfunctions.h" #include "mainwindow.h" diff --git a/qt-ui/profile/divecartesianaxis.h b/profile-widget/divecartesianaxis.h index 27cfa62d8..cc7d0bcf7 100644 --- a/qt-ui/profile/divecartesianaxis.h +++ b/profile-widget/divecartesianaxis.h @@ -3,7 +3,7 @@ #include <QObject> #include <QGraphicsLineItem> -#include <graphicsview-common.h> +#include "subsurface-core/color.h" class QPropertyAnimation; class DiveTextItem; diff --git a/qt-ui/profile/diveeventitem.cpp b/profile-widget/diveeventitem.cpp index 0bbc84267..0bbc84267 100644 --- a/qt-ui/profile/diveeventitem.cpp +++ b/profile-widget/diveeventitem.cpp diff --git a/qt-ui/profile/diveeventitem.h b/profile-widget/diveeventitem.h index f358fee6d..f358fee6d 100644 --- a/qt-ui/profile/diveeventitem.h +++ b/profile-widget/diveeventitem.h diff --git a/qt-ui/profile/divelineitem.cpp b/profile-widget/divelineitem.cpp index f9e288a44..f9e288a44 100644 --- a/qt-ui/profile/divelineitem.cpp +++ b/profile-widget/divelineitem.cpp diff --git a/qt-ui/profile/divelineitem.h b/profile-widget/divelineitem.h index ec88e9da5..ec88e9da5 100644 --- a/qt-ui/profile/divelineitem.h +++ b/profile-widget/divelineitem.h diff --git a/qt-ui/profile/divepixmapitem.cpp b/profile-widget/divepixmapitem.cpp index 581f6f9b4..627473c2f 100644 --- a/qt-ui/profile/divepixmapitem.cpp +++ b/profile-widget/divepixmapitem.cpp @@ -1,7 +1,7 @@ #include "divepixmapitem.h" #include "animationfunctions.h" #include "divepicturemodel.h" -#include <preferences.h> +#include "preferences/preferencesdialog.h" #include <QDesktopServices> #include <QGraphicsView> diff --git a/qt-ui/profile/divepixmapitem.h b/profile-widget/divepixmapitem.h index 02c1523f7..02c1523f7 100644 --- a/qt-ui/profile/divepixmapitem.h +++ b/profile-widget/divepixmapitem.h diff --git a/qt-ui/profile/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp index 2c814678a..14efa9123 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/profile-widget/diveprofileitem.cpp @@ -5,13 +5,13 @@ #include "animationfunctions.h" #include "dive.h" #include "profile.h" -#include "preferences.h" +#include "preferences/preferencesdialog.h" #include "diveplannermodel.h" #include "helpers.h" #include "libdivecomputer/parser.h" #include "mainwindow.h" #include "maintab.h" -#include "profile/profilewidget2.h" +#include "profilewidget2.h" #include "diveplanner.h" #include <QSettings> diff --git a/qt-ui/profile/diveprofileitem.h b/profile-widget/diveprofileitem.h index 2160782f7..0bba7f7a3 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/profile-widget/diveprofileitem.h @@ -5,7 +5,6 @@ #include <QGraphicsPolygonItem> #include <QModelIndex> -#include "graphicsview-common.h" #include "divelineitem.h" /* This is the Profile Item, it should be used for quite a lot of things diff --git a/qt-ui/profile/diverectitem.cpp b/profile-widget/diverectitem.cpp index 8cb60c3f5..8cb60c3f5 100644 --- a/qt-ui/profile/diverectitem.cpp +++ b/profile-widget/diverectitem.cpp diff --git a/qt-ui/profile/diverectitem.h b/profile-widget/diverectitem.h index e616cf591..e616cf591 100644 --- a/qt-ui/profile/diverectitem.h +++ b/profile-widget/diverectitem.h diff --git a/qt-ui/profile/divetextitem.cpp b/profile-widget/divetextitem.cpp index 9c7848cd4..3bf00d68f 100644 --- a/qt-ui/profile/divetextitem.cpp +++ b/profile-widget/divetextitem.cpp @@ -1,6 +1,9 @@ #include "divetextitem.h" #include "mainwindow.h" #include "profilewidget2.h" +#include "subsurface-core/color.h" + +#include <QBrush> DiveTextItem::DiveTextItem(QGraphicsItem *parent) : QGraphicsItemGroup(parent), internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter), diff --git a/qt-ui/profile/divetextitem.h b/profile-widget/divetextitem.h index 3991fe7f3..be0adf292 100644 --- a/qt-ui/profile/divetextitem.h +++ b/profile-widget/divetextitem.h @@ -3,8 +3,8 @@ #include <QObject> #include <QGraphicsItemGroup> -#include "graphicsview-common.h" -#include <QBrush> + +class QBrush; /* A Line Item that has animated-properties. */ class DiveTextItem : public QObject, public QGraphicsItemGroup { diff --git a/qt-ui/profile/divetooltipitem.cpp b/profile-widget/divetooltipitem.cpp index d4818422b..d4818422b 100644 --- a/qt-ui/profile/divetooltipitem.cpp +++ b/profile-widget/divetooltipitem.cpp diff --git a/qt-ui/profile/divetooltipitem.h b/profile-widget/divetooltipitem.h index 4fa7ec2d7..4fa7ec2d7 100644 --- a/qt-ui/profile/divetooltipitem.h +++ b/profile-widget/divetooltipitem.h diff --git a/qt-ui/profile/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index d47467038..653818556 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -29,7 +29,7 @@ #include <QTableView> #endif #include "mainwindow.h" -#include <preferences.h> +#include "preferences/preferencesdialog.h" /* This is the global 'Item position' variable. * it should tell you where to position things up diff --git a/qt-ui/profile/profilewidget2.h b/profile-widget/profilewidget2.h index 23e939869..ce3fda083 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/profile-widget/profilewidget2.h @@ -13,7 +13,6 @@ // * // * It needs to be dynamic, things should *flow* on it, not just appear / disappear. // */ -#include "graphicsview-common.h" #include "divelineitem.h" #include "diveprofileitem.h" #include "display.h" diff --git a/qt-ui/profile/ruleritem.cpp b/profile-widget/ruleritem.cpp index 830985552..a5a61c0fe 100644 --- a/qt-ui/profile/ruleritem.cpp +++ b/profile-widget/ruleritem.cpp @@ -1,5 +1,5 @@ #include "ruleritem.h" -#include "preferences.h" +#include "preferences/preferencesdialog.h" #include "mainwindow.h" #include "profilewidget2.h" #include "display.h" diff --git a/qt-ui/profile/ruleritem.h b/profile-widget/ruleritem.h index 4fad0451c..4fad0451c 100644 --- a/qt-ui/profile/ruleritem.h +++ b/profile-widget/ruleritem.h diff --git a/qt-ui/profile/tankitem.cpp b/profile-widget/tankitem.cpp index c0e75a371..c0e75a371 100644 --- a/qt-ui/profile/tankitem.cpp +++ b/profile-widget/tankitem.cpp diff --git a/qt-ui/profile/tankitem.h b/profile-widget/tankitem.h index fd685fc82..fd685fc82 100644 --- a/qt-ui/profile/tankitem.h +++ b/profile-widget/tankitem.h diff --git a/qt-models/CMakeLists.txt b/qt-models/CMakeLists.txt new file mode 100644 index 000000000..c9bcf5c3d --- /dev/null +++ b/qt-models/CMakeLists.txt @@ -0,0 +1,29 @@ +# the data models that will interface +# with the views. +set(SUBSURFACE_MODELS_LIB_SRCS + cleanertablemodel.cpp + cylindermodel.cpp + diveplannermodel.cpp + models.cpp + filtermodels.cpp + tankinfomodel.cpp + weigthsysteminfomodel.cpp + weightmodel.cpp + divecomputermodel.cpp + treemodel.cpp + tableprintmodel.cpp + yearlystatisticsmodel.cpp + divetripmodel.cpp + divecomputerextradatamodel.cpp + completionmodels.cpp + profileprintmodel.cpp + divepicturemodel.cpp + diveplotdatamodel.cpp + divelocationmodel.cpp + divesitepicturesmodel.cpp + ssrfsortfilterproxymodel.cpp +) + +source_group("Subsurface Models" FILES ${SUBSURFACE_MODELS}) +add_library(subsurface_models STATIC ${SUBSURFACE_MODELS_LIB_SRCS}) +target_link_libraries(subsurface_models ${QT_LIBRARIES})
\ No newline at end of file diff --git a/qt-models/completionmodels.cpp b/qt-models/completionmodels.cpp index 838d239d2..a8b61aed5 100644 --- a/qt-models/completionmodels.cpp +++ b/qt-models/completionmodels.cpp @@ -1,6 +1,7 @@ #include "completionmodels.h" #include "dive.h" -#include "mainwindow.h" +#include <QSet> +#include <QString> #define CREATE_UPDATE_METHOD(Class, diveStructMember) \ void Class::updateModel() \ diff --git a/qt-models/diveplotdatamodel.cpp b/qt-models/diveplotdatamodel.cpp index f219947ac..de156bfac 100644 --- a/qt-models/diveplotdatamodel.cpp +++ b/qt-models/diveplotdatamodel.cpp @@ -1,8 +1,8 @@ #include "diveplotdatamodel.h" #include "dive.h" #include "profile.h" -#include "graphicsview-common.h" #include "divelist.h" +#include "subsurface-core/color.h" DivePlotDataModel::DivePlotDataModel(QObject *parent) : QAbstractTableModel(parent), diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 80ed0cfd5..f56f4be1c 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -1,8 +1,9 @@ #include "filtermodels.h" -#include "mainwindow.h" #include "models.h" -#include "divelistview.h" #include "display.h" +#include "divetripmodel.h" + +#include <QDebug> #define CREATE_INSTANCE_METHOD( CLASS ) \ CLASS *CLASS::instance() \ @@ -355,9 +356,16 @@ bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &s void MultiFilterSortModel::myInvalidate() { + //WARNING: + //TODO: + // THIS CODE BELOW IS COMPLETELY BROKEN. I KNOW, I WROTE IT. + // REMOVE THIS, MAKE IT SANE. + // GRRRRR. + +#if 0 int i; struct dive *d; - DiveListView *dlv = MainWindow::instance()->dive_list(); + // DiveListView *dlv = MainWindow::instance()->dive_list(); divesDisplayed = 0; @@ -395,6 +403,7 @@ void MultiFilterSortModel::myInvalidate() if (curr_dive_site) { dlv->expandAll(); } +#endif } void MultiFilterSortModel::addFilterModel(MultiFilterInterface *model) diff --git a/qt-models/models.h b/qt-models/models.h index c9212195e..f152af469 100644 --- a/qt-models/models.h +++ b/qt-models/models.h @@ -15,9 +15,9 @@ #include "metrics.h" -#include "../dive.h" -#include "../divelist.h" -#include "../divecomputer.h" +#include "subsurface-core/dive.h" +#include "subsurface-core/divelist.h" +#include "subsurface-core/divecomputer.h" #include "cleanertablemodel.h" #include "treemodel.h" diff --git a/qt-ui/graphicsview-common.h b/qt-ui/graphicsview-common.h deleted file mode 100644 index 3c1cb75a0..000000000 --- a/qt-ui/graphicsview-common.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef GRAPHICSVIEW_COMMON_H -#define GRAPHICSVIEW_COMMON_H - -#include "../color.h" -#include <QMap> -#include <QVector> -#include <QColor> - -#define SAC_COLORS_START_IDX SAC_1 -#define SAC_COLORS 9 -#define VELOCITY_COLORS_START_IDX VELO_STABLE -#define VELOCITY_COLORS 5 - -typedef enum { - /* SAC colors. Order is important, the SAC_COLORS_START_IDX define above. */ - SAC_1, - SAC_2, - SAC_3, - SAC_4, - SAC_5, - SAC_6, - SAC_7, - SAC_8, - SAC_9, - - /* Velocity colors. Order is still important, ref VELOCITY_COLORS_START_IDX. */ - VELO_STABLE, - VELO_SLOW, - VELO_MODERATE, - VELO_FAST, - VELO_CRAZY, - - /* gas colors */ - PO2, - PO2_ALERT, - PN2, - PN2_ALERT, - PHE, - PHE_ALERT, - O2SETPOINT, - CCRSENSOR1, - CCRSENSOR2, - CCRSENSOR3, - PP_LINES, - - /* Other colors */ - TEXT_BACKGROUND, - ALERT_BG, - ALERT_FG, - EVENTS, - SAMPLE_DEEP, - SAMPLE_SHALLOW, - SMOOTHED, - MINUTE, - TIME_GRID, - TIME_TEXT, - DEPTH_GRID, - MEAN_DEPTH, - HR_TEXT, - HR_PLOT, - HR_AXIS, - DEPTH_TOP, - DEPTH_BOTTOM, - TEMP_TEXT, - TEMP_PLOT, - SAC_DEFAULT, - BOUNDING_BOX, - PRESSURE_TEXT, - BACKGROUND, - BACKGROUND_TRANS, - CEILING_SHALLOW, - CEILING_DEEP, - CALC_CEILING_SHALLOW, - CALC_CEILING_DEEP, - TISSUE_PERCENTAGE, - GF_LINE, - AMB_PRESSURE_LINE -} color_indice_t; - - -/* profile_color[color indice] = COLOR(screen color, b/w printer color, color printer}} printer & screen colours could be different */ - -extern QMap<color_indice_t, QVector<QColor> > profile_color; -void fill_profile_color(); -QColor getColor(const color_indice_t i, bool isGrayscale = false); -QColor getSacColor(int sac, int diveSac); -struct text_render_options { - double size; - color_indice_t color; - double hpos, vpos; -}; - -typedef text_render_options text_render_options_t; -#endif // GRAPHICSVIEW_COMMON_H diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp deleted file mode 100644 index 6450c41cb..000000000 --- a/qt-ui/preferences.cpp +++ /dev/null @@ -1,559 +0,0 @@ -#include "preferences.h" -#include "mainwindow.h" -#include "models.h" -#include "divelocationmodel.h" -#include "prefs-macros.h" -#include "qthelper.h" -#include "subsurfacestartup.h" - -#include <QSettings> -#include <QFileDialog> -#include <QMessageBox> -#include <QShortcut> -#include <QNetworkProxy> -#include <QNetworkCookieJar> - -#include "subsurfacewebservices.h" - -#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) -#include "socialnetworks.h" -#include <QWebView> -#endif - -PreferencesDialog *PreferencesDialog::instance() -{ - static PreferencesDialog *dialog = new PreferencesDialog(MainWindow::instance()); - return dialog; -} - -PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) -{ - ui.setupUi(this); - setAttribute(Qt::WA_QuitOnClose, false); - -#if defined(Q_OS_ANDROID) || !defined(FBSUPPORT) - for (int i = 0; i < ui.listWidget->count(); i++) { - if (ui.listWidget->item(i)->text() == "Facebook") { - delete ui.listWidget->item(i); - QWidget *fbpage = ui.stackedWidget->widget(i); - ui.stackedWidget->removeWidget(fbpage); - } - } -#endif - - ui.proxyType->clear(); - ui.proxyType->addItem(tr("No proxy"), QNetworkProxy::NoProxy); - ui.proxyType->addItem(tr("System proxy"), QNetworkProxy::DefaultProxy); - ui.proxyType->addItem(tr("HTTP proxy"), QNetworkProxy::HttpProxy); - ui.proxyType->addItem(tr("SOCKS proxy"), QNetworkProxy::Socks5Proxy); - ui.proxyType->setCurrentIndex(-1); - - ui.first_item->setModel(GeoReferencingOptionsModel::instance()); - ui.second_item->setModel(GeoReferencingOptionsModel::instance()); - ui.third_item->setModel(GeoReferencingOptionsModel::instance()); - // Facebook stuff: -#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) - FacebookManager *fb = FacebookManager::instance(); - facebookWebView = new QWebView(this); - ui.fbWebviewContainer->layout()->addWidget(facebookWebView); - if (fb->loggedIn()) { - facebookLoggedIn(); - } else { - facebookDisconnect(); - } - connect(facebookWebView, &QWebView::urlChanged, fb, &FacebookManager::tryLogin); - connect(fb, &FacebookManager::justLoggedIn, this, &PreferencesDialog::facebookLoggedIn); - connect(ui.fbDisconnect, &QPushButton::clicked, fb, &FacebookManager::logout); - connect(fb, &FacebookManager::justLoggedOut, this, &PreferencesDialog::facebookDisconnect); -#endif - connect(ui.proxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(proxyType_changed(int))); - connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); - connect(ui.gflow, SIGNAL(valueChanged(int)), this, SLOT(gflowChanged(int))); - connect(ui.gfhigh, SIGNAL(valueChanged(int)), this, SLOT(gfhighChanged(int))); - // connect(ui.defaultSetpoint, SIGNAL(valueChanged(double)), this, SLOT(defaultSetpointChanged(double))); - QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); - connect(close, SIGNAL(activated()), this, SLOT(close())); - QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); - connect(quit, SIGNAL(activated()), parent, SLOT(close())); - loadSettings(); - setUiFromPrefs(); - rememberPrefs(); -} - -void PreferencesDialog::facebookLoggedIn() -{ -#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) - ui.fbDisconnect->show(); - ui.fbWebviewContainer->hide(); - ui.fbWebviewContainer->setEnabled(false); - ui.FBLabel->setText(tr("To disconnect Subsurface from your Facebook account, use the button below")); -#endif -} - -void PreferencesDialog::facebookDisconnect() -{ -#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) - // remove the connect/disconnect button - // and instead add the login view - ui.fbDisconnect->hide(); - ui.fbWebviewContainer->show(); - ui.fbWebviewContainer->setEnabled(true); - ui.FBLabel->setText(tr("To connect to Facebook, please log in. This enables Subsurface to publish dives to your timeline")); - if (facebookWebView) { - facebookWebView->page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar()); - facebookWebView->setUrl(FacebookManager::instance()->connectUrl()); - } -#endif -} - -void PreferencesDialog::cloudPinNeeded() -{ - ui.cloud_storage_pin->setEnabled(prefs.cloud_verification_status == CS_NEED_TO_VERIFY); - ui.cloud_storage_pin->setVisible(prefs.cloud_verification_status == CS_NEED_TO_VERIFY); - ui.cloud_storage_pin_label->setEnabled(prefs.cloud_verification_status == CS_NEED_TO_VERIFY); - ui.cloud_storage_pin_label->setVisible(prefs.cloud_verification_status == CS_NEED_TO_VERIFY); - ui.cloud_storage_new_passwd->setEnabled(prefs.cloud_verification_status == CS_VERIFIED); - ui.cloud_storage_new_passwd->setVisible(prefs.cloud_verification_status == CS_VERIFIED); - ui.cloud_storage_new_passwd_label->setEnabled(prefs.cloud_verification_status == CS_VERIFIED); - ui.cloud_storage_new_passwd_label->setVisible(prefs.cloud_verification_status == CS_VERIFIED); - if (prefs.cloud_verification_status == CS_VERIFIED) { - ui.cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (credentials verified)")); - ui.cloudDefaultFile->setEnabled(true); - } else { - ui.cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage")); - if (ui.cloudDefaultFile->isChecked()) - ui.noDefaultFile->setChecked(true); - ui.cloudDefaultFile->setEnabled(false); - } - MainWindow::instance()->enableDisableCloudActions(); -} - -#define DANGER_GF (gf > 100) ? "* { color: red; }" : "" -void PreferencesDialog::gflowChanged(int gf) -{ - ui.gflow->setStyleSheet(DANGER_GF); -} -void PreferencesDialog::gfhighChanged(int gf) -{ - ui.gfhigh->setStyleSheet(DANGER_GF); -} -#undef DANGER_GF - -void PreferencesDialog::showEvent(QShowEvent *event) -{ - setUiFromPrefs(); - rememberPrefs(); - QDialog::showEvent(event); -} - -void PreferencesDialog::setUiFromPrefs() -{ - // graphs - ui.pheThreshold->setValue(prefs.pp_graphs.phe_threshold); - ui.po2Threshold->setValue(prefs.pp_graphs.po2_threshold); - ui.pn2Threshold->setValue(prefs.pp_graphs.pn2_threshold); - ui.maxpo2->setValue(prefs.modpO2); - ui.red_ceiling->setChecked(prefs.redceiling); - ui.units_group->setEnabled(ui.personalize->isChecked()); - - ui.gflow->setValue(prefs.gflow); - ui.gfhigh->setValue(prefs.gfhigh); - ui.gf_low_at_maxdepth->setChecked(prefs.gf_low_at_maxdepth); - ui.show_ccr_setpoint->setChecked(prefs.show_ccr_setpoint); - ui.show_ccr_sensors->setChecked(prefs.show_ccr_sensors); - ui.defaultSetpoint->setValue((double)prefs.defaultsetpoint / 1000.0); - ui.psro2rate->setValue(prefs.o2consumption / 1000.0); - ui.pscrfactor->setValue(rint(1000.0 / prefs.pscr_ratio)); - - // units - if (prefs.unit_system == METRIC) - ui.metric->setChecked(true); - else if (prefs.unit_system == IMPERIAL) - ui.imperial->setChecked(true); - else - ui.personalize->setChecked(true); - ui.gpsTraditional->setChecked(prefs.coordinates_traditional); - ui.gpsDecimal->setChecked(!prefs.coordinates_traditional); - - ui.celsius->setChecked(prefs.units.temperature == units::CELSIUS); - ui.fahrenheit->setChecked(prefs.units.temperature == units::FAHRENHEIT); - ui.meter->setChecked(prefs.units.length == units::METERS); - ui.feet->setChecked(prefs.units.length == units::FEET); - ui.bar->setChecked(prefs.units.pressure == units::BAR); - ui.psi->setChecked(prefs.units.pressure == units::PSI); - ui.liter->setChecked(prefs.units.volume == units::LITER); - ui.cuft->setChecked(prefs.units.volume == units::CUFT); - ui.kg->setChecked(prefs.units.weight == units::KG); - ui.lbs->setChecked(prefs.units.weight == units::LBS); - - ui.font->setCurrentFont(QString(prefs.divelist_font)); - ui.fontsize->setValue(prefs.font_size); - ui.defaultfilename->setText(prefs.default_filename); - ui.noDefaultFile->setChecked(prefs.default_file_behavior == NO_DEFAULT_FILE); - ui.cloudDefaultFile->setChecked(prefs.default_file_behavior == CLOUD_DEFAULT_FILE); - ui.localDefaultFile->setChecked(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); - ui.default_cylinder->clear(); - for (int i = 0; tank_info[i].name != NULL; i++) { - ui.default_cylinder->addItem(tank_info[i].name); - if (prefs.default_cylinder && strcmp(tank_info[i].name, prefs.default_cylinder) == 0) - ui.default_cylinder->setCurrentIndex(i); - } - ui.displayinvalid->setChecked(prefs.display_invalid_dives); - ui.display_unused_tanks->setChecked(prefs.display_unused_tanks); - ui.show_average_depth->setChecked(prefs.show_average_depth); - ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES); - ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS); - ui.velocitySlider->setValue(prefs.animation_speed); - - QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(); - filterModel->setSourceModel(LanguageModel::instance()); - filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); - ui.languageView->setModel(filterModel); - filterModel->sort(0); - connect(ui.languageFilter, SIGNAL(textChanged(QString)), filterModel, SLOT(setFilterFixedString(QString))); - - QSettings s; - - ui.save_uid_local->setChecked(s.value("save_uid_local").toBool()); - ui.default_uid->setText(s.value("subsurface_webservice_uid").toString().toUpper()); - - s.beginGroup("Language"); - ui.languageSystemDefault->setChecked(s.value("UseSystemLanguage", true).toBool()); - QAbstractItemModel *m = ui.languageView->model(); - QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, s.value("UiLanguage").toString()); - if (languages.count()) - ui.languageView->setCurrentIndex(languages.first()); - - s.endGroup(); - - ui.proxyHost->setText(prefs.proxy_host); - ui.proxyPort->setValue(prefs.proxy_port); - ui.proxyAuthRequired->setChecked(prefs.proxy_auth); - ui.proxyUsername->setText(prefs.proxy_user); - ui.proxyPassword->setText(prefs.proxy_pass); - ui.proxyType->setCurrentIndex(ui.proxyType->findData(prefs.proxy_type)); - ui.btnUseDefaultFile->setChecked(prefs.use_default_file); - - ui.cloud_storage_email->setText(prefs.cloud_storage_email); - ui.cloud_storage_password->setText(prefs.cloud_storage_password); - ui.save_password_local->setChecked(prefs.save_password_local); - cloudPinNeeded(); - ui.cloud_background_sync->setChecked(prefs.cloud_background_sync); - ui.default_uid->setText(prefs.userid); - - // GeoManagement -#ifdef DISABLED - ui.enable_geocoding->setChecked( prefs.geocoding.enable_geocoding ); - ui.parse_without_gps->setChecked(prefs.geocoding.parse_dive_without_gps); - ui.tag_existing_dives->setChecked(prefs.geocoding.tag_existing_dives); -#endif - ui.first_item->setCurrentIndex(prefs.geocoding.category[0]); - ui.second_item->setCurrentIndex(prefs.geocoding.category[1]); - ui.third_item->setCurrentIndex(prefs.geocoding.category[2]); -} - -void PreferencesDialog::restorePrefs() -{ - prefs = oldPrefs; - setUiFromPrefs(); -} - -void PreferencesDialog::rememberPrefs() -{ - oldPrefs = prefs; -} - -void PreferencesDialog::syncSettings() -{ - QSettings s; - - s.setValue("subsurface_webservice_uid", ui.default_uid->text().toUpper()); - set_save_userid_local(ui.save_uid_local->checkState()); - - // Graph - s.beginGroup("TecDetails"); - SAVE_OR_REMOVE("phethreshold", default_prefs.pp_graphs.phe_threshold, ui.pheThreshold->value()); - SAVE_OR_REMOVE("po2threshold", default_prefs.pp_graphs.po2_threshold, ui.po2Threshold->value()); - SAVE_OR_REMOVE("pn2threshold", default_prefs.pp_graphs.pn2_threshold, ui.pn2Threshold->value()); - SAVE_OR_REMOVE("modpO2", default_prefs.modpO2, ui.maxpo2->value()); - SAVE_OR_REMOVE("redceiling", default_prefs.redceiling, ui.red_ceiling->isChecked()); - SAVE_OR_REMOVE("gflow", default_prefs.gflow, ui.gflow->value()); - SAVE_OR_REMOVE("gfhigh", default_prefs.gfhigh, ui.gfhigh->value()); - SAVE_OR_REMOVE("gf_low_at_maxdepth", default_prefs.gf_low_at_maxdepth, ui.gf_low_at_maxdepth->isChecked()); - SAVE_OR_REMOVE("show_ccr_setpoint", default_prefs.show_ccr_setpoint, ui.show_ccr_setpoint->isChecked()); - SAVE_OR_REMOVE("show_ccr_sensors", default_prefs.show_ccr_sensors, ui.show_ccr_sensors->isChecked()); - SAVE_OR_REMOVE("display_unused_tanks", default_prefs.display_unused_tanks, ui.display_unused_tanks->isChecked()); - SAVE_OR_REMOVE("show_average_depth", default_prefs.show_average_depth, ui.show_average_depth->isChecked()); - s.endGroup(); - - // Units - s.beginGroup("Units"); - QString unitSystem[] = {"metric", "imperial", "personal"}; - short unitValue = ui.metric->isChecked() ? METRIC : (ui.imperial->isChecked() ? IMPERIAL : PERSONALIZE); - SAVE_OR_REMOVE_SPECIAL("unit_system", default_prefs.unit_system, unitValue, unitSystem[unitValue]); - s.setValue("temperature", ui.fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS); - s.setValue("length", ui.feet->isChecked() ? units::FEET : units::METERS); - s.setValue("pressure", ui.psi->isChecked() ? units::PSI : units::BAR); - s.setValue("volume", ui.cuft->isChecked() ? units::CUFT : units::LITER); - s.setValue("weight", ui.lbs->isChecked() ? units::LBS : units::KG); - s.setValue("vertical_speed_time", ui.vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS); - s.setValue("coordinates", ui.gpsTraditional->isChecked()); - s.endGroup(); - - // Defaults - s.beginGroup("GeneralSettings"); - s.setValue("default_filename", ui.defaultfilename->text()); - s.setValue("default_cylinder", ui.default_cylinder->currentText()); - s.setValue("use_default_file", ui.btnUseDefaultFile->isChecked()); - if (ui.noDefaultFile->isChecked()) - s.setValue("default_file_behavior", NO_DEFAULT_FILE); - else if (ui.localDefaultFile->isChecked()) - s.setValue("default_file_behavior", LOCAL_DEFAULT_FILE); - else if (ui.cloudDefaultFile->isChecked()) - s.setValue("default_file_behavior", CLOUD_DEFAULT_FILE); - s.setValue("defaultsetpoint", rint(ui.defaultSetpoint->value() * 1000.0)); - s.setValue("o2consumption", rint(ui.psro2rate->value() *1000.0)); - s.setValue("pscr_ratio", rint(1000.0 / ui.pscrfactor->value())); - s.endGroup(); - - s.beginGroup("Display"); - SAVE_OR_REMOVE_SPECIAL("divelist_font", system_divelist_default_font, ui.font->currentFont().toString(), ui.font->currentFont()); - SAVE_OR_REMOVE("font_size", system_divelist_default_font_size, ui.fontsize->value()); - s.setValue("displayinvalid", ui.displayinvalid->isChecked()); - s.endGroup(); - s.sync(); - - // Locale - QLocale loc; - s.beginGroup("Language"); - bool useSystemLang = s.value("UseSystemLanguage", true).toBool(); - if (useSystemLang != ui.languageSystemDefault->isChecked() || - (!useSystemLang && s.value("UiLanguage").toString() != ui.languageView->currentIndex().data(Qt::UserRole))) { - QMessageBox::warning(MainWindow::instance(), tr("Restart required"), - tr("To correctly load a new language you must restart Subsurface.")); - } - s.setValue("UseSystemLanguage", ui.languageSystemDefault->isChecked()); - s.setValue("UiLanguage", ui.languageView->currentIndex().data(Qt::UserRole)); - s.endGroup(); - - // Animation - s.beginGroup("Animations"); - s.setValue("animation_speed", ui.velocitySlider->value()); - s.endGroup(); - - s.beginGroup("Network"); - s.setValue("proxy_type", ui.proxyType->itemData(ui.proxyType->currentIndex()).toInt()); - s.setValue("proxy_host", ui.proxyHost->text()); - s.setValue("proxy_port", ui.proxyPort->value()); - SB("proxy_auth", ui.proxyAuthRequired); - s.setValue("proxy_user", ui.proxyUsername->text()); - s.setValue("proxy_pass", ui.proxyPassword->text()); - s.endGroup(); - - s.beginGroup("CloudStorage"); - QString email = ui.cloud_storage_email->text(); - QString password = ui.cloud_storage_password->text(); - QString newpassword = ui.cloud_storage_new_passwd->text(); - if (prefs.cloud_verification_status == CS_VERIFIED && !newpassword.isEmpty()) { - // deal with password change - if (!email.isEmpty() && !password.isEmpty()) { - // connect to backend server to check / create credentials - QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$"); - if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) { - report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); - } else { - CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this); - connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded())); - connect(cloudAuth, SIGNAL(passwordChangeSuccessful()), this, SLOT(passwordUpdateSuccessfull())); - QNetworkReply *reply = cloudAuth->backend(email, password, "", newpassword); - ui.cloud_storage_new_passwd->setText(""); - free(prefs.cloud_storage_newpassword); - prefs.cloud_storage_newpassword = strdup(qPrintable(newpassword)); - } - } - } else if (prefs.cloud_verification_status == CS_UNKNOWN || - prefs.cloud_verification_status == CS_INCORRECT_USER_PASSWD || - email != prefs.cloud_storage_email || - password != prefs.cloud_storage_password) { - - // different credentials - reset verification status - prefs.cloud_verification_status = CS_UNKNOWN; - if (!email.isEmpty() && !password.isEmpty()) { - // connect to backend server to check / create credentials - QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$"); - if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) { - report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); - } else { - CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this); - connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded())); - QNetworkReply *reply = cloudAuth->backend(email, password); - } - } - } else if (prefs.cloud_verification_status == CS_NEED_TO_VERIFY) { - QString pin = ui.cloud_storage_pin->text(); - if (!pin.isEmpty()) { - // connect to backend server to check / create credentials - QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$"); - if (!reg.match(email).hasMatch() || !reg.match(password).hasMatch()) { - report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); - } - CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this); - connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded())); - QNetworkReply *reply = cloudAuth->backend(email, password, pin); - } - } - SAVE_OR_REMOVE("email", default_prefs.cloud_storage_email, email); - SAVE_OR_REMOVE("save_password_local", default_prefs.save_password_local, ui.save_password_local->isChecked()); - if (ui.save_password_local->isChecked()) { - SAVE_OR_REMOVE("password", default_prefs.cloud_storage_password, password); - } else { - s.remove("password"); - free(prefs.cloud_storage_password); - prefs.cloud_storage_password = strdup(qPrintable(password)); - } - SAVE_OR_REMOVE("cloud_verification_status", default_prefs.cloud_verification_status, prefs.cloud_verification_status); - SAVE_OR_REMOVE("cloud_background_sync", default_prefs.cloud_background_sync, ui.cloud_background_sync->isChecked()); - - // at this point we intentionally do not have a UI for changing this - // it could go into some sort of "advanced setup" or something - SAVE_OR_REMOVE("cloud_base_url", default_prefs.cloud_base_url, prefs.cloud_base_url); - s.endGroup(); - - s.beginGroup("geocoding"); -#ifdef DISABLED - s.setValue("enable_geocoding", ui.enable_geocoding->isChecked()); - s.setValue("parse_dive_without_gps", ui.parse_without_gps->isChecked()); - s.setValue("tag_existing_dives", ui.tag_existing_dives->isChecked()); -#endif - s.setValue("cat0", ui.first_item->currentIndex()); - s.setValue("cat1", ui.second_item->currentIndex()); - s.setValue("cat2", ui.third_item->currentIndex()); - s.endGroup(); - - loadSettings(); - emit settingsChanged(); -} - -void PreferencesDialog::loadSettings() -{ - // This code was on the mainwindow, it should belong nowhere, but since we didn't - // correctly fixed this code yet ( too much stuff on the code calling preferences ) - // force this here. - loadPreferences(); - QSettings s; - QVariant v; - - ui.save_uid_local->setChecked(s.value("save_uid_local").toBool()); - ui.default_uid->setText(s.value("subsurface_webservice_uid").toString().toUpper()); - - ui.defaultfilename->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); - ui.btnUseDefaultFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); - ui.chooseFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); -} - -void PreferencesDialog::buttonClicked(QAbstractButton *button) -{ - switch (ui.buttonBox->standardButton(button)) { - case QDialogButtonBox::Discard: - restorePrefs(); - syncSettings(); - close(); - break; - case QDialogButtonBox::Apply: - syncSettings(); - break; - case QDialogButtonBox::FirstButton: - syncSettings(); - close(); - break; - default: - break; // ignore warnings. - } -} -#undef SB - -void PreferencesDialog::on_chooseFile_clicked() -{ - QFileInfo fi(system_default_filename()); - QString choosenFileName = QFileDialog::getOpenFileName(this, tr("Open default log file"), fi.absolutePath(), tr("Subsurface XML files (*.ssrf *.xml *.XML)")); - - if (!choosenFileName.isEmpty()) - ui.defaultfilename->setText(choosenFileName); -} - -void PreferencesDialog::on_resetSettings_clicked() -{ - QSettings s; - - QMessageBox response(this); - response.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - response.setDefaultButton(QMessageBox::Cancel); - response.setWindowTitle(tr("Warning")); - response.setText(tr("If you click OK, all settings of Subsurface will be reset to their default values. This will be applied immediately.")); - response.setWindowModality(Qt::WindowModal); - - int result = response.exec(); - if (result == QMessageBox::Ok) { - copy_prefs(&default_prefs, &prefs); - setUiFromPrefs(); - Q_FOREACH (QString key, s.allKeys()) { - s.remove(key); - } - syncSettings(); - close(); - } -} - -void PreferencesDialog::passwordUpdateSuccessfull() -{ - ui.cloud_storage_password->setText(prefs.cloud_storage_password); -} - -void PreferencesDialog::emitSettingsChanged() -{ - emit settingsChanged(); -} - -void PreferencesDialog::proxyType_changed(int idx) -{ - if (idx == -1) { - return; - } - - int proxyType = ui.proxyType->itemData(idx).toInt(); - bool hpEnabled = (proxyType == QNetworkProxy::Socks5Proxy || proxyType == QNetworkProxy::HttpProxy); - ui.proxyHost->setEnabled(hpEnabled); - ui.proxyPort->setEnabled(hpEnabled); - ui.proxyAuthRequired->setEnabled(hpEnabled); - ui.proxyUsername->setEnabled(hpEnabled & ui.proxyAuthRequired->isChecked()); - ui.proxyPassword->setEnabled(hpEnabled & ui.proxyAuthRequired->isChecked()); - ui.proxyAuthRequired->setChecked(ui.proxyAuthRequired->isChecked()); -} - -void PreferencesDialog::on_btnUseDefaultFile_toggled(bool toggle) -{ - if (toggle) { - ui.defaultfilename->setText(system_default_filename()); - ui.defaultfilename->setEnabled(false); - } else { - ui.defaultfilename->setEnabled(true); - } -} - -void PreferencesDialog::on_noDefaultFile_toggled(bool toggle) -{ - prefs.default_file_behavior = NO_DEFAULT_FILE; -} - -void PreferencesDialog::on_localDefaultFile_toggled(bool toggle) -{ - ui.defaultfilename->setEnabled(toggle); - ui.btnUseDefaultFile->setEnabled(toggle); - ui.chooseFile->setEnabled(toggle); - prefs.default_file_behavior = LOCAL_DEFAULT_FILE; -} - -void PreferencesDialog::on_cloudDefaultFile_toggled(bool toggle) -{ - prefs.default_file_behavior = CLOUD_DEFAULT_FILE; -} diff --git a/qt-ui/preferences.h b/qt-ui/preferences.h deleted file mode 100644 index 326b1f964..000000000 --- a/qt-ui/preferences.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef PREFERENCES_H -#define PREFERENCES_H - -#include <QDialog> -#include "pref.h" - -#include "ui_preferences.h" - -#ifndef Q_OS_ANDROID - class QWebView; -#endif - -class QAbstractButton; - -class PreferencesDialog : public QDialog { - Q_OBJECT -public: - static PreferencesDialog *instance(); - void showEvent(QShowEvent *); - void emitSettingsChanged(); - -signals: - void settingsChanged(); -public -slots: - void buttonClicked(QAbstractButton *button); - void on_chooseFile_clicked(); - void on_resetSettings_clicked(); - void syncSettings(); - void loadSettings(); - void restorePrefs(); - void rememberPrefs(); - void gflowChanged(int gf); - void gfhighChanged(int gf); - void proxyType_changed(int idx); - void on_btnUseDefaultFile_toggled(bool toggle); - void on_noDefaultFile_toggled(bool toggle); - void on_localDefaultFile_toggled(bool toggle); - void on_cloudDefaultFile_toggled(bool toggle); - void facebookLoggedIn(); - void facebookDisconnect(); - void cloudPinNeeded(); - void passwordUpdateSuccessfull(); -private: - explicit PreferencesDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); - void setUiFromPrefs(); - Ui::PreferencesDialog ui; - struct preferences oldPrefs; - #ifndef Q_OS_ANDROID - QWebView *facebookWebView; - #endif -}; - -#endif // PREFERENCES_H diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui deleted file mode 100644 index de2d79b91..000000000 --- a/qt-ui/preferences.ui +++ /dev/null @@ -1,1883 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>PreferencesDialog</class> - <widget class="QDialog" name="PreferencesDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>711</width> - <height>662</height> - </rect> - </property> - <property name="windowTitle"> - <string>Preferences</string> - </property> - <property name="windowIcon"> - <iconset> - <normalon>:/subsurface-icon</normalon> - </iconset> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="margin"> - <number>5</number> - </property> - <item> - <layout class="QHBoxLayout" name="mainHorizontalLayout"> - <item> - <widget class="QListWidget" name="listWidget"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>120</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>120</width> - <height>16777215</height> - </size> - </property> - <property name="iconSize"> - <size> - <width>24</width> - <height>24</height> - </size> - </property> - <property name="textElideMode"> - <enum>Qt::ElideNone</enum> - </property> - <property name="movement"> - <enum>QListView::Static</enum> - </property> - <property name="isWrapping" stdset="0"> - <bool>true</bool> - </property> - <property name="layoutMode"> - <enum>QListView::Batched</enum> - </property> - <property name="spacing"> - <number>0</number> - </property> - <property name="gridSize"> - <size> - <width>110</width> - <height>40</height> - </size> - </property> - <property name="viewMode"> - <enum>QListView::ListMode</enum> - </property> - <property name="uniformItemSizes"> - <bool>true</bool> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - <property name="currentRow"> - <number>-1</number> - </property> - <item> - <property name="text"> - <string>Defaults</string> - </property> - <property name="icon"> - <iconset> - <normalon>:/subsurface-icon</normalon> - </iconset> - </property> - </item> - <item> - <property name="text"> - <string>Units</string> - </property> - <property name="icon"> - <iconset> - <normalon>:/units</normalon> - </iconset> - </property> - </item> - <item> - <property name="text"> - <string>Graph</string> - </property> - <property name="icon"> - <iconset> - <normalon>:/graph</normalon> - </iconset> - </property> - </item> - <item> - <property name="text"> - <string>Language</string> - </property> - <property name="icon"> - <iconset> - <normalon>:/advanced</normalon> - </iconset> - </property> - </item> - <item> - <property name="text"> - <string>Network</string> - </property> - <property name="icon"> - <iconset> - <normalon>:/network</normalon> - </iconset> - </property> - </item> - <item> - <property name="text"> - <string>Facebook</string> - </property> - <property name="icon"> - <iconset> - <normalon>:/facebook</normalon> - </iconset> - </property> - </item> - <item> - <property name="text"> - <string>Georeference</string> - </property> - <property name="icon"> - <iconset> - <normalon>:/georeference</normalon> - </iconset> - </property> - </item> - </widget> - </item> - <item> - <widget class="QStackedWidget" name="stackedWidget"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="currentIndex"> - <number>4</number> - </property> - <widget class="QWidget" name="defaults_page"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="spacing"> - <number>5</number> - </property> - <property name="margin"> - <number>5</number> - </property> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Lists and tables</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_11"> - <property name="margin"> - <number>5</number> - </property> - <item> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Font</string> - </property> - </widget> - </item> - <item> - <widget class="QFontComboBox" name="font"/> - </item> - <item> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>Font size</string> - </property> - </widget> - </item> - <item> - <widget class="QDoubleSpinBox" name="fontsize"/> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_3"> - <property name="title"> - <string>Dives</string> - </property> - <layout class="QFormLayout" name="formLayout"> - <property name="horizontalSpacing"> - <number>5</number> - </property> - <property name="verticalSpacing"> - <number>5</number> - </property> - <property name="margin"> - <number>5</number> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="defaultDiveLogFileLabel"> - <property name="text"> - <string>Default dive log file</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <layout class="QHBoxLayout" name="defaultFileBehaviorLayout"> - <item> - <widget class="QRadioButton" name="noDefaultFile"> - <property name="text"> - <string>No default file</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">defaultFileGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QRadioButton" name="localDefaultFile"> - <property name="text"> - <string>&Local default file</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">defaultFileGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QRadioButton" name="cloudDefaultFile"> - <property name="text"> - <string>Clo&ud storage default file</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">defaultFileGroup</string> - </attribute> - </widget> - </item> - </layout> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_9"> - <property name="text"> - <string>Local dive log file</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_3b"> - <item> - <widget class="QLineEdit" name="defaultfilename"/> - </item> - <item> - <widget class="QToolButton" name="btnUseDefaultFile"> - <property name="text"> - <string>Use default</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="chooseFile"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_10"> - <property name="text"> - <string>Display invalid</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QCheckBox" name="displayinvalid"> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_6"> - <property name="title"> - <string>Default cylinder</string> - </property> - <layout class="QFormLayout" name="formLayout_6"> - <property name="horizontalSpacing"> - <number>5</number> - </property> - <property name="verticalSpacing"> - <number>5</number> - </property> - <property name="margin"> - <number>5</number> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="label_11"> - <property name="text"> - <string>Use default cylinder</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QComboBox" name="default_cylinder"/> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_7"> - <property name="title"> - <string>Animations</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_7"> - <property name="margin"> - <number>5</number> - </property> - <item> - <widget class="QLabel" name="label_15"> - <property name="text"> - <string>Speed</string> - </property> - </widget> - </item> - <item> - <widget class="QSlider" name="velocitySlider"> - <property name="maximum"> - <number>500</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="velocitySpinBox"> - <property name="maximum"> - <number>500</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_9"> - <property name="title"> - <string>Clear all settings</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_7b"> - <property name="spacing"> - <number>5</number> - </property> - <property name="margin"> - <number>5</number> - </property> - <item> - <widget class="QPushButton" name="resetSettings"> - <property name="text"> - <string>Reset all settings to their default value</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWidget" name="units_page"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>5</number> - </property> - <property name="margin"> - <number>5</number> - </property> - <item> - <widget class="QGroupBox" name="groupBox_units"> - <property name="title"> - <string>Unit system</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>System</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="metric"> - <property name="text"> - <string>&Metric</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_6</string> - </attribute> - </widget> - </item> - <item> - <widget class="QRadioButton" name="imperial"> - <property name="text"> - <string>Imperial</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_6</string> - </attribute> - </widget> - </item> - <item> - <widget class="QRadioButton" name="personalize"> - <property name="text"> - <string>Personali&ze</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_6</string> - </attribute> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="units_group"> - <property name="title"> - <string>Individual settings</string> - </property> - <property name="checkable"> - <bool>false</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Depth</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QRadioButton" name="meter"> - <property name="text"> - <string>meter</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item row="0" column="2"> - <widget class="QRadioButton" name="feet"> - <property name="text"> - <string>feet</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Pressure</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QRadioButton" name="bar"> - <property name="text"> - <string>bar</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_2</string> - </attribute> - </widget> - </item> - <item row="1" column="2"> - <widget class="QRadioButton" name="psi"> - <property name="text"> - <string>psi</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_2</string> - </attribute> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Volume</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QRadioButton" name="liter"> - <property name="text"> - <string>&liter</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_3</string> - </attribute> - </widget> - </item> - <item row="2" column="2"> - <widget class="QRadioButton" name="cuft"> - <property name="text"> - <string>cu ft</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_3</string> - </attribute> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Temperature</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QRadioButton" name="celsius"> - <property name="text"> - <string>celsius</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_4</string> - </attribute> - </widget> - </item> - <item row="3" column="2"> - <widget class="QRadioButton" name="fahrenheit"> - <property name="text"> - <string>fahrenheit</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_4</string> - </attribute> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Weight</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QRadioButton" name="kg"> - <property name="text"> - <string>kg</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_5</string> - </attribute> - </widget> - </item> - <item row="4" column="2"> - <widget class="QRadioButton" name="lbs"> - <property name="text"> - <string>lbs</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_5</string> - </attribute> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <layout class="QHBoxLayout"> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Time units</string> - </property> - <layout class="QGridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label13"> - <property name="text"> - <string>Ascent/descent speed denominator</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QRadioButton" name="vertical_speed_minutes"> - <property name="text"> - <string>Minutes</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">verticalSpeed</string> - </attribute> - </widget> - </item> - <item row="0" column="2"> - <widget class="QRadioButton" name="vertical_speed_seconds"> - <property name="text"> - <string>Seconds</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">verticalSpeed</string> - </attribute> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QGroupBox" name="groupBox_11"> - <property name="title"> - <string>GPS coordinates</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_12"> - <item> - <widget class="QLabel" name="label_27"> - <property name="text"> - <string>Location Display</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="gpsTraditional"> - <property name="text"> - <string>traditional (dms)</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_7</string> - </attribute> - </widget> - </item> - <item> - <widget class="QRadioButton" name="gpsDecimal"> - <property name="text"> - <string>decimal</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup_7</string> - </attribute> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWidget" name="graph_page"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <property name="spacing"> - <number>5</number> - </property> - <property name="margin"> - <number>5</number> - </property> - <item> - <widget class="QGroupBox" name="groupBox_4"> - <property name="title"> - <string>Show</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QLabel" name="label_12"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="text"> - <string>Threshold when showing pOâ‚‚</string> - </property> - </widget> - </item> - <item> - <widget class="QDoubleSpinBox" name="po2Threshold"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="singleStep"> - <double>0.100000000000000</double> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <item> - <widget class="QLabel" name="label_13"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="text"> - <string>Threshold when showing pNâ‚‚</string> - </property> - </widget> - </item> - <item> - <widget class="QDoubleSpinBox" name="pn2Threshold"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="singleStep"> - <double>0.100000000000000</double> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_8"> - <item> - <widget class="QLabel" name="label_17"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="text"> - <string>Threshold when showing pHe</string> - </property> - </widget> - </item> - <item> - <widget class="QDoubleSpinBox" name="pheThreshold"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="singleStep"> - <double>0.100000000000000</double> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_9"> - <item> - <widget class="QLabel" name="label_18"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="text"> - <string>Max pOâ‚‚ when showing MOD</string> - </property> - </widget> - </item> - <item> - <widget class="QDoubleSpinBox" name="maxpo2"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="singleStep"> - <double>0.100000000000000</double> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_10b"> - <item> - <widget class="QCheckBox" name="red_ceiling"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="text"> - <string>Draw dive computer reported ceiling red</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_11c"> - <item> - <widget class="QCheckBox" name="display_unused_tanks"> - <property name="text"> - <string>Show unused cylinders in Equipment tab</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_11d"> - <item> - <widget class="QCheckBox" name="show_average_depth"> - <property name="text"> - <string>Show average depth</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_5"> - <property name="title"> - <string>Misc</string> - </property> - <layout class="QFormLayout" name="formLayout_3"> - <item row="1" column="0"> - <widget class="QLabel" name="label_19"> - <property name="text"> - <string>GFLow</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QSpinBox" name="gflow"> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_20"> - <property name="text"> - <string>GFHigh</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QSpinBox" name="gfhigh"> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - </widget> - </item> - <item row="4" column="0" colspan="2"> - <widget class="QCheckBox" name="gf_low_at_maxdepth"> - <property name="text"> - <string>GFLow at max depth</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QCheckBox" name="show_ccr_setpoint"> - <property name="text"> - <string>CCR: show setpoints when viewing pOâ‚‚</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QCheckBox" name="show_ccr_sensors"> - <property name="text"> - <string>CCR: show individual Oâ‚‚ sensor values when viewing pOâ‚‚</string> - </property> - </widget> - </item> - <item row="7" column="0"> - <widget class="QLabel" name="label_26"> - <property name="text"> - <string>Default CCR set-point for dive planning</string> - </property> - </widget> - </item> - <item row="7" column="1"> - <widget class="QDoubleSpinBox" name="defaultSetpoint"> - <property name="suffix"> - <string>bar</string> - </property> - <property name="decimals"> - <number>2</number> - </property> - <property name="maximum"> - <double>10.000000000000000</double> - </property> - <property name="singleStep"> - <double>0.100000000000000</double> - </property> - </widget> - </item> - <item row="8" column="0"> - <widget class="QLabel" name="pSCR"> - <property name="text"> - <string>pSCR Oâ‚‚ metabolism rate</string> - </property> - </widget> - </item> - <item row="9" column="0"> - <widget class="QLabel" name="label_28"> - <property name="text"> - <string>pSCR ratio</string> - </property> - </widget> - </item> - <item row="8" column="1"> - <widget class="QDoubleSpinBox" name="psro2rate"> - <property name="suffix"> - <string>â„“/min</string> - </property> - <property name="decimals"> - <number>3</number> - </property> - </widget> - </item> - <item row="9" column="1"> - <widget class="QSpinBox" name="pscrfactor"> - <property name="suffix"> - <string/> - </property> - <property name="prefix"> - <string>1:</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacer_5"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWidget" name="language_page"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QVBoxLayout" name="verticalLayout_6" stretch="0,1,0"> - <property name="spacing"> - <number>5</number> - </property> - <property name="sizeConstraint"> - <enum>QLayout::SetNoConstraint</enum> - </property> - <property name="margin"> - <number>5</number> - </property> - <item> - <widget class="QGroupBox" name="language_group"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>UI language</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <item> - <widget class="QCheckBox" name="languageSystemDefault"> - <property name="text"> - <string>System default</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_14"> - <property name="text"> - <string>Filter</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="languageFilter"/> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QListView" name="languageView"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer_7"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWidget" name="network_page"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QVBoxLayout" name="verticalLayout_15"> - <property name="spacing"> - <number>5</number> - </property> - <property name="margin"> - <number>5</number> - </property> - <item> - <widget class="QGroupBox" name="groupBox_10"> - <property name="title"> - <string>Proxy</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="1" column="2"> - <widget class="QLabel" name="label_23"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Port</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="proxyType"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_22"> - <property name="text"> - <string>Host</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QCheckBox" name="proxyAuthRequired"> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="text"> - <string>Requires authentication</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_21"> - <property name="text"> - <string>Proxy type</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_24"> - <property name="text"> - <string>Username</string> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QSpinBox" name="proxyPort"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximum"> - <number>65535</number> - </property> - <property name="value"> - <number>80</number> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="proxyUsername"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maxLength"> - <number>32</number> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="proxyHost"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>2</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maxLength"> - <number>64</number> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_25"> - <property name="text"> - <string>Password</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="proxyPassword"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maxLength"> - <number>32</number> - </property> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="cloudStorageGroupBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>129</height> - </size> - </property> - <property name="title"> - <string>Subsurface cloud storage</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0"> - <widget class="QLabel" name="label_16b"> - <property name="toolTip"> - <string extracomment="Email address used for the Subsurface cloud storage infrastructure"/> - </property> - <property name="text"> - <string>Email address</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="label_16c"> - <property name="text"> - <string>Password</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLabel" name="cloud_storage_pin_label"> - <property name="text"> - <string>Verification PIN</string> - </property> - </widget> - </item> - <item row="0" column="3"> - <widget class="QLabel" name="cloud_storage_new_passwd_label"> - <property name="text"> - <string>New password</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLineEdit" name="cloud_storage_email"> - <property name="toolTip"> - <string extracomment="Email address used for the Subsurface cloud storage infrastructure"/> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="cloud_storage_password"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QLineEdit" name="cloud_storage_pin"> - <property name="toolTip"> - <string extracomment="One time verification PIN for Subsurface cloud storage infrastructure"/> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QLineEdit" name="cloud_storage_new_passwd"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QCheckBox" name="cloud_background_sync"> - <property name="text"> - <string>Sync to cloud in the background?</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QCheckBox" name="save_password_local"> - <property name="text"> - <string>Save Password locally?</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_8"> - <property name="title"> - <string>Subsurface web service</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_7"> - <property name="spacing"> - <number>5</number> - </property> - <property name="margin"> - <number>5</number> - </property> - <item> - <widget class="QLabel" name="label_16"> - <property name="text"> - <string>Default user ID</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="default_uid"/> - </item> - <item> - <widget class="QCheckBox" name="save_uid_local"> - <property name="text"> - <string>Save user ID locally?</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacer_3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWidget" name="facebook_page"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QVBoxLayout" name="fbLayout" stretch="0"> - <property name="spacing"> - <number>5</number> - </property> - <property name="margin"> - <number>5</number> - </property> - <item> - <widget class="QWidget" name="widget" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_9"> - <item> - <widget class="QLabel" name="FBLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Connect to facebook text placeholder</string> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="fbWebviewContainer" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_10"/> - </widget> - </item> - <item> - <widget class="QPushButton" name="fbDisconnect"> - <property name="text"> - <string>Disconnect</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="geolookup_page"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QVBoxLayout" name="verticalLayout_155"> - <property name="spacing"> - <number>5</number> - </property> - <property name="margin"> - <number>5</number> - </property> - <item> - <widget class="QGroupBox" name="groupBox_12"> - <property name="title"> - <string>Dive Site Layout</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_10"> - <item> - <widget class="QComboBox" name="first_item"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_29"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>/</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="second_item"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_30"> - <property name="text"> - <string>/</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="third_item"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacer_6"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Apply|QDialogButtonBox::Discard|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>PreferencesDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>264</x> - <y>720</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>PreferencesDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>332</x> - <y>720</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>listWidget</sender> - <signal>currentRowChanged(int)</signal> - <receiver>stackedWidget</receiver> - <slot>setCurrentIndex(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>37</x> - <y>97</y> - </hint> - <hint type="destinationlabel"> - <x>282</x> - <y>18</y> - </hint> - </hints> - </connection> - <connection> - <sender>personalize</sender> - <signal>toggled(bool)</signal> - <receiver>units_group</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>185</x> - <y>19</y> - </hint> - <hint type="destinationlabel"> - <x>186</x> - <y>23</y> - </hint> - </hints> - </connection> - <connection> - <sender>languageSystemDefault</sender> - <signal>toggled(bool)</signal> - <receiver>languageView</receiver> - <slot>setDisabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>231</x> - <y>26</y> - </hint> - <hint type="destinationlabel"> - <x>186</x> - <y>30</y> - </hint> - </hints> - </connection> - <connection> - <sender>languageSystemDefault</sender> - <signal>toggled(bool)</signal> - <receiver>languageFilter</receiver> - <slot>setDisabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>231</x> - <y>26</y> - </hint> - <hint type="destinationlabel"> - <x>185</x> - <y>20</y> - </hint> - </hints> - </connection> - <connection> - <sender>imperial</sender> - <signal>toggled(bool)</signal> - <receiver>feet</receiver> - <slot>setChecked(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>164</x> - <y>19</y> - </hint> - <hint type="destinationlabel"> - <x>175</x> - <y>34</y> - </hint> - </hints> - </connection> - <connection> - <sender>metric</sender> - <signal>toggled(bool)</signal> - <receiver>meter</receiver> - <slot>setChecked(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>142</x> - <y>19</y> - </hint> - <hint type="destinationlabel"> - <x>153</x> - <y>34</y> - </hint> - </hints> - </connection> - <connection> - <sender>imperial</sender> - <signal>toggled(bool)</signal> - <receiver>psi</receiver> - <slot>setChecked(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>164</x> - <y>19</y> - </hint> - <hint type="destinationlabel"> - <x>175</x> - <y>33</y> - </hint> - </hints> - </connection> - <connection> - <sender>metric</sender> - <signal>toggled(bool)</signal> - <receiver>bar</receiver> - <slot>setChecked(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>142</x> - <y>19</y> - </hint> - <hint type="destinationlabel"> - <x>153</x> - <y>33</y> - </hint> - </hints> - </connection> - <connection> - <sender>imperial</sender> - <signal>toggled(bool)</signal> - <receiver>cuft</receiver> - <slot>setChecked(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>164</x> - <y>19</y> - </hint> - <hint type="destinationlabel"> - <x>175</x> - <y>31</y> - </hint> - </hints> - </connection> - <connection> - <sender>metric</sender> - <signal>toggled(bool)</signal> - <receiver>liter</receiver> - <slot>setChecked(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>142</x> - <y>19</y> - </hint> - <hint type="destinationlabel"> - <x>153</x> - <y>31</y> - </hint> - </hints> - </connection> - <connection> - <sender>imperial</sender> - <signal>toggled(bool)</signal> - <receiver>fahrenheit</receiver> - <slot>setChecked(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>164</x> - <y>19</y> - </hint> - <hint type="destinationlabel"> - <x>175</x> - <y>29</y> - </hint> - </hints> - </connection> - <connection> - <sender>metric</sender> - <signal>toggled(bool)</signal> - <receiver>celsius</receiver> - <slot>setChecked(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>142</x> - <y>19</y> - </hint> - <hint type="destinationlabel"> - <x>153</x> - <y>29</y> - </hint> - </hints> - </connection> - <connection> - <sender>imperial</sender> - <signal>toggled(bool)</signal> - <receiver>lbs</receiver> - <slot>setChecked(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>164</x> - <y>19</y> - </hint> - <hint type="destinationlabel"> - <x>175</x> - <y>28</y> - </hint> - </hints> - </connection> - <connection> - <sender>metric</sender> - <signal>toggled(bool)</signal> - <receiver>kg</receiver> - <slot>setChecked(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>142</x> - <y>19</y> - </hint> - <hint type="destinationlabel"> - <x>153</x> - <y>28</y> - </hint> - </hints> - </connection> - <connection> - <sender>velocitySlider</sender> - <signal>valueChanged(int)</signal> - <receiver>velocitySpinBox</receiver> - <slot>setValue(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>236</x> - <y>52</y> - </hint> - <hint type="destinationlabel"> - <x>236</x> - <y>52</y> - </hint> - </hints> - </connection> - <connection> - <sender>velocitySpinBox</sender> - <signal>valueChanged(int)</signal> - <receiver>velocitySlider</receiver> - <slot>setValue(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>236</x> - <y>52</y> - </hint> - <hint type="destinationlabel"> - <x>236</x> - <y>52</y> - </hint> - </hints> - </connection> - <connection> - <sender>proxyAuthRequired</sender> - <signal>toggled(bool)</signal> - <receiver>proxyUsername</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>409</x> - <y>123</y> - </hint> - <hint type="destinationlabel"> - <x>409</x> - <y>153</y> - </hint> - </hints> - </connection> - <connection> - <sender>proxyAuthRequired</sender> - <signal>toggled(bool)</signal> - <receiver>proxyPassword</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>409</x> - <y>123</y> - </hint> - <hint type="destinationlabel"> - <x>409</x> - <y>183</y> - </hint> - </hints> - </connection> - <connection> - <sender>btnUseDefaultFile</sender> - <signal>toggled(bool)</signal> - <receiver>chooseFile</receiver> - <slot>setHidden(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>236</x> - <y>44</y> - </hint> - <hint type="destinationlabel"> - <x>236</x> - <y>44</y> - </hint> - </hints> - </connection> - </connections> - <buttongroups> - <buttongroup name="verticalSpeed"/> - <buttongroup name="buttonGroup_2"/> - <buttongroup name="buttonGroup_3"/> - <buttongroup name="buttonGroup_4"/> - <buttongroup name="defaultFileGroup"/> - <buttongroup name="buttonGroup_5"/> - <buttongroup name="buttonGroup_6"/> - <buttongroup name="buttonGroup_7"/> - <buttongroup name="buttonGroup"/> - </buttongroups> -</ui> diff --git a/qt-gui.cpp b/subsurface-android-helper.cpp index a4997a6fe..7b5d5df56 100644 --- a/qt-gui.cpp +++ b/subsurface-android-helper.cpp @@ -2,7 +2,7 @@ /* Qt UI implementation */ #include "dive.h" #include "display.h" -#include "qt-ui/mainwindow.h" +#include "desktop-widgets/mainwindow.h" #include "helpers.h" #include <QApplication> @@ -10,10 +10,8 @@ #include <QNetworkProxy> #include <QLibraryInfo> - #include "qt-gui.h" -#ifdef SUBSURFACE_MOBILE #include <QQuickWindow> #include <QQmlApplicationEngine> #include <QQmlContext> @@ -21,25 +19,16 @@ #include "qt-mobile/qmlmanager.h" #include "qt-models/divelistmodel.h" #include "qt-mobile/qmlprofile.h" -QObject *qqWindowObject = NULL; -#endif -static MainWindow *window = NULL; +QObject *qqWindowObject = NULL; void init_ui() { init_qt_late(); - - window = new MainWindow(); - if (existing_filename && existing_filename[0] != '\0') - window->setTitle(MWTF_FILENAME); - else - window->setTitle(MWTF_DEFAULT); } void run_ui() { -#ifdef SUBSURFACE_MOBILE window->hide(); qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager"); qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile"); @@ -66,15 +55,11 @@ void run_ui() qml_window->setWidth(800); #endif qml_window->show(); -#else - window->show(); -#endif qApp->exec(); } void exit_ui() { - delete window; delete qApp; free((void *)existing_filename); free((void *)default_dive_computer_vendor); @@ -87,5 +72,3 @@ double get_screen_dpi() QDesktopWidget *mydesk = qApp->desktop(); return mydesk->physicalDpiX(); } - - diff --git a/subsurface-android-main.cpp b/subsurface-android-main.cpp new file mode 100644 index 000000000..db974119e --- /dev/null +++ b/subsurface-android-main.cpp @@ -0,0 +1,81 @@ +/* main.c */ +#include <locale.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <time.h> + +#include "dive.h" +#include "qt-gui.h" +#include "subsurfacestartup.h" +#include "desktop-widgets/mainwindow.h" +#include "desktop-widgets/diveplanner.h" +#include "subsurface-core/color.h" +#include "qthelper.h" + +#include <QStringList> +#include <QApplication> +#include <QLoggingCategory> +#include <git2.h> + +QTranslator *qtTranslator, *ssrfTranslator; + +int main(int argc, char **argv) +{ + int i; + bool no_filenames = true; + QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); + QApplication *application = new QApplication(argc, argv); + QStringList files; + QStringList importedFiles; + QStringList arguments = QCoreApplication::arguments(); + + bool dedicated_console = arguments.length() > 1 && + (arguments.at(1) == QString("--win32console")); + subsurface_console_init(dedicated_console); + + for (i = 1; i < arguments.length(); i++) { + QString a = arguments.at(i); + if (a.at(0) == '-') { + parse_argument(a.toLocal8Bit().data()); + continue; + } + if (imported) { + importedFiles.push_back(a); + } else { + no_filenames = false; + files.push_back(a); + } + } +#if !LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR < 22 + git_threads_init(); +#else + git_libgit2_init(); +#endif + setup_system_prefs(); + prefs = default_prefs; + fill_profile_color(); + parse_xml_init(); + taglist_init_global(); + init_ui(); + if (no_filenames) { + if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE) { + QString defaultFile(prefs.default_filename); + if (!defaultFile.isEmpty()) + files.push_back(QString(prefs.default_filename)); + } else if (prefs.default_file_behavior == CLOUD_DEFAULT_FILE) { + QString cloudURL; + if (getCloudURL(cloudURL) == 0) + files.push_back(cloudURL); + } + } + + if (!quit) + run_ui(); + exit_ui(); + taglist_free(g_tag_list); + parse_xml_exit(); + subsurface_console_exit(); + free_prefs(); + return 0; +} diff --git a/subsurface-core/CMakeLists.txt b/subsurface-core/CMakeLists.txt new file mode 100644 index 000000000..e56f8bb34 --- /dev/null +++ b/subsurface-core/CMakeLists.txt @@ -0,0 +1,84 @@ +set(PLATFORM_SRC unknown_platform.c) +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(PLATFORM_SRC linux.c) +elseif(ANDROID) + set(PLATFORM_SRC android.cpp) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(PLATFORM_SRC macos.c) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(PLATFORM_SRC windows.c) +endif() + +if(FTDISUPPORT) + set(SERIAL_FTDI serial_ftdi.c) +endif() + +if(BTSUPPORT) + add_definitions(-DBT_SUPPORT) + set(BT_SRC_FILES qt-ui/btdeviceselectiondialog.cpp) + set(BT_CORE_SRC_FILES qtserialbluetooth.cpp) +endif() + +# compile the core library, in C. +set(SUBSURFACE_CORE_LIB_SRCS + cochran.c + datatrak.c + deco.c + device.c + dive.c + divesite.c + divesite.cpp + divelist.c + equipment.c + file.c + git-access.c + libdivecomputer.c + liquivision.c + load-git.c + membuffer.c + ostctools.c + parse-xml.c + planner.c + profile.c + gaspressures.c + worldmap-save.c + save-git.c + save-xml.c + save-html.c + sha1.c + statistics.c + strtod.c + subsurfacestartup.c + time.c + uemis.c + uemis-downloader.c + version.c + # gettextfrommoc should be added because we are using it on the c-code. + gettextfromc.cpp + # dirk ported some core functionality to c++. + qthelper.cpp + divecomputer.cpp + exif.cpp + subsurfacesysinfo.cpp + devicedetails.cpp + configuredivecomputer.cpp + configuredivecomputerthreads.cpp + divesitehelpers.cpp + taxonomy.c + checkcloudconnection.cpp + windowtitleupdate.cpp + divelogexportlogic.cpp + qt-init.cpp + qtserialbluetooth.cpp + metrics.cpp + color.cpp + pluginmanager.cpp + ${SERIAL_FTDI} + ${PLATFORM_SRC} + ${BT_CORE_SRC_FILES} +) +source_group("Subsurface Core" FILES ${SUBSURFACE_CORE_LIB_SRCS}) + +add_library(subsurface_corelib STATIC ${SUBSURFACE_CORE_LIB_SRCS} ) +target_link_libraries(subsurface_corelib ${QT_LIBRARIES}) + diff --git a/android.cpp b/subsurface-core/android.cpp index 3e14bec02..3e14bec02 100644 --- a/android.cpp +++ b/subsurface-core/android.cpp diff --git a/checkcloudconnection.cpp b/subsurface-core/checkcloudconnection.cpp index be2a2fa18..be2a2fa18 100644 --- a/checkcloudconnection.cpp +++ b/subsurface-core/checkcloudconnection.cpp diff --git a/checkcloudconnection.h b/subsurface-core/checkcloudconnection.h index 58a412797..58a412797 100644 --- a/checkcloudconnection.h +++ b/subsurface-core/checkcloudconnection.h diff --git a/cochran.c b/subsurface-core/cochran.c index 267fe2b4a..267fe2b4a 100644 --- a/cochran.c +++ b/subsurface-core/cochran.c diff --git a/cochran.h b/subsurface-core/cochran.h index 97d4361c8..97d4361c8 100644 --- a/cochran.h +++ b/subsurface-core/cochran.h diff --git a/qt-ui/graphicsview-common.cpp b/subsurface-core/color.cpp index a1813ce2d..cf6f43916 100644 --- a/qt-ui/graphicsview-common.cpp +++ b/subsurface-core/color.cpp @@ -1,4 +1,4 @@ -#include "graphicsview-common.h" +#include "color.h" QMap<color_indice_t, QVector<QColor> > profile_color; diff --git a/color.h b/subsurface-core/color.h index 7938e59a6..57ad77242 100644 --- a/color.h +++ b/subsurface-core/color.h @@ -5,6 +5,8 @@ from http://chir.ag/projects/name-that-color */ #include <QColor> +#include <QMap> +#include <QVector> // Greens #define CAMARONE1 QColor::fromRgbF(0.0, 0.4, 0.0, 1) @@ -64,4 +66,87 @@ // Magentas #define MEDIUMREDVIOLET1_HIGHER_TRANS QColor::fromRgbF(0.7, 0.2, 0.7, 0.1) +#define SAC_COLORS_START_IDX SAC_1 +#define SAC_COLORS 9 +#define VELOCITY_COLORS_START_IDX VELO_STABLE +#define VELOCITY_COLORS 5 + +typedef enum { + /* SAC colors. Order is important, the SAC_COLORS_START_IDX define above. */ + SAC_1, + SAC_2, + SAC_3, + SAC_4, + SAC_5, + SAC_6, + SAC_7, + SAC_8, + SAC_9, + + /* Velocity colors. Order is still important, ref VELOCITY_COLORS_START_IDX. */ + VELO_STABLE, + VELO_SLOW, + VELO_MODERATE, + VELO_FAST, + VELO_CRAZY, + + /* gas colors */ + PO2, + PO2_ALERT, + PN2, + PN2_ALERT, + PHE, + PHE_ALERT, + O2SETPOINT, + CCRSENSOR1, + CCRSENSOR2, + CCRSENSOR3, + PP_LINES, + + /* Other colors */ + TEXT_BACKGROUND, + ALERT_BG, + ALERT_FG, + EVENTS, + SAMPLE_DEEP, + SAMPLE_SHALLOW, + SMOOTHED, + MINUTE, + TIME_GRID, + TIME_TEXT, + DEPTH_GRID, + MEAN_DEPTH, + HR_TEXT, + HR_PLOT, + HR_AXIS, + DEPTH_TOP, + DEPTH_BOTTOM, + TEMP_TEXT, + TEMP_PLOT, + SAC_DEFAULT, + BOUNDING_BOX, + PRESSURE_TEXT, + BACKGROUND, + BACKGROUND_TRANS, + CEILING_SHALLOW, + CEILING_DEEP, + CALC_CEILING_SHALLOW, + CALC_CEILING_DEEP, + TISSUE_PERCENTAGE, + GF_LINE, + AMB_PRESSURE_LINE +} color_indice_t; + +extern QMap<color_indice_t, QVector<QColor> > profile_color; +void fill_profile_color(); +QColor getColor(const color_indice_t i, bool isGrayscale = false); +QColor getSacColor(int sac, int diveSac); +struct text_render_options { + double size; + color_indice_t color; + double hpos, vpos; +}; + +typedef text_render_options text_render_options_t; + #endif // COLOR_H diff --git a/configuredivecomputer.cpp b/subsurface-core/configuredivecomputer.cpp index 2457ffe82..2457ffe82 100644 --- a/configuredivecomputer.cpp +++ b/subsurface-core/configuredivecomputer.cpp diff --git a/configuredivecomputer.h b/subsurface-core/configuredivecomputer.h index f14eeeca3..f14eeeca3 100644 --- a/configuredivecomputer.h +++ b/subsurface-core/configuredivecomputer.h diff --git a/configuredivecomputerthreads.cpp b/subsurface-core/configuredivecomputerthreads.cpp index 78edcb37c..78edcb37c 100644 --- a/configuredivecomputerthreads.cpp +++ b/subsurface-core/configuredivecomputerthreads.cpp diff --git a/configuredivecomputerthreads.h b/subsurface-core/configuredivecomputerthreads.h index 1d7a36f9b..1d7a36f9b 100644 --- a/configuredivecomputerthreads.h +++ b/subsurface-core/configuredivecomputerthreads.h diff --git a/datatrak.c b/subsurface-core/datatrak.c index 03fa71a50..03fa71a50 100644 --- a/datatrak.c +++ b/subsurface-core/datatrak.c diff --git a/datatrak.h b/subsurface-core/datatrak.h index 3a37e0465..3a37e0465 100644 --- a/datatrak.h +++ b/subsurface-core/datatrak.h diff --git a/deco.c b/subsurface-core/deco.c index 506d8b58f..506d8b58f 100644 --- a/deco.c +++ b/subsurface-core/deco.c diff --git a/deco.h b/subsurface-core/deco.h index 08ff93422..08ff93422 100644 --- a/deco.h +++ b/subsurface-core/deco.h diff --git a/device.c b/subsurface-core/device.c index c952c84be..c952c84be 100644 --- a/device.c +++ b/subsurface-core/device.c diff --git a/device.h b/subsurface-core/device.h index 9ff2ce23a..9ff2ce23a 100644 --- a/device.h +++ b/subsurface-core/device.h diff --git a/devicedetails.cpp b/subsurface-core/devicedetails.cpp index 1ac56375d..1ac56375d 100644 --- a/devicedetails.cpp +++ b/subsurface-core/devicedetails.cpp diff --git a/devicedetails.h b/subsurface-core/devicedetails.h index 1ed9914ef..1ed9914ef 100644 --- a/devicedetails.h +++ b/subsurface-core/devicedetails.h diff --git a/display.h b/subsurface-core/display.h index 9e3e1d159..9e3e1d159 100644 --- a/display.h +++ b/subsurface-core/display.h diff --git a/dive.c b/subsurface-core/dive.c index 2ae84ca1e..2ae84ca1e 100644 --- a/dive.c +++ b/subsurface-core/dive.c diff --git a/dive.h b/subsurface-core/dive.h index cef1106fd..cef1106fd 100644 --- a/dive.h +++ b/subsurface-core/dive.h diff --git a/divecomputer.cpp b/subsurface-core/divecomputer.cpp index e4081e1cd..e4081e1cd 100644 --- a/divecomputer.cpp +++ b/subsurface-core/divecomputer.cpp diff --git a/divecomputer.h b/subsurface-core/divecomputer.h index 98d12ab8b..98d12ab8b 100644 --- a/divecomputer.h +++ b/subsurface-core/divecomputer.h diff --git a/divelist.c b/subsurface-core/divelist.c index a14fabf88..a14fabf88 100644 --- a/divelist.c +++ b/subsurface-core/divelist.c diff --git a/divelist.h b/subsurface-core/divelist.h index 5bae09cff..5bae09cff 100644 --- a/divelist.h +++ b/subsurface-core/divelist.h diff --git a/divelogexportlogic.cpp b/subsurface-core/divelogexportlogic.cpp index af5157f4a..af5157f4a 100644 --- a/divelogexportlogic.cpp +++ b/subsurface-core/divelogexportlogic.cpp diff --git a/divelogexportlogic.h b/subsurface-core/divelogexportlogic.h index 84f09c362..84f09c362 100644 --- a/divelogexportlogic.h +++ b/subsurface-core/divelogexportlogic.h diff --git a/divesite.c b/subsurface-core/divesite.c index e9eed2a07..e9eed2a07 100644 --- a/divesite.c +++ b/subsurface-core/divesite.c diff --git a/divesite.cpp b/subsurface-core/divesite.cpp index ae102a14b..ae102a14b 100644 --- a/divesite.cpp +++ b/subsurface-core/divesite.cpp diff --git a/divesite.h b/subsurface-core/divesite.h index f18b2e8e8..f18b2e8e8 100644 --- a/divesite.h +++ b/subsurface-core/divesite.h diff --git a/divesitehelpers.cpp b/subsurface-core/divesitehelpers.cpp index 3542f96fa..3542f96fa 100644 --- a/divesitehelpers.cpp +++ b/subsurface-core/divesitehelpers.cpp diff --git a/divesitehelpers.h b/subsurface-core/divesitehelpers.h index a08069bc0..a08069bc0 100644 --- a/divesitehelpers.h +++ b/subsurface-core/divesitehelpers.h diff --git a/equipment.c b/subsurface-core/equipment.c index 47c439735..47c439735 100644 --- a/equipment.c +++ b/subsurface-core/equipment.c diff --git a/exif.cpp b/subsurface-core/exif.cpp index 0b1cda2bc..0b1cda2bc 100644 --- a/exif.cpp +++ b/subsurface-core/exif.cpp diff --git a/exif.h b/subsurface-core/exif.h index 0fb3a7d4a..0fb3a7d4a 100644 --- a/exif.h +++ b/subsurface-core/exif.h diff --git a/file.c b/subsurface-core/file.c index 0263da457..0263da457 100644 --- a/file.c +++ b/subsurface-core/file.c diff --git a/file.h b/subsurface-core/file.h index 855109960..855109960 100644 --- a/file.h +++ b/subsurface-core/file.h diff --git a/gaspressures.c b/subsurface-core/gaspressures.c index 5f46d6080..5f46d6080 100644 --- a/gaspressures.c +++ b/subsurface-core/gaspressures.c diff --git a/gaspressures.h b/subsurface-core/gaspressures.h index 420c117a2..420c117a2 100644 --- a/gaspressures.h +++ b/subsurface-core/gaspressures.h diff --git a/gettext.h b/subsurface-core/gettext.h index 43ff023c7..43ff023c7 100644 --- a/gettext.h +++ b/subsurface-core/gettext.h diff --git a/gettextfromc.cpp b/subsurface-core/gettextfromc.cpp index c579e3c3c..c579e3c3c 100644 --- a/gettextfromc.cpp +++ b/subsurface-core/gettextfromc.cpp diff --git a/gettextfromc.h b/subsurface-core/gettextfromc.h index 53df18365..53df18365 100644 --- a/gettextfromc.h +++ b/subsurface-core/gettextfromc.h diff --git a/git-access.c b/subsurface-core/git-access.c index 607789f98..607789f98 100644 --- a/git-access.c +++ b/subsurface-core/git-access.c diff --git a/git-access.h b/subsurface-core/git-access.h index a2a9ba3ae..a2a9ba3ae 100644 --- a/git-access.h +++ b/subsurface-core/git-access.h diff --git a/helpers.h b/subsurface-core/helpers.h index 5f2f2f2c5..b5c119870 100644 --- a/helpers.h +++ b/subsurface-core/helpers.h @@ -40,7 +40,6 @@ bool is_same_day (timestamp_t trip_when, timestamp_t dive_when); QString get_trip_date_string(timestamp_t when, int nr, bool getday); QString uiLanguage(QLocale *callerLoc); QLocale getLocale(); -QString getDateFormat(); void selectedDivesGasUsed(QVector<QPair<QString, int> > &gasUsed); QString getUserAgent(); diff --git a/subsurface-core/isocialnetworkintegration.h b/subsurface-core/isocialnetworkintegration.h new file mode 100644 index 000000000..778a171b3 --- /dev/null +++ b/subsurface-core/isocialnetworkintegration.h @@ -0,0 +1,72 @@ +#ifndef ISOCIALNETWORKINTEGRATION_H +#define ISOCIALNETWORKINTEGRATION_H + +#include <QtPlugin> + +/* This Interface represents a Plugin for Social Network integration, + * with it you may be able to create plugins for facebook, instagram, + * twitpic, google plus and any other thing you may imagine. + * + * We bundle facebook integration as an example. + */ + +class ISocialNetworkIntegration { +public: + /*! + * @name socialNetworkName + * @brief The name of this social network + * @return The name of this social network + * + * The name of this social network will be used to populate the Menu to toggle states + * between connected/disconnected, and also submit stuff to it. + */ + virtual QString socialNetworkName() const = 0; + + /*! + * @name socialNetworkIcon + * @brief The icon of this social network + * @return The icon of this social network + * + * The icon of this social network will be used to populate the menu, and can also be + * used on a toolbar if requested. + */ + virtual QString socialNetworkIcon() const = 0; + + /*! + * @name isConnected + * @brief returns true if connected to this social network, false otherwise + * @return true if connected to this social network, false otherwise + */ + virtual bool isConnected() = 0; + + /*! + * @name requestLogin + * @brief try to login on this social network. + * + * Try to login on this social network. All widget implementation that + * manages login should be done inside this function. + */ + virtual void requestLogin() = 0; + + /*! + * @name requestLogoff + * @brief tries to logoff from this social network + * + * Try to logoff from this social network. + */ + virtual void requestLogoff() = 0; + + /*! + * @name uploadCurrentDive + * @brief send the current dive info to the Social Network + * + * Should format all the options and pixmaps from the current dive + * to update to the social network. All widget stuff related to sendint + * dive information should be executed inside this function. + */ + virtual void uploadCurrentDive() = 0; +}; + +Q_DECLARE_INTERFACE(ISocialNetworkIntegration, "org.subsurface.ISocialNetworkIntegration.v1") +Q_DECLARE_METATYPE(ISocialNetworkIntegration*); +#endif
\ No newline at end of file diff --git a/libdivecomputer.c b/subsurface-core/libdivecomputer.c index ca8378379..ca8378379 100644 --- a/libdivecomputer.c +++ b/subsurface-core/libdivecomputer.c diff --git a/libdivecomputer.h b/subsurface-core/libdivecomputer.h index 79817e509..79817e509 100644 --- a/libdivecomputer.h +++ b/subsurface-core/libdivecomputer.h diff --git a/linux.c b/subsurface-core/linux.c index d4131c7ea..d4131c7ea 100644 --- a/linux.c +++ b/subsurface-core/linux.c diff --git a/liquivision.c b/subsurface-core/liquivision.c index 295287c15..295287c15 100644 --- a/liquivision.c +++ b/subsurface-core/liquivision.c diff --git a/load-git.c b/subsurface-core/load-git.c index 39dab4367..39dab4367 100644 --- a/load-git.c +++ b/subsurface-core/load-git.c diff --git a/macos.c b/subsurface-core/macos.c index aa2be4b3b..aa2be4b3b 100644 --- a/macos.c +++ b/subsurface-core/macos.c diff --git a/membuffer.c b/subsurface-core/membuffer.c index 2889a0cdc..2889a0cdc 100644 --- a/membuffer.c +++ b/subsurface-core/membuffer.c diff --git a/membuffer.h b/subsurface-core/membuffer.h index 434b34c71..434b34c71 100644 --- a/membuffer.h +++ b/subsurface-core/membuffer.h diff --git a/qt-ui/metrics.cpp b/subsurface-core/metrics.cpp index 203c2e5e2..203c2e5e2 100644 --- a/qt-ui/metrics.cpp +++ b/subsurface-core/metrics.cpp diff --git a/qt-ui/metrics.h b/subsurface-core/metrics.h index 30295a3d8..30295a3d8 100644 --- a/qt-ui/metrics.h +++ b/subsurface-core/metrics.h diff --git a/ostctools.c b/subsurface-core/ostctools.c index 4b4cff241..4b4cff241 100644 --- a/ostctools.c +++ b/subsurface-core/ostctools.c diff --git a/parse-xml.c b/subsurface-core/parse-xml.c index 93ce74305..93ce74305 100644 --- a/parse-xml.c +++ b/subsurface-core/parse-xml.c diff --git a/planner.c b/subsurface-core/planner.c index 22d37165a..22d37165a 100644 --- a/planner.c +++ b/subsurface-core/planner.c diff --git a/planner.h b/subsurface-core/planner.h index a675989e0..a675989e0 100644 --- a/planner.h +++ b/subsurface-core/planner.h diff --git a/subsurface-core/pluginmanager.cpp b/subsurface-core/pluginmanager.cpp new file mode 100644 index 000000000..5c0f22525 --- /dev/null +++ b/subsurface-core/pluginmanager.cpp @@ -0,0 +1,51 @@ +#include "pluginmanager.h" + +#include <QApplication> +#include <QDir> +#include <QPluginLoader> +#include <QDebug> + +static QList<ISocialNetworkIntegration*> _socialNetworks; + +PluginManager& PluginManager::instance() +{ + static PluginManager self; + return self; +} + +PluginManager::PluginManager() +{ +} + +void PluginManager::loadPlugins() +{ + QDir pluginsDir(qApp->applicationDirPath()); + +#if defined(Q_OS_WIN) + if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release") + pluginsDir.cdUp(); +#elif defined(Q_OS_MAC) + if (pluginsDir.dirName() == "MacOS") { + pluginsDir.cdUp(); + pluginsDir.cdUp(); + pluginsDir.cdUp(); + } +#endif + pluginsDir.cd("plugins"); + + qDebug() << "Plugins Directory: " << pluginsDir; + foreach (const QString& fileName, pluginsDir.entryList(QDir::Files)) { + QPluginLoader loader(pluginsDir.absoluteFilePath(fileName)); + QObject *plugin = loader.instance(); + if(!plugin) + continue; + + if (ISocialNetworkIntegration *social = qobject_cast<ISocialNetworkIntegration*>(plugin)) + _socialNetworks.push_back(social); + } +} + +QList<ISocialNetworkIntegration*> PluginManager::socialNetworkIntegrationPlugins() const +{ + return _socialNetworks; +} diff --git a/subsurface-core/pluginmanager.h b/subsurface-core/pluginmanager.h new file mode 100644 index 000000000..c4943895c --- /dev/null +++ b/subsurface-core/pluginmanager.h @@ -0,0 +1,19 @@ +#ifndef PLUGINMANAGER_H +#define PLUGINMANAGER_H + +#include <QObject> + +#include "isocialnetworkintegration.h" + +class PluginManager { +public: + static PluginManager& instance(); + void loadPlugins(); + QList<ISocialNetworkIntegration*> socialNetworkIntegrationPlugins() const; +private: + PluginManager(); + PluginManager(const PluginManager&) = delete; + PluginManager& operator=(const PluginManager&) = delete; +}; + +#endif
\ No newline at end of file diff --git a/pref.h b/subsurface-core/pref.h index 84975aaaa..9f5f587e2 100644 --- a/pref.h +++ b/subsurface-core/pref.h @@ -44,6 +44,11 @@ struct preferences { const char *default_cylinder; const char *cloud_base_url; const char *cloud_git_url; + const char *time_format; + const char *date_format; + const char *date_format_short; + bool time_format_override; + bool date_format_override; double font_size; partial_pressure_graphs_t pp_graphs; short mod; diff --git a/prefs-macros.h b/subsurface-core/prefs-macros.h index fe459d3da..fe459d3da 100644 --- a/prefs-macros.h +++ b/subsurface-core/prefs-macros.h diff --git a/profile.c b/subsurface-core/profile.c index edba51ebd..edba51ebd 100644 --- a/profile.c +++ b/subsurface-core/profile.c diff --git a/profile.h b/subsurface-core/profile.h index a6dbfcf5f..a6dbfcf5f 100644 --- a/profile.h +++ b/subsurface-core/profile.h diff --git a/qt-gui.h b/subsurface-core/qt-gui.h index ca038b145..ca038b145 100644 --- a/qt-gui.h +++ b/subsurface-core/qt-gui.h diff --git a/qt-init.cpp b/subsurface-core/qt-init.cpp index b52dfd970..b52dfd970 100644 --- a/qt-init.cpp +++ b/subsurface-core/qt-init.cpp diff --git a/qthelper.cpp b/subsurface-core/qthelper.cpp index a12d25333..40c507a7e 100644 --- a/qthelper.cpp +++ b/subsurface-core/qthelper.cpp @@ -33,9 +33,6 @@ #include <libxslt/documents.h> const char *existing_filename; -static QString shortDateFormat; -static QString dateFormat; -static QString timeFormat; static QLocale loc; #define translate(_context, arg) trGettext(arg) @@ -168,8 +165,8 @@ void Dive::put_date_time() { QDateTime localTime = QDateTime::fromTime_t(dive->when - gettimezoneoffset(displayed_dive.when)); localTime.setTimeSpec(Qt::UTC); - m_date = localTime.date().toString(dateFormat); - m_time = localTime.time().toString(timeFormat); + m_date = localTime.date().toString(prefs.date_format); + m_time = localTime.time().toString(prefs.time_format); } void Dive::put_timestamp() @@ -721,7 +718,11 @@ QString getUserAgent() QString uiLanguage(QLocale *callerLoc) { + QString shortDateFormat; + QString dateFormat; + QString timeFormat; QSettings s; + QVariant v; s.beginGroup("Language"); if (!s.value("UseSystemLanguage", true).toBool()) { @@ -731,6 +732,11 @@ QString uiLanguage(QLocale *callerLoc) } QString uiLang = loc.uiLanguages().first(); + GET_BOOL("time_format_override", time_format_override); + GET_BOOL("date_format_override", date_format_override); + GET_TXT("time_format", time_format); + GET_TXT("date_format", date_format); + GET_TXT("date_format_short", date_format_short); s.endGroup(); // there's a stupid Qt bug on MacOS where uiLanguages doesn't give us the country info @@ -742,18 +748,33 @@ QString uiLanguage(QLocale *callerLoc) if (callerLoc) *callerLoc = loc; - // the short format is fine - // the long format uses long weekday and month names, so replace those with the short ones - // for time we don't want the time zone designator and don't want leading zeroes on the hours - shortDateFormat = loc.dateFormat(QLocale::ShortFormat); - dateFormat = loc.dateFormat(QLocale::LongFormat); - dateFormat.replace("dddd,", "ddd").replace("dddd", "ddd").replace("MMMM", "MMM"); - // special hack for Swedish as our switching from long weekday names to short weekday names - // messes things up there - dateFormat.replace("'en' 'den' d:'e'", " d"); - timeFormat = loc.timeFormat(); - timeFormat.replace("(t)", "").replace(" t", "").replace("t", "").replace("hh", "h").replace("HH", "H").replace("'kl'.", ""); - timeFormat.replace(".ss", "").replace(":ss", "").replace("ss", ""); + if (!prefs.date_format_override || same_string(prefs.date_format_short, "") || same_string(prefs.date_format, "")) { + // derive our standard date format from what the locale gives us + // the short format is fine + // the long format uses long weekday and month names, so replace those with the short ones + // for time we don't want the time zone designator and don't want leading zeroes on the hours + shortDateFormat = loc.dateFormat(QLocale::ShortFormat); + dateFormat = loc.dateFormat(QLocale::LongFormat); + dateFormat.replace("dddd,", "ddd").replace("dddd", "ddd").replace("MMMM", "MMM"); + // special hack for Swedish as our switching from long weekday names to short weekday names + // messes things up there + dateFormat.replace("'en' 'den' d:'e'", " d"); + if (!prefs.date_format_override || same_string(prefs.date_format, "")) { + free((void*)prefs.date_format); + prefs.date_format = strdup(qPrintable(dateFormat)); + } + if (!prefs.date_format_override || same_string(prefs.date_format_short, "")) { + free((void*)prefs.date_format_short); + prefs.date_format_short = strdup(qPrintable(shortDateFormat)); + } + } + if (!prefs.time_format_override || same_string(prefs.time_format, "")) { + timeFormat = loc.timeFormat(); + timeFormat.replace("(t)", "").replace(" t", "").replace("t", "").replace("hh", "h").replace("HH", "H").replace("'kl'.", ""); + timeFormat.replace(".ss", "").replace(":ss", "").replace("ss", ""); + free((void*)prefs.time_format); + prefs.time_format = strdup(qPrintable(timeFormat)); + } return uiLang; } @@ -762,10 +783,6 @@ QLocale getLocale() return loc; } -QString getDateFormat() -{ - return dateFormat; -} void set_filename(const char *filename, bool force) { if (!force && existing_filename) @@ -1034,14 +1051,14 @@ QString get_dive_date_string(timestamp_t when) { QDateTime ts; ts.setMSecsSinceEpoch(when * 1000L); - return loc.toString(ts.toUTC(), dateFormat + " " + timeFormat); + return loc.toString(ts.toUTC(), QString(prefs.date_format) + " " + prefs.time_format); } QString get_short_dive_date_string(timestamp_t when) { QDateTime ts; ts.setMSecsSinceEpoch(when * 1000L); - return loc.toString(ts.toUTC(), shortDateFormat + " " + timeFormat); + return loc.toString(ts.toUTC(), QString(prefs.date_format_short) + " " + prefs.time_format); } const char *get_dive_date_c_string(timestamp_t when) @@ -1076,7 +1093,7 @@ QString get_trip_date_string(timestamp_t when, int nr, bool getday) QString suffix = " " + QObject::tr("(%n dive(s))", "", nr); if (getday) { - ret = localTime.date().toString(dateFormat) + suffix; + ret = localTime.date().toString(prefs.date_format) + suffix; } else { ret = localTime.date().toString("MMM yy") + suffix; } diff --git a/qthelper.h b/subsurface-core/qthelper.h index a2b7b6c39..a2b7b6c39 100644 --- a/qthelper.h +++ b/subsurface-core/qthelper.h diff --git a/qthelperfromc.h b/subsurface-core/qthelperfromc.h index d2e80144c..d2e80144c 100644 --- a/qthelperfromc.h +++ b/subsurface-core/qthelperfromc.h diff --git a/qtserialbluetooth.cpp b/subsurface-core/qtserialbluetooth.cpp index 025ab8c34..025ab8c34 100644 --- a/qtserialbluetooth.cpp +++ b/subsurface-core/qtserialbluetooth.cpp diff --git a/save-git.c b/subsurface-core/save-git.c index 69ad0726d..69ad0726d 100644 --- a/save-git.c +++ b/subsurface-core/save-git.c diff --git a/save-html.c b/subsurface-core/save-html.c index 64ce94f66..64ce94f66 100644 --- a/save-html.c +++ b/subsurface-core/save-html.c diff --git a/save-html.h b/subsurface-core/save-html.h index 20743e90a..20743e90a 100644 --- a/save-html.h +++ b/subsurface-core/save-html.h diff --git a/save-xml.c b/subsurface-core/save-xml.c index 166885861..166885861 100644 --- a/save-xml.c +++ b/subsurface-core/save-xml.c diff --git a/serial_ftdi.c b/subsurface-core/serial_ftdi.c index cbac026cf..cbac026cf 100644 --- a/serial_ftdi.c +++ b/subsurface-core/serial_ftdi.c diff --git a/sha1.c b/subsurface-core/sha1.c index acf8c5d9f..acf8c5d9f 100644 --- a/sha1.c +++ b/subsurface-core/sha1.c diff --git a/sha1.h b/subsurface-core/sha1.h index cab6ff77d..cab6ff77d 100644 --- a/sha1.h +++ b/subsurface-core/sha1.h diff --git a/statistics.c b/subsurface-core/statistics.c index 19fd350eb..19fd350eb 100644 --- a/statistics.c +++ b/subsurface-core/statistics.c diff --git a/statistics.h b/subsurface-core/statistics.h index dbab25761..dbab25761 100644 --- a/statistics.h +++ b/subsurface-core/statistics.h diff --git a/strndup.h b/subsurface-core/strndup.h index 84e18b60f..84e18b60f 100644 --- a/strndup.h +++ b/subsurface-core/strndup.h diff --git a/strtod.c b/subsurface-core/strtod.c index 81e5d42d1..81e5d42d1 100644 --- a/strtod.c +++ b/subsurface-core/strtod.c diff --git a/subsurfacestartup.c b/subsurface-core/subsurfacestartup.c index 1286885ee..0bde2a070 100644 --- a/subsurfacestartup.c +++ b/subsurface-core/subsurfacestartup.c @@ -291,6 +291,9 @@ void copy_prefs(struct preferences *src, struct preferences *dest) dest->proxy_host = copy_string(src->proxy_host); dest->proxy_user = copy_string(src->proxy_user); dest->proxy_pass = copy_string(src->proxy_pass); + dest->time_format = copy_string(src->time_format); + dest->date_format = copy_string(src->date_format); + dest->date_format_short = copy_string(src->date_format_short); dest->cloud_storage_password = copy_string(src->cloud_storage_password); dest->cloud_storage_newpassword = copy_string(src->cloud_storage_newpassword); dest->cloud_storage_email = copy_string(src->cloud_storage_email); diff --git a/subsurfacestartup.h b/subsurface-core/subsurfacestartup.h index 3ccc24aa4..3ccc24aa4 100644 --- a/subsurfacestartup.h +++ b/subsurface-core/subsurfacestartup.h diff --git a/subsurfacesysinfo.cpp b/subsurface-core/subsurfacesysinfo.cpp index a7173b169..a7173b169 100644 --- a/subsurfacesysinfo.cpp +++ b/subsurface-core/subsurfacesysinfo.cpp diff --git a/subsurfacesysinfo.h b/subsurface-core/subsurfacesysinfo.h index b2c267b83..b2c267b83 100644 --- a/subsurfacesysinfo.h +++ b/subsurface-core/subsurfacesysinfo.h diff --git a/taxonomy.c b/subsurface-core/taxonomy.c index 670d85ad0..670d85ad0 100644 --- a/taxonomy.c +++ b/subsurface-core/taxonomy.c diff --git a/taxonomy.h b/subsurface-core/taxonomy.h index 51245d562..51245d562 100644 --- a/taxonomy.h +++ b/subsurface-core/taxonomy.h diff --git a/time.c b/subsurface-core/time.c index b658954bc..b658954bc 100644 --- a/time.c +++ b/subsurface-core/time.c diff --git a/uemis-downloader.c b/subsurface-core/uemis-downloader.c index 2a6e5178c..2a6e5178c 100644 --- a/uemis-downloader.c +++ b/subsurface-core/uemis-downloader.c diff --git a/uemis.c b/subsurface-core/uemis.c index 4135e0cfe..4135e0cfe 100644 --- a/uemis.c +++ b/subsurface-core/uemis.c diff --git a/uemis.h b/subsurface-core/uemis.h index 5f32fe76c..5f32fe76c 100644 --- a/uemis.h +++ b/subsurface-core/uemis.h diff --git a/units.h b/subsurface-core/units.h index 1273bd9bb..1273bd9bb 100644 --- a/units.h +++ b/subsurface-core/units.h diff --git a/version.c b/subsurface-core/version.c index 5b54bf4c7..5b54bf4c7 100644 --- a/version.c +++ b/subsurface-core/version.c diff --git a/version.h b/subsurface-core/version.h index bc0aac00d..bc0aac00d 100644 --- a/version.h +++ b/subsurface-core/version.h diff --git a/webservice.h b/subsurface-core/webservice.h index 052b8aae7..052b8aae7 100644 --- a/webservice.h +++ b/subsurface-core/webservice.h diff --git a/windows.c b/subsurface-core/windows.c index a2386fd83..a2386fd83 100644 --- a/windows.c +++ b/subsurface-core/windows.c diff --git a/windowtitleupdate.cpp b/subsurface-core/windowtitleupdate.cpp index eec324c68..eec324c68 100644 --- a/windowtitleupdate.cpp +++ b/subsurface-core/windowtitleupdate.cpp diff --git a/windowtitleupdate.h b/subsurface-core/windowtitleupdate.h index 8650e5868..8650e5868 100644 --- a/windowtitleupdate.h +++ b/subsurface-core/windowtitleupdate.h diff --git a/worldmap-options.h b/subsurface-core/worldmap-options.h index 177443563..177443563 100644 --- a/worldmap-options.h +++ b/subsurface-core/worldmap-options.h diff --git a/worldmap-save.c b/subsurface-core/worldmap-save.c index 25c5ee33f..25c5ee33f 100644 --- a/worldmap-save.c +++ b/subsurface-core/worldmap-save.c diff --git a/worldmap-save.h b/subsurface-core/worldmap-save.h index 102ea40e5..102ea40e5 100644 --- a/worldmap-save.h +++ b/subsurface-core/worldmap-save.h diff --git a/subsurface-desktop-helper.cpp b/subsurface-desktop-helper.cpp new file mode 100644 index 000000000..420f75249 --- /dev/null +++ b/subsurface-desktop-helper.cpp @@ -0,0 +1,65 @@ +/* qt-gui.cpp */ +/* Qt UI implementation */ +#include "dive.h" +#include "display.h" +#include "desktop-widgets/mainwindow.h" +#include "helpers.h" +#include "pluginmanager.h" + +#include <QApplication> +#include <QDesktopWidget> +#include <QNetworkProxy> +#include <QLibraryInfo> + + +#include "qt-gui.h" + +#ifdef SUBSURFACE_MOBILE +#include <QQuickWindow> +#include <QQmlApplicationEngine> +#include <QQmlContext> +#include <QSortFilterProxyModel> +#include "qt-mobile/qmlmanager.h" +#include "qt-models/divelistmodel.h" +#include "qt-mobile/qmlprofile.h" +QObject *qqWindowObject = NULL; +#endif + +static MainWindow *window = NULL; + +void init_ui() +{ + init_qt_late(); + + PluginManager::instance().loadPlugins(); + + window = new MainWindow(); + if (existing_filename && existing_filename[0] != '\0') + window->setTitle(MWTF_FILENAME); + else + window->setTitle(MWTF_DEFAULT); +} + +void run_ui() +{ + window->show(); + qApp->exec(); +} + +void exit_ui() +{ + delete window; + delete qApp; + free((void *)existing_filename); + free((void *)default_dive_computer_vendor); + free((void *)default_dive_computer_product); + free((void *)default_dive_computer_device); +} + +double get_screen_dpi() +{ + QDesktopWidget *mydesk = qApp->desktop(); + return mydesk->physicalDpiX(); +} + + diff --git a/main.cpp b/subsurface-desktop-main.cpp index 171876abf..e7259c3f3 100644 --- a/main.cpp +++ b/subsurface-desktop-main.cpp @@ -8,9 +8,9 @@ #include "dive.h" #include "qt-gui.h" #include "subsurfacestartup.h" -#include "qt-ui/mainwindow.h" -#include "qt-ui/diveplanner.h" -#include "qt-ui/graphicsview-common.h" +#include "desktop-widgets/mainwindow.h" +#include "desktop-widgets/diveplanner.h" +#include "subsurface-core/color.h" #include "qthelper.h" #include <QStringList> diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..23642fb3c --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,28 @@ +# QTest based tests +macro(TEST NAME FILE) + add_executable(${NAME} ${FILE} ) + target_link_libraries(${NAME} subsurface_corelib ${QT_TEST_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES}) + add_test(NAME ${NAME} COMMAND $<TARGET_FILE:${NAME}>) +endmacro() + +enable_testing() +add_definitions(-g) +TEST(TestUnitConversion testunitconversion.cpp) +TEST(TestProfile testprofile.cpp) +TEST(TestGpsCoords testgpscoords.cpp) +TEST(TestParse testparse.cpp) +TEST(TestPlan testplan.cpp) +TEST(TestDiveSiteDuplication testdivesiteduplication.cpp) +TEST(TestRenumber testrenumber.cpp) +TEST(TestGitStorage testgitstorage.cpp) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} + DEPENDS + TestUnitConversion + TestProfile + TestGpsCoords + TestParse + TestGitStorage + TestPlan + TestDiveSiteDuplication +)
\ No newline at end of file |