From cdf83f5ef6415eb44cc95e993ab38b4b44f03427 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 8 Apr 2014 13:45:23 +0200 Subject: [PATCH] Change some references of QSettings to the pref struct. After adding the animation member in the preference struct, it is very resonable to change these references of QSettings to the preference structure instead. Signed-off-by: Gehad elrobey Signed-off-by: Dirk Hohndel --- qt-ui/profile/animationfunctions.cpp | 10 ++++------ qt-ui/profile/profilewidget2.cpp | 12 +++++------- subsurfacestartup.c | 1 + 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/qt-ui/profile/animationfunctions.cpp b/qt-ui/profile/animationfunctions.cpp index 81fbf5eee..05e437cf0 100644 --- a/qt-ui/profile/animationfunctions.cpp +++ b/qt-ui/profile/animationfunctions.cpp @@ -1,7 +1,8 @@ #include "animationfunctions.h" +#include "dive.h" +#include "pref.h" #include #include -#include namespace Animations { @@ -25,12 +26,9 @@ namespace Animations void moveTo(QObject *obj, qreal x, qreal y) { - QSettings s; - s.beginGroup("Animations"); - int msecs = s.value("animation_speed", 500).toInt(); - if (msecs != 0){ + if (prefs.animation != 0){ QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos"); - animation->setDuration(msecs); + animation->setDuration(prefs.animation); animation->setStartValue(obj->property("pos").toPointF()); animation->setEndValue(QPointF(x, y)); animation->start(QAbstractAnimation::DeleteWhenStopped); diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 95f8f49ee..97511c785 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -13,6 +13,8 @@ #include "planner.h" #include "device.h" #include "ruleritem.h" +#include "../../dive.h" +#include "../../pref.h" #include #include #include @@ -336,10 +338,8 @@ void ProfileWidget2::plotDives(QList dives) int animSpeedBackup = -1; if (firstCall && MainWindow::instance()->filesFromCommandLine()) { - QSettings s; - s.beginGroup("Animations"); - animSpeedBackup = s.value("animation_speed", 500).toInt(); - s.setValue("animation_speed", 0); + animSpeedBackup = prefs.animation; + prefs.animation = 0; firstCall = false; } @@ -469,9 +469,7 @@ void ProfileWidget2::plotDives(QList dives) } diveComputerText->setText(currentdc->model); if (MainWindow::instance()->filesFromCommandLine() && animSpeedBackup != -1) { - QSettings s; - s.beginGroup("Animations"); - s.setValue("animation_speed", animSpeedBackup); + prefs.animation = animSpeedBackup; } } diff --git a/subsurfacestartup.c b/subsurfacestartup.c index 3bd2dc0f1..4e7550ce3 100644 --- a/subsurfacestartup.c +++ b/subsurfacestartup.c @@ -26,6 +26,7 @@ struct preferences default_prefs = { .calc_ndl_tts = false, .gflow = 30, .gfhigh = 75, + .animation = 500, .gf_low_at_maxdepth = false, .font_size = -1, .display_invalid_dives = false,