]> git.sesse.net Git - kdenlive/commitdiff
Notes widget: context menu now allows to insert clickable timecode to make easy refer...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 28 Apr 2011 20:05:13 +0000 (20:05 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 28 Apr 2011 20:05:13 +0000 (20:05 +0000)
svn path=/trunk/kdenlive/; revision=5564

src/CMakeLists.txt
src/kdenlivedoc.cpp
src/mainwindow.cpp
src/mainwindow.h
src/noteswidget.cpp [new file with mode: 0644]
src/noteswidget.h [new file with mode: 0644]
src/renderer.h

index 555e3b48c81cf810741dfcdf4de5cdd853697243..e0a15eb4f2910088ba67eeffea42aab844d0d3e9 100644 (file)
@@ -279,6 +279,7 @@ set(kdenlive_SRCS
   monitoreditwidget.cpp
   simplekeyframes/simpletimelinewidget.cpp
   simplekeyframes/simplekeyframewidget.cpp
+  noteswidget.cpp
 )
 
 add_definitions(${KDE4_DEFINITIONS})
index 0e7862d86ac6c2819519d99bc3f54cdd404cf6c2..e953b2eb381392b51b0d3091a9cc9e34041b9946 100644 (file)
@@ -589,7 +589,7 @@ bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene, const
     addedXml.appendChild(docproperties);
 
     QDomElement docnotes = sceneList.createElement("documentnotes");
-    QDomText value = sceneList.createTextNode(m_notesWidget->toPlainText());
+    QDomText value = sceneList.createTextNode(m_notesWidget->toHtml());
     docnotes.appendChild(value);
     addedXml.appendChild(docnotes);
 
index 4013073ffabe9b3b7f3d7a447ca936b8536f13a0..1e18d029eaf47f0c9cd7bac1960f56bcc1a8ddf0 100644 (file)
@@ -215,7 +215,10 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
 
     m_notesDock = new QDockWidget(i18n("Project Notes"), this);
     m_notesDock->setObjectName("notes_widget");
-    m_notesWidget = new KTextEdit();
+    m_notesWidget = new NotesWidget();
+    connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
+    connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
+    
     m_notesWidget->setTabChangesFocus(true);
 #if KDE_IS_VERSION(4,4,0)
     m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
@@ -4230,6 +4233,13 @@ void MainWindow::slotUpdateProxySettings()
     m_projectList->updateProxyConfig();
 }
 
+void MainWindow::slotInsertNotesTimecode()
+{
+    int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
+    QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
+    m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
+}
+
 #include "mainwindow.moc"
 
 #ifdef DEBUG_MAINW
index 6f7b945464e4cdeddb3c7381500f94b232e63f9a..778b8777e5da907e660b043daac4efff169488d1 100644 (file)
@@ -45,6 +45,7 @@
 #include "statusbarmessagelabel.h"
 #include "dvdwizard.h"
 #include "stopmotion/stopmotion.h"
+#include "noteswidget.h"
 
 class KdenliveDoc;
 class TrackView;
@@ -149,7 +150,7 @@ private:
     //KListWidget *m_effectList;
 
     QDockWidget *m_notesDock;
-    KTextEdit *m_notesWidget;
+    NotesWidget *m_notesWidget;
 
     QDockWidget *m_effectStackDock;
     EffectStackView *m_effectStack;
@@ -532,7 +533,8 @@ private slots:
     void slotDoAction(const QString& action_name);
     /** @brief Update project because the use of proxy clips was enabled / disabled. */
     void slotUpdateProxySettings();
+    /** @brief Insert current project's timecode into the notes widget. */
+    void slotInsertNotesTimecode();
 signals:
     Q_SCRIPTABLE void abortRenderJob(const QString &url);
 };
diff --git a/src/noteswidget.cpp b/src/noteswidget.cpp
new file mode 100644 (file)
index 0000000..cf5eac2
--- /dev/null
@@ -0,0 +1,67 @@
+/***************************************************************************
+ *   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 "noteswidget.h"
+
+#include <KLocale>
+#include <KDebug>
+#include <QMenu>
+#include <QMouseEvent>
+
+
+NotesWidget::NotesWidget(QWidget * parent) :
+        KTextEdit(parent)
+{
+    connect(this, SIGNAL(aboutToShowContextMenu(QMenu *)), this, SLOT(slotFillNotesMenu(QMenu *)));
+    setMouseTracking(true);
+}
+
+void NotesWidget::slotFillNotesMenu(QMenu *menu)
+{
+    QAction *a = new QAction(i18n("Insert current timecode"), this);
+    connect(a, SIGNAL(triggered(bool)), this, SIGNAL(insertNotesTimecode()));
+    menu->insertAction(menu->actions().at(0), a);
+}
+
+void NotesWidget::mouseMoveEvent( QMouseEvent * e )
+{
+    QString anchor = anchorAt(e->pos());
+    if (anchor.isEmpty()) viewport()->setCursor(Qt::IBeamCursor);
+    else viewport()->setCursor(Qt::PointingHandCursor);
+}
+
+void NotesWidget::mousePressEvent( QMouseEvent * e )
+{
+    QString anchor = anchorAt(e->pos());
+    if (anchor.isEmpty()) {
+        KTextEdit::mousePressEvent(e);
+        return;
+    }
+    kDebug()<<"+++++++++\nCLICKED NACHOR: "<<anchor;
+    emit seekProject(anchor.toInt());
+    e->setAccepted(true);
+}
+
+NotesWidget::~NotesWidget()
+{
+}
+
+
+
diff --git a/src/noteswidget.h b/src/noteswidget.h
new file mode 100644 (file)
index 0000000..ab9e861
--- /dev/null
@@ -0,0 +1,56 @@
+/***************************************************************************
+ *   Copyright (C) 2011 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 NOTESWIDGET_H
+#define NOTESWIDGET_H
+
+#include <KTextEdit>
+
+/**
+ * @class NotesWidget
+ * @brief A small text editor to create project notes.
+ * @author Jean-Baptiste Mardelle
+ */
+
+class NotesWidget : public KTextEdit
+{
+    Q_OBJECT
+
+public:
+    NotesWidget(QWidget * parent = 0);
+    ~NotesWidget();
+
+protected:
+    virtual void mouseMoveEvent ( QMouseEvent * e );
+    virtual void mousePressEvent ( QMouseEvent * e );
+    
+private slots:
+    void slotFillNotesMenu(QMenu *menu);
+    
+private:
+
+signals:
+    void insertNotesTimecode();
+    void seekProject(int);
+};
+
+
+#endif
+
index 71ce4ef8e723b051f9f6f97354ff982c6cf105e2..191a21cc687a05ba94cec86d0931897f32f49298 100644 (file)
@@ -92,7 +92,6 @@ Q_OBJECT public:
     /** @brief Seeks the renderer clip to the given time. */
     void seek(GenTime time);
     void seek(int time);
-    void seekToFrame(int pos);
     void seekToFrameDiff(int diff);
     int m_isBlocked;
 
@@ -394,6 +393,7 @@ public slots:
     void slotSplitView(bool doit);
     void slotSwitchFullscreen();
     void slotSetVolume(int volume);
+    void seekToFrame(int pos);
 };
 
 #endif