mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Animation speed is a value, not a boolean
This breaks compatibility with old preferences, but it's a single key and not that very important so I don't think it's a bigger issue I've renamed prefs.animation to prefs.animation_speed to denote that it's a value, and not a state. Also, fixed the places that were treating it as a state (on/off) to treat it like a correct value. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
82bcb1767c
commit
65eefe7b59
6 changed files with 18 additions and 18 deletions
2
pref.h
2
pref.h
|
@ -35,7 +35,7 @@ struct preferences {
|
||||||
short calcndltts;
|
short calcndltts;
|
||||||
short gflow;
|
short gflow;
|
||||||
short gfhigh;
|
short gfhigh;
|
||||||
bool animation;
|
int animation_speed;
|
||||||
bool gf_low_at_maxdepth;
|
bool gf_low_at_maxdepth;
|
||||||
short display_invalid_dives;
|
short display_invalid_dives;
|
||||||
short unit_system;
|
short unit_system;
|
||||||
|
|
|
@ -103,7 +103,7 @@ void PreferencesDialog::setUiFromPrefs()
|
||||||
ui.show_average_depth->setChecked(prefs.show_average_depth);
|
ui.show_average_depth->setChecked(prefs.show_average_depth);
|
||||||
ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
|
ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
|
||||||
ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
|
ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
|
||||||
ui.velocitySlider->setValue(prefs.animation);
|
ui.velocitySlider->setValue(prefs.animation_speed);
|
||||||
|
|
||||||
QSortFilterProxyModel *filterModel = new QSortFilterProxyModel();
|
QSortFilterProxyModel *filterModel = new QSortFilterProxyModel();
|
||||||
filterModel->setSourceModel(LanguageModel::instance());
|
filterModel->setSourceModel(LanguageModel::instance());
|
||||||
|
@ -344,7 +344,7 @@ void PreferencesDialog::loadSettings()
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("Animations");
|
s.beginGroup("Animations");
|
||||||
GET_INT("animation_speed", animation);
|
GET_INT("animation_speed", animation_speed);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("Network");
|
s.beginGroup("Network");
|
||||||
|
|
|
@ -122,14 +122,14 @@ int PrintLayout::estimateTotalDives() const
|
||||||
void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
|
void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
|
||||||
{
|
{
|
||||||
int i, row = 0, col = 0, printed = 0, total = estimateTotalDives();
|
int i, row = 0, col = 0, printed = 0, total = estimateTotalDives();
|
||||||
bool animationOriginal = prefs.animation;
|
int animationOriginal = prefs.animation_speed;
|
||||||
|
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
if (!total)
|
if (!total)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// disable animations on the profile:
|
// disable animations on the profile:
|
||||||
prefs.animation = false;
|
prefs.animation_speed = 0;
|
||||||
|
|
||||||
// setup a painter
|
// setup a painter
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
|
@ -223,7 +223,7 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
|
||||||
// we need to force a redraw of the profile so it switches back from print mode
|
// we need to force a redraw of the profile so it switches back from print mode
|
||||||
profile->plotDive(0, true);
|
profile->plotDive(0, true);
|
||||||
// re-enable animations
|
// re-enable animations
|
||||||
prefs.animation = animationOriginal;
|
prefs.animation_speed = animationOriginal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we create a table that has a fixed height, but can stretch to fit certain width */
|
/* we create a table that has a fixed height, but can stretch to fit certain width */
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Animations {
|
||||||
|
|
||||||
void hide(QObject *obj)
|
void hide(QObject *obj)
|
||||||
{
|
{
|
||||||
if (prefs.animation != 0) {
|
if (prefs.animation_speed != 0) {
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
||||||
animation->setStartValue(1);
|
animation->setStartValue(1);
|
||||||
animation->setEndValue(0);
|
animation->setEndValue(0);
|
||||||
|
@ -20,7 +20,7 @@ namespace Animations {
|
||||||
|
|
||||||
void animDelete(QObject *obj)
|
void animDelete(QObject *obj)
|
||||||
{
|
{
|
||||||
if (prefs.animation != 0) {
|
if (prefs.animation_speed != 0) {
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
||||||
obj->connect(animation, SIGNAL(finished()), SLOT(deleteLater()));
|
obj->connect(animation, SIGNAL(finished()), SLOT(deleteLater()));
|
||||||
animation->setStartValue(1);
|
animation->setStartValue(1);
|
||||||
|
@ -33,9 +33,9 @@ namespace Animations {
|
||||||
|
|
||||||
void moveTo(QObject *obj, qreal x, qreal y)
|
void moveTo(QObject *obj, qreal x, qreal y)
|
||||||
{
|
{
|
||||||
if (prefs.animation != 0) {
|
if (prefs.animation_speed != 0) {
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
|
||||||
animation->setDuration(prefs.animation);
|
animation->setDuration(prefs.animation_speed);
|
||||||
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);
|
||||||
|
@ -46,9 +46,9 @@ namespace Animations {
|
||||||
|
|
||||||
void scaleTo(QObject *obj, qreal scale)
|
void scaleTo(QObject *obj, qreal scale)
|
||||||
{
|
{
|
||||||
if (prefs.animation != 0) {
|
if (prefs.animation_speed != 0) {
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "scale");
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "scale");
|
||||||
animation->setDuration(prefs.animation);
|
animation->setDuration(prefs.animation_speed);
|
||||||
animation->setStartValue(obj->property("scale").toReal());
|
animation->setStartValue(obj->property("scale").toReal());
|
||||||
animation->setEndValue(QVariant::fromValue(scale));
|
animation->setEndValue(QVariant::fromValue(scale));
|
||||||
animation->setEasingCurve(QEasingCurve::InCubic);
|
animation->setEasingCurve(QEasingCurve::InCubic);
|
||||||
|
|
|
@ -386,10 +386,10 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
|
||||||
}
|
}
|
||||||
|
|
||||||
// special handling for the first time we display things
|
// special handling for the first time we display things
|
||||||
int animSpeedBackup = -1;
|
int animSpeedBackup = 0;
|
||||||
if (firstCall && MainWindow::instance()->filesFromCommandLine()) {
|
if (firstCall && MainWindow::instance()->filesFromCommandLine()) {
|
||||||
animSpeedBackup = prefs.animation;
|
animSpeedBackup = prefs.animation_speed;
|
||||||
prefs.animation = 0;
|
prefs.animation_speed = 0;
|
||||||
firstCall = false;
|
firstCall = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,8 +518,8 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
|
||||||
if ((nr = number_of_computers(&displayed_dive)) > 1)
|
if ((nr = number_of_computers(&displayed_dive)) > 1)
|
||||||
dcText += tr(" (#%1 of %2)").arg(dc_number + 1).arg(nr);
|
dcText += tr(" (#%1 of %2)").arg(dc_number + 1).arg(nr);
|
||||||
diveComputerText->setText(dcText);
|
diveComputerText->setText(dcText);
|
||||||
if (MainWindow::instance()->filesFromCommandLine() && animSpeedBackup != -1) {
|
if (MainWindow::instance()->filesFromCommandLine() && animSpeedBackup != 0) {
|
||||||
prefs.animation = animSpeedBackup;
|
prefs.animation_speed = animSpeedBackup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentState == ADD || currentState == PLAN) { // TODO: figure a way to move this from here.
|
if (currentState == ADD || currentState == PLAN) { // TODO: figure a way to move this from here.
|
||||||
|
|
|
@ -26,7 +26,7 @@ struct preferences default_prefs = {
|
||||||
.calcndltts = false,
|
.calcndltts = false,
|
||||||
.gflow = 30,
|
.gflow = 30,
|
||||||
.gfhigh = 75,
|
.gfhigh = 75,
|
||||||
.animation = 500,
|
.animation_speed = 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,
|
||||||
|
|
Loading…
Reference in a new issue