mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
cleanup: un-singletonize ShiftTimesDialog
There is no reason that this dialog is a singleton. Since it is modal, it can be created on demand. Apart from removing superfluous global state, this simplifies code, because preparing the widget can now be done in the constructor instead of overriding the showEvent() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
25f1bc488f
commit
7417f865cd
3 changed files with 3 additions and 13 deletions
|
@ -860,7 +860,8 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event)
|
||||||
|
|
||||||
void DiveListView::shiftTimes()
|
void DiveListView::shiftTimes()
|
||||||
{
|
{
|
||||||
ShiftTimesDialog::instance()->show();
|
ShiftTimesDialog dialog(MainWindow::instance());
|
||||||
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveListView::loadImages()
|
void DiveListView::loadImages()
|
||||||
|
|
|
@ -179,12 +179,6 @@ SetpointDialog::SetpointDialog(struct dive *dIn, int dcNrIn, int seconds) : QDia
|
||||||
connect(quit, &QShortcut::activated, MainWindow::instance(), &QWidget::close);
|
connect(quit, &QShortcut::activated, MainWindow::instance(), &QWidget::close);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShiftTimesDialog *ShiftTimesDialog::instance()
|
|
||||||
{
|
|
||||||
static ShiftTimesDialog *self = new ShiftTimesDialog(MainWindow::instance());
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShiftTimesDialog::buttonClicked(QAbstractButton *button)
|
void ShiftTimesDialog::buttonClicked(QAbstractButton *button)
|
||||||
{
|
{
|
||||||
int amount;
|
int amount;
|
||||||
|
@ -196,10 +190,7 @@ void ShiftTimesDialog::buttonClicked(QAbstractButton *button)
|
||||||
if (amount != 0)
|
if (amount != 0)
|
||||||
Command::shiftTime(getDiveSelection(), amount);
|
Command::shiftTime(getDiveSelection(), amount);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ShiftTimesDialog::showEvent(QShowEvent*)
|
|
||||||
{
|
|
||||||
ui.timeEdit->setTime(QTime(0, 0, 0, 0));
|
ui.timeEdit->setTime(QTime(0, 0, 0, 0));
|
||||||
when = get_times(); //get time of first selected dive
|
when = get_times(); //get time of first selected dive
|
||||||
ui.currentTime->setText(get_dive_date_string(when));
|
ui.currentTime->setText(get_dive_date_string(when));
|
||||||
|
|
|
@ -78,15 +78,13 @@ private:
|
||||||
class ShiftTimesDialog : public QDialog {
|
class ShiftTimesDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static ShiftTimesDialog *instance();
|
explicit ShiftTimesDialog(QWidget *parent);
|
||||||
void showEvent(QShowEvent *event);
|
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
void buttonClicked(QAbstractButton *button);
|
void buttonClicked(QAbstractButton *button);
|
||||||
void changeTime();
|
void changeTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ShiftTimesDialog(QWidget *parent);
|
|
||||||
int64_t when;
|
int64_t when;
|
||||||
Ui::ShiftTimesDialog ui;
|
Ui::ShiftTimesDialog ui;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue