]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Merge branch 'master' of git://anongit.kde.org/kdenlive
[kdenlive] / src / projectlist.cpp
index 7be5192807e4b3684a8736533d48cb5cbbde3f2e..6c77cd7e69d5efe8c881f7819887628307d7e158 100644 (file)
@@ -72,6 +72,7 @@
 #include <QIcon>
 #include <QMenu>
 #include <QProcess>
+#include <QScrollBar>
 #include <QHeaderView>
 #include <QInputDialog>
 #include <QtConcurrentRun>
@@ -84,7 +85,15 @@ SmallInfoLabel::SmallInfoLabel(QWidget *parent) : QPushButton(parent)
     
     /*QString style = "QToolButton {background-color: %1;border-style: outset;border-width: 2px;
      border-radius: 5px;border-color: beige;}";*/
-    KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
+    m_timeLine = new QTimeLine(500, this);
+    QObject::connect(m_timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(slotTimeLineChanged(qreal)));
+    QObject::connect(m_timeLine, SIGNAL(finished()), this, SLOT(slotTimeLineFinished()));
+    hide();
+}
+
+const QString SmallInfoLabel::getStyleSheet(const QPalette &p)
+{
+    KColorScheme scheme(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
     QColor bg = scheme.background(KColorScheme::LinkBackground).color();
     QColor fg = scheme.foreground(KColorScheme::LinkText).color();
     QString style = QString("QPushButton {padding:2px;background-color: rgb(%1, %2, %3);border-radius: 4px;border: none;color: rgb(%4, %5, %6)}").arg(bg.red()).arg(bg.green()).arg(bg.blue()).arg(fg.red()).arg(fg.green()).arg(fg.blue());
@@ -93,11 +102,7 @@ SmallInfoLabel::SmallInfoLabel(QWidget *parent) : QPushButton(parent)
     fg = scheme.foreground(KColorScheme::ActiveText).color();
     style.append(QString("\nQPushButton:hover {padding:2px;background-color: rgb(%1, %2, %3);border-radius: 4px;border: none;color: rgb(%4, %5, %6)}").arg(bg.red()).arg(bg.green()).arg(bg.blue()).arg(fg.red()).arg(fg.green()).arg(fg.blue()));
     
-    setStyleSheet(style);
-    m_timeLine = new QTimeLine(500, this);
-    QObject::connect(m_timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(slotTimeLineChanged(qreal)));
-    QObject::connect(m_timeLine, SIGNAL(finished()), this, SLOT(slotTimeLineFinished()));
-    hide();
+    return style;
 }
 
 void SmallInfoLabel::slotTimeLineChanged(qreal value)
@@ -233,6 +238,7 @@ ProjectList::ProjectList(QWidget *parent) :
     
     // small info button for pending jobs
     m_infoLabel = new SmallInfoLabel(this);
+    m_infoLabel->setStyleSheet(SmallInfoLabel::getStyleSheet(palette()));
     connect(this, SIGNAL(jobCount(int)), m_infoLabel, SLOT(slotSetJobCount(int)));
     m_jobsMenu = new QMenu(this);
     connect(m_jobsMenu, SIGNAL(aboutToShow()), this, SLOT(slotPrepareJobsMenu()));
@@ -269,7 +275,7 @@ ProjectList::ProjectList(QWidget *parent) :
     frame->setLayout(box);
     layout->addWidget(frame);
 
-    m_listView = new ProjectListView;
+    m_listView = new ProjectListView(this);
     layout->addWidget(m_listView);
     
 #if KDE_IS_VERSION(4,7,0)    
@@ -687,7 +693,7 @@ void ProjectList::slotReloadClip(const QString &id)
                 item->referencedClip()->setPlaceHolder(true);
                 item->setProperty("file_hash", QString());
             } else if (t == IMAGE) {
-                clip->getProducer()->set("force_reload", 1);
+                //clip->getProducer() clip->getProducer()->set("force_reload", 1);
             }
 
             QDomElement e = item->toXml();
@@ -1032,11 +1038,17 @@ void ProjectList::slotItemEdited(QTreeWidgetItem *item, int column)
                 emit projectModified();
                 EditClipCommand *command = new EditClipCommand(this, clip->clipId(), oldprops, newprops, false);
                 m_commandStack->push(command);
+               QTimer::singleShot(100, this, SLOT(slotCheckScrolling()));
             }
         }
     }
 }
 
+void ProjectList::slotCheckScrolling()
+{
+    m_listView->scrollToItem(m_listView->currentItem());
+}
+
 void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item)
 {
     bool enable = item ? true : false;
@@ -1630,7 +1642,7 @@ void ProjectList::slotAddClip(const QList <QUrl> givenList, const QString &group
         l->addWidget(c);
         l->addStretch(5);
         f->setLayout(l);
-        KFileDialog *d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow(), f);
+        QPointer<KFileDialog> d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow(), f);
         d->setOperationMode(KFileDialog::Opening);
         d->setMode(KFile::Files);
         if (d->exec() == QDialog::Accepted) {
@@ -1656,11 +1668,18 @@ void ProjectList::slotAddClip(const QList <QUrl> givenList, const QString &group
                         while (fileName.at(fileName.size() - 1).isDigit()) {
                             fileName.chop(1);
                         }
-
-                        m_doc->slotCreateSlideshowClipFile(fileName, pattern, count, m_timecode.reformatSeparators(KdenliveSettings::sequence_duration()),
-                                                           false, false, false,
-                                                           m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))), QString(), 0,
-                                                           QString(), groupInfo.at(0), groupInfo.at(1));
+                        QMap <QString, QString> properties;
+                        properties.insert("name", fileName);
+                        properties.insert("resource", pattern);
+                        properties.insert("in", "0");
+                        QString duration = m_timecode.reformatSeparators(KdenliveSettings::sequence_duration());
+                        properties.insert("out", QString::number(m_doc->getFramePos(duration) * count));
+                        properties.insert("ttl", QString::number(m_doc->getFramePos(duration)));
+                        properties.insert("loop", QString::number(false));
+                        properties.insert("crop", QString::number(false));
+                        properties.insert("fade", QString::number(false));
+                        properties.insert("luma_duration", QString::number(m_doc->getFramePos(m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))))));
+                        m_doc->slotCreateSlideshowClipFile(properties, groupInfo.at(0), groupInfo.at(1));
                         return;
                     }
                 }
@@ -1789,7 +1808,7 @@ void ProjectList::slotAddColorClip()
     if (!m_commandStack)
         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
 
-    QDialog *dia = new QDialog(this);
+    QPointer<QDialog> dia = new QDialog(this);
     Ui::ColorClip_UI dia_ui;
     dia_ui.setupUi(dia);
     dia->setWindowTitle(i18n("Color Clip"));
@@ -1821,10 +1840,22 @@ void ProjectList::slotAddSlideshowClip()
 
     if (dia->exec() == QDialog::Accepted) {
         QStringList groupInfo = getGroup();
-        m_doc->slotCreateSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(),
-                                           dia->loop(), dia->crop(), dia->fade(),
-                                           dia->lumaDuration(), dia->lumaFile(), dia->softness(),
-                                           dia->animation(), groupInfo.at(0), groupInfo.at(1));
+        
+        QMap <QString, QString> properties;
+        properties.insert("name", dia->clipName());
+        properties.insert("resource", dia->selectedPath());
+        properties.insert("in", "0");
+        properties.insert("out", QString::number(m_doc->getFramePos(dia->clipDuration()) * dia->imageCount()));
+        properties.insert("ttl", QString::number(m_doc->getFramePos(dia->clipDuration())));
+        properties.insert("loop", QString::number(dia->loop()));
+        properties.insert("crop", QString::number(dia->crop()));
+        properties.insert("fade", QString::number(dia->fade()));
+        properties.insert("luma_duration", dia->lumaDuration());
+        properties.insert("luma_file", dia->lumaFile());
+        properties.insert("softness", QString::number(dia->softness()));
+        properties.insert("animation", dia->animation());
+        
+        m_doc->slotCreateSlideshowClipFile(properties, groupInfo.at(0), groupInfo.at(1));
     }
     delete dia;
 }
@@ -1848,7 +1879,7 @@ void ProjectList::slotAddTitleTemplateClip()
     const QString path = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
     QStringList templateFiles = QDir(path).entryList(filter, QDir::Files);
 
-    QDialog *dia = new QDialog(this);
+    QPointer<QDialog> dia = new QDialog(this);
     Ui::TemplateClip_UI dia_ui;
     dia_ui.setupUi(dia);
     for (int i = 0; i < templateFiles.size(); ++i)
@@ -2604,10 +2635,19 @@ void ProjectList::slotAddOrUpdateSequence(const QString frameName)
         } else {
             // Create sequence
             QStringList groupInfo = getGroup();
-            m_doc->slotCreateSlideshowClipFile(fileName, pattern, count, m_timecode.reformatSeparators(KdenliveSettings::sequence_duration()),
-                                               false, false, false,
-                                               m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))), QString(), 0,
-                                               QString(), groupInfo.at(0), groupInfo.at(1));
+            QMap <QString, QString> properties;
+            properties.insert("name", fileName);
+            properties.insert("resource", pattern);
+            properties.insert("in", "0");
+            QString duration = m_timecode.reformatSeparators(KdenliveSettings::sequence_duration());
+            properties.insert("out", QString::number(m_doc->getFramePos(duration) * count));
+            properties.insert("ttl", QString::number(m_doc->getFramePos(duration)));
+            properties.insert("loop", QString::number(false));
+            properties.insert("crop", QString::number(false));
+            properties.insert("fade", QString::number(false));
+            properties.insert("luma_duration", m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))));
+                        
+            m_doc->slotCreateSlideshowClipFile(properties, groupInfo.at(0), groupInfo.at(1));
         }
     } else emit displayMessage(i18n("Sequence not found"), -2);
 }
@@ -2682,7 +2722,7 @@ void ProjectList::slotCutClipJob(const QString &id, QPoint zone)
     QString timeIn = Timecode::getStringTimecode(in, clipFps, true);
     QString timeOut = Timecode::getStringTimecode(duration, clipFps, true);
     
-    QDialog *d = new QDialog(this);
+    QPointer<QDialog> d = new QDialog(this);
     Ui::CutJobDialog_UI ui;
     ui.setupUi(d);
     ui.extra_params->setVisible(false);
@@ -3344,7 +3384,7 @@ void ProjectList::startClipFilterJob(const QString &filterName, const QString &c
     else {
         destination = item->clipUrl().directory();
     }
-    ClipStabilize *d = new ClipStabilize(destination, ids.count(), filterName);
+    QPointer<ClipStabilize> d = new ClipStabilize(destination, ids.count(), filterName);
     if (d->exec() == QDialog::Accepted) {
         processClipJob(ids, d->destination(), d->autoAddClip(), d->params(), d->desc());
     }
@@ -3420,4 +3460,10 @@ void ProjectList::slotDiscardClipJobs()
     discardJobs(id);
 }
 
+void ProjectList::updatePalette()
+{
+    m_infoLabel->setStyleSheet(SmallInfoLabel::getStyleSheet(QApplication::palette()));
+    m_listView->updateStyleSheet();
+}
+
 #include "projectlist.moc"