diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-05-27 14:00:47 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-27 09:47:35 -0700 |
commit | 25f1bc488f68395390a3a87328b31dfa7deac11c (patch) | |
tree | 7ed5f8806a5b6ba38607b17d441ca4f90ef7e7e6 /desktop-widgets/simplewidgets.cpp | |
parent | 79f90effe97daf1a619941dec50eddebcddc6fa6 (diff) | |
download | subsurface-25f1bc488f68395390a3a87328b31dfa7deac11c.tar.gz |
cleanup: un-singletonize RenumberDialog
There is no reason that this dialog is a singleton. Since it is modal,
it can be created on demand. This simplifies code, because the mode
(selected-only or all-dives) can be set in the constructor.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/simplewidgets.cpp')
-rw-r--r-- | desktop-widgets/simplewidgets.cpp | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp index ba3dc67ee..ef7ca71d0 100644 --- a/desktop-widgets/simplewidgets.cpp +++ b/desktop-widgets/simplewidgets.cpp @@ -124,27 +124,6 @@ void MinMaxAvgWidget::setAvgVisibility(bool visible) avgValue->setVisible(visible); } -RenumberDialog *RenumberDialog::instance() -{ - static RenumberDialog *self = new RenumberDialog(MainWindow::instance()); - return self; -} - -void RenumberDialog::renumberOnlySelected(bool selected) -{ - if (selected && amount_selected == 1) - ui.renumberText->setText(tr("New number")); - else - ui.renumberText->setText(tr("New starting number")); - - if (selected) - ui.groupBox->setTitle(tr("Renumber selected dives")); - else - ui.groupBox->setTitle(tr("Renumber all dives")); - - selectedOnly = selected; -} - void RenumberDialog::buttonClicked(QAbstractButton *button) { if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) { @@ -163,7 +142,7 @@ void RenumberDialog::buttonClicked(QAbstractButton *button) } } -RenumberDialog::RenumberDialog(QWidget *parent) : QDialog(parent), selectedOnly(false) +RenumberDialog::RenumberDialog(bool selectedOnlyIn, QWidget *parent) : QDialog(parent), selectedOnly(selectedOnlyIn) { ui.setupUi(this); connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); @@ -171,6 +150,16 @@ RenumberDialog::RenumberDialog(QWidget *parent) : QDialog(parent), selectedOnly( 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())); + + if (selectedOnly && amount_selected == 1) + ui.renumberText->setText(tr("New number")); + else + ui.renumberText->setText(tr("New starting number")); + + if (selectedOnly) + ui.groupBox->setTitle(tr("Renumber selected dives")); + else + ui.groupBox->setTitle(tr("Renumber all dives")); } void SetpointDialog::buttonClicked(QAbstractButton *button) |