]> git.sesse.net Git - kdenlive/commitdiff
Add, edit and delete markers from clip properties dialog
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 1 Jun 2008 15:10:18 +0000 (15:10 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 1 Jun 2008 15:10:18 +0000 (15:10 +0000)
svn path=/branches/KDE4/; revision=2211

src/CMakeLists.txt
src/clipproperties.cpp
src/clipproperties.h
src/customtrackview.cpp
src/customtrackview.h
src/mainwindow.cpp
src/markerdialog.cpp [new file with mode: 0644]
src/markerdialog.h [new file with mode: 0644]
src/projectlist.cpp
src/widgets/clipproperties_ui.ui
src/widgets/markerdialog_ui.ui [new file with mode: 0644]

index 56c9f4f23e86e805bde9a58d78c59bfba21a4496..81370b87c70e6f192452765bb01129c5e1908a1d 100644 (file)
@@ -47,6 +47,7 @@ kde4_add_ui_files(kdenlive_UI
   widgets/configjogshuttle_ui.ui
   widgets/trackheader_ui.ui
   widgets/clipproperties_ui.ui
+  widgets/markerdialog_ui.ui
 )
  
 set(kdenlive_SRCS 
@@ -108,6 +109,7 @@ set(kdenlive_SRCS
   clipproperties.cpp
   movetransitioncommand.cpp
   slideshowclip.cpp
+  markerdialog.cpp
 )
 
 kde4_add_kcfg_files(kdenlive_SRCS GENERATE_MOC kdenlivesettings.kcfgc )
index a35e8bb966e224ccc4316e1755f5b53db490501a..bec7b3906d83e35b8ffa506a7b2e58cf2f14d64e 100644 (file)
@@ -26,6 +26,7 @@
 #include "kdenlivesettings.h"
 #include "clipproperties.h"
 #include "kthumb.h"
+#include "markerdialog.h"
 
 #define VIDEOTAB 0
 #define AUDIOTAB 1
@@ -104,17 +105,64 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
     m_view.clip_filesize->setText(KIO::convertSize(f.size()));
     m_view.clip_duration->setText(tc.getTimecode(m_clip->duration(), m_fps));
 
-    QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
+    // markers
+    m_view.marker_new->setIcon(KIcon("document-new"));
+    m_view.marker_new->setToolTip(i18n("Add marker"));
+    m_view.marker_edit->setIcon(KIcon("document-properties"));
+    m_view.marker_edit->setToolTip(i18n("Edit marker"));
+    m_view.marker_delete->setIcon(KIcon("trash-empty"));
+    m_view.marker_delete->setToolTip(i18n("Delete marker"));
+
+    slotFillMarkersList();
+    connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
+    connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
+    connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
+    connect(m_view.markers_list, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotEditMarker()));
+
+    adjustSize();
+}
 
+void ClipProperties::slotFillMarkersList() {
+    m_view.markers_list->clear();
+    QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
     for (uint count = 0; count < marks.count(); ++count) {
-       QString time = m_tc.getTimecode(marks[count].time(), m_tc.fps());
-       QStringList itemtext;
-       itemtext << time << marks[count].comment();
-       (void) new QTreeWidgetItem(m_view.markers_list, itemtext);
+        QString time = m_tc.getTimecode(marks[count].time(), m_tc.fps());
+        QStringList itemtext;
+        itemtext << time << marks[count].comment();
+        (void) new QTreeWidgetItem(m_view.markers_list, itemtext);
     }
-    
+}
 
-    adjustSize();
+void ClipProperties::slotAddMarker() {
+    CommentedTime marker(GenTime(), i18n("Marker"));
+    MarkerDialog d(m_clip, marker, m_tc, this);
+    if (d.exec() == QDialog::Accepted) {
+        int id = m_clip->getId();
+        emit addMarker(id, d.newMarker().time(), d.newMarker().comment());
+    }
+    QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
+}
+
+void ClipProperties::slotEditMarker() {
+    QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
+    int pos = m_view.markers_list->currentIndex().row();
+    if (pos < 0 || pos > marks.count() - 1) return;
+    MarkerDialog d(m_clip, marks.at(pos), m_tc, this);
+    if (d.exec() == QDialog::Accepted) {
+        int id = m_clip->getId();
+        emit addMarker(id, d.newMarker().time(), d.newMarker().comment());
+    }
+    QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
+}
+
+void ClipProperties::slotDeleteMarker() {
+    QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
+    int pos = m_view.markers_list->currentIndex().row();
+    if (pos < 0 || pos > marks.count() - 1) return;
+    int id = m_clip->getId();
+    emit addMarker(id, marks.at(pos).time(), QString());
+
+    QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
 }
 
 int ClipProperties::clipId() const {
index 843d71cf7bedaa07c8df30c1f87ceb57cc3e65de..aa5c8e217cf83692a86141e48861b40ee2f98ca8 100644 (file)
@@ -24,8 +24,8 @@
 #include <QDialog>
 
 #include "definitions.h"
-#include "docclipbase.h"
 #include "timecode.h"
+#include "docclipbase.h"
 #include "ui_clipproperties_ui.h"
 
 class ClipProperties : public QDialog {
@@ -39,6 +39,10 @@ public:
 
 private slots:
     void parseFolder();
+    void slotAddMarker();
+    void slotEditMarker();
+    void slotDeleteMarker();
+    void slotFillMarkersList();
 
 private:
     Ui::ClipProperties_UI m_view;
@@ -48,6 +52,9 @@ private:
     /** used to count images in slideshow clip */
     int m_count;
     bool m_clipNeedsRefresh;
+
+signals:
+    void addMarker(int, GenTime, QString);
 };
 
 
index 6bbd28060cb8e4eeea94d848063a4e880d66fb31..cbd487d43498f26457407b5407f1c3df74e05624 100644 (file)
@@ -1131,7 +1131,12 @@ void CustomTrackView::slotAddClipMarker() {
     GenTime position = pos - item->startPos() + item->cropStart();
     QString comment = QInputDialog::getText(this, i18n("Add Marker"), i18n("Enter text for marker on clip <b>%1</b>", clip->clipName()), QLineEdit::Normal, i18n("marker"));
     if (comment.isEmpty()) return;
-    AddMarkerCommand *command = new AddMarkerCommand(this, QString(), comment, id, position, true);
+    slotAddClipMarker(id, position, comment);
+}
+
+void CustomTrackView::slotAddClipMarker(int id, GenTime t, QString c) {
+    QString oldcomment = m_document->clipManager()->getClipById(id)->markerComment(t);
+    AddMarkerCommand *command = new AddMarkerCommand(this, oldcomment, c, id, t, true);
     m_commandStack->push(command);
 }
 
index 0ef150224f77f9afeda8a0882948e3e48385a344..52066bc8275fca0d70c9f2c9f345a6f65ab86d0a 100644 (file)
@@ -29,6 +29,7 @@
 #include <KUndoStack>
 
 #include "kdenlivedoc.h"
+#include "docclipbase.h"
 
 class ClipItem;
 class AbstractClipItem;
@@ -94,6 +95,7 @@ public slots:
     void slotSwitchTrackAudio(int ix);
     void slotSwitchTrackVideo(int ix);
     void slotUpdateClip(int clipId);
+    void slotAddClipMarker(int id, GenTime t, QString c);
 
 protected:
     virtual void drawBackground(QPainter * painter, const QRectF & rect);
index 495d8e85251114e2f7d53347ad0ca68d3fd7fb23..faa36337b11e82db0b2ef48721e5771f5913d040 100644 (file)
@@ -1035,12 +1035,14 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip) {
         m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
         return;
     }
+    TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
     ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
+    connect(&dia, SIGNAL(addMarker(int, GenTime, QString)), currentTab->projectView(), SLOT(slotAddClipMarker(int, GenTime, QString)));
     if (dia.exec() == QDialog::Accepted) {
         m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
         if (dia.needsTimelineRefresh()) {
             // update clip occurences in timeline
-            TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
+
             currentTab->projectView()->slotUpdateClip(dia.clipId());
         }
     }
diff --git a/src/markerdialog.cpp b/src/markerdialog.cpp
new file mode 100644 (file)
index 0000000..91b0b37
--- /dev/null
@@ -0,0 +1,59 @@
+/***************************************************************************
+ *   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 <KDebug>
+
+#include "markerdialog.h"
+
+MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, QWidget * parent): QDialog(parent), m_tc(tc), m_clip(clip), m_marker(t) {
+    setFont(KGlobalSettings::toolBarFont());
+    m_fps = m_tc.fps();
+    m_view.setupUi(this);
+    m_view.marker_position->setText(tc.getTimecode(t.time(), tc.fps()));
+    m_view.marker_comment->setText(t.comment());
+    connect(m_view.position_up, SIGNAL(clicked()), this, SLOT(slotTimeUp()));
+    connect(m_view.position_down, SIGNAL(clicked()), this, SLOT(slotTimeDown()));
+    m_view.marker_comment->selectAll();
+    m_view.marker_comment->setFocus();
+    adjustSize();
+}
+
+
+void MarkerDialog::slotTimeUp() {
+    int duration = m_tc.getFrameCount(m_view.marker_position->text(), m_fps);
+    if (duration >= m_clip->duration().frames(m_fps)) return;
+    duration ++;
+    m_view.marker_position->setText(m_tc.getTimecode(GenTime(duration, m_fps), m_fps));
+}
+
+void MarkerDialog::slotTimeDown() {
+    int duration = m_tc.getFrameCount(m_view.marker_position->text(), m_fps);
+    if (duration <= 0) return;
+    duration --;
+    m_view.marker_position->setText(m_tc.getTimecode(GenTime(duration, m_fps), m_fps));
+}
+
+CommentedTime MarkerDialog::newMarker() {
+    return CommentedTime(GenTime(m_tc.getFrameCount(m_view.marker_position->text(), m_fps), m_fps), m_view.marker_comment->text());
+}
+
+#include "markerdialog.moc"
+
+
diff --git a/src/markerdialog.h b/src/markerdialog.h
new file mode 100644 (file)
index 0000000..10c81fa
--- /dev/null
@@ -0,0 +1,50 @@
+/***************************************************************************
+ *   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 MARKERDIALOG_H
+#define MARKERDIALOG_H
+
+#include <QDialog>
+
+#include "docclipbase.h"
+#include "timecode.h"
+#include "ui_markerdialog_ui.h"
+
+class MarkerDialog : public QDialog {
+    Q_OBJECT
+
+public:
+    MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, QWidget * parent = 0);
+    CommentedTime newMarker();
+private slots:
+    void slotTimeUp();
+    void slotTimeDown();
+
+private:
+    Ui::MarkerDialog_UI m_view;
+    DocClipBase *m_clip;
+    CommentedTime m_marker;
+    Timecode m_tc;
+    double m_fps;
+};
+
+
+#endif
+
index 8b2633044144763fc4390b311c1c3a120d07ed7e..7580fbf1ceb6955943eae18275d9fb2b8c51bf3d 100644 (file)
@@ -126,8 +126,7 @@ ProjectList::~ProjectList() {
     delete m_toolbar;
 }
 
-void ProjectList::slotEditClip()
-{
+void ProjectList::slotEditClip() {
     ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
     if (item && !item->isGroup()) emit clipSelected(item->toXml());
     emit showClipProperties(item->referencedClip());
index a2f138048f2d8273c7a27c1bd0d9cec76a3c25ef..e71b9a796dfc2d9aad65ae09873885f3ebf361ab 100644 (file)
@@ -86,7 +86,7 @@
         <x>0</x>
         <y>0</y>
         <width>284</width>
-        <height>172</height>
+        <height>204</height>
        </rect>
       </property>
       <attribute name="title" >
         <x>0</x>
         <y>0</y>
         <width>284</width>
-        <height>172</height>
+        <height>204</height>
        </rect>
       </property>
       <attribute name="title" >
         <x>0</x>
         <y>0</y>
         <width>284</width>
-        <height>172</height>
+        <height>204</height>
        </rect>
       </property>
       <attribute name="title" >
         <x>0</x>
         <y>0</y>
         <width>284</width>
-        <height>172</height>
+        <height>204</height>
        </rect>
       </property>
       <attribute name="title" >
       </layout>
      </widget>
      <widget class="QWidget" name="tab_3" >
+      <property name="geometry" >
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>284</width>
+        <height>204</height>
+       </rect>
+      </property>
       <attribute name="title" >
        <string>Markers</string>
       </attribute>
       <layout class="QGridLayout" name="gridLayout_7" >
-       <item row="0" column="0" >
+       <item row="0" column="0" colspan="4" >
         <widget class="QTreeWidget" name="markers_list" >
          <property name="alternatingRowColors" >
           <bool>true</bool>
          </column>
         </widget>
        </item>
+       <item row="1" column="0" >
+        <widget class="QToolButton" name="marker_new" >
+         <property name="text" >
+          <string>N</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1" >
+        <widget class="QToolButton" name="marker_edit" >
+         <property name="text" >
+          <string>E</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="2" >
+        <widget class="QToolButton" name="marker_delete" >
+         <property name="text" >
+          <string>D</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="3" >
+        <spacer name="horizontalSpacer" >
+         <property name="orientation" >
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0" >
+          <size>
+           <width>177</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
       </layout>
      </widget>
      <widget class="QWidget" name="tab_advanced" >
         <x>0</x>
         <y>0</y>
         <width>284</width>
-        <height>172</height>
+        <height>204</height>
        </rect>
       </property>
       <attribute name="title" >
diff --git a/src/widgets/markerdialog_ui.ui b/src/widgets/markerdialog_ui.ui
new file mode 100644 (file)
index 0000000..dd90d01
--- /dev/null
@@ -0,0 +1,150 @@
+<ui version="4.0" >
+ <class>MarkerDialog_UI</class>
+ <widget class="QDialog" name="MarkerDialog_UI" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>331</width>
+    <height>109</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Marker</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout" >
+   <item rowspan="3" row="0" column="0" >
+    <widget class="QLabel" name="clip_thumb" >
+     <property name="frameShape" >
+      <enum>QFrame::Box</enum>
+     </property>
+     <property name="text" >
+      <string>Image preview</string>
+     </property>
+     <property name="alignment" >
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item rowspan="2" row="0" column="1" >
+    <widget class="QLabel" name="clip_filesize_2" >
+     <property name="text" >
+      <string>Position</string>
+     </property>
+    </widget>
+   </item>
+   <item rowspan="2" row="0" column="2" colspan="2" >
+    <widget class="KRestrictedLine" name="marker_position" >
+     <property name="inputMask" >
+      <string>99:99:99:99; </string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="4" >
+    <widget class="KArrowButton" name="position_up" />
+   </item>
+   <item row="1" column="4" >
+    <widget class="KArrowButton" name="position_down" >
+     <property name="arrowType" stdset="0" >
+      <number>2</number>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1" >
+    <widget class="QLabel" name="clip_filesize_3" >
+     <property name="text" >
+      <string>Comment</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="1" colspan="3" >
+    <spacer name="verticalSpacer" >
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0" >
+      <size>
+       <width>218</width>
+       <height>2</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="4" column="0" colspan="5" >
+    <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="2" column="2" colspan="3" >
+    <widget class="KLineEdit" name="marker_comment" />
+   </item>
+  </layout>
+  <zorder>buttonBox</zorder>
+  <zorder>marker_position</zorder>
+  <zorder>dial</zorder>
+  <zorder>position_up</zorder>
+  <zorder>position_down</zorder>
+  <zorder>clip_filesize_3</zorder>
+  <zorder>verticalSpacer</zorder>
+  <zorder>clip_thumb</zorder>
+  <zorder>clip_filesize_2</zorder>
+  <zorder>marker_comment</zorder>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KArrowButton</class>
+   <extends>QPushButton</extends>
+   <header>karrowbutton.h</header>
+  </customwidget>
+  <customwidget>
+   <class>KLineEdit</class>
+   <extends>QLineEdit</extends>
+   <header>klineedit.h</header>
+  </customwidget>
+  <customwidget>
+   <class>KRestrictedLine</class>
+   <extends>KLineEdit</extends>
+   <header>krestrictedline.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>MarkerDialog_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>MarkerDialog_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>