mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
33fb6461fb
commit
806cfcee21
3 changed files with 6 additions and 20 deletions
|
@ -174,18 +174,6 @@ RenumberDialog::RenumberDialog(QWidget *parent) : QDialog(parent), selectedOnly(
|
||||||
connect(quit, SIGNAL(activated()), parent, SLOT(close()));
|
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)
|
void SetpointDialog::buttonClicked(QAbstractButton *button)
|
||||||
{
|
{
|
||||||
if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole && dc) {
|
if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole && dc) {
|
||||||
|
@ -197,15 +185,15 @@ void SetpointDialog::buttonClicked(QAbstractButton *button)
|
||||||
MainWindow::instance()->graphics->replot();
|
MainWindow::instance()->graphics->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetpointDialog::SetpointDialog(QWidget *parent) : QDialog(parent),
|
SetpointDialog::SetpointDialog(struct divecomputer *dcIn, int seconds) : QDialog(MainWindow::instance()),
|
||||||
dc(0), time(0)
|
dc(dcIn), time(seconds < 0 ? 0 : seconds)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
|
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
|
||||||
QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
|
QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
|
||||||
connect(close, SIGNAL(activated()), this, SLOT(close()));
|
connect(close, SIGNAL(activated()), this, SLOT(close()));
|
||||||
QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
|
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()
|
ShiftTimesDialog *ShiftTimesDialog::instance()
|
||||||
|
|
|
@ -65,14 +65,12 @@ private:
|
||||||
class SetpointDialog : public QDialog {
|
class SetpointDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static SetpointDialog *instance();
|
SetpointDialog(struct divecomputer *divecomputer, int time);
|
||||||
void setpointData(struct divecomputer *divecomputer, int time);
|
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
void buttonClicked(QAbstractButton *button);
|
void buttonClicked(QAbstractButton *button);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit SetpointDialog(QWidget *parent);
|
|
||||||
Ui::SetpointDialog ui;
|
Ui::SetpointDialog ui;
|
||||||
struct divecomputer *dc;
|
struct divecomputer *dc;
|
||||||
int time;
|
int time;
|
||||||
|
|
|
@ -1611,8 +1611,8 @@ void ProfileWidget2::addDivemodeSwitch(int seconds, int divemode)
|
||||||
|
|
||||||
void ProfileWidget2::addSetpointChange(int seconds)
|
void ProfileWidget2::addSetpointChange(int seconds)
|
||||||
{
|
{
|
||||||
SetpointDialog::instance()->setpointData(current_dc, seconds);
|
SetpointDialog dialog(current_dc, seconds);
|
||||||
SetpointDialog::instance()->show();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileWidget2::splitDive(int seconds)
|
void ProfileWidget2::splitDive(int seconds)
|
||||||
|
|
Loading…
Add table
Reference in a new issue