1 /***************************************************************************
2 geomeytrval.cpp - description
5 copyright : (C) 2008 by Marco Gittler
6 email : g.marco@freenet.de
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
18 #include "positionedit.h"
19 #include "kdenlivesettings.h"
23 PositionEdit::PositionEdit(const QString name, int pos, int min, int max, const Timecode tc, QWidget* parent) :
26 m_frameDisplay(KdenliveSettings::frametimecode())
29 m_ui.label->setText(name);
30 m_ui.horizontalSlider->setRange(min, max);
31 connect(m_ui.horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateTimecode()));
32 connect(m_ui.krestrictedline, SIGNAL(editingFinished()), this, SLOT(slotUpdatePosition()));
33 m_ui.horizontalSlider->setValue(pos);
35 QValidator *valid = new QIntValidator(this);
36 m_ui.krestrictedline->setInputMask("");
37 m_ui.krestrictedline->setValidator(valid);
39 m_ui.krestrictedline->setText(m_tc.getDisplayTimecodeFromFrames(pos, m_frameDisplay));
42 int PositionEdit::getPosition() const
44 return m_ui.horizontalSlider->value();
47 void PositionEdit::setPosition(int pos)
49 m_ui.horizontalSlider->setValue(pos);
50 m_ui.krestrictedline->setText(m_tc.getDisplayTimecodeFromFrames(pos, m_frameDisplay));
53 void PositionEdit::slotUpdateTimecode()
55 m_ui.krestrictedline->setText(m_tc.getDisplayTimecodeFromFrames(m_ui.horizontalSlider->value(), m_frameDisplay));
56 emit parameterChanged();
59 void PositionEdit::slotUpdatePosition()
61 m_ui.horizontalSlider->blockSignals(true);
62 int pos = m_tc.getDisplayFrameCount(m_ui.krestrictedline->text(), m_frameDisplay);
63 m_ui.horizontalSlider->setValue(pos);
64 if (pos != m_ui.horizontalSlider->value()) {
66 m_ui.krestrictedline->setText(m_tc.getDisplayTimecodeFromFrames(m_ui.horizontalSlider->value(), m_frameDisplay));
68 m_ui.horizontalSlider->blockSignals(false);
69 emit parameterChanged();