Mercurial > retraceit
diff src/pngplayer.cpp @ 5:107e435cb569
Enable speed slider in pngplayer
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 25 Mar 2015 14:24:38 +0100 |
parents | 248d5d1cdb38 |
children | c11fe56aa4a2 |
line wrap: on
line diff
--- a/src/pngplayer.cpp Wed Mar 25 14:23:46 2015 +0100 +++ b/src/pngplayer.cpp Wed Mar 25 14:24:38 2015 +0100 @@ -13,11 +13,15 @@ #include <QPushButton> #include <QHBoxLayout> #include <QSlider> +#include <QSettings> #include <QDebug> PNGPlayer::PNGPlayer(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) { setupGUI(); + QSettings settings; + mSpeedSlider->setValue(settings.value(REPLAY_SPEED_KEY, REPLAY_SPEED_DEFAULT).toInt()); + speedChanged(); } void PNGPlayer::setupGUI() { @@ -64,10 +68,14 @@ speedArea->addWidget(speedLabel); mSpeedSlider = new QSlider(Qt::Horizontal); - mSpeedSlider->setMaximum(10000); - mSpeedSlider->setTickInterval(500); + mSpeedSlider->setMaximum(10); + mSpeedSlider->setTickInterval(1); mSpeedSlider->setTickPosition(QSlider::TicksBelow); + mSpeedSlider->setTracking(false); + mSpeedSlider->setInvertedAppearance(true); + speedArea->addWidget(mSpeedSlider); + connect(mSpeedSlider, &QSlider::valueChanged, this, &PNGPlayer::speedChanged); mCurSpeedLabel = new QLabel; speedArea->addWidget(mCurSpeedLabel); @@ -117,12 +125,11 @@ void PNGPlayer::setSpeed(int mSecsPerPicture) { if (mSecsPerPicture == 1000) { mCurSpeedLabel->setText(tr("%1 second per Picture"). - arg(mSecsPerPicture / 1000)); + arg(mSecsPerPicture / 1000.)); } else { mCurSpeedLabel->setText(tr("%1 seconds per Picture"). - arg(mSecsPerPicture / 1000)); + arg(mSecsPerPicture / 1000.)); } - mSpeedSlider->setValue(mSecsPerPicture); mAdvanceTimer.setInterval(mSecsPerPicture); } @@ -162,3 +169,13 @@ void PNGPlayer::lastClicked() { emit jumpToFrame(mMax); } + +void PNGPlayer::speedChanged() { + if (mSpeedSlider->value()) { + setSpeed(mSpeedSlider->value() * REPLAY_SPEED_STEP_MS); + } else { + setSpeed(REPLAY_SPEED_STEP_MS / 2); + } + QSettings settings; + settings.setValue(REPLAY_SPEED_KEY, mSpeedSlider->value()); +}