From 2d7be7a0e366b562fdff914e92219ab1852cd3c8 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 24 Nov 2020 12:50:52 +0100 Subject: preferences: create global settingsChanged signal So far, the PreferencesDialog emitted a settingsChanged signal. This meant that models that listened to that signal had to conditionally compile out the code for mobile or the connection had to be made in MainWindow. Instead, introduce a global signal that does this and move the connects to the listeners to remove inter-dependencies. Signed-off-by: Berthold Stoeger --- profile-widget/divecartesianaxis.cpp | 12 +++--------- profile-widget/divepixmapitem.cpp | 6 ++---- profile-widget/diveprofileitem.cpp | 8 ++------ profile-widget/profilewidget2.cpp | 5 +---- profile-widget/ruleritem.cpp | 3 --- 5 files changed, 8 insertions(+), 26 deletions(-) (limited to 'profile-widget') diff --git a/profile-widget/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp index ec959d03e..40203b00f 100644 --- a/profile-widget/divecartesianaxis.cpp +++ b/profile-widget/divecartesianaxis.cpp @@ -3,9 +3,7 @@ #include "profile-widget/divetextitem.h" #include "core/qthelper.h" #include "core/subsurface-string.h" -#ifndef SUBSURFACE_MOBILE -#include "desktop-widgets/preferences/preferencesdialog.h" -#endif +#include "core/subsurface-qt/divelistnotifier.h" #include "qt-models/diveplotdatamodel.h" #include "profile-widget/animationfunctions.h" #include "profile-widget/divelineitem.h" @@ -365,9 +363,7 @@ QColor DepthAxis::colorForValue(double) DepthAxis::DepthAxis(ProfileWidget2 *widget) : DiveCartesianAxis(widget) { -#ifndef SUBSURFACE_MOBILE - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); -#endif + connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &DepthAxis::settingsChanged); changed = true; settingsChanged(); } @@ -422,9 +418,7 @@ PartialGasPressureAxis::PartialGasPressureAxis(ProfileWidget2 *widget) : DiveCartesianAxis(widget), model(NULL) { -#ifndef SUBSURFACE_MOBILE - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); -#endif + connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &PartialGasPressureAxis::settingsChanged); } void PartialGasPressureAxis::setModel(DivePlotDataModel *m) diff --git a/profile-widget/divepixmapitem.cpp b/profile-widget/divepixmapitem.cpp index 7b2c9cc87..301d80257 100644 --- a/profile-widget/divepixmapitem.cpp +++ b/profile-widget/divepixmapitem.cpp @@ -4,8 +4,8 @@ #include "core/pref.h" #include "core/qthelper.h" #include "core/settings/qPrefDisplay.h" +#include "core/subsurface-qt/divelistnotifier.h" #ifndef SUBSURFACE_MOBILE -#include "desktop-widgets/preferences/preferencesdialog.h" #include "core/dive.h" // for displayed_dive #include "commands/command.h" #endif @@ -50,9 +50,7 @@ DivePictureItem::DivePictureItem(QGraphicsItem *parent): DivePixmapItem(parent), setFlag(ItemIgnoresTransformations); setAcceptHoverEvents(true); setScale(0.2); -#ifndef SUBSURFACE_MOBILE - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); -#endif + connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &DivePictureItem::settingsChanged); canvas->setPen(Qt::NoPen); canvas->setBrush(QColor(Qt::white)); diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp index a63b35863..c6df6ee50 100644 --- a/profile-widget/diveprofileitem.cpp +++ b/profile-widget/diveprofileitem.cpp @@ -5,22 +5,18 @@ #include "profile-widget/divetextitem.h" #include "profile-widget/animationfunctions.h" #include "core/profile.h" -#ifndef SUBSURFACE_MOBILE -#include "desktop-widgets/preferences/preferencesdialog.h" -#endif #include "qt-models/diveplannermodel.h" #include "core/qthelper.h" #include "core/settings/qPrefTechnicalDetails.h" #include "core/settings/qPrefLog.h" +#include "core/subsurface-qt/divelistnotifier.h" #include "libdivecomputer/parser.h" #include "profile-widget/profilewidget2.h" AbstractProfilePolygonItem::AbstractProfilePolygonItem() : QObject(), QGraphicsPolygonItem(), hAxis(NULL), vAxis(NULL), dataModel(NULL), hDataColumn(-1), vDataColumn(-1) { setCacheMode(DeviceCoordinateCache); -#ifndef SUBSURFACE_MOBILE - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); -#endif + connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &AbstractProfilePolygonItem::settingsChanged); } void AbstractProfilePolygonItem::settingsChanged() diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 384826fe4..3d6348bb5 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -31,8 +31,8 @@ #include "core/qthelper.h" #include "core/gettextfromc.h" #include "core/imagedownloader.h" -#include "core/subsurface-qt/divelistnotifier.h" #endif +#include "core/subsurface-qt/divelistnotifier.h" #include #include @@ -47,9 +47,6 @@ #ifndef QT_NO_DEBUG #include #endif -#ifndef SUBSURFACE_MOBILE -#include "desktop-widgets/preferences/preferencesdialog.h" -#endif #include #define PP_GRAPHS_ENABLED (prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe) diff --git a/profile-widget/ruleritem.cpp b/profile-widget/ruleritem.cpp index a76012739..4cf766130 100644 --- a/profile-widget/ruleritem.cpp +++ b/profile-widget/ruleritem.cpp @@ -1,8 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 #include "profile-widget/ruleritem.h" -#ifndef SUBSURFACE_MOBILE -#include "desktop-widgets/preferences/preferencesdialog.h" -#endif #include "profile-widget/profilewidget2.h" #include "core/display.h" #include "core/settings/qPrefTechnicalDetails.h" -- cgit v1.2.3-70-g09d2