mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
8bbd778c28
commit
2d7be7a0e3
16 changed files with 36 additions and 49 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ signals:
|
|||
void divesSelected();
|
||||
public
|
||||
slots:
|
||||
void settingsChanged();
|
||||
void reloadHeaderActions();
|
||||
private
|
||||
slots:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ public:
|
|||
void addPreferencePage(AbstractPreferencesWidget *page);
|
||||
void refreshPages();
|
||||
void defaultsRequested();
|
||||
signals:
|
||||
void settingsChanged();
|
||||
private:
|
||||
PreferencesDialog();
|
||||
void cancelRequested();
|
||||
|
|
|
|||
|
|
@ -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()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue