]> git.sesse.net Git - kdenlive/commitdiff
Fix thumbnail creation in slideshow dialog:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 6 Apr 2010 01:03:10 +0000 (01:03 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 6 Apr 2010 01:03:10 +0000 (01:03 +0000)
http://kdenlive.org/mantis/view.php?id=1546

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

src/kdenlivesettings.kcfg
src/slideshowclip.cpp
src/slideshowclip.h
src/widgets/slideshowclip_ui.ui
src/widgets/titlewidget_ui.ui

index 7ccf949ce72449ea352268956c5587e622d0b4c9..f4d35385500c598e08ab73fab47224d4c3c51074 100644 (file)
       <label>Name of the chosen color theme.</label>
       <default></default>
     </entry>
+    
+    <entry name="showslideshowthumbs" type="Bool">
+      <label>Show thumbnails in slideshow dialog.</label>
+      <default>false</default>
+    </entry>
   </group>
 </kcfg>
index 37195a36f10933581f1c478445a8aa103196cea1..aa1045427ff490d5ab37d06d7d58dc3aebf4cec3 100644 (file)
@@ -25,6 +25,9 @@
 #include <KFileItem>
 
 #include <QDir>
+#include <QtConcurrentRun>
+#include <QFutureWatcher>
+
 
 SlideshowClip::SlideshowClip(Timecode tc, QWidget * parent) :
         QDialog(parent),
@@ -37,9 +40,12 @@ SlideshowClip::SlideshowClip(Timecode tc, QWidget * parent) :
     m_view.clip_name->setText(i18n("Slideshow Clip"));
     m_view.folder_url->setMode(KFile::Directory);
     m_view.icon_list->setIconSize(QSize(50, 50));
+    m_view.show_thumbs->setChecked(KdenliveSettings::showslideshowthumbs());
+
     connect(m_view.folder_url, SIGNAL(textChanged(const QString &)), this, SLOT(parseFolder()));
     connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
 
+    connect(m_view.show_thumbs, SIGNAL(stateChanged(int)), this, SLOT(slotEnableThumbs(int)));
     connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
     connect(m_view.luma_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
 
@@ -106,6 +112,17 @@ void SlideshowClip::slotEnableLuma(int state)
     m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
 }
 
+void SlideshowClip::slotEnableThumbs(int state)
+{
+    if (state == Qt::Checked) {
+        KdenliveSettings::setShowslideshowthumbs(true);
+        slotGenerateThumbs();
+    } else {
+        KdenliveSettings::setShowslideshowthumbs(false);
+    }
+
+}
+
 void SlideshowClip::slotEnableLumaFile(int state)
 {
     bool enable = false;
@@ -137,28 +154,42 @@ void SlideshowClip::parseFolder()
     KIcon unknownicon("unknown");
     foreach(const QString &path, result) {
         i++;
-        if (i < 80) {
-            QIcon icon(dir.filePath(path));
-            item = new QListWidgetItem(icon, KUrl(path).fileName());
-        } else {
-            item = new QListWidgetItem(unknownicon, KUrl(path).fileName());
-            item->setData(Qt::UserRole, dir.filePath(path));
-        }
+        item = new QListWidgetItem(unknownicon, KUrl(path).fileName());
+        item->setData(Qt::UserRole, dir.filePath(path));
         m_view.icon_list->addItem(item);
     }
-    if (m_count >= 80) connect(m_view.icon_list, SIGNAL(currentRowChanged(int)), this, SLOT(slotSetItemIcon(int)));
+    if (m_view.show_thumbs->isChecked()) slotGenerateThumbs();
     m_view.icon_list->setCurrentRow(0);
 }
 
-void SlideshowClip::slotSetItemIcon(int row)
+void SlideshowClip::slotGenerateThumbs()
+{
+    if (!m_future.isRunning()) {
+        connect(&m_watcher, SIGNAL(finished()), this, SLOT(slotCheckGenerateThumbs()));
+        m_future = QtConcurrent::run(this, &SlideshowClip::doGetThumbs);
+        m_watcher.setFuture(m_future);
+    }
+}
+
+void SlideshowClip::slotCheckGenerateThumbs()
+{
+    QListWidgetItem* item = m_view.icon_list->item(m_view.icon_list->count() - 1);
+    if (!item || item->data(Qt::UserRole).toString().isEmpty() || m_view.show_thumbs->isChecked() == false) return;
+    QTimer::singleShot(300, this, SLOT(slotGenerateThumbs()));
+}
+
+void SlideshowClip::doGetThumbs()
 {
-    QListWidgetItem * item = m_view.icon_list->item(row);
-    if (item) {
-        QString path = item->data(Qt::UserRole).toString();
-        if (!path.isEmpty()) {
-            KIcon icon(path);
-            item->setIcon(icon);
-            item->setData(Qt::UserRole, QString());
+    for (int i = 0; i < m_view.icon_list->count(); i++) {
+        QListWidgetItem* item = m_view.icon_list->item(i);
+        if (item && m_view.show_thumbs->isChecked()) {
+            QString path = item->data(Qt::UserRole).toString();
+            if (path.isEmpty()) continue;
+            else {
+                item->setIcon(KIcon(path));
+                item->setData(Qt::UserRole, QString());
+                break;
+            }
         }
     }
 }
index d9b571729345ec48efb8103e2bced12d76d6a4b5..83db3d81c3602b722423ed6f0a93d3ef18d14b2d 100644 (file)
@@ -27,6 +27,9 @@
 #include "timecode.h"
 #include "ui_slideshowclip_ui.h"
 
+#include <QFuture>
+#include <QFutureWatcher>
+
 class SlideshowClip : public QDialog
 {
     Q_OBJECT
@@ -47,14 +50,19 @@ public:
 private slots:
     void parseFolder();
     void slotEnableLuma(int state);
+    void slotEnableThumbs(int state);
     void slotEnableLumaFile(int state);
-    void slotSetItemIcon(int row);
+    void doGetThumbs();
     void slotUpdateDurationFormat(int ix);
+    void slotGenerateThumbs();
+    void slotCheckGenerateThumbs();
 
 private:
     Ui::SlideshowClip_UI m_view;
     int m_count;
     Timecode m_timecode;
+    QFuture<void> m_future;
+    QFutureWatcher<void> m_watcher;
 };
 
 
index 9fb045d85f831c5d1bbf43c73e9084db1d749202..0948951fdc9dd7ac8d7a41ac5bce600313adc4f5 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>275</width>
+    <width>268</width>
     <height>359</height>
    </rect>
   </property>
@@ -81,7 +81,7 @@
    <item row="3" column="1" colspan="2">
     <widget class="KComboBox" name="image_type"/>
    </item>
-   <item row="4" column="0" colspan="3">
+   <item row="4" column="0">
     <widget class="QCheckBox" name="slide_loop">
      <property name="text">
       <string>Loop</string>
     <widget class="KListWidget" name="icon_list"/>
    </item>
    <item row="9" column="0" colspan="3">
-    <widget class="QLabel" name="label_info">
-     <property name="text">
-      <string>No image found</string>
-     </property>
-    </widget>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QCheckBox" name="show_thumbs">
+       <property name="text">
+        <string>Show thumbnails</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QLabel" name="label_info">
+       <property name="text">
+        <string>No image found</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
    </item>
-   <item row="10" column="0" colspan="3">
+   <item row="10" column="1" colspan="2">
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
   </layout>
  </widget>
  <customwidgets>
-  <customwidget>
-   <class>KComboBox</class>
-   <extends>QComboBox</extends>
-   <header>kcombobox.h</header>
-  </customwidget>
   <customwidget>
    <class>KIntSpinBox</class>
    <extends>QSpinBox</extends>
    <header>knuminput.h</header>
   </customwidget>
   <customwidget>
-   <class>KLineEdit</class>
-   <extends>QLineEdit</extends>
-   <header>klineedit.h</header>
+   <class>KUrlRequester</class>
+   <extends>QFrame</extends>
+   <header>kurlrequester.h</header>
   </customwidget>
   <customwidget>
    <class>KListWidget</class>
    <extends>QListWidget</extends>
    <header>klistwidget.h</header>
   </customwidget>
+  <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>
-  <customwidget>
-   <class>KUrlRequester</class>
-   <extends>QFrame</extends>
-   <header>kurlrequester.h</header>
-  </customwidget>
  </customwidgets>
  <resources/>
  <connections>
index d818299950ac1ab7e1419b00add87be8516d8437..4a2b5170b4c7c479ca8387c5fdc7bc55ffebc266 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1383</width>
-    <height>835</height>
+    <width>986</width>
+    <height>621</height>
    </rect>
   </property>
   <property name="sizePolicy">
            </item>
            <item row="0" column="0">
             <widget class="KColorButton" name="backgroundColor">
-             <property name="color" stdset="0">
+             <property name="color">
               <color>
                <red>0</red>
                <green>0</green>
                <blue>0</blue>
               </color>
              </property>
-             <property name="defaultColor" stdset="0">
+             <property name="defaultColor">
               <color>
                <red>0</red>
                <green>0</green>
        </item>
        <item row="0" column="1">
         <widget class="KColorButton" name="rectBColor">
-         <property name="color" stdset="0">
+         <property name="color">
           <color>
            <red>0</red>
            <green>0</green>
            <blue>0</blue>
           </color>
          </property>
-         <property name="defaultColor" stdset="0">
+         <property name="defaultColor">
           <color>
            <red>0</red>
            <green>0</green>
        </item>
        <item row="0" column="5">
         <widget class="KColorButton" name="rectFColor">
-         <property name="color" stdset="0">
+         <property name="color">
           <color>
            <red>0</red>
            <green>0</green>
            <blue>0</blue>
           </color>
          </property>
-         <property name="defaultColor" stdset="0">
+         <property name="defaultColor">
           <color>
            <red>0</red>
            <green>0</green>
          <property name="flat">
           <bool>false</bool>
          </property>
-         <property name="color" stdset="0">
+         <property name="color">
           <color>
            <red>0</red>
            <green>0</green>
            <blue>0</blue>
           </color>
          </property>
-         <property name="defaultColor" stdset="0">
+         <property name="defaultColor">
           <color>
            <red>0</red>
            <green>0</green>