pos = GenTime((int)(mapToScene(m_menuPosition).x()), m_document->fps());
track = (int)(mapToScene(m_menuPosition).y() / m_tracksHeight) + 1;
}
- SpacerDialog d(GenTime(65, m_document->fps()), m_document->timecode(), track, m_document->tracksCount() + 1, this);
+ SpacerDialog d(GenTime(65, m_document->fps()), m_document->timecode(), track, m_document->tracksList(), this);
if (d.exec() != QDialog::Accepted) return;
GenTime spaceDuration = d.selectedDuration();
track = d.selectedTrack();
Geometryval::Geometryval(const MltVideoProfile profile, Timecode t, QPoint frame_size, int startPoint, QWidget* parent) :
QWidget(parent),
m_profile(profile),
- m_timecode(t),
m_paramRect(NULL),
m_geom(NULL),
m_path(NULL),
m_timePos(t)
{
setupUi(this);
- m_timePos.setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
toolbarlayout->addWidget(&m_timePos);
toolbarlayout->insertStretch(-1);
void Geometryval::updateTimecodeFormat()
{
- m_timePos.slotPrepareTimeCodeFormat(m_timecode);
+ m_timePos.slotUpdateTimeCodeFormat();
}
void Geometryval::slotPositionChanged(int pos, bool seek)
private:
MltVideoProfile m_profile;
- Timecode m_timecode;
int m_realWidth;
GraphicsSceneRectMove *m_scene;
QGraphicsRectItem *m_paramRect;
spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
toolbar->addWidget(spacer);
m_timePos = new TimecodeDisplay(m_monitorManager->timecode(), this);
- m_timePos->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
toolbar->addWidget(m_timePos);
connect(m_timePos, SIGNAL(editingFinished()), this, SLOT(slotSeek()));
void Monitor::updateTimecodeFormat()
{
- m_timePos->slotPrepareTimeCodeFormat(m_monitorManager->timecode());
+ m_timePos->slotUpdateTimeCodeFormat();
}
QStringList Monitor::getZoneInfo() const
void PositionEdit::updateTimecodeFormat()
{
- m_display->slotPrepareTimeCodeFormat(m_display->timecode());
+ m_display->slotUpdateTimeCodeFormat();
}
int PositionEdit::getPosition() const
#include <KDebug>
-SpacerDialog::SpacerDialog(const GenTime duration, Timecode tc, int track, int trackNumber, QWidget * parent) :
+SpacerDialog::SpacerDialog(const GenTime duration, Timecode tc, int track, QList <TrackInfo> tracks, QWidget * parent) :
QDialog(parent),
- m_tc(tc)
+ m_in(tc)
{
setFont(KGlobalSettings::toolBarFont());
- m_fps = m_tc.fps();
m_view.setupUi(this);
- m_view.space_duration->setText(tc.getTimecode(duration));
- QStringList tracks;
- tracks << i18n("All tracks");
- for (int i = 0; i < trackNumber - 1; i++) {
- tracks << QString::number(i);
+ m_view.inputLayout->addWidget(&m_in);
+ m_in.setValue(duration);
+
+ QStringList trackItems;
+ trackItems << i18n("All tracks");
+ for (int i = tracks.count() - 1; i >= 0; --i) {
+ if (!tracks.at(i).trackName.isEmpty())
+ trackItems << tracks.at(i).trackName + " (" + QString::number(i) + ")";
+ else
+ trackItems << QString::number(i);
}
- m_view.track_number->addItems(tracks);
+ m_view.track_number->addItems(trackItems);
m_view.track_number->setCurrentIndex(track);
- connect(m_view.position_up, SIGNAL(clicked()), this, SLOT(slotTimeUp()));
- connect(m_view.position_down, SIGNAL(clicked()), this, SLOT(slotTimeDown()));
-
adjustSize();
}
-SpacerDialog::~SpacerDialog()
-{
-}
-
-void SpacerDialog::slotTimeUp()
-{
- int duration = m_tc.getFrameCount(m_view.space_duration->text());
- duration ++;
- m_view.space_duration->setText(m_tc.getTimecode(GenTime(duration, m_fps)));
-}
-
-void SpacerDialog::slotTimeDown()
-{
- int duration = m_tc.getFrameCount(m_view.space_duration->text());
- if (duration <= 0) return;
- duration --;
- m_view.space_duration->setText(m_tc.getTimecode(GenTime(duration, m_fps)));
-}
-
GenTime SpacerDialog::selectedDuration()
{
- return GenTime(m_tc.getFrameCount(m_view.space_duration->text()), m_fps);
-}
-
-void SpacerDialog::wheelEvent(QWheelEvent * event)
-{
- if (m_view.space_duration->underMouse()) {
- if (event->delta() > 0)
- slotTimeUp();
- else
- slotTimeDown();
- }
+ return m_in.gentime();
}
int SpacerDialog::selectedTrack()
#define SPACERDIALOG_H
-#include "timecode.h"
#include "ui_spacerdialog_ui.h"
+#include "timecode.h"
+#include "timecodedisplay.h"
+#include "definitions.h"
class SpacerDialog : public QDialog
{
Q_OBJECT
public:
- SpacerDialog(const GenTime duration, Timecode tc, int track, int trackNumber, QWidget * parent = 0);
- ~SpacerDialog();
+ SpacerDialog(const GenTime duration, Timecode tc, int track, QList <TrackInfo> tracks, QWidget * parent = 0);
GenTime selectedDuration();
int selectedTrack();
-private slots:
- void slotTimeUp();
- void slotTimeDown();
-
-protected:
- void wheelEvent(QWheelEvent * event);
-
private:
Ui::SpacerDialog_UI m_view;
- Timecode m_tc;
- double m_fps;
-
+ TimecodeDisplay m_in;
};
#include "timecodedisplay.h"
#include "kdenlivesettings.h"
-#include <QSize>
-#include <QStyle>
-#include <QStylePainter>
-#include <QStyleOptionSlider>
#include <QLineEdit>
#include <QValidator>
-#include <QHBoxLayout>
-#include <QFrame>
#include <QMouseEvent>
-#include <QToolButton>
#include <kglobal.h>
#include <klocale.h>
TimecodeDisplay::TimecodeDisplay(Timecode t, QWidget *parent)
: QWidget(parent),
+ m_timecode(t),
m_minimum(0),
m_maximum(-1)
{
lineedit->setFont(KGlobalSettings::toolBarFont());
QFontMetrics fm = lineedit->fontMetrics();
lineedit->setMaximumWidth(fm.width("88:88:88:888"));
- slotPrepareTimeCodeFormat(t);
+ setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
+
+ slotUpdateTimeCodeFormat();
+
connect(uparrow, SIGNAL(clicked()), this, SLOT(slotValueUp()));
connect(downarrow, SIGNAL(clicked()), this, SLOT(slotValueDown()));
connect(lineedit, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
}
-TimecodeDisplay::~TimecodeDisplay()
-{
-}
-
void TimecodeDisplay::slotValueUp()
{
int val = value();
val++;
- if (m_maximum > -1 && val > m_maximum) val = m_maximum;
setValue(val);
lineedit->clearFocus();
emit editingFinished();
{
int val = value();
val--;
- if (val < m_minimum) val = m_minimum;
setValue(val);
lineedit->clearFocus();
emit editingFinished();
}
-void TimecodeDisplay::slotPrepareTimeCodeFormat(Timecode t)
+void TimecodeDisplay::setTimeCodeFormat(bool frametimecode)
{
- m_timecode = t;
- m_frametimecode = KdenliveSettings::frametimecode();
- QString val = lineedit->text();
+ int val = value();
+ m_frametimecode = frametimecode;
lineedit->setInputMask("");
if (m_frametimecode) {
- int frames = m_timecode.getFrameCount(lineedit->text());
QIntValidator *valid = new QIntValidator(lineedit);
valid->setBottom(0);
lineedit->setValidator(valid);
- lineedit->setText(QString::number(frames));
} else {
- int pos = lineedit->text().toInt();
lineedit->setValidator(m_timecode.validator());
- lineedit->setText(m_timecode.getTimecodeFromFrames(pos));
}
+ setValue(val);
+}
+
+void TimecodeDisplay::slotUpdateTimeCodeFormat()
+{
+ setTimeCodeFormat(KdenliveSettings::frametimecode());
}
void TimecodeDisplay::keyPressEvent(QKeyEvent *e)
{
- if (e->key() == Qt::Key_Up) slotValueUp();
- else if (e->key() == Qt::Key_Down) slotValueDown();
- else QWidget::keyPressEvent(e);
+ if (e->key() == Qt::Key_Up)
+ slotValueUp();
+ else if (e->key() == Qt::Key_Down)
+ slotValueDown();
+ else
+ QWidget::keyPressEvent(e);
}
void TimecodeDisplay::wheelEvent(QWheelEvent *e)
{
- if (e->delta() > 0) slotValueUp();
- else slotValueDown();
+ if (e->delta() > 0)
+ slotValueUp();
+ else
+ slotValueDown();
}
return frames;
}
+GenTime TimecodeDisplay::gentime() const
+{
+ return GenTime(value(), m_timecode.fps());
+}
+
Timecode TimecodeDisplay::timecode() const
{
return m_timecode;
void TimecodeDisplay::setValue(const QString &value)
{
- if (m_frametimecode) {
- lineedit->setText(QString::number(m_timecode.getFrameCount(value)));
- } else lineedit->setText(value);
+ setValue(m_timecode.getFrameCount(value));
}
void TimecodeDisplay::setValue(int value)
{
- /* if (value < m_minimum)
- value = m_minimum;
- if (value > m_maximum)
- value = m_maximum;*/
- if (m_frametimecode) lineedit->setText(QString::number(value));
- else lineedit->setText(m_timecode.getTimecodeFromFrames(value));
-
- /* setEditText(KGlobal::locale()->formatNumber(value, d->decimals));
- d->slider->blockSignals(true);
- d->slider->setValue(int((value - d->minimum) * 256 / (d->maximum - d->minimum) + 0.5));
- d->slider->blockSignals(false);*/
+ if (value < m_minimum)
+ value = m_minimum;
+ if (m_maximum > m_minimum && value > m_maximum)
+ value = m_maximum;
+
+ downarrow->setEnabled(value > m_minimum);
+ uparrow->setEnabled(m_maximum < m_minimum || value < m_maximum);
+
+ if (m_frametimecode)
+ lineedit->setText(QString::number(value));
+ else
+ lineedit->setText(m_timecode.getTimecodeFromFrames(value));
+
//emit valueChanged(value, true);
}
+void TimecodeDisplay::setValue(GenTime value)
+{
+ setValue(m_timecode.getTimecode(value));
+}
+
#include <timecodedisplay.moc>
#include "ui_timecodedisplay_ui.h"
#include "timecode.h"
-
-#include <KRestrictedLine>
+#include "gentime.h"
/**
- * @short A widget for qreal values with a popup slider
- *
- * TimecodeDisplay combines a numerical input and a dropdown slider in a way that takes up as
- * little screen space as possible.
- *
- * It allows the user to either enter a floating point value or quickly set the value using a slider
+ * @class TimecodeDisplay
+ * @brief A widget for inserting a timecode value.
+ * @author Jean-Baptiste Mardelle
*
- * One signal is emitted when the value changes. The signal is even emitted when the slider
- * is moving. The second argument of the signal however tells you if the value is final or not. A
- * final value is produced by entering a value numerically or by releasing the slider.
- *
- * The input of the numerical line edit is constrained to numbers and decimal signs.
+ * TimecodeDisplay can be used to insert eigther frames
+ * or a timecode in the format HH:MM:SS:FF
*/
class TimecodeDisplay : public QWidget, public Ui::TimecodeDisplay_UI
{
-
Q_OBJECT
public:
-
- /**
- * Constructor for the widget, where value is set to 0
- *
- * @param parent parent QWidget
- */
+ /** @brief Constructor for the widget, sets value to 0.
+ * @param t Timecode object used to setup correct input (frames or HH:MM:SS:FF)
+ * @param parent parent Widget */
TimecodeDisplay(Timecode t, QWidget *parent = 0);
- /**
- * Destructor
- */
- virtual ~TimecodeDisplay();
-
- /**
- * The minimum value that can be entered.
- * default is 0
- */
+ /** @brief Returns the minimum value, which can be entered.
+ * default is 0 */
int minimum() const;
- /**
- * The maximum value that can be entered.
- * default is 100
- */
+ /** @brief Returns the maximum value, which can be entered.
+ * default is no maximum (-1) */
int maximum() const;
- /**
- * Sets the minimum maximum value that can be entered.
- * @param min the minimum value
- * @param max the maximum value
- */
+ /** @brief Sets the minimum maximum value that can be entered.
+ * @param min the minimum value
+ * @param max the maximum value */
void setRange(int min, int max);
- /**
- * The value shown.
- */
+ /** @brief Returns the current input in frames. */
int value() const;
- Timecode timecode() const;
+ /** @brief Returns the current input as a GenTime object. */
+ GenTime gentime() const;
- //virtual QSize minimumSizeHint() const; ///< reimplemented from QComboBox
- //virtual QSize sizeHint() const; ///< reimplemented from QComboBox
+ /** @brief Returs the widget's timecode object. */
+ Timecode timecode() const;
+
+ /** @brief Sets value's format to frames or HH:MM:SS:FF according to @param frametimecode.
+ * @param frametimecode true = frames, false = HH:MM:SS:FF */
+ void setTimeCodeFormat(bool frametimecode);
private:
/** timecode for widget */
int m_maximum;
public slots:
-
- /**
- * Sets the value.
- * The value actually set is forced to be within the legal range: minimum <= value <= maximum
+ /** @brief Sets the value.
* @param value the new value
- */
+ * The value actually set is forced to be within the legal range: minimum <= value <= maximum */
void setValue(int value);
void setValue(const QString &value);
- void slotPrepareTimeCodeFormat(Timecode t);
+ void setValue(GenTime value);
+
+ /** @brief Sets value's format accorrding to Kdenlive's settings.
+ * @param t (optional, if already existing) Timecode object to use */
+ void slotUpdateTimeCodeFormat();
private slots:
void slotValueUp();
void slotValueDown();
signals:
-
/**
* Emitted every time the value changes (by calling setValue() or
* by user interaction).
<string>Add space</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="3">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="KRestrictedLine" name="space_duration">
- <property name="inputMask">
- <string>99:99:99:99; </string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <property name="spacing">
- <number>0</number>
- </property>
- <item>
- <widget class="QToolButton" name="position_up">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>16777215</width>
- <height>18</height>
- </size>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- <property name="arrowType">
- <enum>Qt::UpArrow</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="position_down">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>16777215</width>
- <height>18</height>
- </size>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- <property name="arrowType">
- <enum>Qt::DownArrow</enum>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
<item row="3" column="0" colspan="4">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<item row="1" column="2" colspan="2">
<widget class="KComboBox" name="track_number"/>
</item>
+ <item row="0" column="2" colspan="2">
+ <layout class="QHBoxLayout" name="inputLayout"/>
+ </item>
</layout>
</widget>
<customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
- <customwidget>
- <class>KRestrictedLine</class>
- <extends>KLineEdit</extends>
- <header>krestrictedline.h</header>
- </customwidget>
</customwidgets>
<resources/>
<connections>