From 96a94f1a19d22fa0432e10495315ce3e98b35c4f Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Tue, 25 Nov 2014 21:22:02 +0100 Subject: A widget to add a set-point change Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- qt-ui/setpoint.ui | 130 ++++++++++++++++++++++++++++++++++++++++++++++++ qt-ui/simplewidgets.cpp | 31 ++++++++++++ qt-ui/simplewidgets.h | 18 +++++++ subsurface.pro | 1 + 4 files changed, 180 insertions(+) create mode 100644 qt-ui/setpoint.ui diff --git a/qt-ui/setpoint.ui b/qt-ui/setpoint.ui new file mode 100644 index 000000000..d96488a31 --- /dev/null +++ b/qt-ui/setpoint.ui @@ -0,0 +1,130 @@ + + + SetpointDialog + + + Qt::WindowModal + + + + 0 + 0 + 211 + 125 + + + + Renumber + + + + :/subsurface-icon + + + + + 1 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + New set-point (0 for OC) + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + bar + + + 1 + + + 0.000000000000000 + + + 2.000000000000000 + + + 0.100000000000000 + + + 1.100000000000000 + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + SetpointDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + SetpointDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index da8a7d014..6ab4566fd 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -18,6 +18,8 @@ #include "mainwindow.h" #include "helpers.h" #include "ui_filterwidget.h" +#include "libdivecomputer/parser.h" + class MinMaxAvgWidgetPrivate { public: @@ -160,6 +162,35 @@ 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; +} + +void SetpointDialog::buttonClicked(QAbstractButton *button) +{ + if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) { + add_event(dc, time, SAMPLE_EVENT_PO2, 0, ui.spinbox->value(), "SP change"); + } +} + +SetpointDialog::SetpointDialog(QWidget *parent) : QDialog(parent) +{ + 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())); +} + ShiftTimesDialog *ShiftTimesDialog::instance() { static ShiftTimesDialog *self = new ShiftTimesDialog(MainWindow::instance()); diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index f9a6fdad3..c5631fd75 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -9,11 +9,13 @@ class QAbstractButton; #include #include "ui_renumber.h" +#include "ui_setpoint.h" #include "ui_shifttimes.h" #include "ui_shiftimagetimes.h" #include "ui_divecomponentselection.h" #include "ui_listfilter.h" #include "exif.h" +#include class MinMaxAvgWidget : public QWidget { Q_OBJECT @@ -56,6 +58,22 @@ private: bool selectedOnly; }; +class SetpointDialog : public QDialog { + Q_OBJECT +public: + static SetpointDialog *instance(); + void setpointData(struct divecomputer *divecomputer, int time); +private +slots: + void buttonClicked(QAbstractButton *button); + +private: + explicit SetpointDialog(QWidget *parent); + Ui::SetpointDialog ui; + struct divecomputer *dc; + int time; +}; + class ShiftTimesDialog : public QDialog { Q_OBJECT public: diff --git a/subsurface.pro b/subsurface.pro index 7a4d8bfd4..24aab3a0b 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -220,6 +220,7 @@ FORMS = \ qt-ui/preferences.ui \ qt-ui/printoptions.ui \ qt-ui/renumber.ui \ + qt-ui/setpoint.ui \ qt-ui/shifttimes.ui \ qt-ui/shiftimagetimes.ui \ qt-ui/webservices.ui \ -- cgit v1.2.3-70-g09d2