summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2014-02-12 16:46:17 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-17 10:56:43 -0800
commitfe2a264db3ee9ef49c87e5530d8d198357cd43b5 (patch)
treed18afcb3ab3d71cd48e45b8ad6160091e4a83c05 /qt-ui
parentdd24eaa377bf95fa9dafd43ca5989aebd822663b (diff)
downloadsubsurface-fe2a264db3ee9ef49c87e5530d8d198357cd43b5.tar.gz
Store camera time offset in preferences
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/divelistview.cpp20
-rw-r--r--qt-ui/divelistview.h2
-rw-r--r--qt-ui/simplewidgets.cpp13
-rw-r--r--qt-ui/simplewidgets.h1
4 files changed, 36 insertions, 0 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 028b232c2..14a2f30e5 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -813,7 +813,9 @@ void DiveListView::loadImages()
updateLastUsedImageDir(QFileInfo(fileNames[0]).dir().path());
ShiftImageTimesDialog shiftDialog(this);
+ shiftDialog.setOffset(lastImageTimeOffset());
shiftDialog.exec();
+ updateLastImageTimeOffset(shiftDialog.amount());
for (int i = 0; i < fileNames.size(); ++i) {
struct tm tm;
@@ -890,3 +892,21 @@ void DiveListView::updateLastUsedImageDir(const QString& dir)
s.beginGroup("FileDialog");
s.setValue("LastImageDir", dir);
}
+
+int DiveListView::lastImageTimeOffset()
+{
+ QSettings settings;
+ int offset = 0;
+
+ settings.beginGroup("MainWindow");
+ if (settings.contains("LastImageTimeOffset"))
+ offset = settings.value("LastImageTimeOffset").toInt();
+ return offset;
+}
+
+void DiveListView::updateLastImageTimeOffset(const int offset)
+{
+ QSettings s;
+ s.beginGroup("MainWindow");
+ s.setValue("LastImageTimeOffset", offset);
+}
diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h
index 02efac370..c6321223c 100644
--- a/qt-ui/divelistview.h
+++ b/qt-ui/divelistview.h
@@ -75,6 +75,8 @@ private:
void selectTrip ( dive_trip_t* trip );
QString lastUsedImageDir();
void updateLastUsedImageDir(const QString& s);
+ void updateLastImageTimeOffset(int offset);
+ int lastImageTimeOffset();
};
#endif // DIVELISTVIEW_H
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
index 2a0b48307..5d7ed299a 100644
--- a/qt-ui/simplewidgets.cpp
+++ b/qt-ui/simplewidgets.cpp
@@ -11,6 +11,7 @@
#include <QProcess>
#include <QStringList>
#include <QDebug>
+#include <QTime>
#include "../dive.h"
#include "mainwindow.h"
@@ -163,6 +164,7 @@ void ShiftImageTimesDialog::buttonClicked(QAbstractButton* button)
m_amount = ui.timeEdit->time().hour() * 3600 + ui.timeEdit->time().minute() * 60;
if (ui.backwards->isChecked())
m_amount *= -1;
+
}
}
@@ -177,6 +179,17 @@ int ShiftImageTimesDialog::amount() const
return m_amount;
}
+void ShiftImageTimesDialog::setOffset(int offset)
+{
+ if (offset >= 0) {
+ ui.forward->setDown(TRUE);
+ } else {
+ ui.backwards->setDown(TRUE);
+ offset *= -1;
+ }
+ ui.timeEdit->setTime(QTime::QTime(offset / 3600, (offset % 3600) / 60, offset % 60));
+}
+
bool isGnome3Session()
{
#if defined(QT_OS_WIW) || defined(QT_OS_MAC)
diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h
index 6cf5bcda0..d227c91df 100644
--- a/qt-ui/simplewidgets.h
+++ b/qt-ui/simplewidgets.h
@@ -60,6 +60,7 @@ class ShiftImageTimesDialog : public QDialog {
public:
explicit ShiftImageTimesDialog(QWidget *parent);
int amount() const;
+ void setOffset(int offset);
private slots:
void buttonClicked(QAbstractButton *button);
private: