]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Ensure clip in project tree is visible after a rename:
[kdenlive] / src / projectlist.cpp
index ce01e8281801206d05a52ef6ca029df2134d6303..b3d5f517897abde934c4e378146ca1f4ff5b005e 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)    
@@ -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;
@@ -1831,11 +1843,7 @@ void ProjectList::slotAddSlideshowClip()
         
         QMap <QString, QString> properties;
         properties.insert("name", dia->clipName());
-        int begin = dia->begin();
-        if (begin > 0) 
-            properties.insert("resource", dia->selectedPath() + "?" + QString::number(begin));
-        else
-            properties.insert("resource", dia->selectedPath());
+        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())));
@@ -1846,7 +1854,6 @@ void ProjectList::slotAddSlideshowClip()
         properties.insert("luma_file", dia->lumaFile());
         properties.insert("softness", QString::number(dia->softness()));
         properties.insert("animation", dia->animation());
-        properties.insert("begin", QString::number(dia->begin()));
         
         m_doc->slotCreateSlideshowClipFile(properties, groupInfo.at(0), groupInfo.at(1));
     }
@@ -3453,4 +3460,10 @@ void ProjectList::slotDiscardClipJobs()
     discardJobs(id);
 }
 
+void ProjectList::updatePalette()
+{
+    m_infoLabel->setStyleSheet(SmallInfoLabel::getStyleSheet(QApplication::palette()));
+    m_listView->updateStyleSheet();
+}
+
 #include "projectlist.moc"