summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2014-11-25 21:22:02 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-12-01 14:19:03 -0800
commit96a94f1a19d22fa0432e10495315ce3e98b35c4f (patch)
tree120471db57a8b0bdad99b2bab32390b6adc8f3e3 /qt-ui
parent584775cbc053d8b471f5a5d3ea232857f056e628 (diff)
downloadsubsurface-96a94f1a19d22fa0432e10495315ce3e98b35c4f.tar.gz
A widget to add a set-point change
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/setpoint.ui130
-rw-r--r--qt-ui/simplewidgets.cpp31
-rw-r--r--qt-ui/simplewidgets.h18
3 files changed, 179 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: