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 <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Gehad elrobey 2014-04-08 13:45:23 +02:00 committed by Dirk Hohndel
parent 6a8d929876
commit cdf83f5ef6
3 changed files with 10 additions and 13 deletions

View file

@ -1,7 +1,8 @@
#include "animationfunctions.h" #include "animationfunctions.h"
#include "dive.h"
#include "pref.h"
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include <QPointF> #include <QPointF>
#include <QSettings>
namespace Animations namespace Animations
{ {
@ -25,12 +26,9 @@ namespace Animations
void moveTo(QObject *obj, qreal x, qreal y) void moveTo(QObject *obj, qreal x, qreal y)
{ {
QSettings s; if (prefs.animation != 0){
s.beginGroup("Animations");
int msecs = s.value("animation_speed", 500).toInt();
if (msecs != 0){
QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos"); QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
animation->setDuration(msecs); animation->setDuration(prefs.animation);
animation->setStartValue(obj->property("pos").toPointF()); animation->setStartValue(obj->property("pos").toPointF());
animation->setEndValue(QPointF(x, y)); animation->setEndValue(QPointF(x, y));
animation->start(QAbstractAnimation::DeleteWhenStopped); animation->start(QAbstractAnimation::DeleteWhenStopped);

View file

@ -13,6 +13,8 @@
#include "planner.h" #include "planner.h"
#include "device.h" #include "device.h"
#include "ruleritem.h" #include "ruleritem.h"
#include "../../dive.h"
#include "../../pref.h"
#include <libdivecomputer/parser.h> #include <libdivecomputer/parser.h>
#include <QSignalTransition> #include <QSignalTransition>
#include <QPropertyAnimation> #include <QPropertyAnimation>
@ -336,10 +338,8 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
int animSpeedBackup = -1; int animSpeedBackup = -1;
if (firstCall && MainWindow::instance()->filesFromCommandLine()) { if (firstCall && MainWindow::instance()->filesFromCommandLine()) {
QSettings s; animSpeedBackup = prefs.animation;
s.beginGroup("Animations"); prefs.animation = 0;
animSpeedBackup = s.value("animation_speed", 500).toInt();
s.setValue("animation_speed", 0);
firstCall = false; firstCall = false;
} }
@ -469,9 +469,7 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
} }
diveComputerText->setText(currentdc->model); diveComputerText->setText(currentdc->model);
if (MainWindow::instance()->filesFromCommandLine() && animSpeedBackup != -1) { if (MainWindow::instance()->filesFromCommandLine() && animSpeedBackup != -1) {
QSettings s; prefs.animation = animSpeedBackup;
s.beginGroup("Animations");
s.setValue("animation_speed", animSpeedBackup);
} }
} }

View file

@ -26,6 +26,7 @@ struct preferences default_prefs = {
.calc_ndl_tts = false, .calc_ndl_tts = false,
.gflow = 30, .gflow = 30,
.gfhigh = 75, .gfhigh = 75,
.animation = 500,
.gf_low_at_maxdepth = false, .gf_low_at_maxdepth = false,
.font_size = -1, .font_size = -1,
.display_invalid_dives = false, .display_invalid_dives = false,