Commit 6fac7eba authored by Till Theato's avatar Till Theato

Move notes widget handling to own class.

parent b21c4566
......@@ -32,6 +32,8 @@
#include "effectslist/initeffects.h"
#include "dialogs/profilesdialog.h"
#include "titler/titlewidget.h"
#include "project/notesplugin.h"
#include "project/dialogs/noteswidget.h"
#include <KDebug>
#include <KStandardDirs>
......@@ -62,12 +64,12 @@
const double DOCUMENTVERSION = 0.88;
KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QMap <QString, QString>& properties, const QMap <QString, QString>& metadata, const QPoint &tracks, Render *render, KTextEdit *notes, bool *openBackup, MainWindow *parent, KProgressDialog *progressDialog) :
KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QMap <QString, QString>& properties, const QMap <QString, QString>& metadata, const QPoint &tracks, Render *render, NotesPlugin *notes, bool *openBackup, MainWindow *parent, KProgressDialog *progressDialog) :
QObject(parent),
m_autosave(NULL),
m_url(url),
m_render(render),
m_notesWidget(notes),
m_notesWidget(notes->widget()),
m_commandStack(new QUndoStack(undoGroup)),
m_modified(false),
m_projectFolder(projectFolder)
......
......@@ -40,6 +40,7 @@ class ClipManager;
class DocClipBase;
class MainWindow;
class TrackInfo;
class NotesPlugin;
class KTextEdit;
class KProgressDialog;
......@@ -52,7 +53,7 @@ class KdenliveDoc: public QObject
Q_OBJECT
public:
KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QMap <QString, QString>& properties, const QMap <QString, QString>& metadata, const QPoint &tracks, Render *render, KTextEdit *notes, bool *openBackup, MainWindow *parent = 0, KProgressDialog *progressDialog = 0);
KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QMap <QString, QString>& properties, const QMap <QString, QString>& metadata, const QPoint &tracks, Render *render, NotesPlugin *notes, bool *openBackup, MainWindow *parent = 0, KProgressDialog *progressDialog = 0);
~KdenliveDoc();
QDomNodeList producersList();
double fps() const;
......
......@@ -215,15 +215,6 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
#endif /* ! Q_WS_MAC */
pCore->monitorManager()->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
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 ..."));
#endif
m_notesDock = addDock(i18n("Project Notes"), "notes_widget", m_notesWidget);
m_effectStack = new EffectStackView2(m_projectMonitor);
connect(m_effectStack, SIGNAL(startFilterJob(ItemInfo,QString,QString,QString,QString,QString,QMap<QString,QString>)), m_projectList, SLOT(slotStartFilterJob(ItemInfo,QString,QString,QString,QString,QString,QMap<QString,QString>)));
m_effectStackDock = addDock(i18n("Effect Stack"), "effect_stack", m_effectStack);
......@@ -299,7 +290,6 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
/// Tabify Widgets ///
tabifyDockWidget(m_effectListDock, m_effectStackDock);
tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
tabifyDockWidget(m_projectListDock, m_notesDock);
tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
#ifndef Q_WS_MAC
......@@ -1881,8 +1871,6 @@ void MainWindow::connectDocument(KdenliveDoc *newDoc, KdenliveDoc **projectManag
connect(newDoc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
connect(newDoc, SIGNAL(saveTimelinePreview(QString)), pCore->projectManager()->currentTrackView(), SLOT(slotSaveTimelinePreview(QString)));
connect(m_notesWidget, SIGNAL(textChanged()), newDoc, SLOT(setModified()));
connect(pCore->projectManager()->currentTrackView()->projectView(), SIGNAL(updateClipMarkers(DocClipBase*)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
connect(pCore->projectManager()->currentTrackView(), SIGNAL(showTrackEffects(int,TrackInfo)), this, SLOT(slotTrackSelected(int,TrackInfo)));
......@@ -3629,13 +3617,6 @@ void MainWindow::slotUpdateProxySettings()
m_projectList->updateProxyConfig();
}
void MainWindow::slotInsertNotesTimecode()
{
int frames = m_projectMonitor->render->seekPosition().frames(pCore->projectManager()->current()->fps());
QString position = pCore->projectManager()->current()->timecode().getTimecodeFromFrames(frames);
m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
}
void MainWindow::slotArchiveProject()
{
QList <DocClipBase*> list = m_projectList->documentClipList();
......
......@@ -49,8 +49,6 @@
#include "statusbarmessagelabel.h"
#include "dvdwizard/dvdwizard.h"
#include "stopmotion/stopmotion.h"
#include "project/dialogs/noteswidget.h"
#include "ui_backupdialog_ui.h"
class KdenliveDoc;
class TrackView;
......@@ -128,7 +126,6 @@ public:
ProjectList *m_projectList;
StopmotionWidget *m_stopmotion;
QUndoGroup *m_commandStack;
NotesWidget *m_notesWidget;
KActionCollection *m_tracksActionCollection;
EffectStackView2 *m_effectStack;
TransitionSettings *m_transitionConfig;
......@@ -174,8 +171,6 @@ private:
QDockWidget *m_effectListDock;
EffectsListView *m_effectList;
QDockWidget *m_notesDock;
QDockWidget *m_effectStackDock;
QDockWidget *m_transitionConfigDock;
......@@ -490,8 +485,6 @@ private slots:
void slotOpenStopmotion();
/** @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();
/** @brief Disable proxies for this project. */
void slotDisableProxies();
......
......@@ -15,6 +15,7 @@ set(kdenlive_SRCS
project/projectlistview.cpp
project/subprojectitem.cpp
project/transitionsettings.cpp
project/notesplugin.cpp
project/jobs/abstractclipjob.cpp
project/jobs/proxyclipjob.cpp
project/jobs/cutclipjob.cpp
......
......@@ -29,7 +29,7 @@
NotesWidget::NotesWidget(QWidget * parent) :
KTextEdit(parent)
{
connect(this, SIGNAL(aboutToShowContextMenu(QMenu*)), this, SLOT(slotFillNotesMenu(QMenu*)));
connect(this, SIGNAL(aboutToShowContextMenu(QMenu*)), SLOT(slotFillNotesMenu(QMenu*)));
setMouseTracking(true);
}
......
/*
Copyright (C) 2014 Till Theato <root@ttill.de>
This file is part of kdenlive. See www.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 3 of the License, or
(at your option) any later version.
*/
#include "notesplugin.h"
#include "dialogs/noteswidget.h"
#include "core.h"
#include "mainwindow.h"
#include "monitor/monitormanager.h"
#include "doc/kdenlivedoc.h"
#include "project/projectmanager.h"
NotesPlugin::NotesPlugin(ProjectManager *projectManager) :
QObject(projectManager)
{
m_widget = new NotesWidget();
connect(m_widget, SIGNAL(insertNotesTimecode()), SLOT(slotInsertTimecode()));
m_widget->setTabChangesFocus(true);
#if KDE_IS_VERSION(4,4,0)
m_widget->setClickMessage(i18n("Enter your project notes here ..."));
#endif
pCore->window()->addDock(i18n("Project Notes"), "notes_widget", m_widget);
connect(projectManager, SIGNAL(docOpened(KdenliveDoc*)), SLOT(setProject(KdenliveDoc*)));
}
void NotesPlugin::setProject(KdenliveDoc* document)
{
connect(m_widget, SIGNAL(seekProject(int)), pCore->monitorManager()->projectMonitor()->render, SLOT(seekToFrame(int)));
connect(m_widget, SIGNAL(textChanged()), document, SLOT(setModified()));
}
void NotesPlugin::slotInsertTimecode()
{
int frames = pCore->monitorManager()->projectMonitor()->render->seekPosition().frames(pCore->projectManager()->current()->fps());
QString position = pCore->projectManager()->current()->timecode().getTimecodeFromFrames(frames);
m_widget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
}
NotesWidget* NotesPlugin::widget()
{
return m_widget;
}
#include "notesplugin.moc"
/*
Copyright (C) 2014 Till Theato <root@ttill.de>
This file is part of kdenlive. See www.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 3 of the License, or
(at your option) any later version.
*/
#ifndef NOTESPLUGIN_H
#define NOTESPLUGIN_H
#include <QObject>
class NotesWidget;
class KdenliveDoc;
class ProjectManager;
/**
* @class NotesPlugin
* @brief Handles connection of NotesWidget
*
* Supposed to become a plugin/ProjectPart (@see refactoring branch).
*/
class NotesPlugin : public QObject
{
Q_OBJECT
public:
explicit NotesPlugin(ProjectManager *projectManager);
NotesWidget *widget();
private slots:
void setProject(KdenliveDoc *document);
/** @brief Insert current timecode/cursor position into the widget. */
void slotInsertTimecode();
private:
NotesWidget *m_widget;
};
#endif
......@@ -22,6 +22,7 @@ the Free Software Foundation, either version 3 of the License, or
#include "project/dialogs/archivewidget.h"
#include "effectstack/effectstackview2.h"
#include "project/dialogs/backupwidget.h"
#include "project/notesplugin.h"
#include <KTabWidget>
#include <KFileDialog>
#include <KActionCollection>
......@@ -48,6 +49,8 @@ ProjectManager::ProjectManager(QObject* parent) :
KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
pCore->window()->addAction("open_backup", backupAction);
connect(backupAction, SIGNAL(triggered(bool)), SLOT(slotOpenBackup()));
m_notesPlugin = new NotesPlugin(this);
}
ProjectManager::~ProjectManager()
......@@ -124,7 +127,7 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
pCore->window()->m_timelineArea->setEnabled(true);
pCore->window()->m_projectList->setEnabled(true);
bool openBackup;
KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, pCore->window()->m_commandStack, profileName, documentProperties, documentMetadata, projectTracks, pCore->monitorManager()->projectMonitor()->render, pCore->window()->m_notesWidget, &openBackup, pCore->window());
KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, pCore->window()->m_commandStack, profileName, documentProperties, documentMetadata, projectTracks, pCore->monitorManager()->projectMonitor()->render, m_notesPlugin, &openBackup, pCore->window());
doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
bool ok;
m_trackView = new TrackView(doc, pCore->window()->m_tracksActionCollection->actions(), &ok, pCore->window());
......@@ -138,6 +141,7 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
}
connectDocumentInfo(doc);
pCore->window()->connectDocument(doc, &m_project);
emit docOpened(m_project);
pCore->monitorManager()->activateMonitor(Kdenlive::ClipMonitor);
}
......@@ -349,7 +353,7 @@ void ProjectManager::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
progressDialog.progressBar()->setValue(0);
bool openBackup;
KdenliveDoc *doc = new KdenliveDoc(stale ? KUrl(stale->fileName()) : url, KdenliveSettings::defaultprojectfolder(), pCore->window()->m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), pCore->monitorManager()->projectMonitor()->render, pCore->window()->m_notesWidget, &openBackup, pCore->window(), &progressDialog);
KdenliveDoc *doc = new KdenliveDoc(stale ? KUrl(stale->fileName()) : url, KdenliveSettings::defaultprojectfolder(), pCore->window()->m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), pCore->monitorManager()->projectMonitor()->render, m_notesPlugin, &openBackup, pCore->window(), &progressDialog);
progressDialog.progressBar()->setValue(1);
progressDialog.progressBar()->setMaximum(4);
......@@ -374,6 +378,7 @@ void ProjectManager::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
bool ok;
m_trackView = new TrackView(doc, pCore->window()->m_tracksActionCollection->actions(), &ok, pCore->window());
pCore->window()->connectDocument(doc, &m_project);
emit docOpened(m_project);
progressDialog.progressBar()->setValue(3);
progressDialog.repaint();
......
......@@ -19,6 +19,7 @@ class Project;
class AbstractProjectPart;
class TrackView;
class KdenliveDoc;
class NotesPlugin;
class KAction;
class KUrl;
class KAutoSaveFile;
......@@ -88,6 +89,7 @@ private slots:
void slotOpenBackup(const KUrl &url = KUrl());
signals:
void docOpened(KdenliveDoc *document);
// void projectOpened(Project *project);
private:
......@@ -103,6 +105,7 @@ private:
KAction *m_fileRevert;
KUrl m_startUrl;
KRecentFilesAction *m_recentFilesAction;
NotesPlugin *m_notesPlugin;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment