]> git.sesse.net Git - kdenlive/blobdiff - src/slideshowclip.cpp
Small GUI fix for clip properties dialog
[kdenlive] / src / slideshowclip.cpp
index 01b33b723051d72e2bf847f218e075309d84d0ac..742aaefe72335769248aa12c250b3cdf6081a357 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
 
-#include <QDir>
+#include "slideshowclip.h"
+#include "kdenlivesettings.h"
 
 #include <KStandardDirs>
 #include <KDebug>
 #include <KFileItem>
 
-#include "kdenlivesettings.h"
-#include "slideshowclip.h"
+#include <QDir>
 
-SlideshowClip::SlideshowClip(QWidget * parent): QDialog(parent), m_count(0) {
+SlideshowClip::SlideshowClip(Timecode tc, QWidget * parent) :
+        QDialog(parent),
+        m_count(0),
+        m_timecode(tc)
+{
     setFont(KGlobalSettings::toolBarFont());
     setWindowTitle(i18n("Add Slideshow Clip"));
     m_view.setupUi(this);
@@ -51,6 +55,11 @@ SlideshowClip::SlideshowClip(QWidget * parent): QDialog(parent), m_count(0) {
     m_view.luma_duration->setText("00:00:00:24");
     m_view.folder_url->setUrl(QDir::homePath());
 
+    m_view.clip_duration_format->addItem(i18n("hh:mm:ss::ff"));
+    m_view.clip_duration_format->addItem(i18n("Frames"));
+    connect(m_view.clip_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
+    m_view.clip_duration_frames->setHidden(true);
+    m_view.luma_duration_frames->setHidden(true);
 
     // Check for Kdenlive installed luma files
     QStringList filters;
@@ -74,13 +83,15 @@ SlideshowClip::SlideshowClip(QWidget * parent): QDialog(parent), m_count(0) {
         m_view.luma_file->addItem(KIcon(folder + '/' + fname), fname, folder + '/' + fname);
     }
 
-    adjustSize();
+    //adjustSize();
 }
 
-void SlideshowClip::slotEnableLuma(int state) {
+void SlideshowClip::slotEnableLuma(int state)
+{
     bool enable = false;
     if (state == Qt::Checked) enable = true;
     m_view.luma_duration->setEnabled(enable);
+    m_view.luma_duration_frames->setEnabled(enable);
     m_view.luma_fade->setEnabled(enable);
     if (enable) {
         m_view.luma_file->setEnabled(m_view.luma_fade->isChecked());
@@ -89,7 +100,8 @@ void SlideshowClip::slotEnableLuma(int state) {
     m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
 }
 
-void SlideshowClip::slotEnableLumaFile(int state) {
+void SlideshowClip::slotEnableLumaFile(int state)
+{
     bool enable = false;
     if (state == Qt::Checked) enable = true;
     m_view.luma_file->setEnabled(enable);
@@ -97,15 +109,16 @@ void SlideshowClip::slotEnableLumaFile(int state) {
     m_view.label_softness->setEnabled(enable);
 }
 
-void SlideshowClip::parseFolder() {
+void SlideshowClip::parseFolder()
+{
     m_view.icon_list->clear();
     QDir dir(m_view.folder_url->url().path());
 
     QStringList filters;
     QString filter = m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
     filters << "*." + filter;
-        // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
-        // << "*.jpeg";
+    // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
+    // << "*.jpeg";
 
     dir.setNameFilters(filters);
     const QStringList result = dir.entryList(QDir::Files);
@@ -131,7 +144,8 @@ void SlideshowClip::parseFolder() {
     m_view.icon_list->setCurrentRow(0);
 }
 
-void SlideshowClip::slotSetItemIcon(int row) {
+void SlideshowClip::slotSetItemIcon(int row)
+{
     QListWidgetItem * item = m_view.icon_list->item(row);
     if (item) {
         QString path = item->data(Qt::UserRole).toString();
@@ -143,45 +157,80 @@ void SlideshowClip::slotSetItemIcon(int row) {
     }
 }
 
-QString SlideshowClip::selectedPath() const {
+QString SlideshowClip::selectedPath() const
+{
     QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
     return m_view.folder_url->url().path() + extension;
 }
 
 
-QString SlideshowClip::clipName() const {
+QString SlideshowClip::clipName() const
+{
     return m_view.clip_name->text();
 }
 
-QString SlideshowClip::clipDuration() const {
+QString SlideshowClip::clipDuration() const
+{
+    if (m_view.clip_duration_format->currentIndex() == 1) {
+        // we are in frames mode
+        return m_timecode.getTimecodeFromFrames(m_view.clip_duration_frames->value());
+    }
     return m_view.clip_duration->text();
 }
 
-int SlideshowClip::imageCount() const {
+int SlideshowClip::imageCount() const
+{
     return m_count;
 }
 
-int SlideshowClip::softness() const {
+int SlideshowClip::softness() const
+{
     return m_view.luma_softness->value();
 }
 
-bool SlideshowClip::loop() const {
+bool SlideshowClip::loop() const
+{
     return m_view.slide_loop->isChecked();
 }
 
-bool SlideshowClip::fade() const {
+bool SlideshowClip::fade() const
+{
     return m_view.slide_fade->isChecked();
 }
 
-QString SlideshowClip::lumaDuration() const {
+QString SlideshowClip::lumaDuration() const
+{
+    if (m_view.clip_duration_format->currentIndex() == 1) {
+        // we are in frames mode
+        return m_timecode.getTimecodeFromFrames(m_view.luma_duration_frames->value());
+    }
     return m_view.luma_duration->text();
 }
 
-QString SlideshowClip::lumaFile() const {
+QString SlideshowClip::lumaFile() const
+{
     if (!m_view.luma_fade->isChecked() || !m_view.luma_file->isEnabled()) return QString();
     return m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
 }
 
+void SlideshowClip::slotUpdateDurationFormat(int ix)
+{
+    bool framesFormat = ix == 1;
+    if (framesFormat) {
+        // switching to frames count, update widget
+        m_view.clip_duration_frames->setValue(m_timecode.getFrameCount(m_view.clip_duration->text(), m_timecode.fps()));
+        m_view.luma_duration_frames->setValue(m_timecode.getFrameCount(m_view.luma_duration->text(), m_timecode.fps()));
+    } else {
+        // switching to timecode format
+        m_view.clip_duration->setText(m_timecode.getTimecodeFromFrames(m_view.clip_duration_frames->value()));
+        m_view.luma_duration->setText(m_timecode.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
+    }
+    m_view.clip_duration_frames->setHidden(!framesFormat);
+    m_view.clip_duration->setHidden(framesFormat);
+    m_view.luma_duration_frames->setHidden(!framesFormat);
+    m_view.luma_duration->setHidden(framesFormat);
+}
+
 #include "slideshowclip.moc"