18#include "timecontrols.h"
25#include "playbackmanager.h"
26#include "layermanager.h"
29#include "preferencemanager.h"
38void TimeControls::initUI()
44 mFpsBox->
setValue(settings.value(
"Fps").toInt());
51 mFps = mFpsBox->
value();
54 QMenu* timeSelectMenu =
new QMenu(
tr(
"Display timecode",
"Timeline menu for choose a timecode"),
this);
55 mTimecodeSelect->
setIcon(
QIcon(
":/icons/themes/playful/misc/more-options.svg"));
61 mTimecodeSelect->
setMenu(timeSelectMenu);
63 mTimecodeSelect->
setStyleSheet(
"::menu-indicator{ image: none; }");
64 mTimecodeLabelEnum = mEditor->preference()->getInt(SETTING::TIMECODE_TEXT);
65 mTimecodeLabel =
new QLabel(
this);
69 switch (mTimecodeLabelEnum)
78 mTimecodeLabel->
setToolTip(
tr(
"Timecode format MM:SS:FF"));
87 mLoopStartSpinBox =
new QSpinBox(
this);
89 mLoopStartSpinBox->
setValue(settings.value(
"loopStart").toInt());
92 mLoopStartSpinBox->
setToolTip(
tr(
"Start of playback loop"));
95 mLoopEndSpinBox =
new QSpinBox(
this);
97 mLoopEndSpinBox->
setValue(settings.value(
"loopEnd").toInt());
100 mLoopEndSpinBox->
setToolTip(
tr(
"End of playback loop"));
103 mPlaybackRangeCheckBox =
new QCheckBox(
tr(
"Range"));
105 mPlaybackRangeCheckBox->
setToolTip(
tr(
"Playback range"));
120 mLoopIcon =
QIcon(
":icons/themes/playful/controls/control-loop.svg");
121 mSoundIcon =
QIcon(
":icons/themes/playful/controls/control-sound-enable.svg");
122 mSoundScrubIcon =
QIcon(
":icons/themes/playful/controls/control-sound-scrub.svg");
123 mJumpToEndIcon =
QIcon(
":icons/themes/playful/controls/control-play-end.svg");
124 mJumpToStartIcon =
QIcon(
":icons/themes/playful/controls/control-play-start.svg");
125 mStartIcon =
QIcon(
":icons/themes/playful/controls/control-play.svg");
126 mStopIcon =
QIcon(
":icons/themes/playful/controls/control-stop.svg");
127 mPlayButton->
setIcon(mStartIcon);
128 mLoopButton->
setIcon(mLoopIcon);
129 mSoundButton->
setIcon(mSoundIcon);
130 mSoundScrubButton->
setIcon(mSoundScrubIcon);
131 mJumpToEndButton->
setIcon(mJumpToEndIcon);
132 mJumpToStartButton->
setIcon(mJumpToStartIcon);
137 mSoundScrubButton->
setToolTip(
tr(
"Sound scrub on/off"));
138 mJumpToEndButton->
setToolTip(
tr(
"Jump to the End",
"Tooltip of the jump to end button"));
139 mJumpToStartButton->
setToolTip(
tr(
"Jump to the Start",
"Tooltip of the jump to start button"));
145 mSoundScrubButton->
setChecked(mEditor->preference()->isOn(SETTING::SOUND_SCRUB_ACTIVE));
159 mTimecodeLabelAction =
addWidget(mTimecodeLabel);
166void TimeControls::updateUI()
170 mPlaybackRangeCheckBox->
setChecked(playback->isRangedPlaybackOn());
173 mLoopStartSpinBox->
setValue(playback->markInFrame());
176 mLoopEndSpinBox->
setValue(playback->markOutFrame());
182 mLoopButton->
setChecked(playback->isLooping());
185void TimeControls::setEditor(
Editor* editor)
187 Q_ASSERT(editor !=
nullptr);
191void TimeControls::setFps(
int value)
196 updateTimecodeLabel(mEditor->currentFrame());
199void TimeControls::setLoop(
bool checked)
204void TimeControls::setRangeState(
bool checked)
207 mTimeline->updateLength();
210void TimeControls::makeConnections()
219 connect(mLoopStartSpinBox, spinBoxValueChanged,
this, &TimeControls::loopStartValueChanged);
220 clearFocusOnFinished(mLoopStartSpinBox);
221 connect(mLoopEndSpinBox, spinBoxValueChanged,
this, &TimeControls::loopEndValueChanged);
222 clearFocusOnFinished(mLoopEndSpinBox);
232 connect(mFpsBox, spinBoxValueChanged,
this, &TimeControls::fpsChanged);
235 connect(mFpsBox, spinBoxValueChanged,
this, &TimeControls::setFps);
236 connect(mEditor, &Editor::fpsChanged,
this, &TimeControls::setFps);
243void TimeControls::playButtonClicked()
245 emit playButtonTriggered();
248void TimeControls::updatePlayState()
250 if (mEditor->playback()->isPlaying())
252 mPlayButton->
setIcon(mStopIcon);
257 mPlayButton->
setIcon(mStartIcon);
262void TimeControls::jumpToStartButtonClicked()
266 mEditor->scrubTo(mLoopStartSpinBox->
value());
267 mEditor->playback()->setCheckForSoundsHalfway(
true);
271 mEditor->scrubTo(mEditor->layers()->firstKeyFrameIndex());
273 mEditor->playback()->stopSounds();
276void TimeControls::jumpToEndButtonClicked()
280 mEditor->scrubTo(mLoopEndSpinBox->
value());
284 mEditor->scrubTo(mEditor->layers()->lastKeyFrameIndex());
288void TimeControls::loopButtonClicked(
bool bChecked)
290 mEditor->playback()->setLooping(bChecked);
293void TimeControls::playbackRangeClicked(
bool bChecked)
295 mEditor->playback()->enableRangedPlayback(bChecked);
298void TimeControls::loopStartValueChanged(
int i)
300 if (i >= mLoopEndSpinBox->
value())
306 mEditor->playback()->setRangedStartFrame(i);
307 mTimeline->updateLength();
310void TimeControls::loopEndValueChanged(
int i)
312 mEditor->playback()->setRangedEndFrame(i);
313 mTimeline->updateLength();
316void TimeControls::updateSoundScrubIcon(
bool soundScrubEnabled)
318 mEditor->playback()->setSoundScrubActive(soundScrubEnabled);
319 mEditor->preference()->set(SETTING::SOUND_SCRUB_ACTIVE, soundScrubEnabled);
322void TimeControls::noTimecodeText()
325 settings.setValue(SETTING_TIMECODE_TEXT, NOTEXT);
326 mTimecodeLabelEnum = NOTEXT;
328 updateTimecodeLabel(mEditor->currentFrame());
331void TimeControls::onlyFramesText()
334 settings.setValue(SETTING_TIMECODE_TEXT, FRAMES);
335 mTimecodeLabelEnum = FRAMES;
337 updateTimecodeLabel(mEditor->currentFrame());
340void TimeControls::sffText()
343 settings.setValue(SETTING_TIMECODE_TEXT, SFF);
344 mTimecodeLabelEnum = SFF;
346 updateTimecodeLabel(mEditor->currentFrame());
349void TimeControls::smpteText()
352 settings.setValue(SETTING_TIMECODE_TEXT, SMPTE);
353 mTimecodeLabelEnum = SMPTE;
354 mTimecodeLabel->
setToolTip(
tr(
"Timecode format MM:SS:FF"));
355 updateTimecodeLabel(mEditor->currentFrame());
361 emit fpsChanged(mFpsBox->
value());
362 mFps = mFpsBox->
value();
365void TimeControls::updateTimecodeLabel(
int frame)
369 switch (mTimecodeLabelEnum)
371 case TimecodeTextLevel::SMPTE:
373 .arg(frame / (60 * mFps) % 60, 2, 10,
QLatin1Char(
'0'))
377 case TimecodeTextLevel::SFF:
382 case TimecodeTextLevel::FRAMES:
385 case TimecodeTextLevel::NOTEXT:
393void TimeControls::updateLength(
int frameLength)
395 mLoopStartSpinBox->
setMaximum(frameLength - 1);
void onFpsEditingFinished()
Work-around in case the FPS spin-box "valueChanged" signal doesn't work.
void triggered(bool checked)
void setText(const QString &)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString tr(const char *sourceText, const char *disambiguation, int n)
void setSuffix(const QString &suffix)
QString number(int n, int base)
void setContentsMargins(int left, int top, int right, int bottom)