summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/subsurface-qt/divelistnotifier.h3
-rw-r--r--desktop-widgets/divelistview.cpp8
-rw-r--r--desktop-widgets/divelistview.h1
-rw-r--r--desktop-widgets/diveplanner.cpp4
-rw-r--r--desktop-widgets/filterconstraintwidget.cpp4
-rw-r--r--desktop-widgets/mainwindow.cpp10
-rw-r--r--desktop-widgets/preferences/preferencesdialog.cpp9
-rw-r--r--desktop-widgets/preferences/preferencesdialog.h2
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp4
-rw-r--r--profile-widget/divecartesianaxis.cpp12
-rw-r--r--profile-widget/divepixmapitem.cpp6
-rw-r--r--profile-widget/diveprofileitem.cpp8
-rw-r--r--profile-widget/profilewidget2.cpp5
-rw-r--r--profile-widget/ruleritem.cpp3
-rw-r--r--qt-models/tankinfomodel.cpp1
-rw-r--r--subsurface-desktop-main.cpp5
16 files changed, 36 insertions, 49 deletions
diff --git a/core/subsurface-qt/divelistnotifier.h b/core/subsurface-qt/divelistnotifier.h
index 2cd6eefcb..033458915 100644
--- a/core/subsurface-qt/divelistnotifier.h
+++ b/core/subsurface-qt/divelistnotifier.h
@@ -83,6 +83,9 @@ signals:
// The core structures were completely reset. Repopulate all models.
void dataReset();
+ // The settings changed. Repopulate / rerender unit-dependent data, etc.
+ void settingsChanged();
+
// Note that there are no signals for trips being added and created
// because these events never happen without a dive being added, removed or moved.
// The dives are always sorted according to the dives_less_than() function of the core.
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp
index f98b298f4..07f7435c0 100644
--- a/desktop-widgets/divelistview.cpp
+++ b/desktop-widgets/divelistview.cpp
@@ -9,6 +9,7 @@
#include "desktop-widgets/modeldelegates.h"
#include "desktop-widgets/mainwindow.h"
#include "core/selection.h"
+#include "core/subsurface-qt/divelistnotifier.h"
#include <unistd.h>
#include <QSettings>
#include <QKeyEvent>
@@ -39,6 +40,7 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent),
setModel(m);
connect(m, &MultiFilterSortModel::selectionChanged, this, &DiveListView::diveSelectionChanged);
connect(m, &MultiFilterSortModel::currentDiveChanged, this, &DiveListView::currentDiveChanged);
+ connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &DiveListView::settingsChanged);
setSortingEnabled(true);
setContextMenuPolicy(Qt::DefaultContextMenu);
@@ -348,6 +350,12 @@ void DiveListView::reload()
}
}
+void DiveListView::settingsChanged()
+{
+ update();
+ reloadHeaderActions();
+}
+
void DiveListView::reloadHeaderActions()
{
// Populate the context menu of the headers that will show
diff --git a/desktop-widgets/divelistview.h b/desktop-widgets/divelistview.h
index 17cff4b02..990d0446b 100644
--- a/desktop-widgets/divelistview.h
+++ b/desktop-widgets/divelistview.h
@@ -33,6 +33,7 @@ signals:
void divesSelected();
public
slots:
+ void settingsChanged();
void reloadHeaderActions();
private
slots:
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index 3e63e5ffe..95375643f 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/diveplanner.cpp
@@ -6,6 +6,7 @@
#include "core/qthelper.h"
#include "core/units.h"
#include "core/settings/qPrefDivePlanner.h"
+#include "core/subsurface-qt/divelistnotifier.h"
#include "core/gettextfromc.h"
#include "backend-shared/plannershared.h"
@@ -175,6 +176,8 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent) : QWidget(parent, QFlag(0)
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DURATION, new SpinBoxDelegate(0, 6000, 1, this));
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::CCSETPOINT, new DoubleSpinBoxDelegate(0, 2, 0.1, this));
+ connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &DivePlannerWidget::settingsChanged);
+
/* set defaults. */
ui.ATMPressure->setValue(1013);
ui.atmHeight->setValue(0);
@@ -506,6 +509,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent) : QWidget(parent,
connect(ui.bestmixEND, QOverload<int>::of(&QSpinBox::valueChanged), &PlannerShared::set_bestmixend);
connect(ui.bottomSAC, QOverload<double>::of(&QDoubleSpinBox::valueChanged), &PlannerShared::set_bottomsac);
connect(ui.decoStopSAC, QOverload<double>::of(&QDoubleSpinBox::valueChanged), &PlannerShared::set_decosac);
+ connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &PlannerSettingsWidget::settingsChanged);
settingsChanged();
ui.gflow->setValue(prefs.gflow);
diff --git a/desktop-widgets/filterconstraintwidget.cpp b/desktop-widgets/filterconstraintwidget.cpp
index 418fca0d5..6e5c2d032 100644
--- a/desktop-widgets/filterconstraintwidget.cpp
+++ b/desktop-widgets/filterconstraintwidget.cpp
@@ -2,7 +2,7 @@
#include "filterconstraintwidget.h"
#include "starwidget.h"
#include "core/pref.h"
-#include "desktop-widgets/preferences/preferencesdialog.h"
+#include "core/subsurface-qt/divelistnotifier.h"
#include "qt-models/cleanertablemodel.h" // for trashIcon()
#include "qt-models/filterconstraintmodel.h"
@@ -225,7 +225,7 @@ FilterConstraintWidget::FilterConstraintWidget(FilterConstraintModel *modelIn, c
rangeLayout->addStretch();
// Update the widget if the settings changed to reflect new units.
- connect(PreferencesDialog::instance(), &PreferencesDialog::settingsChanged, this, &FilterConstraintWidget::update);
+ connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &FilterConstraintWidget::update);
addToLayout();
update();
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index b9ee3a15a..dfe039c51 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -189,13 +189,7 @@ MainWindow::MainWindow() : QMainWindow(),
QIcon::setThemeName("subsurface");
}
connect(diveList, &DiveListView::divesSelected, this, &MainWindow::selectionChanged);
- connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(readSettings()));
- connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveList, SLOT(update()));
- connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveList, SLOT(reloadHeaderActions()));
- connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), mainTab.get(), SLOT(updateDiveInfo()));
- connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), divePlannerWidget, SLOT(settingsChanged()));
- connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), divePlannerSettingsWidget, SLOT(settingsChanged()));
- connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update()));
+ connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &MainWindow::readSettings);
for (int i = 0; i < NUM_RECENT_FILES; i++) {
actionsRecent[i] = new QAction(this);
actionsRecent[i]->setData(i);
@@ -324,7 +318,7 @@ MainWindow::MainWindow() : QMainWindow(),
connect(graphics, &ProfileWidget2::editCurrentDive, this, &MainWindow::editCurrentDive);
connect(graphics, &ProfileWidget2::updateDiveInfo, mainTab.get(), &MainTab::updateDiveInfo);
- connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), graphics, SLOT(settingsChanged()));
+ connect(&diveListNotifier, &DiveListNotifier::settingsChanged, graphics, &ProfileWidget2::settingsChanged);
ui.profCalcAllTissues->setChecked(qPrefTechnicalDetails::calcalltissues());
ui.profCalcCeiling->setChecked(qPrefTechnicalDetails::calcceiling());
diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp
index e1c737f99..ca5e606cd 100644
--- a/desktop-widgets/preferences/preferencesdialog.cpp
+++ b/desktop-widgets/preferences/preferencesdialog.cpp
@@ -16,6 +16,7 @@
#include "preferences_reset.h"
#include "core/qthelper.h"
+#include "core/subsurface-qt/divelistnotifier.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
@@ -25,7 +26,7 @@
#include <QAbstractButton>
#include <QDebug>
-PreferencesDialog* PreferencesDialog::instance()
+PreferencesDialog *PreferencesDialog::instance()
{
static PreferencesDialog *self = new PreferencesDialog();
return self;
@@ -130,10 +131,10 @@ void PreferencesDialog::refreshPages()
void PreferencesDialog::applyRequested(bool closeIt)
{
Q_FOREACH(AbstractPreferencesWidget *page, pages) {
- connect(page, &AbstractPreferencesWidget::settingsChanged, this, &PreferencesDialog::settingsChanged, Qt::UniqueConnection);
+ connect(page, &AbstractPreferencesWidget::settingsChanged, &diveListNotifier, &DiveListNotifier::settingsChanged, Qt::UniqueConnection);
page->syncSettings();
}
- emit settingsChanged();
+ emit diveListNotifier.settingsChanged();
if (closeIt)
accept();
}
@@ -152,6 +153,6 @@ void PreferencesDialog::defaultsRequested()
Q_FOREACH(AbstractPreferencesWidget *page, pages) {
page->refreshSettings();
}
- emit settingsChanged();
+ emit diveListNotifier.settingsChanged();
accept();
}
diff --git a/desktop-widgets/preferences/preferencesdialog.h b/desktop-widgets/preferences/preferencesdialog.h
index 67433f0fd..8abf812e9 100644
--- a/desktop-widgets/preferences/preferencesdialog.h
+++ b/desktop-widgets/preferences/preferencesdialog.h
@@ -19,8 +19,6 @@ public:
void addPreferencePage(AbstractPreferencesWidget *page);
void refreshPages();
void defaultsRequested();
-signals:
- void settingsChanged();
private:
PreferencesDialog();
void cancelRequested();
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 386fa454e..8b1973721 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -8,7 +8,6 @@
#include "desktop-widgets/tab-widgets/maintab.h"
#include "desktop-widgets/mainwindow.h"
#include "desktop-widgets/mapwidget.h"
-#include "desktop-widgets/preferences/preferencesdialog.h"
#include "core/qthelper.h"
#include "core/trip.h"
#include "qt-models/diveplannermodel.h"
@@ -91,6 +90,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
connect(&diveListNotifier, &DiveListNotifier::tripChanged, this, &MainTab::tripChanged);
connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &MainTab::diveSiteEdited);
connect(&diveListNotifier, &DiveListNotifier::commandExecuted, this, &MainTab::closeWarning);
+ connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &MainTab::updateDiveInfo);
connect(ui.editDiveSiteButton, &QToolButton::clicked, MainWindow::instance(), &MainWindow::startDiveSiteEdit);
connect(ui.location, &DiveLocationLineEdit::entered, MapWidget::instance(), &MapWidget::centerOnIndex);
@@ -100,7 +100,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
// One might think that we could listen to the precise property-changed signals of the preferences system.
// Alas, this is not the case. When the user switches to system-format, the preferences sends the according
// signal. However, the correct date and time format is set by the preferences dialog later. This should be fixed.
- connect(PreferencesDialog::instance(), &PreferencesDialog::settingsChanged, this, &MainTab::updateDateTimeFields);
+ connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &MainTab::updateDateTimeFields);
QAction *action = new QAction(tr("Apply changes"), this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges()));
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 <libdivecomputer/parser.h>
#include <QScrollBar>
@@ -47,9 +47,6 @@
#ifndef QT_NO_DEBUG
#include <QTableView>
#endif
-#ifndef SUBSURFACE_MOBILE
-#include "desktop-widgets/preferences/preferencesdialog.h"
-#endif
#include <QtWidgets>
#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"
diff --git a/qt-models/tankinfomodel.cpp b/qt-models/tankinfomodel.cpp
index 8d78cf3d5..76d921c71 100644
--- a/qt-models/tankinfomodel.cpp
+++ b/qt-models/tankinfomodel.cpp
@@ -87,6 +87,7 @@ TankInfoModel::TankInfoModel()
{
setHeaderDataStrings(QStringList() << tr("Description") << tr("ml") << tr("bar"));
connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &TankInfoModel::update);
+ connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &TankInfoModel::update);
update();
}
diff --git a/subsurface-desktop-main.cpp b/subsurface-desktop-main.cpp
index 25891e3c0..6f662ecd7 100644
--- a/subsurface-desktop-main.cpp
+++ b/subsurface-desktop-main.cpp
@@ -6,7 +6,6 @@
#include <string.h>
#include <time.h>
-#include "core/color.h"
#include "core/downloadfromdcthread.h" // for fill_computer_list
#include "core/errorhelper.h"
#include "core/parse.h"
@@ -15,11 +14,7 @@
#include "core/subsurfacestartup.h"
#include "core/settings/qPref.h"
#include "core/tag.h"
-#include "desktop-widgets/diveplanner.h"
#include "desktop-widgets/mainwindow.h"
-#include "desktop-widgets/preferences/preferencesdialog.h"
-#include "desktop-widgets/tab-widgets/maintab.h"
-#include "profile-widget/profilewidget2.h"
#include <QApplication>
#include <QLoggingCategory>