diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-03-03 23:09:25 +0100 |
---|---|---|
committer | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-07 00:13:35 +0200 |
commit | 806cfcee212fa89ecfccad0f78225b83159d131e (patch) | |
tree | 1f5ac4a754f251849ca9bcb2421bde6cab994f63 /desktop-widgets | |
parent | 33fb6461fbe7e389081e77853e63638a1a343623 (diff) | |
download | subsurface-806cfcee212fa89ecfccad0f78225b83159d131e.tar.gz |
cleanup: un-singletonify SetpointDialog
We have too many global objects. There is no reason why this dialog
should be a persistent global object.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/simplewidgets.cpp | 18 | ||||
-rw-r--r-- | desktop-widgets/simplewidgets.h | 4 |
2 files changed, 4 insertions, 18 deletions
diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp index fb4d3750b..cbf37c398 100644 --- a/desktop-widgets/simplewidgets.cpp +++ b/desktop-widgets/simplewidgets.cpp @@ -174,18 +174,6 @@ RenumberDialog::RenumberDialog(QWidget *parent) : QDialog(parent), selectedOnly( connect(quit, SIGNAL(activated()), parent, SLOT(close())); } -SetpointDialog *SetpointDialog::instance() -{ - static SetpointDialog *self = new SetpointDialog(MainWindow::instance()); - return self; -} - -void SetpointDialog::setpointData(struct divecomputer *divecomputer, int second) -{ - dc = divecomputer; - time = second < 0 ? 0 : second; -} - void SetpointDialog::buttonClicked(QAbstractButton *button) { if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole && dc) { @@ -197,15 +185,15 @@ void SetpointDialog::buttonClicked(QAbstractButton *button) MainWindow::instance()->graphics->replot(); } -SetpointDialog::SetpointDialog(QWidget *parent) : QDialog(parent), - dc(0), time(0) +SetpointDialog::SetpointDialog(struct divecomputer *dcIn, int seconds) : QDialog(MainWindow::instance()), + dc(dcIn), time(seconds < 0 ? 0 : seconds) { ui.setupUi(this); connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); connect(close, SIGNAL(activated()), this, SLOT(close())); QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); - connect(quit, SIGNAL(activated()), parent, SLOT(close())); + connect(quit, SIGNAL(activated()), parent(), SLOT(close())); } ShiftTimesDialog *ShiftTimesDialog::instance() diff --git a/desktop-widgets/simplewidgets.h b/desktop-widgets/simplewidgets.h index 99cfc0fa2..e293f352c 100644 --- a/desktop-widgets/simplewidgets.h +++ b/desktop-widgets/simplewidgets.h @@ -65,14 +65,12 @@ private: class SetpointDialog : public QDialog { Q_OBJECT public: - static SetpointDialog *instance(); - void setpointData(struct divecomputer *divecomputer, int time); + SetpointDialog(struct divecomputer *divecomputer, int time); private slots: void buttonClicked(QAbstractButton *button); private: - explicit SetpointDialog(QWidget *parent); Ui::SetpointDialog ui; struct divecomputer *dc; int time; |