From 21812fe2e0db89f1044d179eb788bbc1022b5577 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Thu, 28 Apr 2011 20:05:13 +0000 Subject: [PATCH] Notes widget: context menu now allows to insert clickable timecode to make easy reference to some place in the project svn path=/trunk/kdenlive/; revision=5564 --- src/CMakeLists.txt | 1 + src/kdenlivedoc.cpp | 2 +- src/mainwindow.cpp | 12 +++++++- src/mainwindow.h | 6 ++-- src/noteswidget.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++ src/noteswidget.h | 56 +++++++++++++++++++++++++++++++++++++ src/renderer.h | 2 +- 7 files changed, 141 insertions(+), 5 deletions(-) create mode 100644 src/noteswidget.cpp create mode 100644 src/noteswidget.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 555e3b48..e0a15eb4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -279,6 +279,7 @@ set(kdenlive_SRCS monitoreditwidget.cpp simplekeyframes/simpletimelinewidget.cpp simplekeyframes/simplekeyframewidget.cpp + noteswidget.cpp ) add_definitions(${KDE4_DEFINITIONS}) diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 0e7862d8..e953b2eb 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -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); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4013073f..1e18d029 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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("" + position + " "); +} + #include "mainwindow.moc" #ifdef DEBUG_MAINW diff --git a/src/mainwindow.h b/src/mainwindow.h index 6f7b9454..778b8777 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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 index 00000000..cf5eac23 --- /dev/null +++ b/src/noteswidget.cpp @@ -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 +#include +#include +#include + + +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: "<setAccepted(true); +} + +NotesWidget::~NotesWidget() +{ +} + + + diff --git a/src/noteswidget.h b/src/noteswidget.h new file mode 100644 index 00000000..ab9e8611 --- /dev/null +++ b/src/noteswidget.h @@ -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 + +/** + * @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 + diff --git a/src/renderer.h b/src/renderer.h index 71ce4ef8..191a21cc 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -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 -- 2.39.2