From: Till Theato Date: Tue, 15 Jun 2010 16:21:54 +0000 (+0000) Subject: Use TimecodeDisplay in marker dialog X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=533e803489bc102d03f0ef6609200ba04ac81ad2;p=kdenlive Use TimecodeDisplay in marker dialog svn path=/trunk/kdenlive/; revision=4518 --- diff --git a/src/markerdialog.cpp b/src/markerdialog.cpp index c7c04809..0ee5657f 100644 --- a/src/markerdialog.cpp +++ b/src/markerdialog.cpp @@ -30,17 +30,20 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons QDialog(parent), m_producer(NULL), m_profile(NULL), - m_clip(clip), - m_tc(tc), - m_frameDisplay(KdenliveSettings::frametimecode()) + m_clip(clip) { setFont(KGlobalSettings::toolBarFont()); - m_fps = m_tc.fps(); setupUi(this); setWindowTitle(caption); + + m_in = new TimecodeDisplay(tc, this); + inputLayout->addWidget(m_in); + m_in->setValue(t.time()); + m_previewTimer = new QTimer(this); if (m_clip != NULL) { + m_in->setRange(0, m_clip->duration().frames(tc.fps())); m_previewTimer->setInterval(500); connect(m_previewTimer, SIGNAL(timeout()), this, SLOT(slotUpdateThumb())); m_profile = new Mlt::Profile((char*) KdenliveSettings::current_profile().data()); @@ -58,6 +61,7 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons if (width % 2 == 1) width++; QPixmap p(width, 100); QString colour = clip->getProperty("colour"); + switch (m_clip->clipType()) { case VIDEO: case AV: @@ -66,7 +70,7 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons connect(this, SIGNAL(updateThumb()), m_previewTimer, SLOT(start())); case IMAGE: case TEXT: - p = QPixmap::fromImage(KThumb::getFrame(m_producer, t.time().frames(m_fps), width, 100)); + p = QPixmap::fromImage(KThumb::getFrame(m_producer, m_in->value(), width, 100)); break; case COLOR: colour = colour.replace(0, 2, "#"); @@ -75,30 +79,21 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons default: p.fill(Qt::black); } + if (!p.isNull()) { clip_thumb->setFixedWidth(p.width()); clip_thumb->setFixedHeight(p.height()); clip_thumb->setPixmap(p); } - connect(marker_position, SIGNAL(textChanged(const QString &)), this, SIGNAL(updateThumb())); - } else clip_thumb->setHidden(true); - - marker_position->setInputMask(""); - if (m_frameDisplay) { - QIntValidator *valid = new QIntValidator(this); - valid->setBottom(0); - marker_position->setValidator(valid); - } else - marker_position->setValidator(tc.validator()); - marker_position->setText(tc.getDisplayTimecode(t.time(), m_frameDisplay)); + connect(m_in, SIGNAL(editingFinished()), this, SIGNAL(updateThumb())); + } else { + clip_thumb->setHidden(true); + } marker_comment->setText(t.comment()); marker_comment->selectAll(); marker_comment->setFocus(); - connect(position_up, SIGNAL(clicked()), this, SLOT(slotTimeUp())); - connect(position_down, SIGNAL(clicked()), this, SLOT(slotTimeDown())); - adjustSize(); } @@ -112,43 +107,19 @@ MarkerDialog::~MarkerDialog() void MarkerDialog::slotUpdateThumb() { m_previewTimer->stop(); - int pos = m_tc.getDisplayFrameCount(marker_position->text(), m_frameDisplay); + int pos = m_in->value(); int width = 100.0 * m_dar; if (width % 2 == 1) width++; QPixmap p = QPixmap::fromImage(KThumb::getFrame(m_producer, pos, width, 100)); - if (!p.isNull()) clip_thumb->setPixmap(p); - else kDebug() << "!!!!!!!!!!! ERROR CREATING THUMB"; -} - -void MarkerDialog::slotTimeUp() -{ - int duration = m_tc.getDisplayFrameCount(marker_position->text(), m_frameDisplay); - if (m_clip && duration >= m_clip->duration().frames(m_fps)) return; - duration ++; - marker_position->setText(m_tc.getDisplayTimecode(GenTime(duration, m_fps), m_frameDisplay)); -} - -void MarkerDialog::slotTimeDown() -{ - int duration = m_tc.getDisplayFrameCount(marker_position->text(), m_frameDisplay); - if (duration <= 0) return; - duration --; - marker_position->setText(m_tc.getDisplayTimecode(GenTime(duration, m_fps), m_frameDisplay)); + if (!p.isNull()) + clip_thumb->setPixmap(p); + else + kDebug() << "!!!!!!!!!!! ERROR CREATING THUMB"; } CommentedTime MarkerDialog::newMarker() { - return CommentedTime(GenTime(m_tc.getDisplayFrameCount(marker_position->text(), m_frameDisplay), m_fps), marker_comment->text()); -} - -void MarkerDialog::wheelEvent(QWheelEvent * event) -{ - if (marker_position->underMouse() || clip_thumb->underMouse()) { - if (event->delta() > 0) - slotTimeUp(); - else - slotTimeDown(); - } + return CommentedTime(m_in->gentime(), marker_comment->text()); } #include "markerdialog.moc" diff --git a/src/markerdialog.h b/src/markerdialog.h index a3867a25..88960ca4 100644 --- a/src/markerdialog.h +++ b/src/markerdialog.h @@ -22,9 +22,10 @@ #define MARKERDIALOG_H +#include "ui_markerdialog_ui.h" #include "docclipbase.h" #include "timecode.h" -#include "ui_markerdialog_ui.h" +#include "timecodedisplay.h" namespace Mlt { @@ -32,6 +33,12 @@ class Producer; class Profile; }; +/** + * @class MarkerDialog + * @brief A dialog for editing markers and guides. + * @author Jean-Baptiste Mardelle + */ + class MarkerDialog : public QDialog, public Ui::MarkerDialog_UI { Q_OBJECT @@ -42,22 +49,15 @@ public: CommentedTime newMarker(); private slots: - void slotTimeUp(); - void slotTimeDown(); void slotUpdateThumb(); -protected: - void wheelEvent(QWheelEvent * event); - private: Mlt::Producer *m_producer; Mlt::Profile *m_profile; DocClipBase *m_clip; - Timecode m_tc; - double m_fps; + TimecodeDisplay *m_in; double m_dar; QTimer *m_previewTimer; - bool m_frameDisplay; signals: void updateThumb(); diff --git a/src/timecode.cpp b/src/timecode.cpp index 3fcc5ad5..6973e81e 100644 --- a/src/timecode.cpp +++ b/src/timecode.cpp @@ -60,8 +60,6 @@ const QValidator *Timecode::validator() const return m_validator; } - - QString Timecode::reformatSeparators(QString duration) const { if (m_dropFrame) diff --git a/src/widgets/markerdialog_ui.ui b/src/widgets/markerdialog_ui.ui index 35ad987e..089c87a5 100644 --- a/src/widgets/markerdialog_ui.ui +++ b/src/widgets/markerdialog_ui.ui @@ -6,7 +6,7 @@ 0 0 - 321 + 322 111 @@ -14,74 +14,6 @@ Marker - - - - - - 99:99:99:99; - - - - - - - 0 - - - - - - 0 - 0 - - - - - 16777215 - 18 - - - - ... - - - true - - - Qt::UpArrow - - - - - - - - 0 - 0 - - - - - 16777215 - 18 - - - - ... - - - true - - - Qt::DownArrow - - - - - - - @@ -135,6 +67,9 @@ + + + buttonBox clip_filesize_3 @@ -142,6 +77,7 @@ clip_thumb marker_comment clip_filesize_2 + @@ -149,11 +85,6 @@ QLineEdit
klineedit.h
- - KRestrictedLine - KLineEdit -
krestrictedline.h
-