mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-12 13:36:16 +00:00
Correctly disable all animations
This seems to be needed for the correct print of the profile, What was happening on the print code was that the profile even in print mode was doing animations, and we were getting a frame of it and trying to print it. Also, a bit of code cleanup. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3fa908b242
commit
2171b981ac
6 changed files with 36 additions and 19 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;
|
||||||
short animation;
|
bool animation;
|
||||||
bool gf_low_at_maxdepth;
|
bool gf_low_at_maxdepth;
|
||||||
short display_invalid_dives;
|
short display_invalid_dives;
|
||||||
short unit_system;
|
short unit_system;
|
||||||
|
|
|
@ -120,10 +120,15 @@ 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;
|
||||||
|
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
if (!total)
|
if (!total)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// disable animations on the profile:
|
||||||
|
prefs.animation = false;
|
||||||
|
|
||||||
// setup a painter
|
// setup a painter
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
painter.begin(printer);
|
painter.begin(printer);
|
||||||
|
@ -205,6 +210,8 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
|
||||||
profile->resize(originalSize);
|
profile->resize(originalSize);
|
||||||
// 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
|
||||||
|
prefs.animation = 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,19 +8,27 @@ namespace Animations {
|
||||||
|
|
||||||
void hide(QObject *obj)
|
void hide(QObject *obj)
|
||||||
{
|
{
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
if (prefs.animation != 0) {
|
||||||
animation->setStartValue(1);
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
||||||
animation->setEndValue(0);
|
animation->setStartValue(1);
|
||||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
animation->setEndValue(0);
|
||||||
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||||
|
} else {
|
||||||
|
obj->setProperty("opacity", 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void animDelete(QObject *obj)
|
void animDelete(QObject *obj)
|
||||||
{
|
{
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
if (prefs.animation != 0) {
|
||||||
obj->connect(animation, SIGNAL(finished()), SLOT(deleteLater()));
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
||||||
animation->setStartValue(1);
|
obj->connect(animation, SIGNAL(finished()), SLOT(deleteLater()));
|
||||||
animation->setEndValue(0);
|
animation->setStartValue(1);
|
||||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
animation->setEndValue(0);
|
||||||
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||||
|
} else {
|
||||||
|
obj->setProperty("opacity", 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveTo(QObject *obj, qreal x, qreal y)
|
void moveTo(QObject *obj, qreal x, qreal y)
|
||||||
|
@ -38,12 +46,16 @@ namespace Animations {
|
||||||
|
|
||||||
void scaleTo(QObject *obj, qreal scale)
|
void scaleTo(QObject *obj, qreal scale)
|
||||||
{
|
{
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "scale");
|
if (prefs.animation != 0) {
|
||||||
animation->setDuration(prefs.animation);
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "scale");
|
||||||
animation->setStartValue(obj->property("scale").toReal());
|
animation->setDuration(prefs.animation);
|
||||||
animation->setEndValue(QVariant::fromValue(scale));
|
animation->setStartValue(obj->property("scale").toReal());
|
||||||
animation->setEasingCurve(QEasingCurve::InCubic);
|
animation->setEndValue(QVariant::fromValue(scale));
|
||||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
animation->setEasingCurve(QEasingCurve::InCubic);
|
||||||
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||||
|
} else {
|
||||||
|
obj->setProperty("scale", QVariant::fromValue(scale));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveTo(QObject *obj, const QPointF &pos)
|
void moveTo(QObject *obj, const QPointF &pos)
|
||||||
|
|
|
@ -201,7 +201,6 @@ void DiveCartesianAxis::updateTicks(color_indice_t color)
|
||||||
}
|
}
|
||||||
DiveTextItem *label = new DiveTextItem(this);
|
DiveTextItem *label = new DiveTextItem(this);
|
||||||
label->setText(textForValue(currValueText));
|
label->setText(textForValue(currValueText));
|
||||||
label->setBrush(QBrush(textColor));
|
|
||||||
label->setBrush(colorForValue(currValueText));
|
label->setBrush(colorForValue(currValueText));
|
||||||
label->setScale(fontLabelScale());
|
label->setScale(fontLabelScale());
|
||||||
label->setZValue(1);
|
label->setZValue(1);
|
||||||
|
|
|
@ -66,7 +66,7 @@ void DiveTextItem::updateText()
|
||||||
fnt.setPixelSize(size);
|
fnt.setPixelSize(size);
|
||||||
} else {
|
} else {
|
||||||
size = fnt.pointSizeF();
|
size = fnt.pointSizeF();
|
||||||
size *= scale * MainWindow::instance()->graphics()->getFontPrintScale();;
|
size *= scale * MainWindow::instance()->graphics()->getFontPrintScale();
|
||||||
fnt.setPointSizeF(size);
|
fnt.setPointSizeF(size);
|
||||||
}
|
}
|
||||||
QFontMetrics fm(fnt);
|
QFontMetrics fm(fnt);
|
||||||
|
|
|
@ -382,7 +382,6 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//END
|
|
||||||
|
|
||||||
// special handling for the first time we display things
|
// special handling for the first time we display things
|
||||||
int animSpeedBackup = -1;
|
int animSpeedBackup = -1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue