diff options
-rw-r--r-- | qt-ui/setpoint.ui | 130 | ||||
-rw-r--r-- | qt-ui/simplewidgets.cpp | 31 | ||||
-rw-r--r-- | qt-ui/simplewidgets.h | 18 | ||||
-rw-r--r-- | subsurface.pro | 1 |
4 files changed, 180 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SetpointDialog</class> + <widget class="QDialog" name="SetpointDialog"> + <property name="windowModality"> + <enum>Qt::WindowModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>211</width> + <height>125</height> + </rect> + </property> + <property name="windowTitle"> + <string>Renumber</string> + </property> + <property name="windowIcon"> + <iconset> + <normalon>:/subsurface-icon</normalon> + </iconset> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="spacing"> + <number>1</number> + </property> + <property name="leftMargin"> + <number>3</number> + </property> + <property name="topMargin"> + <number>3</number> + </property> + <property name="rightMargin"> + <number>3</number> + </property> + <property name="bottomMargin"> + <number>3</number> + </property> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>New set-point (0 for OC)</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QDoubleSpinBox" name="spinbox"> + <property name="suffix"> + <string>bar</string> + </property> + <property name="decimals"> + <number>1</number> + </property> + <property name="minimum"> + <double>0.000000000000000</double> + </property> + <property name="maximum"> + <double>2.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.100000000000000</double> + </property> + <property name="value"> + <double>1.100000000000000</double> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>SetpointDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>SetpointDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> 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 <stdint.h> #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 <dive.h> 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 \ |