1 /***************************************************************************
2 positionedit.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 "timecodedisplay.h"
20 #include "kdenlivesettings.h"
26 #include <QHBoxLayout>
28 PositionEdit::PositionEdit(const QString name, int pos, int min, int max, const Timecode tc, QWidget* parent) :
31 QHBoxLayout *layout = new QHBoxLayout(this);
33 QLabel *label = new QLabel(name, this);
35 m_slider = new QSlider(Qt::Horizontal);
36 m_slider->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred));
37 m_slider->setRange(min, max);
39 m_display = new TimecodeDisplay(tc, this);
40 m_display->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred));
41 m_display->setRange(min, max);
43 layout->addWidget(label);
44 layout->addWidget(m_slider);
45 layout->addWidget(m_display);
47 connect(m_slider, SIGNAL(valueChanged(int)), m_display, SLOT(setValue(int)));
48 connect(m_slider, SIGNAL(valueChanged(int)), this, SIGNAL(parameterChanged(int)));
49 connect(m_display, SIGNAL(editingFinished()), this, SLOT(slotUpdatePosition()));
50 m_slider->setValue(pos);
53 PositionEdit::~PositionEdit()
55 m_display->blockSignals(true);
56 m_slider->blockSignals(true);
61 void PositionEdit::updateTimecodeFormat()
63 m_display->slotUpdateTimeCodeFormat();
66 int PositionEdit::getPosition() const
68 return m_slider->value();
71 void PositionEdit::setPosition(int pos)
73 m_slider->setValue(pos);
76 void PositionEdit::slotUpdatePosition()
78 m_slider->blockSignals(true);
79 m_slider->setValue(m_display->getValue());
80 m_slider->blockSignals(false);
81 emit parameterChanged(m_display->getValue());
84 void PositionEdit::setRange(int min, int max)
86 m_slider->setRange(min, max);
87 m_display->setRange(min, max);
90 #include "positionedit.moc"