]> git.sesse.net Git - kdenlive/commitdiff
Clip properties dialog
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 23 Mar 2008 19:13:28 +0000 (19:13 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 23 Mar 2008 19:13:28 +0000 (19:13 +0000)
svn path=/branches/KDE4/; revision=2103

19 files changed:
src/CMakeLists.txt
src/clipproperties.cpp [new file with mode: 0644]
src/clipproperties.h [new file with mode: 0644]
src/customtrackview.cpp
src/docclipbase.cpp
src/docclipbase.h
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/kdenlivesettings.kcfg
src/mainwindow.cpp
src/mainwindow.h
src/projectitem.cpp
src/projectitem.h
src/projectlist.cpp
src/projectlist.h
src/projectlistview.cpp
src/projectlistview.h
src/renderer.cpp
src/widgets/clipproperties_ui.ui [new file with mode: 0644]

index 306f6fbc154473fe16691ba4271a283360ef5495..9ad78572d1d336909ab11638c301c7072916a593 100644 (file)
@@ -45,6 +45,7 @@ kde4_add_ui_files(kdenlive_UI
   widgets/transitionsettings_ui.ui
   widgets/configjogshuttle_ui.ui
   widgets/trackheader_ui.ui
+  widgets/clipproperties_ui.ui
 )
  
 set(kdenlive_SRCS 
@@ -100,6 +101,7 @@ set(kdenlive_SRCS
   edittransitioncommand.cpp
   addfoldercommand.cpp
   editfoldercommand.cpp
+  clipproperties.cpp
 )
 
 kde4_add_kcfg_files(kdenlive_SRCS GENERATE_MOC kdenlivesettings.kcfgc )
diff --git a/src/clipproperties.cpp b/src/clipproperties.cpp
new file mode 100644 (file)
index 0000000..63564bb
--- /dev/null
@@ -0,0 +1,58 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+#include <QDir>
+
+#include <KStandardDirs>
+#include <KDebug>
+
+#include "kdenlivesettings.h"
+#include "clipproperties.h"
+#include "kthumb.h"
+
+ClipProperties::ClipProperties(DocClipBase *clip, QWidget * parent): QDialog(parent) {
+    m_view.setupUi(this);
+    m_clip = clip;
+
+    m_view.clip_path->setText(m_clip->fileURL().path());
+    m_view.clip_description->setText(m_clip->description());
+    QMap <QString, QString> props = m_clip->properties();
+    if (props.contains("frame_size"))
+        m_view.clip_size->setText(props["frame_size"]);
+    if (props.contains("videocodec"))
+        m_view.clip_vcodec->setText(props["videocodec"]);
+    if (props.contains("audiocodec"))
+        m_view.clip_acodec->setText(props["audiocodec"]);
+    if (props.contains("fps"))
+        m_view.clip_fps->setText(props["fps"]);
+    if (props.contains("frequency"))
+        m_view.clip_frequency->setText(props["frequency"]);
+    if (props.contains("channels"))
+        m_view.clip_channels->setText(props["channels"]);
+    if (props.contains("aspect_ratio"))
+        m_view.clip_ratio->setText(props["aspect_ratio"]);
+    QPixmap pix = m_clip->thumbProducer()->getImage(m_clip->fileURL(), 240, 180);
+    m_view.clip_thumb->setPixmap(pix);
+    CLIPTYPE t = m_clip->clipType();
+    if (t == IMAGE || t == VIDEO) m_view.tabWidget->removeTab(1);
+}
+
+#include "clipproperties.moc"
+
+
diff --git a/src/clipproperties.h b/src/clipproperties.h
new file mode 100644 (file)
index 0000000..3bb8728
--- /dev/null
@@ -0,0 +1,48 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+
+#ifndef CLIPPROPSDIALOG_H
+#define CLIPPROPSDIALOG_H
+
+#include <QDialog>
+
+#include "definitions.h"
+#include "docclipbase.h"
+#include "ui_clipproperties_ui.h"
+
+class ClipProperties : public QDialog {
+    Q_OBJECT
+
+public:
+    ClipProperties(DocClipBase *clip, QWidget * parent = 0);
+
+
+private slots:
+
+
+private:
+    Ui::ClipProperties_UI m_view;
+    DocClipBase *m_clip;
+
+};
+
+
+#endif
+
index 1217d1ab5e32d7ecc3eb4477f8f2324cc69a7221..f8e1af1a01c342acdbef605c40085f077806bc7d 100644 (file)
@@ -591,10 +591,10 @@ void CustomTrackView::slotTransitionUpdated(QDomElement old, QDomElement newEffe
 }
 
 void CustomTrackView::updateTransition(int track, GenTime pos, QDomElement oldTransition, QDomElement transition) {
-       QString s;
-       QTextStream tx(&s);
-       transition.save(tx,2);
-       kDebug() << "in" << s;
+    QString s;
+    QTextStream tx(&s);
+    transition.save(tx, 2);
+    kDebug() << "in" << s;
     QMap < QString, QString> map;
     QDomNamedNodeMap attribs = transition.attributes();
     for (int i = 0;i < attribs.count();i++) {
index 514abdbde12f3bf2b1119d6c1076e980238fbd59..fdfc143d3d2a3919704b425ea61d33e4302d5c08 100644 (file)
@@ -347,44 +347,15 @@ QString DocClipBase::markerComment(GenTime t) {
     return QString::null;
 }
 
-//static
-QString DocClipBase::getTypeName(CLIPTYPE type) {
-    QString result;
-    switch (type) {
-    case AV:
-        result = i18n("Video Clip");
-        break;
-    case COLOR:
-        result = i18n("Color Clip");
-        break;
-    case PLAYLIST:
-        result = i18n("Playlist Clip");
-        break;
-    case IMAGE:
-        result = i18n("Image Clip");
-        break;
-    case SLIDESHOW:
-        result = i18n("Slideshow Clip");
-        break;
-    case VIRTUAL:
-        result = i18n("Virtual Clip");
-        break;
-    case AUDIO:
-        result = i18n("Audio Clip");
-        break;
-    case VIDEO:
-        result = i18n("Mute Video Clip");
-        break;
-    case TEXT:
-        result = i18n("Text Clip");
-        break;
-    default:
-        result = i18n("None");
-        break;
-    }
-    return result;
+void DocClipBase::setProperties(QMap <QString, QString> properties) {
+    m_properties = properties;
 }
 
+QMap <QString, QString> DocClipBase::properties() {
+    return m_properties;
+}
+
+
 void DocClipBase::slotGetAudioThumbs() {
 
     if (m_audioThumbCreated) {
index 85b2344edcf4c7c6416e9c7e951ee441c3f7288d..68984b1cc289178a9061e4015aa16e67da283f9f 100644 (file)
@@ -195,9 +195,6 @@ Q_OBJECT public:
     /** format is frame -> channel ->bytes */
     QMap<int, QMap<int, QByteArray> > audioFrameChache;
 
-    /** return english name for clip type */
-    static QString getTypeName(CLIPTYPE type);
-
     /** Clip is ready to get thumbs */
     void slotRequestAudioThumbs();
     /** Free cache data */
@@ -234,6 +231,8 @@ private:   // Private attributes
     uint m_projectThumbFrame;
     void setAudioThumbCreated(bool isDone);
 
+    QMap <QString, QString> m_properties;
+
 public slots:
     void updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data);
     void slotGetAudioThumbs();
@@ -249,6 +248,8 @@ public slots:
     QString markerComment(GenTime t);
     void setProjectThumbFrame(const uint &ix);
     uint getProjectThumbFrame() const;
+    void setProperties(QMap <QString, QString> properties);
+    QMap <QString, QString> properties();
 
 signals:
     void getAudioThumbs();
index 06f6ff229424f0861af1332e3051ff0087c73710..1fe50905a2bd09c878b8c04dff04778e99d8649c 100644 (file)
@@ -281,6 +281,10 @@ void KdenliveDoc::setModified(bool mod) {
     emit docModified(m_modified);
 }
 
+bool KdenliveDoc::isModified() {
+    return m_modified;
+}
+
 QString KdenliveDoc::description() const {
     if (m_url.isEmpty())
         return i18n("Untitled") + " / " + m_profile.description;
index 4e0f51de361e398a66575fdf4d099c16a64a59b7..cd8c5afd35c280dcc23db98cbcd6e31c076ed107 100644 (file)
@@ -85,6 +85,8 @@ Q_OBJECT public:
     /** Set to true if document needs saving, false otherwise */
     void setModified(bool mod);
     int getFreeClipId();
+    /** does the document need saving */
+    bool isModified();
 
 private:
     KUrl m_url;
index bd1064b18d7ed6a7cb4db65e4a607a1defdd44b5..83da9419c8d69eb182014f017e2592cf330435a5 100644 (file)
       <default>hdv_1080_50i</default>
     </entry>
 
+    <entry name="showdescriptioncolumn" type="Bool">
+      <label>Show descriptions in project tree view.</label>
+      <default>true</default>
+    </entry>
+    <entry name="showratingcolumn" type="Bool">
+      <label>Show ratings in project tree view.</label>
+      <default>false</default>
+    </entry>
 
   </group>
 </kcfg>
\ No newline at end of file
index 9fdf58b679751bd52f406f4871626196ac1020a1..8c6a5ec1b9638b17171e54b7e959a85e825aac29 100644 (file)
@@ -71,6 +71,7 @@
 #include "renderwidget.h"
 #include "renderer.h"
 #include "jogshuttle.h"
+#include "clipproperties.h"
 
 #define ID_STATUS_MSG 1
 #define ID_EDITMODE_MSG 2
@@ -261,18 +262,26 @@ MainWindow::MainWindow(QWidget *parent)
     activateShuttleDevice();
 }
 
+void MainWindow::queryQuit() {
+    kDebug() << "----- SAVING CONFUIG";
+    if (queryClose()) kapp->quit();
+}
+
 //virtual
 bool MainWindow::queryClose() {
     saveOptions();
-    switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
-    case KMessageBox::Yes :
-        // save document here. If saving fails, return false;
-        return true;
-    case KMessageBox::No :
-        return true;
-    default: // cancel
-        return false;
+    if (m_activeDocument && m_activeDocument->isModified()) {
+        switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
+        case KMessageBox::Yes :
+            // save document here. If saving fails, return false;
+            return true;
+        case KMessageBox::No :
+            return true;
+        default: // cancel
+            return false;
+        }
     }
+    return true;
 }
 
 void MainWindow::activateShuttleDevice() {
@@ -350,6 +359,7 @@ void MainWindow::slotConnectMonitors() {
     m_projectList->setRenderer(m_clipMonitor->render);
     connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
     connect(m_projectList, SIGNAL(receivedClipDuration(int, int)), this, SLOT(slotSetClipDuration(int, int)));
+    connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
     connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
     connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
     connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)));
@@ -424,7 +434,7 @@ void MainWindow::setupActions() {
     actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip);
     connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
 
-    KStandardAction::quit(kapp, SLOT(quit()),
+    KStandardAction::quit(this, SLOT(queryQuit()),
                           actionCollection());
 
     KStandardAction::open(this, SLOT(openFile()),
@@ -474,6 +484,7 @@ void MainWindow::slotDisplayActionMessage(QAction *a) {
 }
 
 void MainWindow::saveOptions() {
+    KdenliveSettings::self()->writeConfig();
     KSharedConfigPtr config = KGlobal::config();
     m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
     config->sync();
@@ -881,6 +892,11 @@ void MainWindow::slotGotProgressInfo(KUrl url, int progress) {
     }
 }
 
+void MainWindow::slotShowClipProperties(DocClipBase *clip) {
+    ClipProperties dia(clip);
+    dia.exec();
+}
+
 void MainWindow::customEvent(QEvent* e) {
     if (e->type() == QEvent::User) {
         // The timeline playing position changed...
index e2627d6e11913e5815ac8143a60b173cf29ae65a..7ac31bcb35fc182055c9ceda64d7be1974350b5a 100644 (file)
@@ -50,13 +50,13 @@ class RecMonitor;
 class CustomTrackView;
 class RenderWidget;
 class JogShuttle;
+class DocClipBase;
 
 class MainWindow : public KXmlGuiWindow {
     Q_OBJECT
 
 public:
     MainWindow(QWidget *parent = 0);
-
     void parseProfiles();
 
 protected:
@@ -130,6 +130,7 @@ private slots:
     void newFile();
     void undo();
     void redo();
+    void queryQuit();
     void activateDocument();
     void connectDocument(TrackView*, KdenliveDoc*);
     void openFile();
@@ -163,6 +164,7 @@ private slots:
     void slotAddCustomEffect(QAction *result);
     void slotAddProjectClip(KUrl url);
     void slotShuttleButton(int code);
+    void slotShowClipProperties(DocClipBase *clip);
 };
 
 #endif
index 62c112cffc0dca3fd1f4cc7ab603d58316fa28e6..54fed84c178f1d233b491d0ba168bc1b27b2d288 100644 (file)
@@ -75,14 +75,15 @@ ProjectItem::ProjectItem(QTreeWidgetItem * parent, const QStringList & strings,
 
 // folder
 ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, int clipId)
-        : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(QDomElement()), m_clipType(FOLDER), m_groupName(strings.at(1)), m_clipId(clipId), m_clip(NULL) {
+        : QTreeWidgetItem(parent, strings), m_element(QDomElement()), m_clipType(FOLDER), m_groupName(strings.at(1)), m_clipId(clipId), m_clip(NULL) {
     setSizeHint(0, QSize(65, 45));
     setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
     setIcon(0, KIcon("folder"));
+    setToolTip(1, "<qt><b>" + i18n("Folder"));
 }
 
 ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip)
-        : QTreeWidgetItem(parent, QStringList(), QTreeWidgetItem::UserType) {
+        : QTreeWidgetItem(parent) {
     setSizeHint(0, QSize(65, 45));
     setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
     m_clip = clip;
@@ -96,7 +97,7 @@ ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip)
 }
 
 ProjectItem::ProjectItem(QTreeWidgetItem * parent, DocClipBase *clip)
-        : QTreeWidgetItem(parent, QStringList(), QTreeWidgetItem::UserType) {
+        : QTreeWidgetItem(parent) {
     setSizeHint(0, QSize(65, 45));
     setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
     m_clip = clip;
@@ -164,25 +165,40 @@ const KUrl ProjectItem::clipUrl() const {
     else return KUrl();
 }
 
+void ProjectItem::changeDuration(int frames) {
+    m_element.setAttribute("duration", frames);
+    m_duration = GenTime(frames, 25);
+    setData(1, DurationRole, Timecode::getEasyTimecode(m_duration, 25));
+    m_durationKnown = true;
+    m_clip->setDuration(m_duration);
+}
+
+void ProjectItem::setDescription(const QString &desc) {
+    m_clip->setDescription(desc);
+}
+
+DocClipBase *ProjectItem::referencedClip() {
+    return m_clip;
+}
 
 void ProjectItem::slotSetToolTip() {
     QString tip = "<qt><b>";
     switch (m_clipType) {
     case 1:
-        tip.append(i18n("Audio clip"));
+        tip.append(i18n("Audio clip") + "</b><br />" + clipUrl().path());
         break;
     case 2:
-        tip.append(i18n("Mute video clip"));
+        tip.append(i18n("Mute video clip") + "</b><br />" + clipUrl().path());
         break;
     case 3:
-        tip.append(i18n("Video clip"));
+        tip.append(i18n("Video clip") + "</b><br />" + clipUrl().path());
         break;
     case 4:
         tip.append(i18n("Color clip"));
         setData(1, DurationRole, Timecode::getEasyTimecode(GenTime(m_element.attribute("out", "250").toInt(), 25), 25));
         break;
     case 5:
-        tip.append(i18n("Image clip"));
+        tip.append(i18n("Image clip") + "</b><br />" + clipUrl().path());
         break;
     case 6:
         tip.append(i18n("Text clip"));
@@ -194,7 +210,7 @@ void ProjectItem::slotSetToolTip() {
         tip.append(i18n("Virtual clip"));
         break;
     case 9:
-        tip.append(i18n("Playlist clip"));
+        tip.append(i18n("Playlist clip") + "</b><br />" + clipUrl().path());
         break;
     default:
         tip.append(i18n("Unknown clip"));
@@ -246,66 +262,17 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con
     m_element.setAttribute("type", (int) m_clipType);
 
     if (KdenliveSettings::audiothumbnails()) m_clip->slotRequestAudioThumbs();
+
+    m_clip->setProperties(attributes);
     /*
-     if (attributes.contains("height")) {
-         m_height = attributes["height"].toInt();
-     } else {
-         m_height = 0;
-     }
-     if (attributes.contains("width")) {
-         m_width = attributes["width"].toInt();
-     } else {
-         m_width = 0;
-     }
-     //decoder name
-     if (attributes.contains("name")) {
-         m_decompressor = attributes["name"];
-     } else {
-         m_decompressor = "n/a";
-     }
-     //video type ntsc/pal
-     if (attributes.contains("system")) {
-         m_system = attributes["system"];
-     } else {
-         m_system = "n/a";
-     }
-     if (attributes.contains("fps")) {
-         m_framesPerSecond = attributes["fps"].toInt();
-     } else {
-         // No frame rate known.
-         m_framesPerSecond = 0;
-     }
-     //audio attributes -reh
-     if (attributes.contains("channels")) {
-         m_channels = attributes["channels"].toInt();
-     } else {
-         m_channels = 0;
-     }
-     if (attributes.contains("format")) {
-         m_format = attributes["format"];
-     } else {
-         m_format = "n/a";
-     }
-     if (attributes.contains("frequency")) {
-         m_frequency = attributes["frequency"].toInt();
-     } else {
-         m_frequency = 0;
-     }
-     if (attributes.contains("videocodec")) {
-         m_videoCodec = attributes["videocodec"];
-     }
-     if (attributes.contains("audiocodec")) {
-         m_audioCodec = attributes["audiocodec"];
-     }
-
-     m_metadata = metadata;
-
-     if (m_metadata.contains("description")) {
-         setDescription (m_metadata["description"]);
-     }
-     else if (m_metadata.contains("comment")) {
-         setDescription (m_metadata["comment"]);
-     }
+         m_metadata = metadata;
+
+         if (m_metadata.contains("description")) {
+             setDescription (m_metadata["description"]);
+         }
+         else if (m_metadata.contains("comment")) {
+             setDescription (m_metadata["comment"]);
+         }
     */
 
 }
index 184d89dc43a6631de0e794fb8c74c62ac078501a..f08ac5f2849232ca14ce6d684c03c910c71cd70c 100644 (file)
@@ -53,6 +53,9 @@ public:
     int clipMaxDuration() const;
     CLIPTYPE clipType() const;
     void setGroup(const QString name, const QString id);
+    void changeDuration(int frames);
+    DocClipBase *referencedClip();
+    void setDescription(const QString &desc);
 
 private:
     QDomElement m_element;
index c648dda8ffbb6206ed149048113723e481ac15f1..f9279782fa2df545a890aec54bc12607359647f6 100644 (file)
@@ -95,11 +95,6 @@ ProjectList::ProjectList(QWidget *parent)
     //m_toolbar->setEnabled(false);
 
     searchView->setTreeWidget(listView);
-    listView->setColumnCount(3);
-    QStringList headers;
-    headers << i18n("Thumbnail") << i18n("Filename") << i18n("Description");
-    listView->setHeaderLabels(headers);
-    listView->sortByColumn(1, Qt::AscendingOrder);
 
     m_menu = new QMenu();
     m_menu->addAction(addClipButton);
@@ -115,11 +110,10 @@ ProjectList::ProjectList(QWidget *parent)
     connect(listView, SIGNAL(addClip()), this, SLOT(slotAddClip()));
     connect(listView, SIGNAL(addClip(QUrl, const QString &)), this, SLOT(slotAddClip(QUrl, const QString &)));
     connect(listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotUpdateItemDescription(QTreeWidgetItem *, int)));
+    connect(listView, SIGNAL(showProperties(DocClipBase *)), this, SIGNAL(showClipProperties(DocClipBase *)));
 
     m_listViewDelegate = new ItemDelegate(listView);
     listView->setItemDelegate(m_listViewDelegate);
-    listView->setIconSize(QSize(60, 40));
-    listView->setSortingEnabled(true);
 }
 
 ProjectList::~ProjectList() {
@@ -127,6 +121,8 @@ ProjectList::~ProjectList() {
     delete m_toolbar;
 }
 
+
+
 void ProjectList::setRenderer(Render *projectRender) {
     m_render = projectRender;
 }
@@ -143,7 +139,8 @@ void ProjectList::slotUpdateItemDescription(QTreeWidgetItem *item, int column) {
         if (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST) {
             // Use Nepomuk system to store clip description
             Nepomuk::Resource f(clip->clipUrl().path());
-            f.setDescription(item->text(2));
+            if (f.isValid()) f.setDescription(item->text(2));
+            clip->setDescription(item->text(2));
             kDebug() << "NEPOMUK, SETTING CLIP: " << clip->clipUrl().path() << ", TO TEXT: " << item->text(2);
         }
     } else if (column == 1 && type == FOLDER) {
@@ -151,29 +148,9 @@ void ProjectList::slotUpdateItemDescription(QTreeWidgetItem *item, int column) {
     }
 }
 
-void ProjectList::slotEditClip() {
-    kDebug() << "////////////////////////////////////////   DBL CLK";
-}
-
-
-void ProjectList::slotEditClip(QTreeWidgetItem *item, int column) {
-    kDebug() << "////////////////////////////////////////   DBL CLK";
-}
-
 void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item) {
     bool enable = false;
     if (item) {
-        QFrame *w = new QFrame;
-        w->setFrameShape(QFrame::StyledPanel);
-        w->setLineWidth(2);
-        w->setAutoFillBackground(true);
-        QHBoxLayout *layout = new QHBoxLayout;
-        layout->addWidget(new QLabel(i18n("Color:")));
-        layout->addWidget(new KColorButton());
-        layout->addWidget(new QLabel(i18n("Duration:")));
-        layout->addWidget(new KRestrictedLine());
-        w->setLayout(layout);
-        m_listViewDelegate->extendItem(w, listView->currentIndex());
         enable = true;
     }
     m_editAction->setEnabled(enable);
@@ -243,7 +220,9 @@ void ProjectList::addClip(const QStringList &name, const QDomElement &elem, cons
     if (!url.isEmpty()) {
         // if file has Nepomuk comment, use it
         Nepomuk::Resource f(url.path());
-        QString annotation = f.description();
+        QString annotation;
+        if (f.isValid()) annotation = f.description();
+
         if (!annotation.isEmpty()) item->setText(2, annotation);
         QString resource = url.path();
         if (resource.endsWith("westley") || resource.endsWith("kdenlive")) {
@@ -280,9 +259,12 @@ void ProjectList::addClip(const QStringList &name, const QDomElement &elem, cons
 }
 
 void ProjectList::slotDeleteClip(int clipId) {
-    kDebug() << "///////  DELETE CLIP: " << clipId;
     ProjectItem *item = getItemById(clipId);
-    if (item) delete item;
+    QTreeWidgetItem *p = item->parent();
+    if (p) {
+        kDebug() << "///////  DELETEED CLIP HAS A PARENT... " << p->indexOfChild(item);
+        QTreeWidgetItem *clone = p->takeChild(p->indexOfChild(item));
+    } else if (item) delete item;
 }
 
 void ProjectList::slotAddFolder() {
@@ -328,11 +310,26 @@ void ProjectList::slotAddFolder(const QString foldername, int clipId, bool remov
 
 void ProjectList::slotAddClip(DocClipBase *clip) {
     const int parent = clip->toXML().attribute("groupid").toInt();
+    ProjectItem *item = NULL;
     if (parent != 0) {
         ProjectItem *parentitem = getItemById(parent);
-        if (parentitem)(void) new ProjectItem(parentitem, clip);
-        else (void) new ProjectItem(listView, clip);
-    } else (void) new ProjectItem(listView, clip);
+        if (parentitem) item = new ProjectItem(parentitem, clip);
+    }
+    if (item == NULL) item = new ProjectItem(listView, clip);
+
+    KUrl url = clip->fileURL();
+    if (!url.isEmpty()) {
+        // if file has Nepomuk comment, use it
+        Nepomuk::Resource f(url.path());
+        QString annotation;
+        if (f.isValid()) {
+            annotation = f.description();
+            /*
+            Nepomuk::Tag tag("test");
+            f.addTag(tag);*/
+        } else kDebug() << "---  CANNOT CONTACT NEPOMUK";
+        if (!annotation.isEmpty()) item->setText(2, annotation);
+    }
     emit getFileProperties(clip->toXML(), clip->getId());
 }
 
index 3f1ff74801b11bc15482ac9fdff0cefe54279b27..998ae510ff11e58adba0e462635a929535f9c7d6 100644 (file)
 #include <QToolBar>
 #include <QTreeWidget>
 #include <QPainter>
+#include <QItemDelegate>
 
 #include <KUndoStack>
 #include <KTreeWidgetSearchLine>
-#include "kextendableitemdelegate.h"
 #include <KUrl>
 
 #include "definitions.h"
@@ -44,11 +44,13 @@ const int NameRole = Qt::UserRole;
 const int DurationRole = NameRole + 1;
 const int UsageRole = NameRole + 2;
 
-class ItemDelegate: public KExtendableItemDelegate {
+class ItemDelegate: public QItemDelegate {
 public:
-    ItemDelegate(QAbstractItemView* parent = 0): KExtendableItemDelegate(parent) {
+    ItemDelegate(QAbstractItemView* parent = 0): QItemDelegate(parent) {
     }
     /*
+    static_cast<ProjectItem *>( index.internalPointer() );
+
     void expand()
     {
       QWidget *w = new QWidget;
@@ -88,7 +90,7 @@ public:
             painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText);
             painter->restore();
         } else {
-            KExtendableItemDelegate::paint(painter, option, index);
+            QItemDelegate::paint(painter, option, index);
         }
     }
 };
@@ -129,17 +131,15 @@ private:
     ProjectItem *getItemById(int id);
     QAction *m_editAction;
     QAction *m_deleteAction;
-    ItemDelegate *m_listViewDelegate;
     KdenliveDoc *m_doc;
+    ItemDelegate *m_listViewDelegate;
 
 private slots:
     void slotAddClip(QUrl givenUrl = QUrl(), QString group = QString());
     void slotRemoveClip();
-    void slotEditClip();
     void slotClipSelected();
     void slotAddColorClip();
     void slotAddTitleClip();
-    void slotEditClip(QTreeWidgetItem *, int);
     void slotContextMenu(const QPoint &pos, QTreeWidgetItem *);
     void slotAddFolder();
     void slotAddFolder(const QString foldername, int clipId, bool remove, bool edit);
@@ -153,6 +153,7 @@ signals:
     void clipSelected(const QDomElement &);
     void getFileProperties(const QDomElement&, int);
     void receivedClipDuration(int, int);
+    void showClipProperties(DocClipBase *);
 };
 
 #endif
index 63e86e625a01eec12f5a075a85efa070da1288a9..f51c0b2330e5f9e4f0434aebec754b5d9cec639d 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
 
-#include "QApplication"
+#include <QApplication>
+#include <QHeaderView>
+#include <QAction>
 
-#include "KDebug"
+#include <KDebug>
+#include <KMenu>
+#include <KLocale>
 
 #include "projectitem.h"
 #include "projectlistview.h"
+#include "kdenlivesettings.h"
 
 
 ProjectListView::ProjectListView(QWidget *parent)
@@ -33,13 +38,69 @@ ProjectListView::ProjectListView(QWidget *parent)
     setAlternatingRowColors(true);
     setDragEnabled(true);
     setAcceptDrops(true);
+
+    setColumnCount(4);
+    QStringList headers;
+    headers << i18n("Thumbnail") << i18n("Filename") << i18n("Description") << i18n("Rating");
+    setHeaderLabels(headers);
+    sortByColumn(1, Qt::AscendingOrder);
+
+    QHeaderView* headerView = header();
+    headerView->setContextMenuPolicy(Qt::CustomContextMenu);
+    connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)),
+            this, SLOT(configureColumns(const QPoint&)));
+
+    connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(slotFocusOut(QTreeWidgetItem *, QTreeWidgetItem *)));
+
+    if (!KdenliveSettings::showdescriptioncolumn()) hideColumn(2);
+    if (!KdenliveSettings::showratingcolumn()) hideColumn(3);
+
+    setIconSize(QSize(60, 40));
+    setSortingEnabled(true);
 }
 
 ProjectListView::~ProjectListView() {
 }
 
-void ProjectListView::editItem(QTreeWidgetItem * item, int column) {
-    kDebug() << "////////////////  EDIT ITEM, COL: " << column;
+
+void ProjectListView::configureColumns(const QPoint& pos) {
+    KMenu popup(this);
+    popup.addTitle(i18nc("@title:menu", "Columns"));
+
+    QHeaderView* headerView = header();
+    for (int i = 2; i < headerView->count(); ++i) {
+        const int logicalIndex = headerView->logicalIndex(i);
+        const QString text = model()->headerData(i, Qt::Horizontal).toString();
+        QAction* action = popup.addAction(text);
+        action->setCheckable(true);
+        action->setChecked(!headerView->isSectionHidden(logicalIndex));
+        action->setData(i);
+    }
+
+    QAction* activatedAction = popup.exec(header()->mapToGlobal(pos));
+    if (activatedAction != 0) {
+        const bool show = activatedAction->isChecked();
+
+        // remember the changed column visibility in the settings
+        const int columnIndex = activatedAction->data().toInt();
+        switch (columnIndex) {
+        case 2:
+            KdenliveSettings::setShowdescriptioncolumn(show);
+            break;
+        case 3:
+            KdenliveSettings::setShowratingcolumn(show);
+            break;
+        default:
+            break;
+        }
+
+        // apply the changed column visibility
+        if (show) {
+            showColumn(columnIndex);
+        } else {
+            hideColumn(columnIndex);
+        }
+    }
 }
 
 // virtual
@@ -52,6 +113,7 @@ void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event) {
     ProjectItem *item = static_cast <ProjectItem *>(itemAt(event->pos()));
     if (!item) emit addClip();
     else if ((item->clipType() == FOLDER && columnAt(event->pos().x()) == 1) || columnAt(event->pos().x()) == 2) QTreeWidget::mouseDoubleClickEvent(event);
+    else emit showProperties(item->referencedClip());
 }
 
 // virtual
index 17885b4f8636124bb95da553bdd6f6445e12355a..474b8d9336d57768f82e5141b39820dfb1e59491 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <QTreeWidget>
 #include <QContextMenuEvent>
+#include <QPainter>
+
 
 class ProjectListView : public QTreeWidget {
     Q_OBJECT
@@ -30,7 +32,6 @@ class ProjectListView : public QTreeWidget {
 public:
     ProjectListView(QWidget *parent = 0);
     virtual ~ProjectListView();
-    void editItem(QTreeWidgetItem * item, int column = 0);
 
 protected:
     virtual void contextMenuEvent(QContextMenuEvent * event);
@@ -51,12 +52,13 @@ private:
     QPoint m_DragStartPosition;
 
 private slots:
-
+    void configureColumns(const QPoint& pos);
 
 signals:
     void requestMenu(const QPoint &, QTreeWidgetItem *);
     void addClip();
     void addClip(QUrl, const QString &);
+    void showProperties(DocClipBase *);
 };
 
 #endif
index c636b75b9cb8e66f9a6cd298e057eaa590dcd1db..de81a7a8e395fbac9585525271e23639fee2aaaf 100644 (file)
@@ -383,18 +383,14 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
     producer.attach(m_convert);
     Mlt::Frame * frame = producer.get_frame();
 
-    filePropertyMap["fps"] =
-        QString::number(mlt_producer_get_fps(producer.get_producer()));
+    //filePropertyMap["fps"] = QString::number(mlt_producer_get_fps(producer.get_producer()));
+    filePropertyMap["fps"] = producer.get("source_fps");
 
     if (frame && frame->is_valid()) {
-        filePropertyMap["width"] =
-            QString::number(frame->get_int("width"));
-        filePropertyMap["height"] =
-            QString::number(frame->get_int("height"));
-        filePropertyMap["frequency"] =
-            QString::number(frame->get_int("frequency"));
-        filePropertyMap["channels"] =
-            QString::number(frame->get_int("channels"));
+        filePropertyMap["frame_size"] = QString::number(frame->get_int("width")) + "x" + QString::number(frame->get_int("height"));
+        filePropertyMap["frequency"] = QString::number(frame->get_int("frequency"));
+        filePropertyMap["channels"] = QString::number(frame->get_int("channels"));
+        filePropertyMap["aspect_ratio"] = frame->get("aspect_ratio");
 
         if (frame->get_int("test_image") == 0) {
             if (url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) {
diff --git a/src/widgets/clipproperties_ui.ui b/src/widgets/clipproperties_ui.ui
new file mode 100644 (file)
index 0000000..3e0f0f3
--- /dev/null
@@ -0,0 +1,360 @@
+<ui version="4.0" >
+ <class>ClipProperties_UI</class>
+ <widget class="QDialog" name="ClipProperties_UI" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>284</width>
+    <height>439</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Dialog</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout_2" >
+   <item row="1" column="0" >
+    <widget class="QLabel" name="label_5" >
+     <property name="text" >
+      <string>Path</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0" >
+    <widget class="KLineEdit" name="clip_path" >
+     <property name="readOnly" >
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0" >
+    <widget class="QLabel" name="label_3" >
+     <property name="text" >
+      <string>Description</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0" >
+    <widget class="KLineEdit" name="clip_description" />
+   </item>
+   <item row="5" column="0" >
+    <widget class="QLabel" name="clip_filesize" >
+     <property name="text" >
+      <string>File size:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="0" >
+    <widget class="QTabWidget" name="tabWidget" >
+     <property name="currentIndex" >
+      <number>0</number>
+     </property>
+     <widget class="QWidget" name="tab_video" >
+      <property name="geometry" >
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>264</width>
+        <height>187</height>
+       </rect>
+      </property>
+      <attribute name="title" >
+       <string>Video</string>
+      </attribute>
+      <layout class="QGridLayout" name="gridLayout" >
+       <item row="0" column="0" >
+        <widget class="QLabel" name="label_8" >
+         <property name="text" >
+          <string>Video codec</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="2" >
+        <widget class="KLineEdit" name="clip_vcodec" >
+         <property name="readOnly" >
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0" colspan="2" >
+        <widget class="QLabel" name="label_6" >
+         <property name="text" >
+          <string>Frame size</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="2" >
+        <widget class="KLineEdit" name="clip_size" >
+         <property name="readOnly" >
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="0" colspan="2" >
+        <widget class="QLabel" name="label_7" >
+         <property name="text" >
+          <string>Frame rate</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="2" >
+        <widget class="KLineEdit" name="clip_fps" >
+         <property name="readOnly" >
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="0" colspan="2" >
+        <widget class="QLabel" name="label_12" >
+         <property name="text" >
+          <string>Aspect ratio</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="2" >
+        <widget class="KLineEdit" name="clip_ratio" >
+         <property name="readOnly" >
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item row="4" column="1" colspan="2" >
+        <spacer name="verticalSpacer_2" >
+         <property name="orientation" >
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0" >
+          <size>
+           <width>20</width>
+           <height>17</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="tab_audio" >
+      <attribute name="title" >
+       <string>Audio</string>
+      </attribute>
+      <layout class="QGridLayout" name="gridLayout_4" >
+       <item row="0" column="1" colspan="2" >
+        <widget class="KLineEdit" name="clip_acodec" >
+         <property name="readOnly" >
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1" colspan="2" >
+        <widget class="KLineEdit" name="clip_channels" >
+         <property name="readOnly" >
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="1" colspan="2" >
+        <widget class="KLineEdit" name="clip_frequency" >
+         <property name="readOnly" >
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="2" >
+        <spacer name="verticalSpacer_3" >
+         <property name="orientation" >
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0" >
+          <size>
+           <width>77</width>
+           <height>68</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item row="0" column="0" >
+        <widget class="QLabel" name="label_9" >
+         <property name="text" >
+          <string>Audio codec</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0" >
+        <widget class="QLabel" name="label_11" >
+         <property name="text" >
+          <string>Channels</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="0" >
+        <widget class="QLabel" name="label_10" >
+         <property name="text" >
+          <string>Frequency</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+      <zorder>ClipProperties_2</zorder>
+      <zorder>clip_acodec</zorder>
+      <zorder>clip_frequency</zorder>
+      <zorder>verticalSpacer_3</zorder>
+      <zorder>clip_channels</zorder>
+      <zorder>label_9</zorder>
+      <zorder>label_11</zorder>
+      <zorder>label_10</zorder>
+     </widget>
+     <widget class="QWidget" name="tab_advanced" >
+      <property name="geometry" >
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>264</width>
+        <height>187</height>
+       </rect>
+      </property>
+      <attribute name="title" >
+       <string>Advanced</string>
+      </attribute>
+      <layout class="QGridLayout" name="gridLayout_3" >
+       <item row="0" column="0" >
+        <widget class="QCheckBox" name="clip_force_ar" >
+         <property name="text" >
+          <string>Force aspect ratio</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="1" >
+        <widget class="KDoubleNumInput" name="clip_ar" />
+       </item>
+       <item row="1" column="0" >
+        <widget class="QLabel" name="label_4" >
+         <property name="text" >
+          <string>Decoding threads</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1" >
+        <widget class="QSpinBox" name="clip_threads" >
+         <property name="maximum" >
+          <number>4</number>
+         </property>
+         <property name="value" >
+          <number>1</number>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="0" >
+        <widget class="QLabel" name="label" >
+         <property name="text" >
+          <string>Video index</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="1" >
+        <widget class="QSpinBox" name="clip_vindex" >
+         <property name="minimum" >
+          <number>-1</number>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="0" >
+        <widget class="QLabel" name="label_2" >
+         <property name="text" >
+          <string>Audio index</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="1" >
+        <widget class="QSpinBox" name="clip_aindex" >
+         <property name="minimum" >
+          <number>-1</number>
+         </property>
+        </widget>
+       </item>
+       <item row="4" column="1" >
+        <spacer name="verticalSpacer" >
+         <property name="orientation" >
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0" >
+          <size>
+           <width>20</width>
+           <height>35</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+   <item row="7" column="0" >
+    <widget class="QDialogButtonBox" name="buttonBox" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons" >
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="0" >
+    <widget class="QLabel" name="clip_thumb" >
+     <property name="text" >
+      <string>Image preview</string>
+     </property>
+     <property name="alignment" >
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KDoubleNumInput</class>
+   <extends>QWidget</extends>
+   <header>knuminput.h</header>
+  </customwidget>
+  <customwidget>
+   <class>KLineEdit</class>
+   <extends>QLineEdit</extends>
+   <header>klineedit.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>ClipProperties_UI</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>ClipProperties_UI</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>