From a0798214231c652ac6142228f5ddfc4b65c921f8 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 2 Sep 2015 19:09:08 -0300 Subject: [PATCH 01/48] Start to clean CMake CMake can be a good system but if we keep everything into one big cmake file things can go nuts really quick. Since I already took quite a start on an subsurface layer separation some time ago, I'm improving it by making each module on Subsurface depend on it's own CMake module. This first patch moves the qt-ui part to qt-ui/CMakeLists.txt file, it cleans tons of the main cmake file ( moving all parts to the in ternal folder ), and makes things more easily manageable by the programmer that will change the ui bits, he doesn't need to play hide and seek with the CMakeLists.txt file anymore, trying to figure out where should he put his newly generated file. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 89 +-------------- qt-ui/CMakeLists.txt | 104 ++++++++++++++++++ printer.cpp => qt-ui/printer.cpp | 0 printer.h => qt-ui/printer.h | 0 .../templatelayout.cpp | 0 templatelayout.h => qt-ui/templatelayout.h | 0 6 files changed, 106 insertions(+), 87 deletions(-) create mode 100644 qt-ui/CMakeLists.txt rename printer.cpp => qt-ui/printer.cpp (100%) rename printer.h => qt-ui/printer.h (100%) rename templatelayout.cpp => qt-ui/templatelayout.cpp (100%) rename templatelayout.h => qt-ui/templatelayout.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ae1e9b45..ba6544210 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,13 +159,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 +167,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() @@ -410,71 +402,6 @@ set(SUBSURFACE_MODELS_LIB_SRCS ) 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}) - # the main app. set(SUBSURFACE_APP main.cpp @@ -483,24 +410,10 @@ set(SUBSURFACE_APP ) 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}) # add pthread to the end of the library list on Linux # this is only needed on Ubuntu (why do these idiots break everything?) @@ -509,6 +422,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ANDROID) set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lpthread) endif() +add_subdirectory(qt-ui) + # create the executables if(SUBSURFACE_MOBILE) set(MOBILE_SRC qt-mobile/qmlmanager.cpp qt-mobile/qmlprofile.cpp qt-models/divelistmodel.cpp) diff --git a/qt-ui/CMakeLists.txt b/qt-ui/CMakeLists.txt new file mode 100644 index 000000000..9def39ff3 --- /dev/null +++ b/qt-ui/CMakeLists.txt @@ -0,0 +1,104 @@ +# create the libraries +file(GLOB SUBSURFACE_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}) + +# the interface, in C++ +set(SUBSURFACE_INTERFACE + updatemanager.cpp + about.cpp + divecomputermanagementdialog.cpp + divelistview.cpp + diveplanner.cpp + diveshareexportdialog.cpp + downloadfromdivecomputer.cpp + globe.cpp + graphicsview-common.cpp + kmessagewidget.cpp + maintab.cpp + mainwindow.cpp + modeldelegates.cpp + metrics.cpp + notificationwidget.cpp + preferences.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 profile widget +set(SUBSURFACE_PROFILE_LIB_SRCS + profile/profilewidget2.cpp + profile/diverectitem.cpp + profile/divepixmapitem.cpp + profile/divelineitem.cpp + profile/divetextitem.cpp + profile/animationfunctions.cpp + profile/divecartesianaxis.cpp + profile/diveprofileitem.cpp + profile/diveeventitem.cpp + profile/divetooltipitem.cpp + profile/ruleritem.cpp + profile/tankitem.cpp +) +source_group("Subsurface Profile" FILES ${SUBSURFACE_PROFILE_LIB_SRCS}) + +# 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_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}) diff --git a/printer.cpp b/qt-ui/printer.cpp similarity index 100% rename from printer.cpp rename to qt-ui/printer.cpp diff --git a/printer.h b/qt-ui/printer.h similarity index 100% rename from printer.h rename to qt-ui/printer.h diff --git a/templatelayout.cpp b/qt-ui/templatelayout.cpp similarity index 100% rename from templatelayout.cpp rename to qt-ui/templatelayout.cpp diff --git a/templatelayout.h b/qt-ui/templatelayout.h similarity index 100% rename from templatelayout.h rename to qt-ui/templatelayout.h From 4c0156e3d51b389db8eccc3fa3da4b8f248f9b13 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 2 Sep 2015 20:52:34 -0300 Subject: [PATCH 02/48] Move all core-functionality to subsurface-core And adapt a new CMakeLists.txt file for it. On the way I've also found out that we where double-compilling a few files. I've also set the subsurface-core as a include_path but that was just to reduce the noise on this commit, since I plan to remove it from the include path to make it obligatory to specify something like include "subsurface-core/dive.h" for the header files. Since the app is growing quite a bit we ended up having a few different files with almost same name that did similar things, I want to kill that (for instance Dive.h, dive.h, PrintDive.h and such). Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 81 +++---------------- qt-models/models.h | 6 +- qt-ui/CMakeLists.txt | 4 + qt-ui/configuredivecomputerdialog.h | 2 +- qt-ui/divelogimportdialog.h | 4 +- qt-ui/graphicsview-common.h | 2 +- subsurface-core/CMakeLists.txt | 81 +++++++++++++++++++ android.cpp => subsurface-core/android.cpp | 0 .../checkcloudconnection.cpp | 0 .../checkcloudconnection.h | 0 cochran.c => subsurface-core/cochran.c | 0 cochran.h => subsurface-core/cochran.h | 0 color.h => subsurface-core/color.h | 0 .../configuredivecomputer.cpp | 0 .../configuredivecomputer.h | 0 .../configuredivecomputerthreads.cpp | 0 .../configuredivecomputerthreads.h | 0 datatrak.c => subsurface-core/datatrak.c | 0 datatrak.h => subsurface-core/datatrak.h | 0 deco.c => subsurface-core/deco.c | 0 deco.h => subsurface-core/deco.h | 0 device.c => subsurface-core/device.c | 0 device.h => subsurface-core/device.h | 0 .../devicedetails.cpp | 0 .../devicedetails.h | 0 display.h => subsurface-core/display.h | 0 dive.c => subsurface-core/dive.c | 0 dive.h => subsurface-core/dive.h | 0 .../divecomputer.cpp | 0 .../divecomputer.h | 0 divelist.c => subsurface-core/divelist.c | 0 divelist.h => subsurface-core/divelist.h | 0 .../divelogexportlogic.cpp | 0 .../divelogexportlogic.h | 0 divesite.c => subsurface-core/divesite.c | 0 divesite.cpp => subsurface-core/divesite.cpp | 0 divesite.h => subsurface-core/divesite.h | 0 .../divesitehelpers.cpp | 0 .../divesitehelpers.h | 0 equipment.c => subsurface-core/equipment.c | 0 exif.cpp => subsurface-core/exif.cpp | 0 exif.h => subsurface-core/exif.h | 0 file.c => subsurface-core/file.c | 0 file.h => subsurface-core/file.h | 0 .../gaspressures.c | 0 .../gaspressures.h | 0 gettext.h => subsurface-core/gettext.h | 0 .../gettextfromc.cpp | 0 .../gettextfromc.h | 0 git-access.c => subsurface-core/git-access.c | 0 git-access.h => subsurface-core/git-access.h | 0 helpers.h => subsurface-core/helpers.h | 0 .../libdivecomputer.c | 0 .../libdivecomputer.h | 0 linux.c => subsurface-core/linux.c | 0 .../liquivision.c | 0 load-git.c => subsurface-core/load-git.c | 0 macos.c => subsurface-core/macos.c | 0 membuffer.c => subsurface-core/membuffer.c | 0 membuffer.h => subsurface-core/membuffer.h | 0 ostctools.c => subsurface-core/ostctools.c | 0 parse-xml.c => subsurface-core/parse-xml.c | 0 planner.c => subsurface-core/planner.c | 0 planner.h => subsurface-core/planner.h | 0 pref.h => subsurface-core/pref.h | 0 .../prefs-macros.h | 0 profile.c => subsurface-core/profile.c | 0 profile.h => subsurface-core/profile.h | 0 qt-gui.h => subsurface-core/qt-gui.h | 0 qt-init.cpp => subsurface-core/qt-init.cpp | 0 qthelper.cpp => subsurface-core/qthelper.cpp | 0 qthelper.h => subsurface-core/qthelper.h | 0 .../qthelperfromc.h | 0 .../qtserialbluetooth.cpp | 0 save-git.c => subsurface-core/save-git.c | 0 save-html.c => subsurface-core/save-html.c | 0 save-html.h => subsurface-core/save-html.h | 0 save-xml.c => subsurface-core/save-xml.c | 0 .../serial_ftdi.c | 0 sha1.c => subsurface-core/sha1.c | 0 sha1.h => subsurface-core/sha1.h | 0 statistics.c => subsurface-core/statistics.c | 0 statistics.h => subsurface-core/statistics.h | 0 strndup.h => subsurface-core/strndup.h | 0 strtod.c => subsurface-core/strtod.c | 0 .../subsurfacestartup.c | 0 .../subsurfacestartup.h | 0 .../subsurfacesysinfo.cpp | 0 .../subsurfacesysinfo.h | 0 taxonomy.c => subsurface-core/taxonomy.c | 0 taxonomy.h => subsurface-core/taxonomy.h | 0 time.c => subsurface-core/time.c | 0 .../uemis-downloader.c | 0 uemis.c => subsurface-core/uemis.c | 0 uemis.h => subsurface-core/uemis.h | 0 units.h => subsurface-core/units.h | 0 version.c => subsurface-core/version.c | 0 version.h => subsurface-core/version.h | 0 webservice.h => subsurface-core/webservice.h | 0 windows.c => subsurface-core/windows.c | 0 .../windowtitleupdate.cpp | 0 .../windowtitleupdate.h | 0 .../worldmap-options.h | 0 .../worldmap-save.c | 0 .../worldmap-save.h | 0 105 files changed, 102 insertions(+), 78 deletions(-) create mode 100644 subsurface-core/CMakeLists.txt rename android.cpp => subsurface-core/android.cpp (100%) rename checkcloudconnection.cpp => subsurface-core/checkcloudconnection.cpp (100%) rename checkcloudconnection.h => subsurface-core/checkcloudconnection.h (100%) rename cochran.c => subsurface-core/cochran.c (100%) rename cochran.h => subsurface-core/cochran.h (100%) rename color.h => subsurface-core/color.h (100%) rename configuredivecomputer.cpp => subsurface-core/configuredivecomputer.cpp (100%) rename configuredivecomputer.h => subsurface-core/configuredivecomputer.h (100%) rename configuredivecomputerthreads.cpp => subsurface-core/configuredivecomputerthreads.cpp (100%) rename configuredivecomputerthreads.h => subsurface-core/configuredivecomputerthreads.h (100%) rename datatrak.c => subsurface-core/datatrak.c (100%) rename datatrak.h => subsurface-core/datatrak.h (100%) rename deco.c => subsurface-core/deco.c (100%) rename deco.h => subsurface-core/deco.h (100%) rename device.c => subsurface-core/device.c (100%) rename device.h => subsurface-core/device.h (100%) rename devicedetails.cpp => subsurface-core/devicedetails.cpp (100%) rename devicedetails.h => subsurface-core/devicedetails.h (100%) rename display.h => subsurface-core/display.h (100%) rename dive.c => subsurface-core/dive.c (100%) rename dive.h => subsurface-core/dive.h (100%) rename divecomputer.cpp => subsurface-core/divecomputer.cpp (100%) rename divecomputer.h => subsurface-core/divecomputer.h (100%) rename divelist.c => subsurface-core/divelist.c (100%) rename divelist.h => subsurface-core/divelist.h (100%) rename divelogexportlogic.cpp => subsurface-core/divelogexportlogic.cpp (100%) rename divelogexportlogic.h => subsurface-core/divelogexportlogic.h (100%) rename divesite.c => subsurface-core/divesite.c (100%) rename divesite.cpp => subsurface-core/divesite.cpp (100%) rename divesite.h => subsurface-core/divesite.h (100%) rename divesitehelpers.cpp => subsurface-core/divesitehelpers.cpp (100%) rename divesitehelpers.h => subsurface-core/divesitehelpers.h (100%) rename equipment.c => subsurface-core/equipment.c (100%) rename exif.cpp => subsurface-core/exif.cpp (100%) rename exif.h => subsurface-core/exif.h (100%) rename file.c => subsurface-core/file.c (100%) rename file.h => subsurface-core/file.h (100%) rename gaspressures.c => subsurface-core/gaspressures.c (100%) rename gaspressures.h => subsurface-core/gaspressures.h (100%) rename gettext.h => subsurface-core/gettext.h (100%) rename gettextfromc.cpp => subsurface-core/gettextfromc.cpp (100%) rename gettextfromc.h => subsurface-core/gettextfromc.h (100%) rename git-access.c => subsurface-core/git-access.c (100%) rename git-access.h => subsurface-core/git-access.h (100%) rename helpers.h => subsurface-core/helpers.h (100%) rename libdivecomputer.c => subsurface-core/libdivecomputer.c (100%) rename libdivecomputer.h => subsurface-core/libdivecomputer.h (100%) rename linux.c => subsurface-core/linux.c (100%) rename liquivision.c => subsurface-core/liquivision.c (100%) rename load-git.c => subsurface-core/load-git.c (100%) rename macos.c => subsurface-core/macos.c (100%) rename membuffer.c => subsurface-core/membuffer.c (100%) rename membuffer.h => subsurface-core/membuffer.h (100%) rename ostctools.c => subsurface-core/ostctools.c (100%) rename parse-xml.c => subsurface-core/parse-xml.c (100%) rename planner.c => subsurface-core/planner.c (100%) rename planner.h => subsurface-core/planner.h (100%) rename pref.h => subsurface-core/pref.h (100%) rename prefs-macros.h => subsurface-core/prefs-macros.h (100%) rename profile.c => subsurface-core/profile.c (100%) rename profile.h => subsurface-core/profile.h (100%) rename qt-gui.h => subsurface-core/qt-gui.h (100%) rename qt-init.cpp => subsurface-core/qt-init.cpp (100%) rename qthelper.cpp => subsurface-core/qthelper.cpp (100%) rename qthelper.h => subsurface-core/qthelper.h (100%) rename qthelperfromc.h => subsurface-core/qthelperfromc.h (100%) rename qtserialbluetooth.cpp => subsurface-core/qtserialbluetooth.cpp (100%) rename save-git.c => subsurface-core/save-git.c (100%) rename save-html.c => subsurface-core/save-html.c (100%) rename save-html.h => subsurface-core/save-html.h (100%) rename save-xml.c => subsurface-core/save-xml.c (100%) rename serial_ftdi.c => subsurface-core/serial_ftdi.c (100%) rename sha1.c => subsurface-core/sha1.c (100%) rename sha1.h => subsurface-core/sha1.h (100%) rename statistics.c => subsurface-core/statistics.c (100%) rename statistics.h => subsurface-core/statistics.h (100%) rename strndup.h => subsurface-core/strndup.h (100%) rename strtod.c => subsurface-core/strtod.c (100%) rename subsurfacestartup.c => subsurface-core/subsurfacestartup.c (100%) rename subsurfacestartup.h => subsurface-core/subsurfacestartup.h (100%) rename subsurfacesysinfo.cpp => subsurface-core/subsurfacesysinfo.cpp (100%) rename subsurfacesysinfo.h => subsurface-core/subsurfacesysinfo.h (100%) rename taxonomy.c => subsurface-core/taxonomy.c (100%) rename taxonomy.h => subsurface-core/taxonomy.h (100%) rename time.c => subsurface-core/time.c (100%) rename uemis-downloader.c => subsurface-core/uemis-downloader.c (100%) rename uemis.c => subsurface-core/uemis.c (100%) rename uemis.h => subsurface-core/uemis.h (100%) rename units.h => subsurface-core/units.h (100%) rename version.c => subsurface-core/version.c (100%) rename version.h => subsurface-core/version.h (100%) rename webservice.h => subsurface-core/webservice.h (100%) rename windows.c => subsurface-core/windows.c (100%) rename windowtitleupdate.cpp => subsurface-core/windowtitleupdate.cpp (100%) rename windowtitleupdate.h => subsurface-core/windowtitleupdate.h (100%) rename worldmap-options.h => subsurface-core/worldmap-options.h (100%) rename worldmap-save.c => subsurface-core/worldmap-save.c (100%) rename worldmap-save.h => subsurface-core/worldmap-save.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba6544210..0a14db6de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,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 @@ -34,6 +40,7 @@ include_directories(. qt-ui qt-models qt-ui/profile + subsurface-core/ ) # get the version string -- this is only used for Mac Bundle at this point @@ -268,19 +275,16 @@ add_custom_target( 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}) @@ -299,7 +303,6 @@ 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) @@ -307,68 +310,7 @@ endif() # 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) if(FBSUPPORT) add_definitions(-DFBSUPPORT) @@ -406,12 +348,9 @@ source_group("Subsurface Models" FILES ${SUBSURFACE_MODELS}) set(SUBSURFACE_APP main.cpp qt-gui.cpp - qthelper.cpp ) source_group("Subsurface App" FILES ${SUBSURFACE_APP}) -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}) @@ -483,7 +422,7 @@ 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 @@ -495,7 +434,7 @@ macro(TEST NAME FILE) 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() 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/CMakeLists.txt b/qt-ui/CMakeLists.txt index 9def39ff3..a860faed5 100644 --- a/qt-ui/CMakeLists.txt +++ b/qt-ui/CMakeLists.txt @@ -4,6 +4,10 @@ qt5_wrap_ui(SUBSURFACE_UI_HDRS ${SUBSURFACE_UI}) qt5_add_resources(SUBSURFACE_RESOURCES subsurface.qrc) source_group("Subsurface Interface Files" FILES ${SUBSURFACE_UI}) +if(BTSUPPORT) + set(BT_SRC_FILES btdeviceselectiondialog.cpp) +endif() + # the interface, in C++ set(SUBSURFACE_INTERFACE updatemanager.cpp diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index be76644a9..9ad30ac67 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -4,7 +4,7 @@ #include #include #include "ui_configuredivecomputerdialog.h" -#include "../libdivecomputer.h" +#include "subsurface-core/libdivecomputer.h" #include "configuredivecomputer.h" #include #include diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h index 03bb14029..2d12c7cac 100644 --- a/qt-ui/divelogimportdialog.h +++ b/qt-ui/divelogimportdialog.h @@ -9,8 +9,8 @@ #include #include -#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/graphicsview-common.h b/qt-ui/graphicsview-common.h index 3c1cb75a0..2a757b2ae 100644 --- a/qt-ui/graphicsview-common.h +++ b/qt-ui/graphicsview-common.h @@ -1,7 +1,7 @@ #ifndef GRAPHICSVIEW_COMMON_H #define GRAPHICSVIEW_COMMON_H -#include "../color.h" +#include "subsurface-core/color.h" #include #include #include diff --git a/subsurface-core/CMakeLists.txt b/subsurface-core/CMakeLists.txt new file mode 100644 index 000000000..e7f531527 --- /dev/null +++ b/subsurface-core/CMakeLists.txt @@ -0,0 +1,81 @@ +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 + ${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 similarity index 100% rename from android.cpp rename to subsurface-core/android.cpp diff --git a/checkcloudconnection.cpp b/subsurface-core/checkcloudconnection.cpp similarity index 100% rename from checkcloudconnection.cpp rename to subsurface-core/checkcloudconnection.cpp diff --git a/checkcloudconnection.h b/subsurface-core/checkcloudconnection.h similarity index 100% rename from checkcloudconnection.h rename to subsurface-core/checkcloudconnection.h diff --git a/cochran.c b/subsurface-core/cochran.c similarity index 100% rename from cochran.c rename to subsurface-core/cochran.c diff --git a/cochran.h b/subsurface-core/cochran.h similarity index 100% rename from cochran.h rename to subsurface-core/cochran.h diff --git a/color.h b/subsurface-core/color.h similarity index 100% rename from color.h rename to subsurface-core/color.h diff --git a/configuredivecomputer.cpp b/subsurface-core/configuredivecomputer.cpp similarity index 100% rename from configuredivecomputer.cpp rename to subsurface-core/configuredivecomputer.cpp diff --git a/configuredivecomputer.h b/subsurface-core/configuredivecomputer.h similarity index 100% rename from configuredivecomputer.h rename to subsurface-core/configuredivecomputer.h diff --git a/configuredivecomputerthreads.cpp b/subsurface-core/configuredivecomputerthreads.cpp similarity index 100% rename from configuredivecomputerthreads.cpp rename to subsurface-core/configuredivecomputerthreads.cpp diff --git a/configuredivecomputerthreads.h b/subsurface-core/configuredivecomputerthreads.h similarity index 100% rename from configuredivecomputerthreads.h rename to subsurface-core/configuredivecomputerthreads.h diff --git a/datatrak.c b/subsurface-core/datatrak.c similarity index 100% rename from datatrak.c rename to subsurface-core/datatrak.c diff --git a/datatrak.h b/subsurface-core/datatrak.h similarity index 100% rename from datatrak.h rename to subsurface-core/datatrak.h diff --git a/deco.c b/subsurface-core/deco.c similarity index 100% rename from deco.c rename to subsurface-core/deco.c diff --git a/deco.h b/subsurface-core/deco.h similarity index 100% rename from deco.h rename to subsurface-core/deco.h diff --git a/device.c b/subsurface-core/device.c similarity index 100% rename from device.c rename to subsurface-core/device.c diff --git a/device.h b/subsurface-core/device.h similarity index 100% rename from device.h rename to subsurface-core/device.h diff --git a/devicedetails.cpp b/subsurface-core/devicedetails.cpp similarity index 100% rename from devicedetails.cpp rename to subsurface-core/devicedetails.cpp diff --git a/devicedetails.h b/subsurface-core/devicedetails.h similarity index 100% rename from devicedetails.h rename to subsurface-core/devicedetails.h diff --git a/display.h b/subsurface-core/display.h similarity index 100% rename from display.h rename to subsurface-core/display.h diff --git a/dive.c b/subsurface-core/dive.c similarity index 100% rename from dive.c rename to subsurface-core/dive.c diff --git a/dive.h b/subsurface-core/dive.h similarity index 100% rename from dive.h rename to subsurface-core/dive.h diff --git a/divecomputer.cpp b/subsurface-core/divecomputer.cpp similarity index 100% rename from divecomputer.cpp rename to subsurface-core/divecomputer.cpp diff --git a/divecomputer.h b/subsurface-core/divecomputer.h similarity index 100% rename from divecomputer.h rename to subsurface-core/divecomputer.h diff --git a/divelist.c b/subsurface-core/divelist.c similarity index 100% rename from divelist.c rename to subsurface-core/divelist.c diff --git a/divelist.h b/subsurface-core/divelist.h similarity index 100% rename from divelist.h rename to subsurface-core/divelist.h diff --git a/divelogexportlogic.cpp b/subsurface-core/divelogexportlogic.cpp similarity index 100% rename from divelogexportlogic.cpp rename to subsurface-core/divelogexportlogic.cpp diff --git a/divelogexportlogic.h b/subsurface-core/divelogexportlogic.h similarity index 100% rename from divelogexportlogic.h rename to subsurface-core/divelogexportlogic.h diff --git a/divesite.c b/subsurface-core/divesite.c similarity index 100% rename from divesite.c rename to subsurface-core/divesite.c diff --git a/divesite.cpp b/subsurface-core/divesite.cpp similarity index 100% rename from divesite.cpp rename to subsurface-core/divesite.cpp diff --git a/divesite.h b/subsurface-core/divesite.h similarity index 100% rename from divesite.h rename to subsurface-core/divesite.h diff --git a/divesitehelpers.cpp b/subsurface-core/divesitehelpers.cpp similarity index 100% rename from divesitehelpers.cpp rename to subsurface-core/divesitehelpers.cpp diff --git a/divesitehelpers.h b/subsurface-core/divesitehelpers.h similarity index 100% rename from divesitehelpers.h rename to subsurface-core/divesitehelpers.h diff --git a/equipment.c b/subsurface-core/equipment.c similarity index 100% rename from equipment.c rename to subsurface-core/equipment.c diff --git a/exif.cpp b/subsurface-core/exif.cpp similarity index 100% rename from exif.cpp rename to subsurface-core/exif.cpp diff --git a/exif.h b/subsurface-core/exif.h similarity index 100% rename from exif.h rename to subsurface-core/exif.h diff --git a/file.c b/subsurface-core/file.c similarity index 100% rename from file.c rename to subsurface-core/file.c diff --git a/file.h b/subsurface-core/file.h similarity index 100% rename from file.h rename to subsurface-core/file.h diff --git a/gaspressures.c b/subsurface-core/gaspressures.c similarity index 100% rename from gaspressures.c rename to subsurface-core/gaspressures.c diff --git a/gaspressures.h b/subsurface-core/gaspressures.h similarity index 100% rename from gaspressures.h rename to subsurface-core/gaspressures.h diff --git a/gettext.h b/subsurface-core/gettext.h similarity index 100% rename from gettext.h rename to subsurface-core/gettext.h diff --git a/gettextfromc.cpp b/subsurface-core/gettextfromc.cpp similarity index 100% rename from gettextfromc.cpp rename to subsurface-core/gettextfromc.cpp diff --git a/gettextfromc.h b/subsurface-core/gettextfromc.h similarity index 100% rename from gettextfromc.h rename to subsurface-core/gettextfromc.h diff --git a/git-access.c b/subsurface-core/git-access.c similarity index 100% rename from git-access.c rename to subsurface-core/git-access.c diff --git a/git-access.h b/subsurface-core/git-access.h similarity index 100% rename from git-access.h rename to subsurface-core/git-access.h diff --git a/helpers.h b/subsurface-core/helpers.h similarity index 100% rename from helpers.h rename to subsurface-core/helpers.h diff --git a/libdivecomputer.c b/subsurface-core/libdivecomputer.c similarity index 100% rename from libdivecomputer.c rename to subsurface-core/libdivecomputer.c diff --git a/libdivecomputer.h b/subsurface-core/libdivecomputer.h similarity index 100% rename from libdivecomputer.h rename to subsurface-core/libdivecomputer.h diff --git a/linux.c b/subsurface-core/linux.c similarity index 100% rename from linux.c rename to subsurface-core/linux.c diff --git a/liquivision.c b/subsurface-core/liquivision.c similarity index 100% rename from liquivision.c rename to subsurface-core/liquivision.c diff --git a/load-git.c b/subsurface-core/load-git.c similarity index 100% rename from load-git.c rename to subsurface-core/load-git.c diff --git a/macos.c b/subsurface-core/macos.c similarity index 100% rename from macos.c rename to subsurface-core/macos.c diff --git a/membuffer.c b/subsurface-core/membuffer.c similarity index 100% rename from membuffer.c rename to subsurface-core/membuffer.c diff --git a/membuffer.h b/subsurface-core/membuffer.h similarity index 100% rename from membuffer.h rename to subsurface-core/membuffer.h diff --git a/ostctools.c b/subsurface-core/ostctools.c similarity index 100% rename from ostctools.c rename to subsurface-core/ostctools.c diff --git a/parse-xml.c b/subsurface-core/parse-xml.c similarity index 100% rename from parse-xml.c rename to subsurface-core/parse-xml.c diff --git a/planner.c b/subsurface-core/planner.c similarity index 100% rename from planner.c rename to subsurface-core/planner.c diff --git a/planner.h b/subsurface-core/planner.h similarity index 100% rename from planner.h rename to subsurface-core/planner.h diff --git a/pref.h b/subsurface-core/pref.h similarity index 100% rename from pref.h rename to subsurface-core/pref.h diff --git a/prefs-macros.h b/subsurface-core/prefs-macros.h similarity index 100% rename from prefs-macros.h rename to subsurface-core/prefs-macros.h diff --git a/profile.c b/subsurface-core/profile.c similarity index 100% rename from profile.c rename to subsurface-core/profile.c diff --git a/profile.h b/subsurface-core/profile.h similarity index 100% rename from profile.h rename to subsurface-core/profile.h diff --git a/qt-gui.h b/subsurface-core/qt-gui.h similarity index 100% rename from qt-gui.h rename to subsurface-core/qt-gui.h diff --git a/qt-init.cpp b/subsurface-core/qt-init.cpp similarity index 100% rename from qt-init.cpp rename to subsurface-core/qt-init.cpp diff --git a/qthelper.cpp b/subsurface-core/qthelper.cpp similarity index 100% rename from qthelper.cpp rename to subsurface-core/qthelper.cpp diff --git a/qthelper.h b/subsurface-core/qthelper.h similarity index 100% rename from qthelper.h rename to subsurface-core/qthelper.h diff --git a/qthelperfromc.h b/subsurface-core/qthelperfromc.h similarity index 100% rename from qthelperfromc.h rename to subsurface-core/qthelperfromc.h diff --git a/qtserialbluetooth.cpp b/subsurface-core/qtserialbluetooth.cpp similarity index 100% rename from qtserialbluetooth.cpp rename to subsurface-core/qtserialbluetooth.cpp diff --git a/save-git.c b/subsurface-core/save-git.c similarity index 100% rename from save-git.c rename to subsurface-core/save-git.c diff --git a/save-html.c b/subsurface-core/save-html.c similarity index 100% rename from save-html.c rename to subsurface-core/save-html.c diff --git a/save-html.h b/subsurface-core/save-html.h similarity index 100% rename from save-html.h rename to subsurface-core/save-html.h diff --git a/save-xml.c b/subsurface-core/save-xml.c similarity index 100% rename from save-xml.c rename to subsurface-core/save-xml.c diff --git a/serial_ftdi.c b/subsurface-core/serial_ftdi.c similarity index 100% rename from serial_ftdi.c rename to subsurface-core/serial_ftdi.c diff --git a/sha1.c b/subsurface-core/sha1.c similarity index 100% rename from sha1.c rename to subsurface-core/sha1.c diff --git a/sha1.h b/subsurface-core/sha1.h similarity index 100% rename from sha1.h rename to subsurface-core/sha1.h diff --git a/statistics.c b/subsurface-core/statistics.c similarity index 100% rename from statistics.c rename to subsurface-core/statistics.c diff --git a/statistics.h b/subsurface-core/statistics.h similarity index 100% rename from statistics.h rename to subsurface-core/statistics.h diff --git a/strndup.h b/subsurface-core/strndup.h similarity index 100% rename from strndup.h rename to subsurface-core/strndup.h diff --git a/strtod.c b/subsurface-core/strtod.c similarity index 100% rename from strtod.c rename to subsurface-core/strtod.c diff --git a/subsurfacestartup.c b/subsurface-core/subsurfacestartup.c similarity index 100% rename from subsurfacestartup.c rename to subsurface-core/subsurfacestartup.c diff --git a/subsurfacestartup.h b/subsurface-core/subsurfacestartup.h similarity index 100% rename from subsurfacestartup.h rename to subsurface-core/subsurfacestartup.h diff --git a/subsurfacesysinfo.cpp b/subsurface-core/subsurfacesysinfo.cpp similarity index 100% rename from subsurfacesysinfo.cpp rename to subsurface-core/subsurfacesysinfo.cpp diff --git a/subsurfacesysinfo.h b/subsurface-core/subsurfacesysinfo.h similarity index 100% rename from subsurfacesysinfo.h rename to subsurface-core/subsurfacesysinfo.h diff --git a/taxonomy.c b/subsurface-core/taxonomy.c similarity index 100% rename from taxonomy.c rename to subsurface-core/taxonomy.c diff --git a/taxonomy.h b/subsurface-core/taxonomy.h similarity index 100% rename from taxonomy.h rename to subsurface-core/taxonomy.h diff --git a/time.c b/subsurface-core/time.c similarity index 100% rename from time.c rename to subsurface-core/time.c diff --git a/uemis-downloader.c b/subsurface-core/uemis-downloader.c similarity index 100% rename from uemis-downloader.c rename to subsurface-core/uemis-downloader.c diff --git a/uemis.c b/subsurface-core/uemis.c similarity index 100% rename from uemis.c rename to subsurface-core/uemis.c diff --git a/uemis.h b/subsurface-core/uemis.h similarity index 100% rename from uemis.h rename to subsurface-core/uemis.h diff --git a/units.h b/subsurface-core/units.h similarity index 100% rename from units.h rename to subsurface-core/units.h diff --git a/version.c b/subsurface-core/version.c similarity index 100% rename from version.c rename to subsurface-core/version.c diff --git a/version.h b/subsurface-core/version.h similarity index 100% rename from version.h rename to subsurface-core/version.h diff --git a/webservice.h b/subsurface-core/webservice.h similarity index 100% rename from webservice.h rename to subsurface-core/webservice.h diff --git a/windows.c b/subsurface-core/windows.c similarity index 100% rename from windows.c rename to subsurface-core/windows.c diff --git a/windowtitleupdate.cpp b/subsurface-core/windowtitleupdate.cpp similarity index 100% rename from windowtitleupdate.cpp rename to subsurface-core/windowtitleupdate.cpp diff --git a/windowtitleupdate.h b/subsurface-core/windowtitleupdate.h similarity index 100% rename from windowtitleupdate.h rename to subsurface-core/windowtitleupdate.h diff --git a/worldmap-options.h b/subsurface-core/worldmap-options.h similarity index 100% rename from worldmap-options.h rename to subsurface-core/worldmap-options.h diff --git a/worldmap-save.c b/subsurface-core/worldmap-save.c similarity index 100% rename from worldmap-save.c rename to subsurface-core/worldmap-save.c diff --git a/worldmap-save.h b/subsurface-core/worldmap-save.h similarity index 100% rename from worldmap-save.h rename to subsurface-core/worldmap-save.h From 6cd711a11b1a2d9484eb05915de0bd5dc60907b2 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 2 Sep 2015 21:22:29 -0300 Subject: [PATCH 03/48] Modify code to make it compile after rebase Did a git rebase and some stuff changed in the meantime; This is a compatibility commit: Add a few include directories on the cmake to quiet some ui_headers.h not being found (the ones that are created automatically by uic) and a few noiseances like models requiring interface functionality. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 1 + qt-models/completionmodels.cpp | 3 ++- qt-models/filtermodels.cpp | 11 +++++++++-- qt-ui/CMakeLists.txt | 5 +++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a14db6de..f1c143b36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ set(CMAKE_MODULE_PATH include_directories(. ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/qt-ui qt-ui qt-models qt-ui/profile 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 +#include #define CREATE_UPDATE_METHOD(Class, diveStructMember) \ void Class::updateModel() \ diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 80ed0cfd5..29853cb3d 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -1,5 +1,4 @@ #include "filtermodels.h" -#include "mainwindow.h" #include "models.h" #include "divelistview.h" #include "display.h" @@ -355,9 +354,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 +401,7 @@ void MultiFilterSortModel::myInvalidate() if (curr_dive_site) { dlv->expandAll(); } +#endif } void MultiFilterSortModel::addFilterModel(MultiFilterInterface *model) diff --git a/qt-ui/CMakeLists.txt b/qt-ui/CMakeLists.txt index a860faed5..45447771a 100644 --- a/qt-ui/CMakeLists.txt +++ b/qt-ui/CMakeLists.txt @@ -8,6 +8,11 @@ if(BTSUPPORT) set(BT_SRC_FILES btdeviceselectiondialog.cpp) endif() +include_directories(. + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} +) + # the interface, in C++ set(SUBSURFACE_INTERFACE updatemanager.cpp From 588abd019fb2ed3f607682f2b6c7fe86a7a5bb90 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 3 Sep 2015 13:35:11 -0300 Subject: [PATCH 04/48] Move the icons to the icons folder There was no reason at all to keep those icons on the root folder. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 2 +- satellite.svg => icons/satellite.svg | 0 subsurface-icon.svg => icons/subsurface-icon.svg | 0 subsurface-mobile-icon.svg => icons/subsurface-mobile-icon.svg | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename satellite.svg => icons/satellite.svg (100%) rename subsurface-icon.svg => icons/subsurface-icon.svg (100%) rename subsurface-mobile-icon.svg => icons/subsurface-mobile-icon.svg (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1c143b36..7e4e5f53d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -659,7 +659,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) diff --git a/satellite.svg b/icons/satellite.svg similarity index 100% rename from satellite.svg rename to icons/satellite.svg diff --git a/subsurface-icon.svg b/icons/subsurface-icon.svg similarity index 100% rename from subsurface-icon.svg rename to icons/subsurface-icon.svg diff --git a/subsurface-mobile-icon.svg b/icons/subsurface-mobile-icon.svg similarity index 100% rename from subsurface-mobile-icon.svg rename to icons/subsurface-mobile-icon.svg From e49d6213ad129284a45d53c3fcdc03249e84efe2 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 3 Sep 2015 14:20:19 -0300 Subject: [PATCH 05/48] Move qt-ui to desktop-widgets Since we have now destkop and mobile versions, 'qt-ui' was a very poor name choice for a folder that contains only destkop-enabled widgets. Also, move the graphicsview-common.h/cpp to subsurface-core because it doesn't depend on qgraphicsview, it merely implements all the colors that we use throughout Subsurface, and we will use colors on both desktop and mobile versions Same thing applies for metrics.h/cpp Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 8 +- {qt-ui => desktop-widgets}/CMakeLists.txt | 2 - {qt-ui => desktop-widgets}/about.cpp | 0 {qt-ui => desktop-widgets}/about.h | 0 {qt-ui => desktop-widgets}/about.ui | 0 .../btdeviceselectiondialog.cpp | 0 .../btdeviceselectiondialog.h | 0 .../btdeviceselectiondialog.ui | 0 .../configuredivecomputerdialog.cpp | 0 .../configuredivecomputerdialog.h | 0 .../configuredivecomputerdialog.ui | 0 {qt-ui => desktop-widgets}/css/tableviews.css | 0 .../divecomponentselection.ui | 0 .../divecomputermanagementdialog.cpp | 0 .../divecomputermanagementdialog.h | 0 .../divecomputermanagementdialog.ui | 0 {qt-ui => desktop-widgets}/divelistview.cpp | 0 {qt-ui => desktop-widgets}/divelistview.h | 0 .../divelogexportdialog.cpp | 0 .../divelogexportdialog.h | 0 .../divelogexportdialog.ui | 0 .../divelogimportdialog.cpp | 0 .../divelogimportdialog.h | 0 .../divelogimportdialog.ui | 0 .../divepicturewidget.cpp | 0 .../divepicturewidget.h | 0 {qt-ui => desktop-widgets}/diveplanner.cpp | 0 {qt-ui => desktop-widgets}/diveplanner.h | 0 {qt-ui => desktop-widgets}/diveplanner.ui | 0 .../diveshareexportdialog.cpp | 0 .../diveshareexportdialog.h | 0 .../diveshareexportdialog.ui | 0 .../downloadfromdivecomputer.cpp | 0 .../downloadfromdivecomputer.h | 0 .../downloadfromdivecomputer.ui | 0 {qt-ui => desktop-widgets}/filterwidget.ui | 0 {qt-ui => desktop-widgets}/globe.cpp | 0 {qt-ui => desktop-widgets}/globe.h | 0 .../groupedlineedit.cpp | 0 {qt-ui => desktop-widgets}/groupedlineedit.h | 0 {qt-ui => desktop-widgets}/kmessagewidget.cpp | 0 {qt-ui => desktop-widgets}/kmessagewidget.h | 0 {qt-ui => desktop-widgets}/listfilter.ui | 0 .../locationInformation.ui | 0 .../locationinformation.cpp | 0 .../locationinformation.h | 0 {qt-ui => desktop-widgets}/maintab.cpp | 0 {qt-ui => desktop-widgets}/maintab.h | 0 {qt-ui => desktop-widgets}/maintab.ui | 6 +- {qt-ui => desktop-widgets}/mainwindow.cpp | 1 + {qt-ui => desktop-widgets}/mainwindow.h | 0 {qt-ui => desktop-widgets}/mainwindow.ui | 0 .../marble/GeoDataTreeModel.h | 0 {qt-ui => desktop-widgets}/modeldelegates.cpp | 0 {qt-ui => desktop-widgets}/modeldelegates.h | 0 .../notificationwidget.cpp | 0 .../notificationwidget.h | 0 {qt-ui => desktop-widgets}/plannerDetails.ui | 0 {qt-ui => desktop-widgets}/plannerSettings.ui | 0 {qt-ui => desktop-widgets}/preferences.cpp | 0 {qt-ui => desktop-widgets}/preferences.h | 0 {qt-ui => desktop-widgets}/preferences.ui | 0 {qt-ui => desktop-widgets}/printdialog.cpp | 0 {qt-ui => desktop-widgets}/printdialog.h | 0 {qt-ui => desktop-widgets}/printer.cpp | 0 {qt-ui => desktop-widgets}/printer.h | 0 {qt-ui => desktop-widgets}/printoptions.cpp | 0 {qt-ui => desktop-widgets}/printoptions.h | 0 {qt-ui => desktop-widgets}/printoptions.ui | 0 .../profile/animationfunctions.cpp | 0 .../profile/animationfunctions.h | 0 .../profile/divecartesianaxis.cpp | 0 .../profile/divecartesianaxis.h | 2 +- .../profile/diveeventitem.cpp | 0 .../profile/diveeventitem.h | 0 .../profile/divelineitem.cpp | 0 .../profile/divelineitem.h | 0 .../profile/divepixmapitem.cpp | 0 .../profile/divepixmapitem.h | 0 .../profile/diveprofileitem.cpp | 0 .../profile/diveprofileitem.h | 1 - .../profile/diverectitem.cpp | 0 .../profile/diverectitem.h | 0 .../profile/divetextitem.cpp | 3 + .../profile/divetextitem.h | 4 +- .../profile/divetooltipitem.cpp | 0 .../profile/divetooltipitem.h | 0 .../profile/profilewidget2.cpp | 0 .../profile/profilewidget2.h | 1 - .../profile/ruleritem.cpp | 0 .../profile/ruleritem.h | 0 .../profile/tankitem.cpp | 0 {qt-ui => desktop-widgets}/profile/tankitem.h | 0 .../qtwaitingspinner.cpp | 0 {qt-ui => desktop-widgets}/qtwaitingspinner.h | 0 {qt-ui => desktop-widgets}/renumber.ui | 0 {qt-ui => desktop-widgets}/searchbar.ui | 0 {qt-ui => desktop-widgets}/setpoint.ui | 0 {qt-ui => desktop-widgets}/shiftimagetimes.ui | 0 {qt-ui => desktop-widgets}/shifttimes.ui | 0 {qt-ui => desktop-widgets}/simplewidgets.cpp | 0 {qt-ui => desktop-widgets}/simplewidgets.h | 0 {qt-ui => desktop-widgets}/socialnetworks.cpp | 0 {qt-ui => desktop-widgets}/socialnetworks.h | 0 .../socialnetworksdialog.ui | 0 {qt-ui => desktop-widgets}/starwidget.cpp | 0 {qt-ui => desktop-widgets}/starwidget.h | 0 .../statistics/monthstatistics.cpp | 0 .../statistics/monthstatistics.h | 0 .../statistics/statisticsbar.cpp | 0 .../statistics/statisticsbar.h | 0 .../statistics/statisticswidget.cpp | 0 .../statistics/statisticswidget.h | 0 .../statistics/yearstatistics.cpp | 0 .../statistics/yearstatistics.h | 0 .../subsurfacewebservices.cpp | 0 .../subsurfacewebservices.h | 0 {qt-ui => desktop-widgets}/tableview.cpp | 0 {qt-ui => desktop-widgets}/tableview.h | 0 {qt-ui => desktop-widgets}/tableview.ui | 0 {qt-ui => desktop-widgets}/tagwidget.cpp | 0 {qt-ui => desktop-widgets}/tagwidget.h | 0 {qt-ui => desktop-widgets}/templateedit.cpp | 0 {qt-ui => desktop-widgets}/templateedit.h | 0 {qt-ui => desktop-widgets}/templateedit.ui | 0 {qt-ui => desktop-widgets}/templatelayout.cpp | 0 {qt-ui => desktop-widgets}/templatelayout.h | 0 {qt-ui => desktop-widgets}/undocommands.cpp | 0 {qt-ui => desktop-widgets}/undocommands.h | 0 {qt-ui => desktop-widgets}/updatemanager.cpp | 0 {qt-ui => desktop-widgets}/updatemanager.h | 0 {qt-ui => desktop-widgets}/urldialog.ui | 0 {qt-ui => desktop-widgets}/usermanual.cpp | 0 {qt-ui => desktop-widgets}/usermanual.h | 0 {qt-ui => desktop-widgets}/usersurvey.cpp | 0 {qt-ui => desktop-widgets}/usersurvey.h | 0 {qt-ui => desktop-widgets}/usersurvey.ui | 0 {qt-ui => desktop-widgets}/webservices.ui | 0 main.cpp | 6 +- qt-gui.cpp | 2 +- qt-models/diveplotdatamodel.cpp | 2 +- qt-models/filtermodels.cpp | 4 +- qt-ui/graphicsview-common.h | 94 ------------------- subsurface-core/CMakeLists.txt | 2 + .../color.cpp | 2 +- subsurface-core/color.h | 85 +++++++++++++++++ {qt-ui => subsurface-core}/metrics.cpp | 0 {qt-ui => subsurface-core}/metrics.h | 0 148 files changed, 110 insertions(+), 115 deletions(-) rename {qt-ui => desktop-widgets}/CMakeLists.txt (98%) rename {qt-ui => desktop-widgets}/about.cpp (100%) rename {qt-ui => desktop-widgets}/about.h (100%) rename {qt-ui => desktop-widgets}/about.ui (100%) rename {qt-ui => desktop-widgets}/btdeviceselectiondialog.cpp (100%) rename {qt-ui => desktop-widgets}/btdeviceselectiondialog.h (100%) rename {qt-ui => desktop-widgets}/btdeviceselectiondialog.ui (100%) rename {qt-ui => desktop-widgets}/configuredivecomputerdialog.cpp (100%) rename {qt-ui => desktop-widgets}/configuredivecomputerdialog.h (100%) rename {qt-ui => desktop-widgets}/configuredivecomputerdialog.ui (100%) rename {qt-ui => desktop-widgets}/css/tableviews.css (100%) rename {qt-ui => desktop-widgets}/divecomponentselection.ui (100%) rename {qt-ui => desktop-widgets}/divecomputermanagementdialog.cpp (100%) rename {qt-ui => desktop-widgets}/divecomputermanagementdialog.h (100%) rename {qt-ui => desktop-widgets}/divecomputermanagementdialog.ui (100%) rename {qt-ui => desktop-widgets}/divelistview.cpp (100%) rename {qt-ui => desktop-widgets}/divelistview.h (100%) rename {qt-ui => desktop-widgets}/divelogexportdialog.cpp (100%) rename {qt-ui => desktop-widgets}/divelogexportdialog.h (100%) rename {qt-ui => desktop-widgets}/divelogexportdialog.ui (100%) rename {qt-ui => desktop-widgets}/divelogimportdialog.cpp (100%) rename {qt-ui => desktop-widgets}/divelogimportdialog.h (100%) rename {qt-ui => desktop-widgets}/divelogimportdialog.ui (100%) rename {qt-ui => desktop-widgets}/divepicturewidget.cpp (100%) rename {qt-ui => desktop-widgets}/divepicturewidget.h (100%) rename {qt-ui => desktop-widgets}/diveplanner.cpp (100%) rename {qt-ui => desktop-widgets}/diveplanner.h (100%) rename {qt-ui => desktop-widgets}/diveplanner.ui (100%) rename {qt-ui => desktop-widgets}/diveshareexportdialog.cpp (100%) rename {qt-ui => desktop-widgets}/diveshareexportdialog.h (100%) rename {qt-ui => desktop-widgets}/diveshareexportdialog.ui (100%) rename {qt-ui => desktop-widgets}/downloadfromdivecomputer.cpp (100%) rename {qt-ui => desktop-widgets}/downloadfromdivecomputer.h (100%) rename {qt-ui => desktop-widgets}/downloadfromdivecomputer.ui (100%) rename {qt-ui => desktop-widgets}/filterwidget.ui (100%) rename {qt-ui => desktop-widgets}/globe.cpp (100%) rename {qt-ui => desktop-widgets}/globe.h (100%) rename {qt-ui => desktop-widgets}/groupedlineedit.cpp (100%) rename {qt-ui => desktop-widgets}/groupedlineedit.h (100%) rename {qt-ui => desktop-widgets}/kmessagewidget.cpp (100%) rename {qt-ui => desktop-widgets}/kmessagewidget.h (100%) rename {qt-ui => desktop-widgets}/listfilter.ui (100%) rename {qt-ui => desktop-widgets}/locationInformation.ui (100%) rename {qt-ui => desktop-widgets}/locationinformation.cpp (100%) rename {qt-ui => desktop-widgets}/locationinformation.h (100%) rename {qt-ui => desktop-widgets}/maintab.cpp (100%) rename {qt-ui => desktop-widgets}/maintab.h (100%) rename {qt-ui => desktop-widgets}/maintab.ui (99%) rename {qt-ui => desktop-widgets}/mainwindow.cpp (99%) rename {qt-ui => desktop-widgets}/mainwindow.h (100%) rename {qt-ui => desktop-widgets}/mainwindow.ui (100%) rename {qt-ui => desktop-widgets}/marble/GeoDataTreeModel.h (100%) rename {qt-ui => desktop-widgets}/modeldelegates.cpp (100%) rename {qt-ui => desktop-widgets}/modeldelegates.h (100%) rename {qt-ui => desktop-widgets}/notificationwidget.cpp (100%) rename {qt-ui => desktop-widgets}/notificationwidget.h (100%) rename {qt-ui => desktop-widgets}/plannerDetails.ui (100%) rename {qt-ui => desktop-widgets}/plannerSettings.ui (100%) rename {qt-ui => desktop-widgets}/preferences.cpp (100%) rename {qt-ui => desktop-widgets}/preferences.h (100%) rename {qt-ui => desktop-widgets}/preferences.ui (100%) rename {qt-ui => desktop-widgets}/printdialog.cpp (100%) rename {qt-ui => desktop-widgets}/printdialog.h (100%) rename {qt-ui => desktop-widgets}/printer.cpp (100%) rename {qt-ui => desktop-widgets}/printer.h (100%) rename {qt-ui => desktop-widgets}/printoptions.cpp (100%) rename {qt-ui => desktop-widgets}/printoptions.h (100%) rename {qt-ui => desktop-widgets}/printoptions.ui (100%) rename {qt-ui => desktop-widgets}/profile/animationfunctions.cpp (100%) rename {qt-ui => desktop-widgets}/profile/animationfunctions.h (100%) rename {qt-ui => desktop-widgets}/profile/divecartesianaxis.cpp (100%) rename {qt-ui => desktop-widgets}/profile/divecartesianaxis.h (98%) rename {qt-ui => desktop-widgets}/profile/diveeventitem.cpp (100%) rename {qt-ui => desktop-widgets}/profile/diveeventitem.h (100%) rename {qt-ui => desktop-widgets}/profile/divelineitem.cpp (100%) rename {qt-ui => desktop-widgets}/profile/divelineitem.h (100%) rename {qt-ui => desktop-widgets}/profile/divepixmapitem.cpp (100%) rename {qt-ui => desktop-widgets}/profile/divepixmapitem.h (100%) rename {qt-ui => desktop-widgets}/profile/diveprofileitem.cpp (100%) rename {qt-ui => desktop-widgets}/profile/diveprofileitem.h (99%) rename {qt-ui => desktop-widgets}/profile/diverectitem.cpp (100%) rename {qt-ui => desktop-widgets}/profile/diverectitem.h (100%) rename {qt-ui => desktop-widgets}/profile/divetextitem.cpp (98%) rename {qt-ui => desktop-widgets}/profile/divetextitem.h (94%) rename {qt-ui => desktop-widgets}/profile/divetooltipitem.cpp (100%) rename {qt-ui => desktop-widgets}/profile/divetooltipitem.h (100%) rename {qt-ui => desktop-widgets}/profile/profilewidget2.cpp (100%) rename {qt-ui => desktop-widgets}/profile/profilewidget2.h (99%) rename {qt-ui => desktop-widgets}/profile/ruleritem.cpp (100%) rename {qt-ui => desktop-widgets}/profile/ruleritem.h (100%) rename {qt-ui => desktop-widgets}/profile/tankitem.cpp (100%) rename {qt-ui => desktop-widgets}/profile/tankitem.h (100%) rename {qt-ui => desktop-widgets}/qtwaitingspinner.cpp (100%) rename {qt-ui => desktop-widgets}/qtwaitingspinner.h (100%) rename {qt-ui => desktop-widgets}/renumber.ui (100%) rename {qt-ui => desktop-widgets}/searchbar.ui (100%) rename {qt-ui => desktop-widgets}/setpoint.ui (100%) rename {qt-ui => desktop-widgets}/shiftimagetimes.ui (100%) rename {qt-ui => desktop-widgets}/shifttimes.ui (100%) rename {qt-ui => desktop-widgets}/simplewidgets.cpp (100%) rename {qt-ui => desktop-widgets}/simplewidgets.h (100%) rename {qt-ui => desktop-widgets}/socialnetworks.cpp (100%) rename {qt-ui => desktop-widgets}/socialnetworks.h (100%) rename {qt-ui => desktop-widgets}/socialnetworksdialog.ui (100%) rename {qt-ui => desktop-widgets}/starwidget.cpp (100%) rename {qt-ui => desktop-widgets}/starwidget.h (100%) rename {qt-ui => desktop-widgets}/statistics/monthstatistics.cpp (100%) rename {qt-ui => desktop-widgets}/statistics/monthstatistics.h (100%) rename {qt-ui => desktop-widgets}/statistics/statisticsbar.cpp (100%) rename {qt-ui => desktop-widgets}/statistics/statisticsbar.h (100%) rename {qt-ui => desktop-widgets}/statistics/statisticswidget.cpp (100%) rename {qt-ui => desktop-widgets}/statistics/statisticswidget.h (100%) rename {qt-ui => desktop-widgets}/statistics/yearstatistics.cpp (100%) rename {qt-ui => desktop-widgets}/statistics/yearstatistics.h (100%) rename {qt-ui => desktop-widgets}/subsurfacewebservices.cpp (100%) rename {qt-ui => desktop-widgets}/subsurfacewebservices.h (100%) rename {qt-ui => desktop-widgets}/tableview.cpp (100%) rename {qt-ui => desktop-widgets}/tableview.h (100%) rename {qt-ui => desktop-widgets}/tableview.ui (100%) rename {qt-ui => desktop-widgets}/tagwidget.cpp (100%) rename {qt-ui => desktop-widgets}/tagwidget.h (100%) rename {qt-ui => desktop-widgets}/templateedit.cpp (100%) rename {qt-ui => desktop-widgets}/templateedit.h (100%) rename {qt-ui => desktop-widgets}/templateedit.ui (100%) rename {qt-ui => desktop-widgets}/templatelayout.cpp (100%) rename {qt-ui => desktop-widgets}/templatelayout.h (100%) rename {qt-ui => desktop-widgets}/undocommands.cpp (100%) rename {qt-ui => desktop-widgets}/undocommands.h (100%) rename {qt-ui => desktop-widgets}/updatemanager.cpp (100%) rename {qt-ui => desktop-widgets}/updatemanager.h (100%) rename {qt-ui => desktop-widgets}/urldialog.ui (100%) rename {qt-ui => desktop-widgets}/usermanual.cpp (100%) rename {qt-ui => desktop-widgets}/usermanual.h (100%) rename {qt-ui => desktop-widgets}/usersurvey.cpp (100%) rename {qt-ui => desktop-widgets}/usersurvey.h (100%) rename {qt-ui => desktop-widgets}/usersurvey.ui (100%) rename {qt-ui => desktop-widgets}/webservices.ui (100%) delete mode 100644 qt-ui/graphicsview-common.h rename qt-ui/graphicsview-common.cpp => subsurface-core/color.cpp (99%) rename {qt-ui => subsurface-core}/metrics.cpp (100%) rename {qt-ui => subsurface-core}/metrics.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e4e5f53d..74b9d0d94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,10 +37,10 @@ set(CMAKE_MODULE_PATH include_directories(. ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/qt-ui - qt-ui + ${CMAKE_BINARY_DIR}/desktop-widgets + desktop-widgets/ qt-models - qt-ui/profile + desktop-widgets/profile subsurface-core/ ) @@ -362,7 +362,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ANDROID) set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lpthread) endif() -add_subdirectory(qt-ui) +add_subdirectory(desktop-widgets) # create the executables if(SUBSURFACE_MOBILE) diff --git a/qt-ui/CMakeLists.txt b/desktop-widgets/CMakeLists.txt similarity index 98% rename from qt-ui/CMakeLists.txt rename to desktop-widgets/CMakeLists.txt index 45447771a..2c373b83f 100644 --- a/qt-ui/CMakeLists.txt +++ b/desktop-widgets/CMakeLists.txt @@ -23,12 +23,10 @@ set(SUBSURFACE_INTERFACE diveshareexportdialog.cpp downloadfromdivecomputer.cpp globe.cpp - graphicsview-common.cpp kmessagewidget.cpp maintab.cpp mainwindow.cpp modeldelegates.cpp - metrics.cpp notificationwidget.cpp preferences.cpp simplewidgets.cpp diff --git a/qt-ui/about.cpp b/desktop-widgets/about.cpp similarity index 100% rename from qt-ui/about.cpp rename to desktop-widgets/about.cpp diff --git a/qt-ui/about.h b/desktop-widgets/about.h similarity index 100% rename from qt-ui/about.h rename to desktop-widgets/about.h diff --git a/qt-ui/about.ui b/desktop-widgets/about.ui similarity index 100% rename from qt-ui/about.ui rename to desktop-widgets/about.ui diff --git a/qt-ui/btdeviceselectiondialog.cpp b/desktop-widgets/btdeviceselectiondialog.cpp similarity index 100% rename from qt-ui/btdeviceselectiondialog.cpp rename to desktop-widgets/btdeviceselectiondialog.cpp diff --git a/qt-ui/btdeviceselectiondialog.h b/desktop-widgets/btdeviceselectiondialog.h similarity index 100% rename from qt-ui/btdeviceselectiondialog.h rename to desktop-widgets/btdeviceselectiondialog.h diff --git a/qt-ui/btdeviceselectiondialog.ui b/desktop-widgets/btdeviceselectiondialog.ui similarity index 100% rename from qt-ui/btdeviceselectiondialog.ui rename to desktop-widgets/btdeviceselectiondialog.ui diff --git a/qt-ui/configuredivecomputerdialog.cpp b/desktop-widgets/configuredivecomputerdialog.cpp similarity index 100% rename from qt-ui/configuredivecomputerdialog.cpp rename to desktop-widgets/configuredivecomputerdialog.cpp diff --git a/qt-ui/configuredivecomputerdialog.h b/desktop-widgets/configuredivecomputerdialog.h similarity index 100% rename from qt-ui/configuredivecomputerdialog.h rename to desktop-widgets/configuredivecomputerdialog.h diff --git a/qt-ui/configuredivecomputerdialog.ui b/desktop-widgets/configuredivecomputerdialog.ui similarity index 100% rename from qt-ui/configuredivecomputerdialog.ui rename to desktop-widgets/configuredivecomputerdialog.ui diff --git a/qt-ui/css/tableviews.css b/desktop-widgets/css/tableviews.css similarity index 100% rename from qt-ui/css/tableviews.css rename to desktop-widgets/css/tableviews.css diff --git a/qt-ui/divecomponentselection.ui b/desktop-widgets/divecomponentselection.ui similarity index 100% rename from qt-ui/divecomponentselection.ui rename to desktop-widgets/divecomponentselection.ui diff --git a/qt-ui/divecomputermanagementdialog.cpp b/desktop-widgets/divecomputermanagementdialog.cpp similarity index 100% rename from qt-ui/divecomputermanagementdialog.cpp rename to desktop-widgets/divecomputermanagementdialog.cpp diff --git a/qt-ui/divecomputermanagementdialog.h b/desktop-widgets/divecomputermanagementdialog.h similarity index 100% rename from qt-ui/divecomputermanagementdialog.h rename to desktop-widgets/divecomputermanagementdialog.h diff --git a/qt-ui/divecomputermanagementdialog.ui b/desktop-widgets/divecomputermanagementdialog.ui similarity index 100% rename from qt-ui/divecomputermanagementdialog.ui rename to desktop-widgets/divecomputermanagementdialog.ui diff --git a/qt-ui/divelistview.cpp b/desktop-widgets/divelistview.cpp similarity index 100% rename from qt-ui/divelistview.cpp rename to desktop-widgets/divelistview.cpp diff --git a/qt-ui/divelistview.h b/desktop-widgets/divelistview.h similarity index 100% rename from qt-ui/divelistview.h rename to desktop-widgets/divelistview.h diff --git a/qt-ui/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp similarity index 100% rename from qt-ui/divelogexportdialog.cpp rename to desktop-widgets/divelogexportdialog.cpp diff --git a/qt-ui/divelogexportdialog.h b/desktop-widgets/divelogexportdialog.h similarity index 100% rename from qt-ui/divelogexportdialog.h rename to desktop-widgets/divelogexportdialog.h diff --git a/qt-ui/divelogexportdialog.ui b/desktop-widgets/divelogexportdialog.ui similarity index 100% rename from qt-ui/divelogexportdialog.ui rename to desktop-widgets/divelogexportdialog.ui diff --git a/qt-ui/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp similarity index 100% rename from qt-ui/divelogimportdialog.cpp rename to desktop-widgets/divelogimportdialog.cpp diff --git a/qt-ui/divelogimportdialog.h b/desktop-widgets/divelogimportdialog.h similarity index 100% rename from qt-ui/divelogimportdialog.h rename to desktop-widgets/divelogimportdialog.h diff --git a/qt-ui/divelogimportdialog.ui b/desktop-widgets/divelogimportdialog.ui similarity index 100% rename from qt-ui/divelogimportdialog.ui rename to desktop-widgets/divelogimportdialog.ui diff --git a/qt-ui/divepicturewidget.cpp b/desktop-widgets/divepicturewidget.cpp similarity index 100% rename from qt-ui/divepicturewidget.cpp rename to desktop-widgets/divepicturewidget.cpp diff --git a/qt-ui/divepicturewidget.h b/desktop-widgets/divepicturewidget.h similarity index 100% rename from qt-ui/divepicturewidget.h rename to desktop-widgets/divepicturewidget.h diff --git a/qt-ui/diveplanner.cpp b/desktop-widgets/diveplanner.cpp similarity index 100% rename from qt-ui/diveplanner.cpp rename to desktop-widgets/diveplanner.cpp diff --git a/qt-ui/diveplanner.h b/desktop-widgets/diveplanner.h similarity index 100% rename from qt-ui/diveplanner.h rename to desktop-widgets/diveplanner.h diff --git a/qt-ui/diveplanner.ui b/desktop-widgets/diveplanner.ui similarity index 100% rename from qt-ui/diveplanner.ui rename to desktop-widgets/diveplanner.ui diff --git a/qt-ui/diveshareexportdialog.cpp b/desktop-widgets/diveshareexportdialog.cpp similarity index 100% rename from qt-ui/diveshareexportdialog.cpp rename to desktop-widgets/diveshareexportdialog.cpp diff --git a/qt-ui/diveshareexportdialog.h b/desktop-widgets/diveshareexportdialog.h similarity index 100% rename from qt-ui/diveshareexportdialog.h rename to desktop-widgets/diveshareexportdialog.h diff --git a/qt-ui/diveshareexportdialog.ui b/desktop-widgets/diveshareexportdialog.ui similarity index 100% rename from qt-ui/diveshareexportdialog.ui rename to desktop-widgets/diveshareexportdialog.ui diff --git a/qt-ui/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp similarity index 100% rename from qt-ui/downloadfromdivecomputer.cpp rename to desktop-widgets/downloadfromdivecomputer.cpp diff --git a/qt-ui/downloadfromdivecomputer.h b/desktop-widgets/downloadfromdivecomputer.h similarity index 100% rename from qt-ui/downloadfromdivecomputer.h rename to desktop-widgets/downloadfromdivecomputer.h diff --git a/qt-ui/downloadfromdivecomputer.ui b/desktop-widgets/downloadfromdivecomputer.ui similarity index 100% rename from qt-ui/downloadfromdivecomputer.ui rename to desktop-widgets/downloadfromdivecomputer.ui diff --git a/qt-ui/filterwidget.ui b/desktop-widgets/filterwidget.ui similarity index 100% rename from qt-ui/filterwidget.ui rename to desktop-widgets/filterwidget.ui diff --git a/qt-ui/globe.cpp b/desktop-widgets/globe.cpp similarity index 100% rename from qt-ui/globe.cpp rename to desktop-widgets/globe.cpp diff --git a/qt-ui/globe.h b/desktop-widgets/globe.h similarity index 100% rename from qt-ui/globe.h rename to desktop-widgets/globe.h diff --git a/qt-ui/groupedlineedit.cpp b/desktop-widgets/groupedlineedit.cpp similarity index 100% rename from qt-ui/groupedlineedit.cpp rename to desktop-widgets/groupedlineedit.cpp diff --git a/qt-ui/groupedlineedit.h b/desktop-widgets/groupedlineedit.h similarity index 100% rename from qt-ui/groupedlineedit.h rename to desktop-widgets/groupedlineedit.h diff --git a/qt-ui/kmessagewidget.cpp b/desktop-widgets/kmessagewidget.cpp similarity index 100% rename from qt-ui/kmessagewidget.cpp rename to desktop-widgets/kmessagewidget.cpp diff --git a/qt-ui/kmessagewidget.h b/desktop-widgets/kmessagewidget.h similarity index 100% rename from qt-ui/kmessagewidget.h rename to desktop-widgets/kmessagewidget.h diff --git a/qt-ui/listfilter.ui b/desktop-widgets/listfilter.ui similarity index 100% rename from qt-ui/listfilter.ui rename to desktop-widgets/listfilter.ui diff --git a/qt-ui/locationInformation.ui b/desktop-widgets/locationInformation.ui similarity index 100% rename from qt-ui/locationInformation.ui rename to desktop-widgets/locationInformation.ui diff --git a/qt-ui/locationinformation.cpp b/desktop-widgets/locationinformation.cpp similarity index 100% rename from qt-ui/locationinformation.cpp rename to desktop-widgets/locationinformation.cpp diff --git a/qt-ui/locationinformation.h b/desktop-widgets/locationinformation.h similarity index 100% rename from qt-ui/locationinformation.h rename to desktop-widgets/locationinformation.h diff --git a/qt-ui/maintab.cpp b/desktop-widgets/maintab.cpp similarity index 100% rename from qt-ui/maintab.cpp rename to desktop-widgets/maintab.cpp diff --git a/qt-ui/maintab.h b/desktop-widgets/maintab.h similarity index 100% rename from qt-ui/maintab.h rename to desktop-widgets/maintab.h diff --git a/qt-ui/maintab.ui b/desktop-widgets/maintab.ui similarity index 99% rename from qt-ui/maintab.ui rename to desktop-widgets/maintab.ui index 2c515a225..7bc516b1a 100644 --- a/qt-ui/maintab.ui +++ b/desktop-widgets/maintab.ui @@ -525,8 +525,8 @@ 0 0 - 70 - 16 + 445 + 754 @@ -1229,7 +1229,7 @@ TagWidget QPlainTextEdit -
qt-ui/tagwidget.h
+
tagwidget.h
DivePictureWidget diff --git a/qt-ui/mainwindow.cpp b/desktop-widgets/mainwindow.cpp similarity index 99% rename from qt-ui/mainwindow.cpp rename to desktop-widgets/mainwindow.cpp index e0476381f..e1e0d81a2 100644 --- a/qt-ui/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -50,6 +50,7 @@ #include #include #include +#include "subsurface-core/color.h" #if defined(FBSUPPORT) #include "socialnetworks.h" diff --git a/qt-ui/mainwindow.h b/desktop-widgets/mainwindow.h similarity index 100% rename from qt-ui/mainwindow.h rename to desktop-widgets/mainwindow.h diff --git a/qt-ui/mainwindow.ui b/desktop-widgets/mainwindow.ui similarity index 100% rename from qt-ui/mainwindow.ui rename to desktop-widgets/mainwindow.ui diff --git a/qt-ui/marble/GeoDataTreeModel.h b/desktop-widgets/marble/GeoDataTreeModel.h similarity index 100% rename from qt-ui/marble/GeoDataTreeModel.h rename to desktop-widgets/marble/GeoDataTreeModel.h diff --git a/qt-ui/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp similarity index 100% rename from qt-ui/modeldelegates.cpp rename to desktop-widgets/modeldelegates.cpp diff --git a/qt-ui/modeldelegates.h b/desktop-widgets/modeldelegates.h similarity index 100% rename from qt-ui/modeldelegates.h rename to desktop-widgets/modeldelegates.h diff --git a/qt-ui/notificationwidget.cpp b/desktop-widgets/notificationwidget.cpp similarity index 100% rename from qt-ui/notificationwidget.cpp rename to desktop-widgets/notificationwidget.cpp diff --git a/qt-ui/notificationwidget.h b/desktop-widgets/notificationwidget.h similarity index 100% rename from qt-ui/notificationwidget.h rename to desktop-widgets/notificationwidget.h diff --git a/qt-ui/plannerDetails.ui b/desktop-widgets/plannerDetails.ui similarity index 100% rename from qt-ui/plannerDetails.ui rename to desktop-widgets/plannerDetails.ui diff --git a/qt-ui/plannerSettings.ui b/desktop-widgets/plannerSettings.ui similarity index 100% rename from qt-ui/plannerSettings.ui rename to desktop-widgets/plannerSettings.ui diff --git a/qt-ui/preferences.cpp b/desktop-widgets/preferences.cpp similarity index 100% rename from qt-ui/preferences.cpp rename to desktop-widgets/preferences.cpp diff --git a/qt-ui/preferences.h b/desktop-widgets/preferences.h similarity index 100% rename from qt-ui/preferences.h rename to desktop-widgets/preferences.h diff --git a/qt-ui/preferences.ui b/desktop-widgets/preferences.ui similarity index 100% rename from qt-ui/preferences.ui rename to desktop-widgets/preferences.ui diff --git a/qt-ui/printdialog.cpp b/desktop-widgets/printdialog.cpp similarity index 100% rename from qt-ui/printdialog.cpp rename to desktop-widgets/printdialog.cpp diff --git a/qt-ui/printdialog.h b/desktop-widgets/printdialog.h similarity index 100% rename from qt-ui/printdialog.h rename to desktop-widgets/printdialog.h diff --git a/qt-ui/printer.cpp b/desktop-widgets/printer.cpp similarity index 100% rename from qt-ui/printer.cpp rename to desktop-widgets/printer.cpp diff --git a/qt-ui/printer.h b/desktop-widgets/printer.h similarity index 100% rename from qt-ui/printer.h rename to desktop-widgets/printer.h diff --git a/qt-ui/printoptions.cpp b/desktop-widgets/printoptions.cpp similarity index 100% rename from qt-ui/printoptions.cpp rename to desktop-widgets/printoptions.cpp diff --git a/qt-ui/printoptions.h b/desktop-widgets/printoptions.h similarity index 100% rename from qt-ui/printoptions.h rename to desktop-widgets/printoptions.h diff --git a/qt-ui/printoptions.ui b/desktop-widgets/printoptions.ui similarity index 100% rename from qt-ui/printoptions.ui rename to desktop-widgets/printoptions.ui diff --git a/qt-ui/profile/animationfunctions.cpp b/desktop-widgets/profile/animationfunctions.cpp similarity index 100% rename from qt-ui/profile/animationfunctions.cpp rename to desktop-widgets/profile/animationfunctions.cpp diff --git a/qt-ui/profile/animationfunctions.h b/desktop-widgets/profile/animationfunctions.h similarity index 100% rename from qt-ui/profile/animationfunctions.h rename to desktop-widgets/profile/animationfunctions.h diff --git a/qt-ui/profile/divecartesianaxis.cpp b/desktop-widgets/profile/divecartesianaxis.cpp similarity index 100% rename from qt-ui/profile/divecartesianaxis.cpp rename to desktop-widgets/profile/divecartesianaxis.cpp diff --git a/qt-ui/profile/divecartesianaxis.h b/desktop-widgets/profile/divecartesianaxis.h similarity index 98% rename from qt-ui/profile/divecartesianaxis.h rename to desktop-widgets/profile/divecartesianaxis.h index 27cfa62d8..cc7d0bcf7 100644 --- a/qt-ui/profile/divecartesianaxis.h +++ b/desktop-widgets/profile/divecartesianaxis.h @@ -3,7 +3,7 @@ #include #include -#include +#include "subsurface-core/color.h" class QPropertyAnimation; class DiveTextItem; diff --git a/qt-ui/profile/diveeventitem.cpp b/desktop-widgets/profile/diveeventitem.cpp similarity index 100% rename from qt-ui/profile/diveeventitem.cpp rename to desktop-widgets/profile/diveeventitem.cpp diff --git a/qt-ui/profile/diveeventitem.h b/desktop-widgets/profile/diveeventitem.h similarity index 100% rename from qt-ui/profile/diveeventitem.h rename to desktop-widgets/profile/diveeventitem.h diff --git a/qt-ui/profile/divelineitem.cpp b/desktop-widgets/profile/divelineitem.cpp similarity index 100% rename from qt-ui/profile/divelineitem.cpp rename to desktop-widgets/profile/divelineitem.cpp diff --git a/qt-ui/profile/divelineitem.h b/desktop-widgets/profile/divelineitem.h similarity index 100% rename from qt-ui/profile/divelineitem.h rename to desktop-widgets/profile/divelineitem.h diff --git a/qt-ui/profile/divepixmapitem.cpp b/desktop-widgets/profile/divepixmapitem.cpp similarity index 100% rename from qt-ui/profile/divepixmapitem.cpp rename to desktop-widgets/profile/divepixmapitem.cpp diff --git a/qt-ui/profile/divepixmapitem.h b/desktop-widgets/profile/divepixmapitem.h similarity index 100% rename from qt-ui/profile/divepixmapitem.h rename to desktop-widgets/profile/divepixmapitem.h diff --git a/qt-ui/profile/diveprofileitem.cpp b/desktop-widgets/profile/diveprofileitem.cpp similarity index 100% rename from qt-ui/profile/diveprofileitem.cpp rename to desktop-widgets/profile/diveprofileitem.cpp diff --git a/qt-ui/profile/diveprofileitem.h b/desktop-widgets/profile/diveprofileitem.h similarity index 99% rename from qt-ui/profile/diveprofileitem.h rename to desktop-widgets/profile/diveprofileitem.h index 2160782f7..0bba7f7a3 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/desktop-widgets/profile/diveprofileitem.h @@ -5,7 +5,6 @@ #include #include -#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/desktop-widgets/profile/diverectitem.cpp similarity index 100% rename from qt-ui/profile/diverectitem.cpp rename to desktop-widgets/profile/diverectitem.cpp diff --git a/qt-ui/profile/diverectitem.h b/desktop-widgets/profile/diverectitem.h similarity index 100% rename from qt-ui/profile/diverectitem.h rename to desktop-widgets/profile/diverectitem.h diff --git a/qt-ui/profile/divetextitem.cpp b/desktop-widgets/profile/divetextitem.cpp similarity index 98% rename from qt-ui/profile/divetextitem.cpp rename to desktop-widgets/profile/divetextitem.cpp index 9c7848cd4..3bf00d68f 100644 --- a/qt-ui/profile/divetextitem.cpp +++ b/desktop-widgets/profile/divetextitem.cpp @@ -1,6 +1,9 @@ #include "divetextitem.h" #include "mainwindow.h" #include "profilewidget2.h" +#include "subsurface-core/color.h" + +#include DiveTextItem::DiveTextItem(QGraphicsItem *parent) : QGraphicsItemGroup(parent), internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter), diff --git a/qt-ui/profile/divetextitem.h b/desktop-widgets/profile/divetextitem.h similarity index 94% rename from qt-ui/profile/divetextitem.h rename to desktop-widgets/profile/divetextitem.h index 3991fe7f3..be0adf292 100644 --- a/qt-ui/profile/divetextitem.h +++ b/desktop-widgets/profile/divetextitem.h @@ -3,8 +3,8 @@ #include #include -#include "graphicsview-common.h" -#include + +class QBrush; /* A Line Item that has animated-properties. */ class DiveTextItem : public QObject, public QGraphicsItemGroup { diff --git a/qt-ui/profile/divetooltipitem.cpp b/desktop-widgets/profile/divetooltipitem.cpp similarity index 100% rename from qt-ui/profile/divetooltipitem.cpp rename to desktop-widgets/profile/divetooltipitem.cpp diff --git a/qt-ui/profile/divetooltipitem.h b/desktop-widgets/profile/divetooltipitem.h similarity index 100% rename from qt-ui/profile/divetooltipitem.h rename to desktop-widgets/profile/divetooltipitem.h diff --git a/qt-ui/profile/profilewidget2.cpp b/desktop-widgets/profile/profilewidget2.cpp similarity index 100% rename from qt-ui/profile/profilewidget2.cpp rename to desktop-widgets/profile/profilewidget2.cpp diff --git a/qt-ui/profile/profilewidget2.h b/desktop-widgets/profile/profilewidget2.h similarity index 99% rename from qt-ui/profile/profilewidget2.h rename to desktop-widgets/profile/profilewidget2.h index 2d1a7bfb4..f11ec5be1 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/desktop-widgets/profile/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/desktop-widgets/profile/ruleritem.cpp similarity index 100% rename from qt-ui/profile/ruleritem.cpp rename to desktop-widgets/profile/ruleritem.cpp diff --git a/qt-ui/profile/ruleritem.h b/desktop-widgets/profile/ruleritem.h similarity index 100% rename from qt-ui/profile/ruleritem.h rename to desktop-widgets/profile/ruleritem.h diff --git a/qt-ui/profile/tankitem.cpp b/desktop-widgets/profile/tankitem.cpp similarity index 100% rename from qt-ui/profile/tankitem.cpp rename to desktop-widgets/profile/tankitem.cpp diff --git a/qt-ui/profile/tankitem.h b/desktop-widgets/profile/tankitem.h similarity index 100% rename from qt-ui/profile/tankitem.h rename to desktop-widgets/profile/tankitem.h diff --git a/qt-ui/qtwaitingspinner.cpp b/desktop-widgets/qtwaitingspinner.cpp similarity index 100% rename from qt-ui/qtwaitingspinner.cpp rename to desktop-widgets/qtwaitingspinner.cpp diff --git a/qt-ui/qtwaitingspinner.h b/desktop-widgets/qtwaitingspinner.h similarity index 100% rename from qt-ui/qtwaitingspinner.h rename to desktop-widgets/qtwaitingspinner.h diff --git a/qt-ui/renumber.ui b/desktop-widgets/renumber.ui similarity index 100% rename from qt-ui/renumber.ui rename to desktop-widgets/renumber.ui diff --git a/qt-ui/searchbar.ui b/desktop-widgets/searchbar.ui similarity index 100% rename from qt-ui/searchbar.ui rename to desktop-widgets/searchbar.ui diff --git a/qt-ui/setpoint.ui b/desktop-widgets/setpoint.ui similarity index 100% rename from qt-ui/setpoint.ui rename to desktop-widgets/setpoint.ui diff --git a/qt-ui/shiftimagetimes.ui b/desktop-widgets/shiftimagetimes.ui similarity index 100% rename from qt-ui/shiftimagetimes.ui rename to desktop-widgets/shiftimagetimes.ui diff --git a/qt-ui/shifttimes.ui b/desktop-widgets/shifttimes.ui similarity index 100% rename from qt-ui/shifttimes.ui rename to desktop-widgets/shifttimes.ui diff --git a/qt-ui/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp similarity index 100% rename from qt-ui/simplewidgets.cpp rename to desktop-widgets/simplewidgets.cpp diff --git a/qt-ui/simplewidgets.h b/desktop-widgets/simplewidgets.h similarity index 100% rename from qt-ui/simplewidgets.h rename to desktop-widgets/simplewidgets.h diff --git a/qt-ui/socialnetworks.cpp b/desktop-widgets/socialnetworks.cpp similarity index 100% rename from qt-ui/socialnetworks.cpp rename to desktop-widgets/socialnetworks.cpp diff --git a/qt-ui/socialnetworks.h b/desktop-widgets/socialnetworks.h similarity index 100% rename from qt-ui/socialnetworks.h rename to desktop-widgets/socialnetworks.h diff --git a/qt-ui/socialnetworksdialog.ui b/desktop-widgets/socialnetworksdialog.ui similarity index 100% rename from qt-ui/socialnetworksdialog.ui rename to desktop-widgets/socialnetworksdialog.ui diff --git a/qt-ui/starwidget.cpp b/desktop-widgets/starwidget.cpp similarity index 100% rename from qt-ui/starwidget.cpp rename to desktop-widgets/starwidget.cpp diff --git a/qt-ui/starwidget.h b/desktop-widgets/starwidget.h similarity index 100% rename from qt-ui/starwidget.h rename to desktop-widgets/starwidget.h diff --git a/qt-ui/statistics/monthstatistics.cpp b/desktop-widgets/statistics/monthstatistics.cpp similarity index 100% rename from qt-ui/statistics/monthstatistics.cpp rename to desktop-widgets/statistics/monthstatistics.cpp diff --git a/qt-ui/statistics/monthstatistics.h b/desktop-widgets/statistics/monthstatistics.h similarity index 100% rename from qt-ui/statistics/monthstatistics.h rename to desktop-widgets/statistics/monthstatistics.h diff --git a/qt-ui/statistics/statisticsbar.cpp b/desktop-widgets/statistics/statisticsbar.cpp similarity index 100% rename from qt-ui/statistics/statisticsbar.cpp rename to desktop-widgets/statistics/statisticsbar.cpp diff --git a/qt-ui/statistics/statisticsbar.h b/desktop-widgets/statistics/statisticsbar.h similarity index 100% rename from qt-ui/statistics/statisticsbar.h rename to desktop-widgets/statistics/statisticsbar.h diff --git a/qt-ui/statistics/statisticswidget.cpp b/desktop-widgets/statistics/statisticswidget.cpp similarity index 100% rename from qt-ui/statistics/statisticswidget.cpp rename to desktop-widgets/statistics/statisticswidget.cpp diff --git a/qt-ui/statistics/statisticswidget.h b/desktop-widgets/statistics/statisticswidget.h similarity index 100% rename from qt-ui/statistics/statisticswidget.h rename to desktop-widgets/statistics/statisticswidget.h diff --git a/qt-ui/statistics/yearstatistics.cpp b/desktop-widgets/statistics/yearstatistics.cpp similarity index 100% rename from qt-ui/statistics/yearstatistics.cpp rename to desktop-widgets/statistics/yearstatistics.cpp diff --git a/qt-ui/statistics/yearstatistics.h b/desktop-widgets/statistics/yearstatistics.h similarity index 100% rename from qt-ui/statistics/yearstatistics.h rename to desktop-widgets/statistics/yearstatistics.h diff --git a/qt-ui/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp similarity index 100% rename from qt-ui/subsurfacewebservices.cpp rename to desktop-widgets/subsurfacewebservices.cpp diff --git a/qt-ui/subsurfacewebservices.h b/desktop-widgets/subsurfacewebservices.h similarity index 100% rename from qt-ui/subsurfacewebservices.h rename to desktop-widgets/subsurfacewebservices.h diff --git a/qt-ui/tableview.cpp b/desktop-widgets/tableview.cpp similarity index 100% rename from qt-ui/tableview.cpp rename to desktop-widgets/tableview.cpp diff --git a/qt-ui/tableview.h b/desktop-widgets/tableview.h similarity index 100% rename from qt-ui/tableview.h rename to desktop-widgets/tableview.h diff --git a/qt-ui/tableview.ui b/desktop-widgets/tableview.ui similarity index 100% rename from qt-ui/tableview.ui rename to desktop-widgets/tableview.ui diff --git a/qt-ui/tagwidget.cpp b/desktop-widgets/tagwidget.cpp similarity index 100% rename from qt-ui/tagwidget.cpp rename to desktop-widgets/tagwidget.cpp diff --git a/qt-ui/tagwidget.h b/desktop-widgets/tagwidget.h similarity index 100% rename from qt-ui/tagwidget.h rename to desktop-widgets/tagwidget.h diff --git a/qt-ui/templateedit.cpp b/desktop-widgets/templateedit.cpp similarity index 100% rename from qt-ui/templateedit.cpp rename to desktop-widgets/templateedit.cpp diff --git a/qt-ui/templateedit.h b/desktop-widgets/templateedit.h similarity index 100% rename from qt-ui/templateedit.h rename to desktop-widgets/templateedit.h diff --git a/qt-ui/templateedit.ui b/desktop-widgets/templateedit.ui similarity index 100% rename from qt-ui/templateedit.ui rename to desktop-widgets/templateedit.ui diff --git a/qt-ui/templatelayout.cpp b/desktop-widgets/templatelayout.cpp similarity index 100% rename from qt-ui/templatelayout.cpp rename to desktop-widgets/templatelayout.cpp diff --git a/qt-ui/templatelayout.h b/desktop-widgets/templatelayout.h similarity index 100% rename from qt-ui/templatelayout.h rename to desktop-widgets/templatelayout.h diff --git a/qt-ui/undocommands.cpp b/desktop-widgets/undocommands.cpp similarity index 100% rename from qt-ui/undocommands.cpp rename to desktop-widgets/undocommands.cpp diff --git a/qt-ui/undocommands.h b/desktop-widgets/undocommands.h similarity index 100% rename from qt-ui/undocommands.h rename to desktop-widgets/undocommands.h diff --git a/qt-ui/updatemanager.cpp b/desktop-widgets/updatemanager.cpp similarity index 100% rename from qt-ui/updatemanager.cpp rename to desktop-widgets/updatemanager.cpp diff --git a/qt-ui/updatemanager.h b/desktop-widgets/updatemanager.h similarity index 100% rename from qt-ui/updatemanager.h rename to desktop-widgets/updatemanager.h diff --git a/qt-ui/urldialog.ui b/desktop-widgets/urldialog.ui similarity index 100% rename from qt-ui/urldialog.ui rename to desktop-widgets/urldialog.ui diff --git a/qt-ui/usermanual.cpp b/desktop-widgets/usermanual.cpp similarity index 100% rename from qt-ui/usermanual.cpp rename to desktop-widgets/usermanual.cpp diff --git a/qt-ui/usermanual.h b/desktop-widgets/usermanual.h similarity index 100% rename from qt-ui/usermanual.h rename to desktop-widgets/usermanual.h diff --git a/qt-ui/usersurvey.cpp b/desktop-widgets/usersurvey.cpp similarity index 100% rename from qt-ui/usersurvey.cpp rename to desktop-widgets/usersurvey.cpp diff --git a/qt-ui/usersurvey.h b/desktop-widgets/usersurvey.h similarity index 100% rename from qt-ui/usersurvey.h rename to desktop-widgets/usersurvey.h diff --git a/qt-ui/usersurvey.ui b/desktop-widgets/usersurvey.ui similarity index 100% rename from qt-ui/usersurvey.ui rename to desktop-widgets/usersurvey.ui diff --git a/qt-ui/webservices.ui b/desktop-widgets/webservices.ui similarity index 100% rename from qt-ui/webservices.ui rename to desktop-widgets/webservices.ui diff --git a/main.cpp b/main.cpp index 171876abf..e7259c3f3 100644 --- a/main.cpp +++ b/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 diff --git a/qt-gui.cpp b/qt-gui.cpp index a4997a6fe..5c7157fe6 100644 --- a/qt-gui.cpp +++ b/qt-gui.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 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 29853cb3d..f56f4be1c 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -1,7 +1,9 @@ #include "filtermodels.h" #include "models.h" -#include "divelistview.h" #include "display.h" +#include "divetripmodel.h" + +#include #define CREATE_INSTANCE_METHOD( CLASS ) \ CLASS *CLASS::instance() \ diff --git a/qt-ui/graphicsview-common.h b/qt-ui/graphicsview-common.h deleted file mode 100644 index 2a757b2ae..000000000 --- a/qt-ui/graphicsview-common.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef GRAPHICSVIEW_COMMON_H -#define GRAPHICSVIEW_COMMON_H - -#include "subsurface-core/color.h" -#include -#include -#include - -#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 > 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/subsurface-core/CMakeLists.txt b/subsurface-core/CMakeLists.txt index e7f531527..60efb7d92 100644 --- a/subsurface-core/CMakeLists.txt +++ b/subsurface-core/CMakeLists.txt @@ -70,6 +70,8 @@ set(SUBSURFACE_CORE_LIB_SRCS divelogexportlogic.cpp qt-init.cpp qtserialbluetooth.cpp + metrics.cpp + color.cpp ${SERIAL_FTDI} ${PLATFORM_SRC} ${BT_CORE_SRC_FILES} diff --git a/qt-ui/graphicsview-common.cpp b/subsurface-core/color.cpp similarity index 99% rename from qt-ui/graphicsview-common.cpp rename to 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 > profile_color; diff --git a/subsurface-core/color.h b/subsurface-core/color.h index 7938e59a6..57ad77242 100644 --- a/subsurface-core/color.h +++ b/subsurface-core/color.h @@ -5,6 +5,8 @@ from http://chir.ag/projects/name-that-color */ #include +#include +#include // 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 > 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/qt-ui/metrics.cpp b/subsurface-core/metrics.cpp similarity index 100% rename from qt-ui/metrics.cpp rename to subsurface-core/metrics.cpp diff --git a/qt-ui/metrics.h b/subsurface-core/metrics.h similarity index 100% rename from qt-ui/metrics.h rename to subsurface-core/metrics.h From 45c97640739198cf9a9cc5c42e81fb9811702b46 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 3 Sep 2015 14:49:59 -0300 Subject: [PATCH 06/48] main.cpp -> {android-main, desktop-main} This is needed to compile both in a single call to make. Also it will help removing some of the mistakes in the current android version: it always created the mainwindow, even without using it for anything, so tons of memory will be freed now for the android version, making it snappier and smoother. This is a necessary move so we don't need to #ifdef all over the place for the two different versions, and imo the changes needed to keep both versions will not be that huge if we keep things in subsurface-core sane. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 54 ++++++++------ qt-gui.cpp => subsurface-android-helper.cpp | 19 +---- subsurface-android-main.cpp | 81 +++++++++++++++++++++ subsurface-desktop-helper.cpp | 62 ++++++++++++++++ main.cpp => subsurface-desktop-main.cpp | 0 5 files changed, 175 insertions(+), 41 deletions(-) rename qt-gui.cpp => subsurface-android-helper.cpp (86%) create mode 100644 subsurface-android-main.cpp create mode 100644 subsurface-desktop-helper.cpp rename main.cpp => subsurface-desktop-main.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74b9d0d94..620b496ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,9 +347,10 @@ source_group("Subsurface Models" FILES ${SUBSURFACE_MODELS}) # the main app. set(SUBSURFACE_APP - main.cpp - qt-gui.cpp + subsurface-desktop-main.cpp + subsurface-desktop-helper.cpp ) + source_group("Subsurface App" FILES ${SUBSURFACE_APP}) add_library(subsurface_models STATIC ${SUBSURFACE_MODELS_LIB_SRCS}) @@ -366,13 +367,19 @@ add_subdirectory(desktop-widgets) # 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 @@ -383,26 +390,27 @@ if(SUBSURFACE_MOBILE) subsurface_models subsurface_corelib ${SUBSURFACE_LINK_LIBRARIES}) -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} -) 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() + 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) add_dependencies(subsurface_interface subsurface_generated_ui) diff --git a/qt-gui.cpp b/subsurface-android-helper.cpp similarity index 86% rename from qt-gui.cpp rename to subsurface-android-helper.cpp index 5c7157fe6..7b5d5df56 100644 --- a/qt-gui.cpp +++ b/subsurface-android-helper.cpp @@ -10,10 +10,8 @@ #include #include - #include "qt-gui.h" -#ifdef SUBSURFACE_MOBILE #include #include #include @@ -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("org.subsurfacedivelog.mobile", 1, 0, "QMLManager"); qmlRegisterType("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 +#include +#include +#include +#include + +#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 +#include +#include +#include + +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-desktop-helper.cpp b/subsurface-desktop-helper.cpp new file mode 100644 index 000000000..af366fb84 --- /dev/null +++ b/subsurface-desktop-helper.cpp @@ -0,0 +1,62 @@ +/* qt-gui.cpp */ +/* Qt UI implementation */ +#include "dive.h" +#include "display.h" +#include "desktop-widgets/mainwindow.h" +#include "helpers.h" + +#include +#include +#include +#include + + +#include "qt-gui.h" + +#ifdef SUBSURFACE_MOBILE +#include +#include +#include +#include +#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(); + + 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 similarity index 100% rename from main.cpp rename to subsurface-desktop-main.cpp From 50ec7200e66637abefe685e1875f3d4de2101158 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 3 Sep 2015 15:25:01 -0300 Subject: [PATCH 07/48] Single CMake to handle the models This one was pretty easy because of the work I did a few months ago to separate the models from the UI. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 33 ++++----------------------------- qt-models/CMakeLists.txt | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 qt-models/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 620b496ff..cdee60858 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,38 +312,16 @@ endif() # include translations add_subdirectory(translations) add_subdirectory(subsurface-core) +add_subdirectory(qt-models) 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}) +if(BTSUPPORT) + add_definitions(-DBT_SUPPORT) +endif() # the main app. set(SUBSURFACE_APP @@ -353,9 +331,6 @@ set(SUBSURFACE_APP source_group("Subsurface App" FILES ${SUBSURFACE_APP}) -add_library(subsurface_models STATIC ${SUBSURFACE_MODELS_LIB_SRCS}) -target_link_libraries(subsurface_models ${QT_LIBRARIES}) - # add pthread to the end of the library list on Linux # this is only needed on Ubuntu (why do these idiots break everything?) # but shouldn't hurt on other Linux versions diff --git a/qt-models/CMakeLists.txt b/qt-models/CMakeLists.txt new file mode 100644 index 000000000..463d61412 --- /dev/null +++ b/qt-models/CMakeLists.txt @@ -0,0 +1,28 @@ +# 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 From 1d6683f3e07d9a73af5fab702bc3a551ec7dabc9 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 3 Sep 2015 15:56:37 -0300 Subject: [PATCH 08/48] Move Profile widget out of desktop-widgets The reason for that is, even if profile widget is made with qpainter and for that reason it should be a desktop widget, it's being used on the mobile version because of a lack of QML plotting library that is fast and reliable. We discovered that it was faster just to encapsulate our Profile in a QML class and call it directly. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 3 ++- desktop-widgets/CMakeLists.txt | 19 ------------------- desktop-widgets/diveplanner.cpp | 6 +++--- desktop-widgets/maintab.cpp | 2 +- desktop-widgets/mainwindow.cpp | 2 +- desktop-widgets/modeldelegates.cpp | 2 +- desktop-widgets/printer.cpp | 1 + desktop-widgets/printer.h | 1 - desktop-widgets/simplewidgets.cpp | 2 +- desktop-widgets/socialnetworks.cpp | 2 +- profile-widget/CMakeLists.txt | 19 +++++++++++++++++++ .../animationfunctions.cpp | 0 .../animationfunctions.h | 0 .../divecartesianaxis.cpp | 0 .../divecartesianaxis.h | 0 .../diveeventitem.cpp | 0 .../diveeventitem.h | 0 .../divelineitem.cpp | 0 .../profile => profile-widget}/divelineitem.h | 0 .../divepixmapitem.cpp | 0 .../divepixmapitem.h | 0 .../diveprofileitem.cpp | 2 +- .../diveprofileitem.h | 0 .../diverectitem.cpp | 0 .../profile => profile-widget}/diverectitem.h | 0 .../divetextitem.cpp | 0 .../profile => profile-widget}/divetextitem.h | 0 .../divetooltipitem.cpp | 0 .../divetooltipitem.h | 0 .../profilewidget2.cpp | 0 .../profilewidget2.h | 0 .../profile => profile-widget}/ruleritem.cpp | 0 .../profile => profile-widget}/ruleritem.h | 0 .../profile => profile-widget}/tankitem.cpp | 0 .../profile => profile-widget}/tankitem.h | 0 qt-models/CMakeLists.txt | 1 + 36 files changed, 32 insertions(+), 30 deletions(-) create mode 100644 profile-widget/CMakeLists.txt rename {desktop-widgets/profile => profile-widget}/animationfunctions.cpp (100%) rename {desktop-widgets/profile => profile-widget}/animationfunctions.h (100%) rename {desktop-widgets/profile => profile-widget}/divecartesianaxis.cpp (100%) rename {desktop-widgets/profile => profile-widget}/divecartesianaxis.h (100%) rename {desktop-widgets/profile => profile-widget}/diveeventitem.cpp (100%) rename {desktop-widgets/profile => profile-widget}/diveeventitem.h (100%) rename {desktop-widgets/profile => profile-widget}/divelineitem.cpp (100%) rename {desktop-widgets/profile => profile-widget}/divelineitem.h (100%) rename {desktop-widgets/profile => profile-widget}/divepixmapitem.cpp (100%) rename {desktop-widgets/profile => profile-widget}/divepixmapitem.h (100%) rename {desktop-widgets/profile => profile-widget}/diveprofileitem.cpp (99%) rename {desktop-widgets/profile => profile-widget}/diveprofileitem.h (100%) rename {desktop-widgets/profile => profile-widget}/diverectitem.cpp (100%) rename {desktop-widgets/profile => profile-widget}/diverectitem.h (100%) rename {desktop-widgets/profile => profile-widget}/divetextitem.cpp (100%) rename {desktop-widgets/profile => profile-widget}/divetextitem.h (100%) rename {desktop-widgets/profile => profile-widget}/divetooltipitem.cpp (100%) rename {desktop-widgets/profile => profile-widget}/divetooltipitem.h (100%) rename {desktop-widgets/profile => profile-widget}/profilewidget2.cpp (100%) rename {desktop-widgets/profile => profile-widget}/profilewidget2.h (100%) rename {desktop-widgets/profile => profile-widget}/ruleritem.cpp (100%) rename {desktop-widgets/profile => profile-widget}/ruleritem.h (100%) rename {desktop-widgets/profile => profile-widget}/tankitem.cpp (100%) rename {desktop-widgets/profile => profile-widget}/tankitem.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index cdee60858..b5b0195a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -313,6 +313,8 @@ endif() add_subdirectory(translations) add_subdirectory(subsurface-core) add_subdirectory(qt-models) +add_subdirectory(profile-widget) +add_subdirectory(desktop-widgets) if(FBSUPPORT) add_definitions(-DFBSUPPORT) @@ -338,7 +340,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ANDROID) set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lpthread) endif() -add_subdirectory(desktop-widgets) # create the executables if(SUBSURFACE_MOBILE) diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt index 2c373b83f..635a8b68e 100644 --- a/desktop-widgets/CMakeLists.txt +++ b/desktop-widgets/CMakeLists.txt @@ -75,23 +75,6 @@ endif() source_group("Subsurface Interface" FILES ${SUBSURFACE_INTERFACE}) -# the profile widget -set(SUBSURFACE_PROFILE_LIB_SRCS - profile/profilewidget2.cpp - profile/diverectitem.cpp - profile/divepixmapitem.cpp - profile/divelineitem.cpp - profile/divetextitem.cpp - profile/animationfunctions.cpp - profile/divecartesianaxis.cpp - profile/diveprofileitem.cpp - profile/diveeventitem.cpp - profile/divetooltipitem.cpp - profile/ruleritem.cpp - profile/tankitem.cpp -) -source_group("Subsurface Profile" FILES ${SUBSURFACE_PROFILE_LIB_SRCS}) - # the yearly statistics widget. set(SUBSURFACE_STATISTICS_LIB_SRCS statistics/statisticswidget.cpp @@ -101,8 +84,6 @@ set(SUBSURFACE_STATISTICS_LIB_SRCS ) source_group("Subsurface Statistics" FILES ${SUBSURFACE_STATISTICS_LIB_SRCS}) -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}) diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index b4413d11a..86f03b1d2 100644 --- a/desktop-widgets/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 @@ -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/desktop-widgets/maintab.cpp b/desktop-widgets/maintab.cpp index 0afb7b4c0..4d4cd3a5e 100644 --- a/desktop-widgets/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" diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index e1e0d81a2..43b433d62 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -21,7 +21,7 @@ #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" diff --git a/desktop-widgets/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp index 881037a83..1b1a31c0b 100644 --- a/desktop-widgets/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/desktop-widgets/printer.cpp b/desktop-widgets/printer.cpp index f0197d446..33ee71b55 100644 --- a/desktop-widgets/printer.cpp +++ b/desktop-widgets/printer.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "profile-widget/profilewidget2.h" Printer::Printer(QPaintDevice *paintDevice, print_options *printOptions, template_options *templateOptions, PrintMode printMode) { diff --git a/desktop-widgets/printer.h b/desktop-widgets/printer.h index 979cacd6a..e5f16d77d 100644 --- a/desktop-widgets/printer.h +++ b/desktop-widgets/printer.h @@ -6,7 +6,6 @@ #include #include -#include "profile/profilewidget2.h" #include "printoptions.h" #include "templateedit.h" diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp index 62a9cc646..43ad1ddc0 100644 --- a/desktop-widgets/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/desktop-widgets/socialnetworks.cpp b/desktop-widgets/socialnetworks.cpp index 6e191267a..0794c764e 100644 --- a/desktop-widgets/socialnetworks.cpp +++ b/desktop-widgets/socialnetworks.cpp @@ -16,7 +16,7 @@ #include #include #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/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/desktop-widgets/profile/animationfunctions.cpp b/profile-widget/animationfunctions.cpp similarity index 100% rename from desktop-widgets/profile/animationfunctions.cpp rename to profile-widget/animationfunctions.cpp diff --git a/desktop-widgets/profile/animationfunctions.h b/profile-widget/animationfunctions.h similarity index 100% rename from desktop-widgets/profile/animationfunctions.h rename to profile-widget/animationfunctions.h diff --git a/desktop-widgets/profile/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp similarity index 100% rename from desktop-widgets/profile/divecartesianaxis.cpp rename to profile-widget/divecartesianaxis.cpp diff --git a/desktop-widgets/profile/divecartesianaxis.h b/profile-widget/divecartesianaxis.h similarity index 100% rename from desktop-widgets/profile/divecartesianaxis.h rename to profile-widget/divecartesianaxis.h diff --git a/desktop-widgets/profile/diveeventitem.cpp b/profile-widget/diveeventitem.cpp similarity index 100% rename from desktop-widgets/profile/diveeventitem.cpp rename to profile-widget/diveeventitem.cpp diff --git a/desktop-widgets/profile/diveeventitem.h b/profile-widget/diveeventitem.h similarity index 100% rename from desktop-widgets/profile/diveeventitem.h rename to profile-widget/diveeventitem.h diff --git a/desktop-widgets/profile/divelineitem.cpp b/profile-widget/divelineitem.cpp similarity index 100% rename from desktop-widgets/profile/divelineitem.cpp rename to profile-widget/divelineitem.cpp diff --git a/desktop-widgets/profile/divelineitem.h b/profile-widget/divelineitem.h similarity index 100% rename from desktop-widgets/profile/divelineitem.h rename to profile-widget/divelineitem.h diff --git a/desktop-widgets/profile/divepixmapitem.cpp b/profile-widget/divepixmapitem.cpp similarity index 100% rename from desktop-widgets/profile/divepixmapitem.cpp rename to profile-widget/divepixmapitem.cpp diff --git a/desktop-widgets/profile/divepixmapitem.h b/profile-widget/divepixmapitem.h similarity index 100% rename from desktop-widgets/profile/divepixmapitem.h rename to profile-widget/divepixmapitem.h diff --git a/desktop-widgets/profile/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp similarity index 99% rename from desktop-widgets/profile/diveprofileitem.cpp rename to profile-widget/diveprofileitem.cpp index 2c814678a..7cdccee32 100644 --- a/desktop-widgets/profile/diveprofileitem.cpp +++ b/profile-widget/diveprofileitem.cpp @@ -11,7 +11,7 @@ #include "libdivecomputer/parser.h" #include "mainwindow.h" #include "maintab.h" -#include "profile/profilewidget2.h" +#include "profilewidget2.h" #include "diveplanner.h" #include diff --git a/desktop-widgets/profile/diveprofileitem.h b/profile-widget/diveprofileitem.h similarity index 100% rename from desktop-widgets/profile/diveprofileitem.h rename to profile-widget/diveprofileitem.h diff --git a/desktop-widgets/profile/diverectitem.cpp b/profile-widget/diverectitem.cpp similarity index 100% rename from desktop-widgets/profile/diverectitem.cpp rename to profile-widget/diverectitem.cpp diff --git a/desktop-widgets/profile/diverectitem.h b/profile-widget/diverectitem.h similarity index 100% rename from desktop-widgets/profile/diverectitem.h rename to profile-widget/diverectitem.h diff --git a/desktop-widgets/profile/divetextitem.cpp b/profile-widget/divetextitem.cpp similarity index 100% rename from desktop-widgets/profile/divetextitem.cpp rename to profile-widget/divetextitem.cpp diff --git a/desktop-widgets/profile/divetextitem.h b/profile-widget/divetextitem.h similarity index 100% rename from desktop-widgets/profile/divetextitem.h rename to profile-widget/divetextitem.h diff --git a/desktop-widgets/profile/divetooltipitem.cpp b/profile-widget/divetooltipitem.cpp similarity index 100% rename from desktop-widgets/profile/divetooltipitem.cpp rename to profile-widget/divetooltipitem.cpp diff --git a/desktop-widgets/profile/divetooltipitem.h b/profile-widget/divetooltipitem.h similarity index 100% rename from desktop-widgets/profile/divetooltipitem.h rename to profile-widget/divetooltipitem.h diff --git a/desktop-widgets/profile/profilewidget2.cpp b/profile-widget/profilewidget2.cpp similarity index 100% rename from desktop-widgets/profile/profilewidget2.cpp rename to profile-widget/profilewidget2.cpp diff --git a/desktop-widgets/profile/profilewidget2.h b/profile-widget/profilewidget2.h similarity index 100% rename from desktop-widgets/profile/profilewidget2.h rename to profile-widget/profilewidget2.h diff --git a/desktop-widgets/profile/ruleritem.cpp b/profile-widget/ruleritem.cpp similarity index 100% rename from desktop-widgets/profile/ruleritem.cpp rename to profile-widget/ruleritem.cpp diff --git a/desktop-widgets/profile/ruleritem.h b/profile-widget/ruleritem.h similarity index 100% rename from desktop-widgets/profile/ruleritem.h rename to profile-widget/ruleritem.h diff --git a/desktop-widgets/profile/tankitem.cpp b/profile-widget/tankitem.cpp similarity index 100% rename from desktop-widgets/profile/tankitem.cpp rename to profile-widget/tankitem.cpp diff --git a/desktop-widgets/profile/tankitem.h b/profile-widget/tankitem.h similarity index 100% rename from desktop-widgets/profile/tankitem.h rename to profile-widget/tankitem.h diff --git a/qt-models/CMakeLists.txt b/qt-models/CMakeLists.txt index 463d61412..c9bcf5c3d 100644 --- a/qt-models/CMakeLists.txt +++ b/qt-models/CMakeLists.txt @@ -23,6 +23,7 @@ set(SUBSURFACE_MODELS_LIB_SRCS 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 From 044e593957acc8de045c02003fa468bd76c98767 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 3 Sep 2015 17:10:50 -0300 Subject: [PATCH 09/48] CMake for tests in its own folder Besides making it more simple to add a new test now since you don't need to play hide and seek with the main cmake this has another good thing: on IDE's that scan the cmake to create targets on the project tree, the main project was being popullated with test-targets on the main tree and not inside the tests directory. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 31 ++++++------------------------- tests/CMakeLists.txt | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 25 deletions(-) create mode 100644 tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index b5b0195a6..7abe3d6c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,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) @@ -340,7 +340,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ANDROID) set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lpthread) endif() - # create the executables if(SUBSURFACE_MOBILE) set(MOBILE_SRC @@ -410,29 +409,6 @@ endif() 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(-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) @@ -661,7 +637,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/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..0b322d053 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,28 @@ +# QTest based tests +macro(TEST NAME FILE) + add_executable(${NAME} ${FILE} ${SUBSURFACE_RESOURCES}) + target_link_libraries(${NAME} subsurface_corelib ${QT_TEST_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES}) + add_test(NAME ${NAME} COMMAND $) +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 From 225ac07005e72d52b1f70ae88e7033528789fc21 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 3 Sep 2015 17:19:18 -0300 Subject: [PATCH 10/48] Clear the main CMake file A bit of dust was setting here, when I moved tons of things around I forgot to remove some bits. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7abe3d6c5..8e177c311 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,7 +144,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() @@ -273,7 +272,6 @@ 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) # in some builds we appear to be missing libz for some strange reason... @@ -318,7 +316,6 @@ add_subdirectory(desktop-widgets) if(FBSUPPORT) add_definitions(-DFBSUPPORT) - set(SOCIALNETWORKS qt-ui/socialnetworks.cpp) endif() if(BTSUPPORT) From b35ccc3a3533a3fcf9c7434584470537b6d0001e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 17 Sep 2015 14:04:27 -0300 Subject: [PATCH 11/48] Preferences: start to port preferences to a more sane design Our preferences dialog right now is a rather huge dialog with more than 9 subpages, and all of those pages are programmed inside of the same class, same methods and all that - which means that if I change something on the dialog I can break any other thing quite easily. The idea of this patch series is to make it harder to break user settings and the settings dialog. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/CMakeLists.txt | 2 ++ desktop-widgets/preferences/CMakeLists.txt | 9 +++++++ .../preferences/abstractpreferenceswidget.cpp | 21 +++++++++++++++ .../preferences/abstractpreferenceswidget.h | 27 +++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 desktop-widgets/preferences/CMakeLists.txt create mode 100644 desktop-widgets/preferences/abstractpreferenceswidget.cpp create mode 100644 desktop-widgets/preferences/abstractpreferenceswidget.h diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt index 635a8b68e..6d9051b10 100644 --- a/desktop-widgets/CMakeLists.txt +++ b/desktop-widgets/CMakeLists.txt @@ -13,6 +13,8 @@ include_directories(. ${CMAKE_BINARY_DIR} ) +add_subdirectory(preferences) + # the interface, in C++ set(SUBSURFACE_INTERFACE updatemanager.cpp diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt new file mode 100644 index 000000000..953c587b1 --- /dev/null +++ b/desktop-widgets/preferences/CMakeLists.txt @@ -0,0 +1,9 @@ +# the profile widget +set(SUBSURFACE_PREFERENCES_LIB_SRCS + abstractpreferenceswidget.cpp +) + +source_group("Subsurface Preferences" FILES ${SUBSURFACE_PREFERENCES_LIB_SRCS}) + +add_library(subsurface_desktop_preferences STATIC ${SUBSURFACE_PREFERENCES_LIB_SRCS}) +target_link_libraries(subsurface_desktop_preferences ${QT_LIBRARIES}) \ No newline at end of file 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 +#include + +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 From 255325e219f7d1922ac7740649fdbc89228a36c1 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 17 Sep 2015 15:58:26 -0300 Subject: [PATCH 12/48] Preferences: add a new page for language This is not hooked into anything - It's the bare minimum that I need to continue creating the new preferences dialog. But take a look at it... very simple. :) Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/CMakeLists.txt | 16 +++- .../preferences/preferences_language.cpp | 47 ++++++++++++ .../preferences/preferences_language.h | 21 +++++ desktop-widgets/preferences/prefs_language.ui | 76 +++++++++++++++++++ 4 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 desktop-widgets/preferences/preferences_language.cpp create mode 100644 desktop-widgets/preferences/preferences_language.h create mode 100644 desktop-widgets/preferences/prefs_language.ui diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt index 953c587b1..6af8b4a73 100644 --- a/desktop-widgets/preferences/CMakeLists.txt +++ b/desktop-widgets/preferences/CMakeLists.txt @@ -1,9 +1,21 @@ # 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 + preferences_language.cpp ) source_group("Subsurface Preferences" FILES ${SUBSURFACE_PREFERENCES_LIB_SRCS}) -add_library(subsurface_desktop_preferences STATIC ${SUBSURFACE_PREFERENCES_LIB_SRCS}) -target_link_libraries(subsurface_desktop_preferences ${QT_LIBRARIES}) \ No newline at end of file +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/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp new file mode 100644 index 000000000..7254482e2 --- /dev/null +++ b/desktop-widgets/preferences/preferences_language.cpp @@ -0,0 +1,47 @@ +#include "preferences_language.h" +#include "ui_prefs_language.h" + +#include +#include +#include + + +PreferencesLanguage::PreferencesLanguage() : AbstractPreferencesWidget(tr("Language"), QIcon(":/language"), 4) +{ + ui = new Ui::PreferencesLanguage(); + ui->setupUi(this); +} + +PreferencesLanguage::~PreferencesLanguage() +{ + delete ui; +} + +void PreferencesLanguage::refreshSettings() +{ + QSettings s; + 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(); +} + +void PreferencesLanguage::syncSettings() +{ + // Locale + QLocale loc; + QSettings s; + 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(this, 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(); +} \ No newline at end of file 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/prefs_language.ui b/desktop-widgets/preferences/prefs_language.ui new file mode 100644 index 000000000..80671fca8 --- /dev/null +++ b/desktop-widgets/preferences/prefs_language.ui @@ -0,0 +1,76 @@ + + + PreferencesLanguage + + + + 0 + 0 + 576 + 523 + + + + Form + + + + + + + 0 + 0 + + + + UI language + + + + + + System default + + + + + + + Qt::Horizontal + + + + 203 + 20 + + + + + + + + Filter + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + From b7a476169d50dbf4d40b134faac5b88cabd4fa17 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 17 Sep 2015 17:16:40 -0300 Subject: [PATCH 13/48] Preferecnes: add the initial skeleton This Preferences dialog should be visually similar to the old one - the main difference is how it acts on the preferences. It's also not based on .ui files since it's a very simple widget I prefered to mount it by hand - no more than 6 lines of c++ code. Right now we have only one preference page on this, and nothing is hoocked up. I've also changed mainwindow a bit to only show this dialog for testing purposes. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/CMakeLists.txt | 2 +- desktop-widgets/mainwindow.cpp | 3 + desktop-widgets/preferences/CMakeLists.txt | 1 + .../preferences/preferencesdialog.cpp | 83 +++++++++++++++++++ .../preferences/preferencesdialog.h | 30 +++++++ 5 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 desktop-widgets/preferences/preferencesdialog.cpp create mode 100644 desktop-widgets/preferences/preferencesdialog.h diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt index 6d9051b10..7b3e60f3b 100644 --- a/desktop-widgets/CMakeLists.txt +++ b/desktop-widgets/CMakeLists.txt @@ -91,4 +91,4 @@ 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}) +target_link_libraries(subsurface_interface ${QT_LIBRARIES} ${MARBLE_LIBRARIES} subsurface_desktop_preferences) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 43b433d62..156034598 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -40,6 +40,7 @@ #include "divesitehelpers.h" #include "windowtitleupdate.h" #include "locationinformation.h" +#include "preferences/preferencesdialog.h" #ifndef NO_USERMANUAL #include "usermanual.h" @@ -254,6 +255,8 @@ MainWindow::MainWindow() : QMainWindow(), ui.menubar->show(); set_git_update_cb(&updateProgress); + PreferencesDialogV2 *d = new PreferencesDialogV2(); + d->show(); } MainWindow::~MainWindow() diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt index 6af8b4a73..468501e7d 100644 --- a/desktop-widgets/preferences/CMakeLists.txt +++ b/desktop-widgets/preferences/CMakeLists.txt @@ -11,6 +11,7 @@ source_group("Subsurface Interface Files" FILES ${SUBSURFACE_PREFERENCES_UI}) set(SUBSURFACE_PREFERENCES_LIB_SRCS abstractpreferenceswidget.cpp + preferencesdialog.cpp preferences_language.cpp ) diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp new file mode 100644 index 000000000..b2eb77975 --- /dev/null +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -0,0 +1,83 @@ +#include "preferencesdialog.h" + +#include "abstractpreferenceswidget.h" +#include "preferences_language.h" + +#include +#include +#include +#include +#include + +PreferencesDialogV2::PreferencesDialogV2() +{ + pagesList = new QListWidget(); + pagesStack = new QStackedWidget(); + buttonBox = new QDialogButtonBox(QDialogButtonBox::Apply|QDialogButtonBox::RestoreDefaults|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()); + refreshPages(); + connect(pagesList, &QListWidget::currentRowChanged, + pagesStack, &QStackedWidget::setCurrentIndex); +} + +PreferencesDialogV2::~PreferencesDialogV2() +{ +} + +bool abstractpreferenceswidget_lessthan(AbstractPreferencesWidget *p1, AbstractPreferencesWidget *p2) +{ + return p1->positionHeight() <= p2->positionHeight(); +} + +void PreferencesDialogV2::addPreferencePage(AbstractPreferencesWidget *page) +{ + pages.push_back(page); + qSort(pages.begin(), pages.end(), abstractpreferenceswidget_lessthan); +} + +void PreferencesDialogV2::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); + } +} + +void PreferencesDialogV2::applyRequested() +{ + //TODO +} + +void PreferencesDialogV2::cancelRequested() +{ + //TODO +} + +void PreferencesDialogV2::defaultsRequested() +{ + //TODO +} diff --git a/desktop-widgets/preferences/preferencesdialog.h b/desktop-widgets/preferences/preferencesdialog.h new file mode 100644 index 000000000..a1db94b43 --- /dev/null +++ b/desktop-widgets/preferences/preferencesdialog.h @@ -0,0 +1,30 @@ +#ifndef PREFERENCES_WIDGET_H +#define PREFERENCES_WIDGET_H + +#include +#include "pref.h" + +class AbstractPreferencesWidget; +class QListWidget; +class QStackedWidget; +class QDialogButtonBox; + +class PreferencesDialogV2 : public QDialog { + Q_OBJECT +public: + PreferencesDialogV2(); + virtual ~PreferencesDialogV2(); + void addPreferencePage(AbstractPreferencesWidget *page); + void refreshPages(); +private: + void cancelRequested(); + void applyRequested(); + void defaultsRequested(); + + QList pages; + QListWidget *pagesList; + QStackedWidget *pagesStack; + QDialogButtonBox *buttonBox; +}; + +#endif \ No newline at end of file From b7daffbf084c44b099c9d1f84fb3935ce5735b39 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 17 Sep 2015 17:53:39 -0300 Subject: [PATCH 14/48] Preferences: Hook up the dialog buttons and make it work Since I'm using a dialog created by hand, I also need to hook things by hand. the code is very simple - debug output kept in just to make sure things are indeed working. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- .../preferences/preferencesdialog.cpp | 29 +++++++++++++++---- .../preferences/preferencesdialog.h | 3 +- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index b2eb77975..e21207761 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -8,12 +8,17 @@ #include #include #include +#include +#include PreferencesDialogV2::PreferencesDialogV2() { pagesList = new QListWidget(); pagesStack = new QStackedWidget(); - buttonBox = new QDialogButtonBox(QDialogButtonBox::Apply|QDialogButtonBox::RestoreDefaults|QDialogButtonBox::Cancel); + buttonBox = new QDialogButtonBox( + QDialogButtonBox::Save | + QDialogButtonBox::RestoreDefaults | + QDialogButtonBox::Cancel); pagesList->setMinimumWidth(120); pagesList->setMaximumWidth(120); @@ -21,23 +26,35 @@ PreferencesDialogV2::PreferencesDialogV2() 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()); refreshPages(); + connect(pagesList, &QListWidget::currentRowChanged, pagesStack, &QStackedWidget::setCurrentIndex); + connect(buttonBox, &QDialogButtonBox::clicked, + this, &PreferencesDialogV2::buttonClicked); } PreferencesDialogV2::~PreferencesDialogV2() { } +void PreferencesDialogV2::buttonClicked(QAbstractButton* btn) +{ + QDialogButtonBox::ButtonRole role = buttonBox->buttonRole(btn); + switch(role) { + case QDialogButtonBox::AcceptRole : applyRequested(); return; + case QDialogButtonBox::RejectRole : cancelRequested(); return; + case QDialogButtonBox::ResetRole : defaultsRequested(); return; + } +} + bool abstractpreferenceswidget_lessthan(AbstractPreferencesWidget *p1, AbstractPreferencesWidget *p2) { return p1->positionHeight() <= p2->positionHeight(); @@ -69,15 +86,15 @@ void PreferencesDialogV2::refreshPages() void PreferencesDialogV2::applyRequested() { - //TODO + qDebug() << "Apply Clicked"; } void PreferencesDialogV2::cancelRequested() { - //TODO + qDebug() << "Cancel Clicked"; } void PreferencesDialogV2::defaultsRequested() { - //TODO + qDebug() << "Defaults Clicked"; } diff --git a/desktop-widgets/preferences/preferencesdialog.h b/desktop-widgets/preferences/preferencesdialog.h index a1db94b43..dcc97bf94 100644 --- a/desktop-widgets/preferences/preferencesdialog.h +++ b/desktop-widgets/preferences/preferencesdialog.h @@ -8,6 +8,7 @@ class AbstractPreferencesWidget; class QListWidget; class QStackedWidget; class QDialogButtonBox; +class QAbstractButton; class PreferencesDialogV2 : public QDialog { Q_OBJECT @@ -20,7 +21,7 @@ private: void cancelRequested(); void applyRequested(); void defaultsRequested(); - + void buttonClicked(QAbstractButton *btn); QList pages; QListWidget *pagesList; QStackedWidget *pagesStack; From c0d16267afd66e03591a449d9fa4bff78903b203 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 17 Sep 2015 17:57:41 -0300 Subject: [PATCH 15/48] Preferences: Apply / Cancel / Defaults All functions that should control the preferences are created. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/preferencesdialog.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index e21207761..a50e6c406 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -86,15 +86,22 @@ void PreferencesDialogV2::refreshPages() void PreferencesDialogV2::applyRequested() { - qDebug() << "Apply Clicked"; + Q_FOREACH(AbstractPreferencesWidget *page, pages) { + page->syncSettings(); + } } void PreferencesDialogV2::cancelRequested() { - qDebug() << "Cancel Clicked"; + Q_FOREACH(AbstractPreferencesWidget *page, pages) { + page->refreshSettings(); + } } void PreferencesDialogV2::defaultsRequested() { - qDebug() << "Defaults Clicked"; + prefs = default_prefs; + Q_FOREACH(AbstractPreferencesWidget *page, pages) { + page->refreshSettings(); + } } From c06813317f1030f4c16968fc523746c064d24aab Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 17 Sep 2015 18:08:24 -0300 Subject: [PATCH 16/48] Preferences: hook up the missing parts for the language prefs ui And this actually made me find one memory leak on the old version: We are constantly creating / leaking a new QSortFilterProxyModel everytime a sync() is done on the settings. That's not a lot, maybe once per time a user changes its settings... but it's still a leak. And the code is more sanely separated this time. yey. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/preferences_language.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp index 7254482e2..f9cd1da93 100644 --- a/desktop-widgets/preferences/preferences_language.cpp +++ b/desktop-widgets/preferences/preferences_language.cpp @@ -4,12 +4,23 @@ #include #include #include +#include +#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->languageView->setModel(filterModel); + filterModel->sort(0); + connect(ui->languageFilter, &QLineEdit::textChanged, + filterModel, &QSortFilterProxyModel::setFilterFixedString); + } PreferencesLanguage::~PreferencesLanguage() From 5461eadd1bd88844194073c56a2f8397c98dda04 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 17 Sep 2015 18:10:32 -0300 Subject: [PATCH 17/48] Preferences: start with all settings set Load all settings as soon as we start the preferences. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/preferencesdialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index a50e6c406..5bdc75dbb 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -81,6 +81,7 @@ void PreferencesDialogV2::refreshPages() QListWidgetItem *item = new QListWidgetItem(page->icon(), page->name()); pagesList->addItem(item); pagesStack->addWidget(page); + page->refreshSettings(); } } From 315641b0b497a06dd508d8dee08b792623e091c7 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 17 Sep 2015 19:22:19 -0300 Subject: [PATCH 18/48] Preferences: add GeoReference Straigth port from the old version. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/CMakeLists.txt | 1 + .../preferences/preferences_georeference.cpp | 45 +++++++ .../preferences/preferences_georeference.h | 21 +++ .../preferences/preferencesdialog.cpp | 2 + .../preferences/prefs_georeference.ui | 123 ++++++++++++++++++ 5 files changed, 192 insertions(+) create mode 100644 desktop-widgets/preferences/preferences_georeference.cpp create mode 100644 desktop-widgets/preferences/preferences_georeference.h create mode 100644 desktop-widgets/preferences/prefs_georeference.ui diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt index 468501e7d..4eb2f7d23 100644 --- a/desktop-widgets/preferences/CMakeLists.txt +++ b/desktop-widgets/preferences/CMakeLists.txt @@ -13,6 +13,7 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS abstractpreferenceswidget.cpp preferencesdialog.cpp preferences_language.cpp + preferences_georeference.cpp ) source_group("Subsurface Preferences" FILES ${SUBSURFACE_PREFERENCES_LIB_SRCS}) 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 +#include + +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/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index 5bdc75dbb..3975994a9 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -2,6 +2,7 @@ #include "abstractpreferenceswidget.h" #include "preferences_language.h" +#include "preferences_georeference.h" #include #include @@ -33,6 +34,7 @@ PreferencesDialogV2::PreferencesDialogV2() setLayout(v); addPreferencePage(new PreferencesLanguage()); + addPreferencePage(new PreferencesGeoreference()); refreshPages(); connect(pagesList, &QListWidget::currentRowChanged, 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 @@ + + + PreferencesGeoreference + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Dive site geo lookup + + + + + + Enable geocoding for dive site management + + + + + + + Parse site without GPS data + + + + + + + Same format for existing dives + + + + + + + + + + Dive Site Layout + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + / + + + + + + + + 0 + 0 + + + + + + + + / + + + + + + + + 0 + 0 + + + + + + + + + + + Qt::Vertical + + + + 20 + 109 + + + + + + + + + From 8cdae5ce24fbb2795ef4ee2cd5d35805e4d5646d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 17 Sep 2015 19:22:44 -0300 Subject: [PATCH 19/48] Code cleanup Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/preferences_language.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp index f9cd1da93..07b60c3a3 100644 --- a/desktop-widgets/preferences/preferences_language.cpp +++ b/desktop-widgets/preferences/preferences_language.cpp @@ -20,7 +20,6 @@ PreferencesLanguage::PreferencesLanguage() : AbstractPreferencesWidget(tr("Langu filterModel->sort(0); connect(ui->languageFilter, &QLineEdit::textChanged, filterModel, &QSortFilterProxyModel::setFilterFixedString); - } PreferencesLanguage::~PreferencesLanguage() @@ -42,8 +41,6 @@ void PreferencesLanguage::refreshSettings() void PreferencesLanguage::syncSettings() { - // Locale - QLocale loc; QSettings s; s.beginGroup("Language"); bool useSystemLang = s.value("UseSystemLanguage", true).toBool(); From 7cd9e2b7bb101719ec5c50a10fc889ba4b7bd9c5 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 17 Sep 2015 19:24:26 -0300 Subject: [PATCH 20/48] Make icons work again Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 2 ++ desktop-widgets/CMakeLists.txt | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e177c311..99e22116e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -307,6 +307,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows") add_definitions(-mwindows -D_WIN32) endif() +qt5_add_resources(SUBSURFACE_RESOURCES subsurface.qrc) + # include translations add_subdirectory(translations) add_subdirectory(subsurface-core) diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt index 7b3e60f3b..07a8f3709 100644 --- a/desktop-widgets/CMakeLists.txt +++ b/desktop-widgets/CMakeLists.txt @@ -1,7 +1,6 @@ # create the libraries file(GLOB SUBSURFACE_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}) if(BTSUPPORT) From 1d2d046c0f80d8884d783aad57340c9b6867985a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 25 Sep 2015 16:15:37 -0300 Subject: [PATCH 21/48] Preferences: Port the default preferences to the new system Simple port of the default preferences to the new preferences structure. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences.cpp | 83 +----- desktop-widgets/preferences.h | 5 - desktop-widgets/preferences.ui | 276 +----------------- desktop-widgets/preferences/CMakeLists.txt | 1 + .../preferences/preferences_defaults.cpp | 115 ++++++++ .../preferences/preferences_defaults.h | 30 ++ .../preferences/preferences_defaults.ui | 251 ++++++++++++++++ .../preferences/preferencesdialog.cpp | 2 + 8 files changed, 402 insertions(+), 361 deletions(-) create mode 100644 desktop-widgets/preferences/preferences_defaults.cpp create mode 100644 desktop-widgets/preferences/preferences_defaults.h create mode 100644 desktop-widgets/preferences/preferences_defaults.ui diff --git a/desktop-widgets/preferences.cpp b/desktop-widgets/preferences.cpp index 6450c41cb..cb19ce759 100644 --- a/desktop-widgets/preferences.cpp +++ b/desktop-widgets/preferences.cpp @@ -118,12 +118,8 @@ void PreferencesDialog::cloudPinNeeded() 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(); } @@ -186,24 +182,11 @@ void PreferencesDialog::setUiFromPrefs() 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()); @@ -232,7 +215,7 @@ void PreferencesDialog::setUiFromPrefs() 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); @@ -302,27 +285,11 @@ void PreferencesDialog::syncSettings() // 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"); @@ -336,11 +303,6 @@ void PreferencesDialog::syncSettings() 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()); @@ -445,10 +407,6 @@ void PreferencesDialog::loadSettings() 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) @@ -472,15 +430,6 @@ void PreferencesDialog::buttonClicked(QAbstractButton *button) } #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; @@ -529,31 +478,3 @@ void PreferencesDialog::proxyType_changed(int idx) 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/desktop-widgets/preferences.h b/desktop-widgets/preferences.h index 326b1f964..c05145611 100644 --- a/desktop-widgets/preferences.h +++ b/desktop-widgets/preferences.h @@ -24,7 +24,6 @@ signals: public slots: void buttonClicked(QAbstractButton *button); - void on_chooseFile_clicked(); void on_resetSettings_clicked(); void syncSettings(); void loadSettings(); @@ -33,10 +32,6 @@ slots: 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(); diff --git a/desktop-widgets/preferences.ui b/desktop-widgets/preferences.ui index de2d79b91..aa5dc4cb5 100644 --- a/desktop-widgets/preferences.ui +++ b/desktop-widgets/preferences.ui @@ -164,7 +164,7 @@ - 4 + 0 @@ -180,232 +180,6 @@ 5 - - - - Lists and tables - - - - 5 - - - - - Font - - - - - - - - - - Font size - - - - - - - - - - - - - Dives - - - - 5 - - - 5 - - - 5 - - - - - Default dive log file - - - - - - - - - No default file - - - defaultFileGroup - - - - - - - &Local default file - - - defaultFileGroup - - - - - - - Clo&ud storage default file - - - defaultFileGroup - - - - - - - - - Local dive log file - - - - - - - - - - - - Use default - - - true - - - - - - - ... - - - - - - - - - Display invalid - - - - - - - - - - - - - - - - - Default cylinder - - - - 5 - - - 5 - - - 5 - - - - - Use default cylinder - - - - - - - - - - - - - - - - - Animations - - - - 5 - - - - - Speed - - - - - - - 500 - - - Qt::Horizontal - - - - - - - 500 - - - - - - - - - - Clear all settings - - - - 5 - - - 5 - - - - - Reset all settings to their default value - - - - - - @@ -1788,38 +1562,6 @@ - - velocitySlider - valueChanged(int) - velocitySpinBox - setValue(int) - - - 236 - 52 - - - 236 - 52 - - - - - velocitySpinBox - valueChanged(int) - velocitySlider - setValue(int) - - - 236 - 52 - - - 236 - 52 - - - proxyAuthRequired toggled(bool) @@ -1852,22 +1594,6 @@ - - btnUseDefaultFile - toggled(bool) - chooseFile - setHidden(bool) - - - 236 - 44 - - - 236 - 44 - - - diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt index 4eb2f7d23..c55d7b881 100644 --- a/desktop-widgets/preferences/CMakeLists.txt +++ b/desktop-widgets/preferences/CMakeLists.txt @@ -14,6 +14,7 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS preferencesdialog.cpp preferences_language.cpp preferences_georeference.cpp + preferences_defaults.cpp ) source_group("Subsurface Preferences" FILES ${SUBSURFACE_PREFERENCES_LIB_SRCS}) diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp new file mode 100644 index 000000000..637117105 --- /dev/null +++ b/desktop-widgets/preferences/preferences_defaults.cpp @@ -0,0 +1,115 @@ +#include "preferences_defaults.h" +#include "ui_preferences_defaults.h" +#include "dive.h" +#include "subsurface-core/prefs-macros.h" + +#include +#include + +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_noDefaultFile_toggled(bool toggle) +{ + prefs.default_file_behavior = NO_DEFAULT_FILE; +} + +void PreferencesDefaults::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 PreferencesDefaults::on_cloudDefaultFile_toggled(bool toggle) +{ + prefs.default_file_behavior = CLOUD_DEFAULT_FILE; +} + +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..94de8b28a --- /dev/null +++ b/desktop-widgets/preferences/preferences_defaults.h @@ -0,0 +1,30 @@ +#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_noDefaultFile_toggled(bool toggled); + void on_localDefaultFile_toggled(bool toggled); + void on_cloudDefaultFile_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 @@ + + + PreferencesDefaults + + + + 0 + 0 + 555 + 558 + + + + Form + + + + + + Lists and tables + + + + 5 + + + + + Font + + + + + + + + + + Font size + + + + + + + + + + + + + Dives + + + + 5 + + + 5 + + + 5 + + + + + Default dive log file + + + + + + + + + No default file + + + + + + + &Local default file + + + + + + + Clo&ud storage default file + + + + + + + + + Local dive log file + + + + + + + + + + + + Use default + + + true + + + + + + + ... + + + + + + + + + Display invalid + + + + + + + + + + + + + + + + + Default cylinder + + + + 5 + + + 5 + + + 5 + + + + + Use default cylinder + + + + + + + + + + + + + + + + + Animations + + + + 5 + + + + + Speed + + + + + + + 500 + + + Qt::Horizontal + + + + + + + 500 + + + + + + + + + + Clear all settings + + + + 5 + + + 5 + + + + + Reset all settings to their default value + + + + + + + + + + Qt::Vertical + + + + 0 + 195 + + + + + + + + + diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index 3975994a9..6f66d856d 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -3,6 +3,7 @@ #include "abstractpreferenceswidget.h" #include "preferences_language.h" #include "preferences_georeference.h" +#include "preferences_defaults.h" #include #include @@ -35,6 +36,7 @@ PreferencesDialogV2::PreferencesDialogV2() addPreferencePage(new PreferencesLanguage()); addPreferencePage(new PreferencesGeoreference()); + addPreferencePage(new PreferencesDefaults()); refreshPages(); connect(pagesList, &QListWidget::currentRowChanged, From c53615315e151a2790218c13898f128d561df1b9 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 25 Sep 2015 16:25:05 -0300 Subject: [PATCH 22/48] Code cleanup Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences.cpp | 48 +----- desktop-widgets/preferences.ui | 268 +------------------------------- 2 files changed, 4 insertions(+), 312 deletions(-) diff --git a/desktop-widgets/preferences.cpp b/desktop-widgets/preferences.cpp index cb19ce759..2ce96bd77 100644 --- a/desktop-widgets/preferences.cpp +++ b/desktop-widgets/preferences.cpp @@ -48,10 +48,6 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial 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); @@ -187,28 +183,11 @@ void PreferencesDialog::setUiFromPrefs() ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES); ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS); - - 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); @@ -222,17 +201,6 @@ void PreferencesDialog::setUiFromPrefs() 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() @@ -290,19 +258,6 @@ void PreferencesDialog::syncSettings() s.setValue("pscr_ratio", rint(1000.0 / ui.pscrfactor->value())); s.endGroup(); - // 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(); - s.beginGroup("Network"); s.setValue("proxy_type", ui.proxyType->itemData(ui.proxyType->currentIndex()).toInt()); s.setValue("proxy_host", ui.proxyHost->text()); @@ -381,6 +336,7 @@ void PreferencesDialog::syncSettings() SAVE_OR_REMOVE("cloud_base_url", default_prefs.cloud_base_url, prefs.cloud_base_url); s.endGroup(); +<<<<<<< HEAD s.beginGroup("geocoding"); #ifdef DISABLED s.setValue("enable_geocoding", ui.enable_geocoding->isChecked()); @@ -392,6 +348,8 @@ void PreferencesDialog::syncSettings() s.setValue("cat2", ui.third_item->currentIndex()); s.endGroup(); +======= +>>>>>>> Code Cleanup loadSettings(); emit settingsChanged(); } diff --git a/desktop-widgets/preferences.ui b/desktop-widgets/preferences.ui index aa5dc4cb5..a799d966c 100644 --- a/desktop-widgets/preferences.ui +++ b/desktop-widgets/preferences.ui @@ -83,16 +83,6 @@ -1 - - - Defaults - - - - :/subsurface-icon - - - Units @@ -113,16 +103,6 @@ - - - Language - - - - :/advanced - - - Network @@ -143,16 +123,6 @@ - - - Georeference - - - - :/georeference - - - @@ -164,37 +134,8 @@ - 0 + 3 - - - - 0 - 0 - - - - - 5 - - - 5 - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - @@ -787,93 +728,6 @@
- - - - 0 - 0 - - - - - 5 - - - QLayout::SetNoConstraint - - - 5 - - - - - - 0 - 0 - - - - UI language - - - - - - System default - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Filter - - - - - - - - - - - - - - 0 - 0 - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - @@ -1200,94 +1054,6 @@ - - - - 0 - 0 - - - - - 5 - - - 5 - - - - - Dive Site Layout - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - / - - - - - - - - 0 - 0 - - - - - - - - / - - - - - - - - 0 - 0 - - - - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - @@ -1370,38 +1136,6 @@ - - languageSystemDefault - toggled(bool) - languageView - setDisabled(bool) - - - 231 - 26 - - - 186 - 30 - - - - - languageSystemDefault - toggled(bool) - languageFilter - setDisabled(bool) - - - 231 - 26 - - - 185 - 20 - - - imperial toggled(bool) From 57d7b59bdc62a5b01fa420bc420dbdcf1414a23a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 25 Sep 2015 17:07:04 -0300 Subject: [PATCH 23/48] Preferences: move units to the new dialog Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences.cpp | 39 -- desktop-widgets/preferences.ui | 489 +----------------- desktop-widgets/preferences/CMakeLists.txt | 1 + .../preferences/preferences_units.cpp | 60 +++ .../preferences/preferences_units.h | 21 + .../preferences/preferences_units.ui | 251 +++++++++ .../preferences/preferencesdialog.cpp | 2 + 7 files changed, 336 insertions(+), 527 deletions(-) create mode 100644 desktop-widgets/preferences/preferences_units.cpp create mode 100644 desktop-widgets/preferences/preferences_units.h create mode 100644 desktop-widgets/preferences/preferences_units.ui diff --git a/desktop-widgets/preferences.cpp b/desktop-widgets/preferences.cpp index 2ce96bd77..672d75906 100644 --- a/desktop-widgets/preferences.cpp +++ b/desktop-widgets/preferences.cpp @@ -146,7 +146,6 @@ void PreferencesDialog::setUiFromPrefs() 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); @@ -157,31 +156,8 @@ void PreferencesDialog::setUiFromPrefs() 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.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); QSettings s; @@ -237,20 +213,6 @@ void PreferencesDialog::syncSettings() 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("defaultsetpoint", rint(ui.defaultSetpoint->value() * 1000.0)); @@ -391,7 +353,6 @@ void PreferencesDialog::buttonClicked(QAbstractButton *button) void PreferencesDialog::on_resetSettings_clicked() { QSettings s; - QMessageBox response(this); response.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); response.setDefaultButton(QMessageBox::Cancel); diff --git a/desktop-widgets/preferences.ui b/desktop-widgets/preferences.ui index a799d966c..12ba10d4b 100644 --- a/desktop-widgets/preferences.ui +++ b/desktop-widgets/preferences.ui @@ -83,16 +83,6 @@ -1 - - - Units - - - - :/units - - - Graph @@ -134,309 +124,8 @@ - 3 + 0 - - - - 0 - 0 - - - - - 5 - - - 5 - - - - - Unit system - - - - - - System - - - - - - - &Metric - - - buttonGroup_6 - - - - - - - Imperial - - - buttonGroup_6 - - - - - - - Personali&ze - - - buttonGroup_6 - - - - - - - - - - Individual settings - - - false - - - false - - - - - - Depth - - - - - - - meter - - - buttonGroup - - - - - - - feet - - - buttonGroup - - - - - - - Pressure - - - - - - - bar - - - buttonGroup_2 - - - - - - - psi - - - buttonGroup_2 - - - - - - - Volume - - - - - - - &liter - - - buttonGroup_3 - - - - - - - cu ft - - - buttonGroup_3 - - - - - - - Temperature - - - - - - - celsius - - - buttonGroup_4 - - - - - - - fahrenheit - - - buttonGroup_4 - - - - - - - Weight - - - - - - - kg - - - buttonGroup_5 - - - - - - - lbs - - - buttonGroup_5 - - - - - - - - - - - - Time units - - - - - - Ascent/descent speed denominator - - - - - - - Minutes - - - verticalSpeed - - - - - - - Seconds - - - verticalSpeed - - - - - - - - - - - - GPS coordinates - - - - - - Location Display - - - - - - - traditional (dms) - - - buttonGroup_7 - - - - - - - decimal - - - buttonGroup_7 - - - - - - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - @@ -1120,182 +809,6 @@ - - personalize - toggled(bool) - units_group - setEnabled(bool) - - - 185 - 19 - - - 186 - 23 - - - - - imperial - toggled(bool) - feet - setChecked(bool) - - - 164 - 19 - - - 175 - 34 - - - - - metric - toggled(bool) - meter - setChecked(bool) - - - 142 - 19 - - - 153 - 34 - - - - - imperial - toggled(bool) - psi - setChecked(bool) - - - 164 - 19 - - - 175 - 33 - - - - - metric - toggled(bool) - bar - setChecked(bool) - - - 142 - 19 - - - 153 - 33 - - - - - imperial - toggled(bool) - cuft - setChecked(bool) - - - 164 - 19 - - - 175 - 31 - - - - - metric - toggled(bool) - liter - setChecked(bool) - - - 142 - 19 - - - 153 - 31 - - - - - imperial - toggled(bool) - fahrenheit - setChecked(bool) - - - 164 - 19 - - - 175 - 29 - - - - - metric - toggled(bool) - celsius - setChecked(bool) - - - 142 - 19 - - - 153 - 29 - - - - - imperial - toggled(bool) - lbs - setChecked(bool) - - - 164 - 19 - - - 175 - 28 - - - - - metric - toggled(bool) - kg - setChecked(bool) - - - 142 - 19 - - - 153 - 28 - - - proxyAuthRequired toggled(bool) diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt index c55d7b881..8ea4bd79c 100644 --- a/desktop-widgets/preferences/CMakeLists.txt +++ b/desktop-widgets/preferences/CMakeLists.txt @@ -15,6 +15,7 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS preferences_language.cpp preferences_georeference.cpp preferences_defaults.cpp + preferences_units.cpp ) source_group("Subsurface Preferences" FILES ${SUBSURFACE_PREFERENCES_LIB_SRCS}) diff --git a/desktop-widgets/preferences/preferences_units.cpp b/desktop-widgets/preferences/preferences_units.cpp new file mode 100644 index 000000000..76f2078d7 --- /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 + +PreferencesUnits::PreferencesUnits(): AbstractPreferencesWidget(tr("Units"),QIcon(":units"),1), ui(new Ui::PreferencesUnits()) +{ + ui->setupUi(this); +} + +PreferencesUnits::~PreferencesUnits() +{ + +} + +void PreferencesUnits::refreshSettings() +{ + 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(); +} + +void PreferencesUnits::syncSettings() +{ + 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); +} 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 @@ + + + PreferencesUnits + + + + 0 + 0 + 400 + 374 + + + + Form + + + + + + Unit system + + + + + + System + + + + + + + &Metric + + + + + + + Imperial + + + + + + + Personali&ze + + + + + + + + + + Individual settings + + + false + + + false + + + + + + Depth + + + + + + + meter + + + + + + + feet + + + + + + + Pressure + + + + + + + bar + + + + + + + psi + + + + + + + Volume + + + + + + + &liter + + + + + + + cu ft + + + + + + + Temperature + + + + + + + celsius + + + + + + + fahrenheit + + + + + + + Weight + + + + + + + kg + + + + + + + lbs + + + + + + + + + + Time units + + + + + + Ascent/descent speed denominator + + + + + + + Minutes + + + + + + + Seconds + + + + + + + + + + GPS coordinates + + + + + + Location Display + + + + + + + traditional (dms) + + + + + + + decimal + + + + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + + diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index 6f66d856d..7d9e17d7e 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -4,6 +4,7 @@ #include "preferences_language.h" #include "preferences_georeference.h" #include "preferences_defaults.h" +#include "preferences_units.h" #include #include @@ -37,6 +38,7 @@ PreferencesDialogV2::PreferencesDialogV2() addPreferencePage(new PreferencesLanguage()); addPreferencePage(new PreferencesGeoreference()); addPreferencePage(new PreferencesDefaults()); + addPreferencePage(new PreferencesUnits()); refreshPages(); connect(pagesList, &QListWidget::currentRowChanged, From cfecd1a9ab6f1ac870622427af56fa43a87bf14b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 1 Oct 2015 18:59:53 -0300 Subject: [PATCH 24/48] Preferences: move graph preferences to the new dialog Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences.cpp | 56 +-- desktop-widgets/preferences.h | 2 - desktop-widgets/preferences.ui | 360 ++---------------- desktop-widgets/preferences/CMakeLists.txt | 1 + .../preferences/preferences_graph.cpp | 78 ++++ .../preferences/preferences_graph.h | 27 ++ .../preferences/preferences_graph.ui | 268 +++++++++++++ .../preferences/preferencesdialog.cpp | 2 + 8 files changed, 419 insertions(+), 375 deletions(-) create mode 100644 desktop-widgets/preferences/preferences_graph.cpp create mode 100644 desktop-widgets/preferences/preferences_graph.h create mode 100644 desktop-widgets/preferences/preferences_graph.ui diff --git a/desktop-widgets/preferences.cpp b/desktop-widgets/preferences.cpp index 672d75906..9ef93fafc 100644 --- a/desktop-widgets/preferences.cpp +++ b/desktop-widgets/preferences.cpp @@ -64,8 +64,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial #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())); @@ -120,17 +119,6 @@ void PreferencesDialog::cloudPinNeeded() 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(); @@ -140,25 +128,6 @@ void PreferencesDialog::showEvent(QShowEvent *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.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); - QSettings s; ui.save_uid_local->setChecked(s.value("save_uid_local").toBool()); @@ -197,29 +166,6 @@ void PreferencesDialog::syncSettings() 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(); - - // Defaults - 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("Network"); s.setValue("proxy_type", ui.proxyType->itemData(ui.proxyType->currentIndex()).toInt()); s.setValue("proxy_host", ui.proxyHost->text()); diff --git a/desktop-widgets/preferences.h b/desktop-widgets/preferences.h index c05145611..4d2c33e76 100644 --- a/desktop-widgets/preferences.h +++ b/desktop-widgets/preferences.h @@ -29,8 +29,6 @@ slots: void loadSettings(); void restorePrefs(); void rememberPrefs(); - void gflowChanged(int gf); - void gfhighChanged(int gf); void proxyType_changed(int idx); void facebookLoggedIn(); void facebookDisconnect(); diff --git a/desktop-widgets/preferences.ui b/desktop-widgets/preferences.ui index 12ba10d4b..97e281433 100644 --- a/desktop-widgets/preferences.ui +++ b/desktop-widgets/preferences.ui @@ -6,8 +6,8 @@ 0 0 - 711 - 662 + 835 + 698 @@ -19,7 +19,16 @@ - + + 5 + + + 5 + + + 5 + + 5 @@ -83,16 +92,6 @@ -1 - - - Graph - - - - :/graph - - - Network @@ -126,297 +125,6 @@ 0 - - - - 0 - 0 - - - - - 5 - - - 5 - - - - - Show - - - - - - - - true - - - Threshold when showing pOâ‚‚ - - - - - - - true - - - 0.100000000000000 - - - - - - - - - - - true - - - Threshold when showing pNâ‚‚ - - - - - - - true - - - 0.100000000000000 - - - - - - - - - - - true - - - Threshold when showing pHe - - - - - - - true - - - 0.100000000000000 - - - - - - - - - - - true - - - Max pOâ‚‚ when showing MOD - - - - - - - true - - - 0.100000000000000 - - - - - - - - - - - true - - - Draw dive computer reported ceiling red - - - - - - - - - - - Show unused cylinders in Equipment tab - - - - - - - - - - - Show average depth - - - - - - - - - - - - Misc - - - - - - GFLow - - - - - - - 1 - - - 150 - - - - - - - GFHigh - - - - - - - 1 - - - 150 - - - - - - - GFLow at max depth - - - - - - - CCR: show setpoints when viewing pOâ‚‚ - - - - - - - CCR: show individual Oâ‚‚ sensor values when viewing pOâ‚‚ - - - - - - - Default CCR set-point for dive planning - - - - - - - bar - - - 2 - - - 10.000000000000000 - - - 0.100000000000000 - - - - - - - pSCR Oâ‚‚ metabolism rate - - - - - - - pSCR ratio - - - - - - - â„“/min - - - 3 - - - - - - - - - - 1: - - - - - - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - @@ -428,7 +136,16 @@ 5 - + + 5 + + + 5 + + + 5 + + 5 @@ -658,7 +375,16 @@ 5 - + + 5 + + + 5 + + + 5 + + 5 @@ -707,7 +433,16 @@ 5 - + + 5 + + + 5 + + + 5 + + 5 @@ -842,15 +577,4 @@ - - - - - - - - - - - diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt index 8ea4bd79c..b3ef4e3d5 100644 --- a/desktop-widgets/preferences/CMakeLists.txt +++ b/desktop-widgets/preferences/CMakeLists.txt @@ -16,6 +16,7 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS preferences_georeference.cpp preferences_defaults.cpp preferences_units.cpp + preferences_graph.cpp ) source_group("Subsurface Preferences" FILES ${SUBSURFACE_PREFERENCES_LIB_SRCS}) diff --git a/desktop-widgets/preferences/preferences_graph.cpp b/desktop-widgets/preferences/preferences_graph.cpp new file mode 100644 index 000000000..f671076f4 --- /dev/null +++ b/desktop-widgets/preferences/preferences_graph.cpp @@ -0,0 +1,78 @@ +#include "preferences_graph.h" +#include "ui_preferences_graph.h" +#include "subsurface-core/prefs-macros.h" + +#include +#include + +#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(); + + // 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(); +} + +#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 @@ + + + PreferencesGraph + + + + 0 + 0 + 505 + 623 + + + + Form + + + + + + Show + + + + + + true + + + Threshold when showing pOâ‚‚ + + + + + + + true + + + 0.100000000000000 + + + + + + + true + + + Threshold when showing pNâ‚‚ + + + + + + + true + + + 0.100000000000000 + + + + + + + true + + + Threshold when showing pHe + + + + + + + true + + + 0.100000000000000 + + + + + + + true + + + Max pOâ‚‚ when showing MOD + + + + + + + true + + + 0.100000000000000 + + + + + + + true + + + Draw dive computer reported ceiling red + + + + + + + Show unused cylinders in Equipment tab + + + + + + + Show average depth + + + + + + + + + + Misc + + + + + + 1 + + + 150 + + + + + + + bar + + + 2 + + + 10.000000000000000 + + + 0.100000000000000 + + + + + + + Default CCR set-point for dive planning + + + + + + + pSCR Oâ‚‚ metabolism rate + + + + + + + GFLow + + + + + + + GFHigh + + + + + + + 1 + + + 150 + + + + + + + â„“/min + + + 3 + + + + + + + pSCR ratio + + + + + + + + + + 1: + + + + + + + CCR: show individual Oâ‚‚ sensor values when viewing pOâ‚‚ + + + + + + + CCR: show setpoints when viewing pOâ‚‚ + + + + + + + GFLow at max depth + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index 7d9e17d7e..db1d30113 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -5,6 +5,7 @@ #include "preferences_georeference.h" #include "preferences_defaults.h" #include "preferences_units.h" +#include "preferences_graph.h" #include #include @@ -39,6 +40,7 @@ PreferencesDialogV2::PreferencesDialogV2() addPreferencePage(new PreferencesGeoreference()); addPreferencePage(new PreferencesDefaults()); addPreferencePage(new PreferencesUnits()); + addPreferencePage(new PreferencesGraph()); refreshPages(); connect(pagesList, &QListWidget::currentRowChanged, From d9595ad266021575522f73bb87dfc51517461d59 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 1 Oct 2015 19:48:57 -0300 Subject: [PATCH 25/48] Preferences: move network preferences to the new dialog Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences.cpp | 177 +-------- desktop-widgets/preferences.h | 3 - desktop-widgets/preferences.ui | 339 ------------------ desktop-widgets/preferences/CMakeLists.txt | 1 + .../preferences/preferences_network.cpp | 173 +++++++++ .../preferences/preferences_network.h | 26 ++ .../preferences/preferences_network.ui | 293 +++++++++++++++ .../preferences/preferencesdialog.cpp | 2 + 8 files changed, 496 insertions(+), 518 deletions(-) create mode 100644 desktop-widgets/preferences/preferences_network.cpp create mode 100644 desktop-widgets/preferences/preferences_network.h create mode 100644 desktop-widgets/preferences/preferences_network.ui diff --git a/desktop-widgets/preferences.cpp b/desktop-widgets/preferences.cpp index 9ef93fafc..2ec9ee96d 100644 --- a/desktop-widgets/preferences.cpp +++ b/desktop-widgets/preferences.cpp @@ -31,23 +31,6 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial 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); - #if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) FacebookManager *fb = FacebookManager::instance(); facebookWebView = new QWebView(this); @@ -62,7 +45,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial 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.defaultSetpoint, SIGNAL(valueChanged(double)), this, SLOT(defaultSetpointChanged(double))); @@ -101,24 +84,6 @@ void PreferencesDialog::facebookDisconnect() #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)")); - } else { - ui.cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage")); - } - MainWindow::instance()->enableDisableCloudActions(); -} - void PreferencesDialog::showEvent(QShowEvent *event) { setUiFromPrefs(); @@ -128,24 +93,7 @@ void PreferencesDialog::showEvent(QShowEvent *event) void PreferencesDialog::setUiFromPrefs() { - QSettings s; - ui.save_uid_local->setChecked(s.value("save_uid_local").toBool()); - ui.default_uid->setText(s.value("subsurface_webservice_uid").toString().toUpper()); - - 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); - cloudPinNeeded(); - ui.cloud_background_sync->setChecked(prefs.cloud_background_sync); } void PreferencesDialog::restorePrefs() @@ -161,105 +109,6 @@ void PreferencesDialog::rememberPrefs() void PreferencesDialog::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(); - -<<<<<<< HEAD - 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(); - -======= ->>>>>>> Code Cleanup - loadSettings(); - emit settingsChanged(); } void PreferencesDialog::loadSettings() @@ -270,9 +119,6 @@ void PreferencesDialog::loadSettings() 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()); } void PreferencesDialog::buttonClicked(QAbstractButton *button) @@ -318,28 +164,7 @@ void PreferencesDialog::on_resetSettings_clicked() } } -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()); -} diff --git a/desktop-widgets/preferences.h b/desktop-widgets/preferences.h index 4d2c33e76..0fda4d390 100644 --- a/desktop-widgets/preferences.h +++ b/desktop-widgets/preferences.h @@ -29,11 +29,8 @@ slots: void loadSettings(); void restorePrefs(); void rememberPrefs(); - void proxyType_changed(int idx); void facebookLoggedIn(); void facebookDisconnect(); - void cloudPinNeeded(); - void passwordUpdateSuccessfull(); private: explicit PreferencesDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); void setUiFromPrefs(); diff --git a/desktop-widgets/preferences.ui b/desktop-widgets/preferences.ui index 97e281433..8d0b18900 100644 --- a/desktop-widgets/preferences.ui +++ b/desktop-widgets/preferences.ui @@ -92,16 +92,6 @@ -1 - - - Network - - - - :/network - - - Facebook @@ -125,303 +115,6 @@ 0 - - - - 0 - 0 - - - - - 5 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - Proxy - - - - - - - 0 - 0 - - - - Port - - - - - - - - - - Host - - - - - - - Qt::LeftToRight - - - Requires authentication - - - - - - - Proxy type - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Username - - - - - - - - 1 - 0 - - - - 65535 - - - 80 - - - - - - - - 0 - 0 - - - - 32 - - - - - - - - 2 - 0 - - - - 64 - - - - - - - Password - - - - - - - - 0 - 0 - - - - 32 - - - QLineEdit::Password - - - - - - - - - - - 0 - 0 - - - - - 0 - 129 - - - - Subsurface cloud storage - - - - - - - - - Email address - - - - - - - Password - - - - - - - Verification PIN - - - - - - - New password - - - - - - - - - - - - - - QLineEdit::Password - - - - - - - - - - - - - - QLineEdit::Password - - - - - - - Sync to cloud in the background? - - - - - - - Save Password locally? - - - - - - - - - - Subsurface web service - - - - 5 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - Default user ID - - - - - - - - - - Save user ID locally? - - - - - - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - @@ -544,37 +237,5 @@ - - proxyAuthRequired - toggled(bool) - proxyUsername - setEnabled(bool) - - - 409 - 123 - - - 409 - 153 - - - - - proxyAuthRequired - toggled(bool) - proxyPassword - setEnabled(bool) - - - 409 - 123 - - - 409 - 183 - - - diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt index b3ef4e3d5..4e506ed73 100644 --- a/desktop-widgets/preferences/CMakeLists.txt +++ b/desktop-widgets/preferences/CMakeLists.txt @@ -17,6 +17,7 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS preferences_defaults.cpp preferences_units.cpp preferences_graph.cpp + preferences_network.cpp ) source_group("Subsurface Preferences" FILES ${SUBSURFACE_PREFERENCES_LIB_SRCS}) diff --git a/desktop-widgets/preferences/preferences_network.cpp b/desktop-widgets/preferences/preferences_network.cpp new file mode 100644 index 000000000..000df1e7f --- /dev/null +++ b/desktop-widgets/preferences/preferences_network.cpp @@ -0,0 +1,173 @@ +#include "preferences_network.h" +#include "ui_preferences_network.h" +#include "preferences.h" +#include "dive.h" +#include "subsurfacewebservices.h" +#include "subsurface-core/prefs-macros.h" + +#include +#include + +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..8f35adeb0 --- /dev/null +++ b/desktop-widgets/preferences/preferences_network.h @@ -0,0 +1,26 @@ +#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(); + +private: + Ui::PreferencesNetwork *ui; + + void cloudPinNeeded(); + void proxyType_changed(int i); + 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 @@ + + + PreferencesNetwork + + + + 0 + 0 + 713 + 558 + + + + Form + + + + + + Proxy + + + + + + + 0 + 0 + + + + Port + + + + + + + Host + + + + + + + Proxy type + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Username + + + + + + + + 1 + 0 + + + + 65535 + + + 80 + + + + + + + + 2 + 0 + + + + 64 + + + + + + + + + + Qt::LeftToRight + + + Requires authentication + + + + + + + + 0 + 0 + + + + 32 + + + + + + + Password + + + + + + + + 0 + 0 + + + + 32 + + + QLineEdit::Password + + + + + + + + + + + 0 + 0 + + + + + 0 + 129 + + + + Subsurface cloud storage + + + + + + + + + Email address + + + + + + + Password + + + + + + + Verification PIN + + + + + + + New password + + + + + + + + + + + + + + QLineEdit::Password + + + + + + + + + + + + + + QLineEdit::Password + + + + + + + Sync to cloud in the background? + + + + + + + Save Password locally? + + + + + + + + + + Subsurface web service + + + + 5 + + + 5 + + + 5 + + + 5 + + + 5 + + + + + Default user ID + + + + + + + + + + Save user ID locally? + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index db1d30113..bf751bff7 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -6,6 +6,7 @@ #include "preferences_defaults.h" #include "preferences_units.h" #include "preferences_graph.h" +#include "preferences_network.h" #include #include @@ -41,6 +42,7 @@ PreferencesDialogV2::PreferencesDialogV2() addPreferencePage(new PreferencesDefaults()); addPreferencePage(new PreferencesUnits()); addPreferencePage(new PreferencesGraph()); + addPreferencePage(new PreferencesNetwork()); refreshPages(); connect(pagesList, &QListWidget::currentRowChanged, From 8a54a46779bac174cb9216d1c8aa76a3bfc1bc84 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 2 Oct 2015 11:09:13 -0300 Subject: [PATCH 26/48] Preferences: random fixes Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- .../preferences/preferences_defaults.cpp | 12 ------- .../preferences/preferences_defaults.h | 2 -- .../preferences/preferences_graph.cpp | 1 - .../preferences/preferences_units.cpp | 34 +++++++++---------- .../preferences/preferencesdialog.cpp | 5 +++ .../preferences/preferencesdialog.h | 2 ++ 6 files changed, 24 insertions(+), 32 deletions(-) diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp index 637117105..45888ebec 100644 --- a/desktop-widgets/preferences/preferences_defaults.cpp +++ b/desktop-widgets/preferences/preferences_defaults.cpp @@ -25,7 +25,6 @@ void PreferencesDefaults::on_chooseFile_clicked() ui->defaultfilename->setText(choosenFileName); } - void PreferencesDefaults::on_btnUseDefaultFile_toggled(bool toggle) { if (toggle) { @@ -36,22 +35,11 @@ void PreferencesDefaults::on_btnUseDefaultFile_toggled(bool toggle) } } -void PreferencesDefaults::on_noDefaultFile_toggled(bool toggle) -{ - prefs.default_file_behavior = NO_DEFAULT_FILE; -} - void PreferencesDefaults::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 PreferencesDefaults::on_cloudDefaultFile_toggled(bool toggle) -{ - prefs.default_file_behavior = CLOUD_DEFAULT_FILE; } void PreferencesDefaults::refreshSettings() diff --git a/desktop-widgets/preferences/preferences_defaults.h b/desktop-widgets/preferences/preferences_defaults.h index 94de8b28a..c72be31a6 100644 --- a/desktop-widgets/preferences/preferences_defaults.h +++ b/desktop-widgets/preferences/preferences_defaults.h @@ -18,9 +18,7 @@ public: public slots: void on_chooseFile_clicked(); void on_btnUseDefaultFile_toggled(bool toggled); - void on_noDefaultFile_toggled(bool toggled); void on_localDefaultFile_toggled(bool toggled); - void on_cloudDefaultFile_toggled(bool toggled); private: Ui::PreferencesDefaults *ui; diff --git a/desktop-widgets/preferences/preferences_graph.cpp b/desktop-widgets/preferences/preferences_graph.cpp index f671076f4..327557692 100644 --- a/desktop-widgets/preferences/preferences_graph.cpp +++ b/desktop-widgets/preferences/preferences_graph.cpp @@ -49,7 +49,6 @@ void PreferencesGraph::syncSettings() s.setValue("pscr_ratio", rint(1000.0 / ui->pscrfactor->value())); s.endGroup(); - // 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()); diff --git a/desktop-widgets/preferences/preferences_units.cpp b/desktop-widgets/preferences/preferences_units.cpp index 76f2078d7..cc77e51bb 100644 --- a/desktop-widgets/preferences/preferences_units.cpp +++ b/desktop-widgets/preferences/preferences_units.cpp @@ -16,23 +16,6 @@ PreferencesUnits::~PreferencesUnits() } void PreferencesUnits::refreshSettings() -{ - 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(); -} - -void PreferencesUnits::syncSettings() { switch(prefs.unit_system) { case METRIC: ui->metric->setChecked(true); break; @@ -58,3 +41,20 @@ void PreferencesUnits::syncSettings() 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/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index bf751bff7..5b4cc560e 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -100,6 +100,8 @@ void PreferencesDialogV2::applyRequested() Q_FOREACH(AbstractPreferencesWidget *page, pages) { page->syncSettings(); } + emit settingsChanged(); + accept(); } void PreferencesDialogV2::cancelRequested() @@ -107,6 +109,7 @@ void PreferencesDialogV2::cancelRequested() Q_FOREACH(AbstractPreferencesWidget *page, pages) { page->refreshSettings(); } + reject(); } void PreferencesDialogV2::defaultsRequested() @@ -115,4 +118,6 @@ void PreferencesDialogV2::defaultsRequested() Q_FOREACH(AbstractPreferencesWidget *page, pages) { page->refreshSettings(); } + emit settingsChanged(); + accept(); } diff --git a/desktop-widgets/preferences/preferencesdialog.h b/desktop-widgets/preferences/preferencesdialog.h index dcc97bf94..720b94c25 100644 --- a/desktop-widgets/preferences/preferencesdialog.h +++ b/desktop-widgets/preferences/preferencesdialog.h @@ -17,6 +17,8 @@ public: virtual ~PreferencesDialogV2(); void addPreferencePage(AbstractPreferencesWidget *page); void refreshPages(); +signals: + void settingsChanged(); private: void cancelRequested(); void applyRequested(); From f682a2e6ac85de3542e1904b2396ceb8f3c9d1c9 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 9 Oct 2015 18:05:06 -0300 Subject: [PATCH 27/48] Remove reference to non-existing signal Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences.h | 1 - 1 file changed, 1 deletion(-) diff --git a/desktop-widgets/preferences.h b/desktop-widgets/preferences.h index 0fda4d390..4b619dde4 100644 --- a/desktop-widgets/preferences.h +++ b/desktop-widgets/preferences.h @@ -24,7 +24,6 @@ signals: public slots: void buttonClicked(QAbstractButton *button); - void on_resetSettings_clicked(); void syncSettings(); void loadSettings(); void restorePrefs(); From c1b2907071432f6a313605950fa95c8eff000a55 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 9 Oct 2015 18:11:18 -0300 Subject: [PATCH 28/48] Fix warnings Also, disable Facebook temporarely since I'm removing the preferences widget in a few commits. Facebook will have to change to use a new way of connection that I'm still creating. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/mainwindow.ui | 1 - desktop-widgets/preferences.cpp | 3 +++ desktop-widgets/preferences/preferences_network.h | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/desktop-widgets/mainwindow.ui b/desktop-widgets/mainwindow.ui index 5e3200cfc..c62e1df7f 100644 --- a/desktop-widgets/mainwindow.ui +++ b/desktop-widgets/mainwindow.ui @@ -142,7 +142,6 @@ Share on - diff --git a/desktop-widgets/preferences.cpp b/desktop-widgets/preferences.cpp index 2ec9ee96d..29e9d2458 100644 --- a/desktop-widgets/preferences.cpp +++ b/desktop-widgets/preferences.cpp @@ -142,6 +142,8 @@ void PreferencesDialog::buttonClicked(QAbstractButton *button) } #undef SB +#if 0 +// TODO: Copy this later. void PreferencesDialog::on_resetSettings_clicked() { QSettings s; @@ -163,6 +165,7 @@ void PreferencesDialog::on_resetSettings_clicked() close(); } } +#endif void PreferencesDialog::emitSettingsChanged() { diff --git a/desktop-widgets/preferences/preferences_network.h b/desktop-widgets/preferences/preferences_network.h index 8f35adeb0..3e17d51b0 100644 --- a/desktop-widgets/preferences/preferences_network.h +++ b/desktop-widgets/preferences/preferences_network.h @@ -9,17 +9,19 @@ namespace Ui { 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 proxyType_changed(int i); void passwordUpdateSuccessfull(); }; From 6930c689b7b5449a98f91430cbd96627050d8e2e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 9 Oct 2015 18:16:34 -0300 Subject: [PATCH 29/48] Add an interface for Social Network Interfaces The Social Network plugins need an interface file to describe the expected behavior of it, this little header file will serve for that. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- subsurface-core/isocialnetworkintegration.h | 67 +++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 subsurface-core/isocialnetworkintegration.h diff --git a/subsurface-core/isocialnetworkintegration.h b/subsurface-core/isocialnetworkintegration.h new file mode 100644 index 000000000..e20ab646f --- /dev/null +++ b/subsurface-core/isocialnetworkintegration.h @@ -0,0 +1,67 @@ +#ifndef ISOCIALNETWORKINTEGRATION_H +#define ISOCIALNETWORKINTEGRATION_H + +/* 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 { + /*! + * @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. + */ + 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. + */ + QIcon 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 + */ + 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. + */ + void requestLogin() = 0; + + /*! + * @name requestLogoff + * @brief tries to logoff from this social network + * + * Try to logoff from this social network. + */ + 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. + */ + void uploadCurrentDive() = 0; +}; + +#endif \ No newline at end of file From 628eb76af456374bbab90f785d8285a916e50399 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 9 Oct 2015 18:19:10 -0300 Subject: [PATCH 30/48] It's safe to delete a Null Pointer So don't check it with an if. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/mainwindow.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 156034598..dcdbb89b4 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1901,8 +1901,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); From 53a5f6d7a46c4bbdddf394f542f20bc1a842c3a0 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 9 Oct 2015 19:15:58 -0300 Subject: [PATCH 31/48] Make code compile in gnu11 and c++11 This is to make it possible to use some nice to have features of c11 and c++11 like range based loops, delete default functions, auto variable assignment. Talked to Dirk about this and he is ok with the change, but he also states that he will not accept lambdas Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99e22116e..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) @@ -55,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 From 1d3bf5f407ab39987b2274c28493220fb363e13f Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 9 Oct 2015 19:17:58 -0300 Subject: [PATCH 32/48] Fix the ISocialNetworkIntegration interface I missed a few virtuals there. :) Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- subsurface-core/isocialnetworkintegration.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/subsurface-core/isocialnetworkintegration.h b/subsurface-core/isocialnetworkintegration.h index e20ab646f..9e54c87ab 100644 --- a/subsurface-core/isocialnetworkintegration.h +++ b/subsurface-core/isocialnetworkintegration.h @@ -1,6 +1,8 @@ #ifndef ISOCIALNETWORKINTEGRATION_H #define ISOCIALNETWORKINTEGRATION_H +#include + /* 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. @@ -17,7 +19,7 @@ class ISocialNetworkIntegration { * 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. */ - QString socialNetworkName() const = 0; + virtual QString socialNetworkName() const = 0; /*! * @name socialNetworkIcon @@ -27,14 +29,14 @@ class ISocialNetworkIntegration { * The icon of this social network will be used to populate the menu, and can also be * used on a toolbar if requested. */ - QIcon socialNetworkIcon() const = 0; + 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 */ - bool isConnected() = 0; + virtual bool isConnected() = 0; /*! * @name requestLogin @@ -43,7 +45,7 @@ class ISocialNetworkIntegration { * Try to login on this social network. All widget implementation that * manages login should be done inside this function. */ - void requestLogin() = 0; + virtual void requestLogin() = 0; /*! * @name requestLogoff @@ -51,7 +53,7 @@ class ISocialNetworkIntegration { * * Try to logoff from this social network. */ - void requestLogoff() = 0; + virtual void requestLogoff() = 0; /*! * @name uploadCurrentDive @@ -61,7 +63,9 @@ class ISocialNetworkIntegration { * to update to the social network. All widget stuff related to sendint * dive information should be executed inside this function. */ - void uploadCurrentDive() = 0; + virtual void uploadCurrentDive() = 0; }; +Q_DECLARE_INTERFACE(ISocialNetworkIntegration, "org.subsurface.ISocialNetworkIntegration.v1") + #endif \ No newline at end of file From 66d3e99ff2bea172d991ad59db19586ce7bcbed6 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 9 Oct 2015 19:18:45 -0300 Subject: [PATCH 33/48] Add a PluginManager class This class is currently very small but the reason of existence is to allow subsurface to be easily extendable via plugins. The current type of plugin that I'm making is Social Network, but another possibilities: - Dive Simulation Algorithm - Import/Export Filters - Profile Overlays Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- subsurface-core/CMakeLists.txt | 1 + subsurface-core/pluginmanager.cpp | 44 +++++++++++++++++++++++++++++++ subsurface-core/pluginmanager.h | 19 +++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 subsurface-core/pluginmanager.cpp create mode 100644 subsurface-core/pluginmanager.h diff --git a/subsurface-core/CMakeLists.txt b/subsurface-core/CMakeLists.txt index 60efb7d92..e56f8bb34 100644 --- a/subsurface-core/CMakeLists.txt +++ b/subsurface-core/CMakeLists.txt @@ -72,6 +72,7 @@ set(SUBSURFACE_CORE_LIB_SRCS qtserialbluetooth.cpp metrics.cpp color.cpp + pluginmanager.cpp ${SERIAL_FTDI} ${PLATFORM_SRC} ${BT_CORE_SRC_FILES} diff --git a/subsurface-core/pluginmanager.cpp b/subsurface-core/pluginmanager.cpp new file mode 100644 index 000000000..41d226f61 --- /dev/null +++ b/subsurface-core/pluginmanager.cpp @@ -0,0 +1,44 @@ +#include "pluginmanager.h" + +#include +#include +#include + +static QList _socialNetworks; + +PluginManager& PluginManager::instance() { + static PluginManager self; + return self; +} + +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"); + + 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(plugin)){ + _socialNetworks.push_back(social); + } + } +} + +QList PluginManager::socialNetworkIntegrationPlugins() const { + return _socialNetworks; +} \ No newline at end of file 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 + +#include "isocialnetworkintegration.h" + +class PluginManager { +public: + static PluginManager& instance(); + void loadPlugins(); + QList socialNetworkIntegrationPlugins() const; +private: + PluginManager(); + PluginManager(const PluginManager&) = delete; + PluginManager& operator=(const PluginManager&) = delete; +}; + +#endif \ No newline at end of file From e62d439bda65801ae6f3d2e73bec1a706a46ca90 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 9 Oct 2015 19:26:05 -0300 Subject: [PATCH 34/48] Start the Plugin Manager This bit of code will try to load all plugins avaliable. Now I need to port a Facebook plugin for this new system, then I'll delete the old preferences widget. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- subsurface-core/pluginmanager.cpp | 3 +++ subsurface-desktop-helper.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/subsurface-core/pluginmanager.cpp b/subsurface-core/pluginmanager.cpp index 41d226f61..290f43df0 100644 --- a/subsurface-core/pluginmanager.cpp +++ b/subsurface-core/pluginmanager.cpp @@ -11,6 +11,9 @@ PluginManager& PluginManager::instance() { return self; } +PluginManager::PluginManager() { +} + void PluginManager::loadPlugins() { QDir pluginsDir(qApp->applicationDirPath()); diff --git a/subsurface-desktop-helper.cpp b/subsurface-desktop-helper.cpp index af366fb84..420f75249 100644 --- a/subsurface-desktop-helper.cpp +++ b/subsurface-desktop-helper.cpp @@ -4,6 +4,7 @@ #include "display.h" #include "desktop-widgets/mainwindow.h" #include "helpers.h" +#include "pluginmanager.h" #include #include @@ -30,6 +31,8 @@ void init_ui() { init_qt_late(); + PluginManager::instance().loadPlugins(); + window = new MainWindow(); if (existing_filename && existing_filename[0] != '\0') window->setTitle(MWTF_FILENAME); From 9d1117cd6c513b6b64f45520a60051a1717ca50b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 9 Oct 2015 19:36:03 -0300 Subject: [PATCH 35/48] Constify, Referencify Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index dcdbb89b4..2afc8f979 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1168,7 +1168,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); From d3a8288ad5a25db502cb0c782b72c3242f3f30e9 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 9 Oct 2015 20:15:26 -0300 Subject: [PATCH 36/48] Populate the MainMenu with social network actions The magic happens here: We are iterating over the plugins and populating the main menu with all actions provided by them. Currently we can't test this as we don't have a single plugin. Next patch series of commits will be adding the Facebook plugin. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/mainwindow.cpp | 21 +++++++++++++++++++++ subsurface-core/isocialnetworkintegration.h | 1 + 2 files changed, 22 insertions(+) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 2afc8f979..0150a7c6f 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -11,6 +11,7 @@ #include #include #include + #include "version.h" #include "divelistview.h" #include "downloadfromdivecomputer.h" @@ -52,6 +53,8 @@ #include #include #include "subsurface-core/color.h" +#include "subsurface-core/isocialnetworkintegration.h" +#include "subsurface-core/pluginmanager.h" #if defined(FBSUPPORT) #include "socialnetworks.h" @@ -252,6 +255,24 @@ MainWindow::MainWindow() : QMainWindow(), ui.actionFacebook->setEnabled(false); #endif + if(PluginManager::instance().socialNetworkIntegrationPlugins().count()) { + QMenu *connections = new QMenu(); + for(ISocialNetworkIntegration *plugin : PluginManager::instance().socialNetworkIntegrationPlugins()){ + QAction *toggle_connection = new QAction(this); + toggle_connection->setText(plugin->socialNetworkName()); + toggle_connection->setIcon(QIcon(plugin->socialNetworkIcon())); + + QAction *share_on = new QAction(this); + share_on->setText(plugin->socialNetworkName()); + share_on->setIcon(QIcon(plugin->socialNetworkIcon())); + 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); diff --git a/subsurface-core/isocialnetworkintegration.h b/subsurface-core/isocialnetworkintegration.h index 9e54c87ab..97ff91dc2 100644 --- a/subsurface-core/isocialnetworkintegration.h +++ b/subsurface-core/isocialnetworkintegration.h @@ -11,6 +11,7 @@ */ class ISocialNetworkIntegration { +public: /*! * @name socialNetworkName * @brief The name of this social network From 391172240ae00e9729ddb9db1b2cd50be3feb51b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 29 Oct 2015 20:12:36 -0200 Subject: [PATCH 37/48] Facebook plugin skeleton Just to see if a plugin will compile. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/CMakeLists.txt | 1 + desktop-widgets/plugins/CMakeLists.txt | 1 + desktop-widgets/plugins/facebook/CMakeLists.txt | 5 +++++ desktop-widgets/plugins/facebook/facebook_integration.cpp | 0 desktop-widgets/plugins/facebook/facebook_integration.h | 0 5 files changed, 7 insertions(+) create mode 100644 desktop-widgets/plugins/CMakeLists.txt create mode 100644 desktop-widgets/plugins/facebook/CMakeLists.txt create mode 100644 desktop-widgets/plugins/facebook/facebook_integration.cpp create mode 100644 desktop-widgets/plugins/facebook/facebook_integration.h diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt index 07a8f3709..62be916cc 100644 --- a/desktop-widgets/CMakeLists.txt +++ b/desktop-widgets/CMakeLists.txt @@ -13,6 +13,7 @@ include_directories(. ) add_subdirectory(preferences) +add_subdirectory(plugins) # the interface, in C++ set(SUBSURFACE_INTERFACE 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..cccfec1f5 --- /dev/null +++ b/desktop-widgets/plugins/facebook/CMakeLists.txt @@ -0,0 +1,5 @@ +set(FACEBOOK_PLUGIN_SRCS facebook_integration.cpp) + +add_library(facebook_integration ${FACEBOOK_PLUGIN_SRCS}) + +target_link_libraries(facebook_integration subsurface_core ${QT_LIBRARIES}) diff --git a/desktop-widgets/plugins/facebook/facebook_integration.cpp b/desktop-widgets/plugins/facebook/facebook_integration.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/desktop-widgets/plugins/facebook/facebook_integration.h b/desktop-widgets/plugins/facebook/facebook_integration.h new file mode 100644 index 000000000..e69de29bb From 8dad3457ef1f412517c4d81f08ebd14680788ec3 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 29 Oct 2015 21:47:08 -0200 Subject: [PATCH 38/48] Make the skeleton Facebook plugin and make sure it is loaded Currently we need to copy manually the plugin dynamic library to the /plugins folder. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/mainwindow.cpp | 4 ++- .../plugins/facebook/CMakeLists.txt | 5 +-- .../plugins/facebook/facebook_integration.cpp | 36 +++++++++++++++++++ .../plugins/facebook/facebook_integration.h | 21 +++++++++++ subsurface-core/isocialnetworkintegration.h | 2 +- subsurface-core/pluginmanager.cpp | 24 +++++++------ 6 files changed, 78 insertions(+), 14 deletions(-) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 0150a7c6f..23b4fb9b0 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -256,15 +256,17 @@ MainWindow::MainWindow() : QMainWindow(), #endif if(PluginManager::instance().socialNetworkIntegrationPlugins().count()) { - QMenu *connections = new QMenu(); + 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); } diff --git a/desktop-widgets/plugins/facebook/CMakeLists.txt b/desktop-widgets/plugins/facebook/CMakeLists.txt index cccfec1f5..8628bd070 100644 --- a/desktop-widgets/plugins/facebook/CMakeLists.txt +++ b/desktop-widgets/plugins/facebook/CMakeLists.txt @@ -1,5 +1,6 @@ set(FACEBOOK_PLUGIN_SRCS facebook_integration.cpp) -add_library(facebook_integration ${FACEBOOK_PLUGIN_SRCS}) +add_library(facebook_integration SHARED ${FACEBOOK_PLUGIN_SRCS}) -target_link_libraries(facebook_integration subsurface_core ${QT_LIBRARIES}) +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 index e69de29bb..e9b2297a0 100644 --- a/desktop-widgets/plugins/facebook/facebook_integration.cpp +++ 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 index e69de29bb..a9d212e7e 100644 --- a/desktop-widgets/plugins/facebook/facebook_integration.h +++ 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 + +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/subsurface-core/isocialnetworkintegration.h b/subsurface-core/isocialnetworkintegration.h index 97ff91dc2..778a171b3 100644 --- a/subsurface-core/isocialnetworkintegration.h +++ b/subsurface-core/isocialnetworkintegration.h @@ -68,5 +68,5 @@ public: }; Q_DECLARE_INTERFACE(ISocialNetworkIntegration, "org.subsurface.ISocialNetworkIntegration.v1") - +Q_DECLARE_METATYPE(ISocialNetworkIntegration*); #endif \ No newline at end of file diff --git a/subsurface-core/pluginmanager.cpp b/subsurface-core/pluginmanager.cpp index 290f43df0..5c0f22525 100644 --- a/subsurface-core/pluginmanager.cpp +++ b/subsurface-core/pluginmanager.cpp @@ -3,18 +3,22 @@ #include #include #include +#include static QList _socialNetworks; -PluginManager& PluginManager::instance() { +PluginManager& PluginManager::instance() +{ static PluginManager self; return self; } -PluginManager::PluginManager() { +PluginManager::PluginManager() +{ } -void PluginManager::loadPlugins() { +void PluginManager::loadPlugins() +{ QDir pluginsDir(qApp->applicationDirPath()); #if defined(Q_OS_WIN) @@ -29,19 +33,19 @@ void PluginManager::loadPlugins() { #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) { + if(!plugin) continue; - } - if (ISocialNetworkIntegration *social = qobject_cast(plugin)){ + if (ISocialNetworkIntegration *social = qobject_cast(plugin)) _socialNetworks.push_back(social); - } - } + } } -QList PluginManager::socialNetworkIntegrationPlugins() const { +QList PluginManager::socialNetworkIntegrationPlugins() const +{ return _socialNetworks; -} \ No newline at end of file +} From 9eed778c68f72862b27695bee8b4dd1ba553bdc2 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 30 Oct 2015 13:14:06 -0700 Subject: [PATCH 39/48] Preferences: switch language preference to be a dropdown The list widget takes too much space and isn't really any better. The dropdown plus fliter is actually rather neat. Also added back the connections so the dropdown and filter get disabled when system default is selected (just as it was in the old preferences dialog). Signed-off-by: Dirk Hohndel --- .../preferences/preferences_language.cpp | 14 ++-- desktop-widgets/preferences/prefs_language.ui | 65 +++++++++++++++---- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp index 07b60c3a3..ec4eed471 100644 --- a/desktop-widgets/preferences/preferences_language.cpp +++ b/desktop-widgets/preferences/preferences_language.cpp @@ -16,7 +16,7 @@ PreferencesLanguage::PreferencesLanguage() : AbstractPreferencesWidget(tr("Langu QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(); filterModel->setSourceModel(LanguageModel::instance()); filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); - ui->languageView->setModel(filterModel); + ui->languageDropdown->setModel(filterModel); filterModel->sort(0); connect(ui->languageFilter, &QLineEdit::textChanged, filterModel, &QSortFilterProxyModel::setFilterFixedString); @@ -32,10 +32,10 @@ void PreferencesLanguage::refreshSettings() QSettings s; s.beginGroup("Language"); ui->languageSystemDefault->setChecked(s.value("UseSystemLanguage", true).toBool()); - QAbstractItemModel *m = ui->languageView->model(); + QAbstractItemModel *m = ui->languageDropdown->model(); QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, s.value("UiLanguage").toString()); if (languages.count()) - ui->languageView->setCurrentIndex(languages.first()); + ui->languageDropdown->setCurrentIndex(languages.first().row()); s.endGroup(); } @@ -44,12 +44,14 @@ 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() != ui->languageView->currentIndex().data(Qt::UserRole))) { + (!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("UseSystemLanguage", ui->languageSystemDefault->isChecked()); - s.setValue("UiLanguage", ui->languageView->currentIndex().data(Qt::UserRole)); + s.setValue("UiLanguage", currentText); s.endGroup(); -} \ No newline at end of file +} diff --git a/desktop-widgets/preferences/prefs_language.ui b/desktop-widgets/preferences/prefs_language.ui index 80671fca8..650d543f6 100644 --- a/desktop-widgets/preferences/prefs_language.ui +++ b/desktop-widgets/preferences/prefs_language.ui @@ -6,7 +6,7 @@ 0 0 - 576 + 621 523 @@ -17,7 +17,7 @@ - + 0 0 @@ -33,6 +33,9 @@ + + + @@ -59,18 +62,54 @@ - - - - - 0 - 0 - - - - + + + + Qt::Vertical + + + + 20 + 20 + + + + - + + + languageSystemDefault + toggled(bool) + languageDropdown + setDisabled(bool) + + + 73 + 273 + + + 179 + 273 + + + + + languageSystemDefault + toggled(bool) + languageFilter + setDisabled(bool) + + + 73 + 273 + + + 539 + 273 + + + + From 222ce62bceac4c7f95e7a0564f11b5789dc18d29 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 30 Oct 2015 13:26:05 -0700 Subject: [PATCH 40/48] Preferences: add date and time format to language page Not hooked up, yet. Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/prefs_language.ui | 155 +++++++++++++++++- 1 file changed, 150 insertions(+), 5 deletions(-) diff --git a/desktop-widgets/preferences/prefs_language.ui b/desktop-widgets/preferences/prefs_language.ui index 650d543f6..af3a0ad87 100644 --- a/desktop-widgets/preferences/prefs_language.ui +++ b/desktop-widgets/preferences/prefs_language.ui @@ -29,7 +29,7 @@ - System default + Use system default @@ -62,19 +62,116 @@ - - + + + + + 0 + 0 + + + + Date format + + + + + + <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> + + + + + + + Use UI language default + + + + + + + + + + This is used in places where there is less space to show the full date + + + Short format + + + + + - Qt::Vertical + Qt::Horizontal - 20 + 203 20 + + + + + + + + 0 + 0 + + + + Time format + + + + + + Use UI language default + + + + + + + <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> + + + + + + + Qt::Horizontal + + + + 203 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + @@ -111,5 +208,53 @@ + + dateFormatSystemDefault + toggled(bool) + dateFormatEntry + setDisabled(bool) + + + 79 + 132 + + + 264 + 132 + + + + + timeFormatSystemDefault + toggled(bool) + timeFormatEntry + setDisabled(bool) + + + 79 + 210 + + + 264 + 210 + + + + + dateFormatSystemDefault + toggled(bool) + shortDateFormatEntry + setDisabled(bool) + + + 99 + 132 + + + 293 + 169 + + + From f85883c707e9d6c021025dfe406c9acfb6441e57 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 29 Oct 2015 16:57:43 -0700 Subject: [PATCH 41/48] Create date and time formats preferences Now we can actually change them in preferences instead of just deriving them from the language set. Signed-off-by: Dirk Hohndel --- desktop-widgets/diveplanner.cpp | 2 +- desktop-widgets/maintab.cpp | 2 +- subsurface-core/helpers.h | 1 - subsurface-core/pref.h | 5 +++++ subsurface-core/qthelper.cpp | 24 +++++++++++++----------- subsurface-core/subsurfacestartup.c | 3 +++ 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index 86f03b1d2..fd14944f0 100644 --- a/desktop-widgets/diveplanner.cpp +++ b/desktop-widgets/diveplanner.cpp @@ -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); diff --git a/desktop-widgets/maintab.cpp b/desktop-widgets/maintab.cpp index 4d4cd3a5e..c7961735a 100644 --- a/desktop-widgets/maintab.cpp +++ b/desktop-widgets/maintab.cpp @@ -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/subsurface-core/helpers.h b/subsurface-core/helpers.h index 5f2f2f2c5..b5c119870 100644 --- a/subsurface-core/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 > &gasUsed); QString getUserAgent(); diff --git a/subsurface-core/pref.h b/subsurface-core/pref.h index 84975aaaa..9f5f587e2 100644 --- a/subsurface-core/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/subsurface-core/qthelper.cpp b/subsurface-core/qthelper.cpp index a12d25333..a91e1aae2 100644 --- a/subsurface-core/qthelper.cpp +++ b/subsurface-core/qthelper.cpp @@ -33,9 +33,6 @@ #include 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,6 +718,9 @@ QString getUserAgent() QString uiLanguage(QLocale *callerLoc) { + QString shortDateFormat; + QString dateFormat; + QString timeFormat; QSettings s; s.beginGroup("Language"); @@ -754,6 +754,12 @@ QString uiLanguage(QLocale *callerLoc) 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)); + free((void*)prefs.date_format); + prefs.date_format = strdup(qPrintable(dateFormat)); + free((void*)prefs.date_format_short); + prefs.date_format_short = strdup(qPrintable(shortDateFormat)); return uiLang; } @@ -762,10 +768,6 @@ QLocale getLocale() return loc; } -QString getDateFormat() -{ - return dateFormat; -} void set_filename(const char *filename, bool force) { if (!force && existing_filename) @@ -1034,14 +1036,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) diff --git a/subsurface-core/subsurfacestartup.c b/subsurface-core/subsurfacestartup.c index 1286885ee..0bde2a070 100644 --- a/subsurface-core/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); From 8a3fb854c2b835271cc03ea02e1046f2ec0fd5d5 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 2 Nov 2015 11:32:46 -0800 Subject: [PATCH 42/48] Preferences: hook up the UI page with the preferences structure With this the new date and time formats mostly work Signed-off-by: Dirk Hohndel --- .../preferences/preferences_language.cpp | 15 +++++- subsurface-core/qthelper.cpp | 53 ++++++++++++------- 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp index ec4eed471..1b5ee19a8 100644 --- a/desktop-widgets/preferences/preferences_language.cpp +++ b/desktop-widgets/preferences/preferences_language.cpp @@ -32,6 +32,11 @@ 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()) @@ -51,7 +56,15 @@ void PreferencesLanguage::syncSettings() QMessageBox::warning(this, tr("Restart required"), tr("To correctly load a new language you must restart Subsurface.")); } - s.setValue("UseSystemLanguage", ui->languageSystemDefault->isChecked()); 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(); } diff --git a/subsurface-core/qthelper.cpp b/subsurface-core/qthelper.cpp index a91e1aae2..40c507a7e 100644 --- a/subsurface-core/qthelper.cpp +++ b/subsurface-core/qthelper.cpp @@ -722,6 +722,7 @@ QString uiLanguage(QLocale *callerLoc) 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,24 +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", ""); - free((void*)prefs.time_format); - prefs.time_format = strdup(qPrintable(timeFormat)); - free((void*)prefs.date_format); - prefs.date_format = strdup(qPrintable(dateFormat)); - free((void*)prefs.date_format_short); - prefs.date_format_short = strdup(qPrintable(shortDateFormat)); + 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; } @@ -1078,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; } From ff57881265a305fe06691b065bc3f0efae88e6b3 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sat, 31 Oct 2015 21:02:16 -0200 Subject: [PATCH 43/48] Preferences: Remove the old dialog and use the new one The new preferences dialog still needs a bit of fine tuning but should already work. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/CMakeLists.txt | 1 - desktop-widgets/mainwindow.cpp | 4 +- desktop-widgets/preferences.h | 43 ------------------- .../preferences/preferences_network.cpp | 1 - .../preferences/preferencesdialog.cpp | 29 +++++++++---- .../preferences/preferencesdialog.h | 8 ++-- profile-widget/divecartesianaxis.cpp | 2 +- profile-widget/divepixmapitem.cpp | 2 +- profile-widget/diveprofileitem.cpp | 2 +- profile-widget/profilewidget2.cpp | 2 +- profile-widget/ruleritem.cpp | 2 +- 11 files changed, 31 insertions(+), 65 deletions(-) delete mode 100644 desktop-widgets/preferences.h diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt index 62be916cc..0a0059ee3 100644 --- a/desktop-widgets/CMakeLists.txt +++ b/desktop-widgets/CMakeLists.txt @@ -30,7 +30,6 @@ set(SUBSURFACE_INTERFACE mainwindow.cpp modeldelegates.cpp notificationwidget.cpp - preferences.cpp simplewidgets.cpp starwidget.cpp subsurfacewebservices.cpp diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 23b4fb9b0..dc45d1d8d 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -15,7 +15,6 @@ #include "version.h" #include "divelistview.h" #include "downloadfromdivecomputer.h" -#include "preferences.h" #include "subsurfacewebservices.h" #include "divecomputermanagementdialog.h" #include "about.h" @@ -278,8 +277,6 @@ MainWindow::MainWindow() : QMainWindow(), ui.menubar->show(); set_git_update_cb(&updateProgress); - PreferencesDialogV2 *d = new PreferencesDialogV2(); - d->show(); } MainWindow::~MainWindow() @@ -1785,6 +1782,7 @@ void MainWindow::editCurrentDive() } } +// TODO: Remove the dependency to the PreferencesDialog here. #define PREF_PROFILE(QT_PREFS) \ QSettings s; \ s.beginGroup("TecDetails"); \ diff --git a/desktop-widgets/preferences.h b/desktop-widgets/preferences.h deleted file mode 100644 index 4b619dde4..000000000 --- a/desktop-widgets/preferences.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef PREFERENCES_H -#define PREFERENCES_H - -#include -#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 syncSettings(); - void loadSettings(); - void restorePrefs(); - void rememberPrefs(); - void facebookLoggedIn(); - void facebookDisconnect(); -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/desktop-widgets/preferences/preferences_network.cpp b/desktop-widgets/preferences/preferences_network.cpp index 000df1e7f..3780a6c91 100644 --- a/desktop-widgets/preferences/preferences_network.cpp +++ b/desktop-widgets/preferences/preferences_network.cpp @@ -1,6 +1,5 @@ #include "preferences_network.h" #include "ui_preferences_network.h" -#include "preferences.h" #include "dive.h" #include "subsurfacewebservices.h" #include "subsurface-core/prefs-macros.h" diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index 5b4cc560e..d59296519 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -16,7 +16,18 @@ #include #include -PreferencesDialogV2::PreferencesDialogV2() +PreferencesDialog* PreferencesDialog::instance() +{ + PreferencesDialog *self = new PreferencesDialog(); + return self; +} + +void PreferencesDialog::emitSettingsChanged() +{ + emit settingsChanged(); +} + +PreferencesDialog::PreferencesDialog() { pagesList = new QListWidget(); pagesStack = new QStackedWidget(); @@ -48,14 +59,14 @@ PreferencesDialogV2::PreferencesDialogV2() connect(pagesList, &QListWidget::currentRowChanged, pagesStack, &QStackedWidget::setCurrentIndex); connect(buttonBox, &QDialogButtonBox::clicked, - this, &PreferencesDialogV2::buttonClicked); + this, &PreferencesDialog::buttonClicked); } -PreferencesDialogV2::~PreferencesDialogV2() +PreferencesDialog::~PreferencesDialog() { } -void PreferencesDialogV2::buttonClicked(QAbstractButton* btn) +void PreferencesDialog::buttonClicked(QAbstractButton* btn) { QDialogButtonBox::ButtonRole role = buttonBox->buttonRole(btn); switch(role) { @@ -70,13 +81,13 @@ bool abstractpreferenceswidget_lessthan(AbstractPreferencesWidget *p1, AbstractP return p1->positionHeight() <= p2->positionHeight(); } -void PreferencesDialogV2::addPreferencePage(AbstractPreferencesWidget *page) +void PreferencesDialog::addPreferencePage(AbstractPreferencesWidget *page) { pages.push_back(page); qSort(pages.begin(), pages.end(), abstractpreferenceswidget_lessthan); } -void PreferencesDialogV2::refreshPages() +void PreferencesDialog::refreshPages() { // Remove things pagesList->clear(); @@ -95,7 +106,7 @@ void PreferencesDialogV2::refreshPages() } } -void PreferencesDialogV2::applyRequested() +void PreferencesDialog::applyRequested() { Q_FOREACH(AbstractPreferencesWidget *page, pages) { page->syncSettings(); @@ -104,7 +115,7 @@ void PreferencesDialogV2::applyRequested() accept(); } -void PreferencesDialogV2::cancelRequested() +void PreferencesDialog::cancelRequested() { Q_FOREACH(AbstractPreferencesWidget *page, pages) { page->refreshSettings(); @@ -112,7 +123,7 @@ void PreferencesDialogV2::cancelRequested() reject(); } -void PreferencesDialogV2::defaultsRequested() +void PreferencesDialog::defaultsRequested() { prefs = default_prefs; Q_FOREACH(AbstractPreferencesWidget *page, pages) { diff --git a/desktop-widgets/preferences/preferencesdialog.h b/desktop-widgets/preferences/preferencesdialog.h index 720b94c25..611bd5fac 100644 --- a/desktop-widgets/preferences/preferencesdialog.h +++ b/desktop-widgets/preferences/preferencesdialog.h @@ -10,16 +10,18 @@ class QStackedWidget; class QDialogButtonBox; class QAbstractButton; -class PreferencesDialogV2 : public QDialog { +class PreferencesDialog : public QDialog { Q_OBJECT public: - PreferencesDialogV2(); - virtual ~PreferencesDialogV2(); + static PreferencesDialog* instance(); + virtual ~PreferencesDialog(); void addPreferencePage(AbstractPreferencesWidget *page); void refreshPages(); + void emitSettingsChanged(); signals: void settingsChanged(); private: + PreferencesDialog(); void cancelRequested(); void applyRequested(); void defaultsRequested(); diff --git a/profile-widget/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp index bf5a5380c..f40e1c3e5 100644 --- a/profile-widget/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/profile-widget/divepixmapitem.cpp b/profile-widget/divepixmapitem.cpp index 581f6f9b4..627473c2f 100644 --- a/profile-widget/divepixmapitem.cpp +++ b/profile-widget/divepixmapitem.cpp @@ -1,7 +1,7 @@ #include "divepixmapitem.h" #include "animationfunctions.h" #include "divepicturemodel.h" -#include +#include "preferences/preferencesdialog.h" #include #include diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp index 7cdccee32..14efa9123 100644 --- a/profile-widget/diveprofileitem.cpp +++ b/profile-widget/diveprofileitem.cpp @@ -5,7 +5,7 @@ #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" diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 3ccd1bb6d..8ff8e8669 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -29,7 +29,7 @@ #include #endif #include "mainwindow.h" -#include +#include "preferences/preferencesdialog.h" /* This is the global 'Item position' variable. * it should tell you where to position things up diff --git a/profile-widget/ruleritem.cpp b/profile-widget/ruleritem.cpp index 830985552..a5a61c0fe 100644 --- a/profile-widget/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" From bf12c3533c73054066c4a1223bdb0a533778d44c Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sat, 31 Oct 2015 21:26:52 -0200 Subject: [PATCH 44/48] Preferences: Use apply instead of reset to defaults Change the Reset to Defaults button to Apply in the preferences dialog. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/preferencesdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index d59296519..0af7a78bd 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -33,7 +33,7 @@ PreferencesDialog::PreferencesDialog() pagesStack = new QStackedWidget(); buttonBox = new QDialogButtonBox( QDialogButtonBox::Save | - QDialogButtonBox::RestoreDefaults | + QDialogButtonBox::Apply | QDialogButtonBox::Cancel); pagesList->setMinimumWidth(120); From c66de6f707dea0b1b0f1d343e4a508880171ebc3 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sat, 31 Oct 2015 21:45:52 -0200 Subject: [PATCH 45/48] Do not depend on the subsurface_core qrc for tests Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0b322d053..23642fb3c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,6 @@ # QTest based tests macro(TEST NAME FILE) - add_executable(${NAME} ${FILE} ${SUBSURFACE_RESOURCES}) + add_executable(${NAME} ${FILE} ) target_link_libraries(${NAME} subsurface_corelib ${QT_TEST_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES}) add_test(NAME ${NAME} COMMAND $) endmacro() From a48e6241dc86c722032f7cd15bcffb565d5dbb4f Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sat, 31 Oct 2015 21:54:59 -0200 Subject: [PATCH 46/48] Forgot to set the static variable static Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/preferencesdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index 0af7a78bd..9041668f8 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -18,7 +18,7 @@ PreferencesDialog* PreferencesDialog::instance() { - PreferencesDialog *self = new PreferencesDialog(); + static PreferencesDialog *self = new PreferencesDialog(); return self; } From 9f93b9a934e23be05322ff47a0c6a8fa3b8b3adb Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sun, 1 Nov 2015 12:14:40 -0200 Subject: [PATCH 47/48] Preferences: Call LoadPreferences from whitin the new dialog When I removed the old preferences dialog, I forgot to load them again. The code is in the wrong place: it should be on every and each preferences dialog (or on the main preferences) Beware if you used this wip code before, I may have destroyed your preferences. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/preferencesdialog.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index 9041668f8..a7934a96d 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -8,6 +8,8 @@ #include "preferences_graph.h" #include "preferences_network.h" +#include "subsurface-core/qthelper.h" + #include #include #include @@ -29,6 +31,8 @@ void PreferencesDialog::emitSettingsChanged() PreferencesDialog::PreferencesDialog() { + loadPreferences(); //TODO: Move this code out of the qthelper.cpp + pagesList = new QListWidget(); pagesStack = new QStackedWidget(); buttonBox = new QDialogButtonBox( From df7818a9b8495285b4d9812e5d6d50d6f9c08813 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 2 Nov 2015 12:50:17 -0800 Subject: [PATCH 48/48] Preferences: make apply work We didn't respond at all to that button. Also, the language settings didn't propagate without this explicit call. Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/preferences_language.cpp | 2 ++ desktop-widgets/preferences/preferencesdialog.cpp | 12 +++++++----- desktop-widgets/preferences/preferencesdialog.h | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp index 1b5ee19a8..31bbd1c20 100644 --- a/desktop-widgets/preferences/preferences_language.cpp +++ b/desktop-widgets/preferences/preferences_language.cpp @@ -1,5 +1,6 @@ #include "preferences_language.h" #include "ui_prefs_language.h" +#include "subsurface-core/helpers.h" #include #include @@ -67,4 +68,5 @@ void PreferencesLanguage::syncSettings() s.setValue("date_format_short", ui->shortDateFormatEntry->text()); } s.endGroup(); + uiLanguage(NULL); } diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index a7934a96d..d8798879a 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -74,9 +74,10 @@ void PreferencesDialog::buttonClicked(QAbstractButton* btn) { QDialogButtonBox::ButtonRole role = buttonBox->buttonRole(btn); switch(role) { - case QDialogButtonBox::AcceptRole : applyRequested(); return; - case QDialogButtonBox::RejectRole : cancelRequested(); return; - case QDialogButtonBox::ResetRole : defaultsRequested(); return; + case QDialogButtonBox::ApplyRole : applyRequested(false); return; + case QDialogButtonBox::AcceptRole : applyRequested(true); return; + case QDialogButtonBox::RejectRole : cancelRequested(); return; + case QDialogButtonBox::ResetRole : defaultsRequested(); return; } } @@ -110,13 +111,14 @@ void PreferencesDialog::refreshPages() } } -void PreferencesDialog::applyRequested() +void PreferencesDialog::applyRequested(bool closeIt) { Q_FOREACH(AbstractPreferencesWidget *page, pages) { page->syncSettings(); } emit settingsChanged(); - accept(); + if (closeIt) + accept(); } void PreferencesDialog::cancelRequested() diff --git a/desktop-widgets/preferences/preferencesdialog.h b/desktop-widgets/preferences/preferencesdialog.h index 611bd5fac..5f7f5f979 100644 --- a/desktop-widgets/preferences/preferencesdialog.h +++ b/desktop-widgets/preferences/preferencesdialog.h @@ -23,7 +23,7 @@ signals: private: PreferencesDialog(); void cancelRequested(); - void applyRequested(); + void applyRequested(bool closeIt); void defaultsRequested(); void buttonClicked(QAbstractButton *btn); QList pages; @@ -32,4 +32,4 @@ private: QDialogButtonBox *buttonBox; }; -#endif \ No newline at end of file +#endif