]> git.sesse.net Git - kdenlive/commitdiff
Insert Space Dialog:
authorTill Theato <root@ttill.de>
Sun, 13 Jun 2010 10:36:03 +0000 (10:36 +0000)
committerTill Theato <root@ttill.de>
Sun, 13 Jun 2010 10:36:03 +0000 (10:36 +0000)
 - Use TimecodeDisplay
 - Show track names in track selection drop down
TimecodeDisplay:
 - Disable up and down buttons if not usable (at min or max)
 - Cleanup

svn path=/trunk/kdenlive/; revision=4511

src/customtrackview.cpp
src/geometryval.cpp
src/geometryval.h
src/monitor.cpp
src/positionedit.cpp
src/spacerdialog.cpp
src/spacerdialog.h
src/timecodedisplay.cpp
src/timecodedisplay.h
src/widgets/spacerdialog_ui.ui

index 838a41551bcf40993415b3391b4b2ab2d79a68e4..bed6afbeffd68e1b393023261474293b65437b55 100644 (file)
@@ -2771,7 +2771,7 @@ void CustomTrackView::slotInsertSpace()
         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();
index bb878d304a94cc4cc0e78ac76c5ef983713aa647..736214a566c7eb649009f7f62b07f5995c4ffe48 100644 (file)
@@ -31,7 +31,6 @@
 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),
@@ -41,7 +40,6 @@ Geometryval::Geometryval(const MltVideoProfile profile, Timecode t, QPoint frame
         m_timePos(t)
 {
     setupUi(this);
-    m_timePos.setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
     toolbarlayout->addWidget(&m_timePos);
     toolbarlayout->insertStretch(-1);
 
@@ -247,7 +245,7 @@ void Geometryval::slotSyncCursor()
 
 void Geometryval::updateTimecodeFormat()
 {
-    m_timePos.slotPrepareTimeCodeFormat(m_timecode);
+    m_timePos.slotUpdateTimeCodeFormat();
 }
 
 void Geometryval::slotPositionChanged(int pos, bool seek)
index 9aef22499428f1aeb23eefc5b9c8ae8cc275be8c..af41aa37d97e1c65f1e4cc9d4ecbd83232636803 100644 (file)
@@ -51,7 +51,6 @@ public:
 
 private:
     MltVideoProfile m_profile;
-    Timecode m_timecode;
     int m_realWidth;
     GraphicsSceneRectMove *m_scene;
     QGraphicsRectItem *m_paramRect;
index 924e25d95906fd70bd8180f1548d898c463793b9..edce9a5fec35677cbb29c1c650f45c3398353d8a 100644 (file)
@@ -113,7 +113,6 @@ Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget
     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()));
 
@@ -806,7 +805,7 @@ void Monitor::slotSwitchMonitorInfo(bool show)
 
 void Monitor::updateTimecodeFormat()
 {
-    m_timePos->slotPrepareTimeCodeFormat(m_monitorManager->timecode());
+    m_timePos->slotUpdateTimeCodeFormat();
 }
 
 QStringList Monitor::getZoneInfo() const
index 402a8ec97ac5a1bc70e03ea9b988722797459891..7877f7e0f7d42f49b4b2b3927a943d8ce2284920 100644 (file)
@@ -57,7 +57,7 @@ PositionEdit::~PositionEdit()
 
 void PositionEdit::updateTimecodeFormat()
 {
-    m_display->slotPrepareTimeCodeFormat(m_display->timecode());
+    m_display->slotUpdateTimeCodeFormat();
 }
 
 int PositionEdit::getPosition() const
index b9f20e78e76597c8e14e9a408022c6fd009708e8..66ddbbb626748b2c1c0b64a2b7344c39a36fff87 100644 (file)
 #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()
index 9f527b78654232c6db4755a5e58010840b4baef7..711019bef2052d3e65c79af2b87c4d5cfb75ac97 100644 (file)
 #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;
 };
 
 
index e37dc6109c2a5bfb05739c99149c125aba5eebef..f3e98203449847e27013ea6d718cd527ed1db1fa 100644 (file)
 #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>
@@ -38,6 +31,7 @@
 
 TimecodeDisplay::TimecodeDisplay(Timecode t, QWidget *parent)
         : QWidget(parent),
+        m_timecode(t),
         m_minimum(0),
         m_maximum(-1)
 {
@@ -45,21 +39,19 @@ TimecodeDisplay::TimecodeDisplay(Timecode t, QWidget *parent)
     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();
@@ -69,42 +61,47 @@ void TimecodeDisplay::slotValueDown()
 {
     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();
 }
 
 
@@ -126,6 +123,11 @@ int TimecodeDisplay::value() const
     return frames;
 }
 
+GenTime TimecodeDisplay::gentime() const
+{
+    return GenTime(value(), m_timecode.fps());
+}
+
 Timecode TimecodeDisplay::timecode() const
 {
     return m_timecode;
@@ -139,25 +141,30 @@ void TimecodeDisplay::setRange(int min, int max)
 
 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>
index 074b3e744ba3432fc22fb4048af39c553c664a67..241b5db9cf53aba390db4c62666d08064e058be9 100644 (file)
 
 #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 */
@@ -97,22 +78,22 @@ private:
     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).
index 58cb713b975eb54c9ba4ce3d965609ad131b2c39..b1f1099e9743df59ae79e49d537c9bc1a7d2fd4c 100644 (file)
    <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>