3 #include <KApplication>
6 #include <KActionCollection>
7 #include <KStandardAction>
11 #include <KIO/NetAccess>
14 #include <QTextStream>
16 #include <mlt++/Mlt.h>
18 #include "mainwindow.h"
19 #include "trackview.h"
21 MainWindow::MainWindow(QWidget *parent)
22 : KXmlGuiWindow(parent),
25 m_timelineArea = new KTabWidget(this);
26 m_timelineArea->setHoverCloseButton(true);
27 m_timelineArea->setTabReorderingEnabled(true);
28 connect(m_timelineArea, SIGNAL(currentChanged (int)), this, SLOT(activateDocument()));
29 setCentralWidget(m_timelineArea);
31 projectListDock = new QDockWidget(i18n("Project Tree"), this);
32 m_projectList = new ProjectList(NULL, this);
33 projectListDock->setWidget(m_projectList);
34 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
36 effectListDock = new QDockWidget(i18n("Effect List"), this);
37 effectList = new KListWidget(this);
38 effectListDock->setWidget(effectList);
39 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
41 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
42 effectStack = new KListWidget(this);
43 effectStackDock->setWidget(effectStack);
44 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
46 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
47 transitionConfig = new KListWidget(this);
48 transitionConfigDock->setWidget(transitionConfig);
49 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
51 Mlt::Factory::init(NULL);
53 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
54 m_clipMonitor = new Monitor("clip", this);
55 clipMonitorDock->setWidget(m_clipMonitor);
56 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
58 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
59 m_projectMonitor = new Monitor("project", this);
60 projectMonitorDock->setWidget(m_projectMonitor);
61 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
64 tabifyDockWidget (effectListDock, projectListDock);
65 tabifyDockWidget (effectListDock, effectStackDock);
66 tabifyDockWidget (effectListDock, transitionConfigDock);
68 tabifyDockWidget (clipMonitorDock, projectMonitorDock);
70 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_projectMonitor, SLOT(slotSetXml(const QDomElement &)));
72 connect(m_projectList, SIGNAL(getFileProperties(const KUrl &, uint)), m_projectMonitor->render, SLOT(getFileProperties(const KUrl &, uint)));
74 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const KUrl &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const KUrl &, int, const QPixmap &, int, int)));
76 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(const QMap < QString, QString > &, const QMap < QString, QString > &)));
80 void MainWindow::setupActions()
82 KAction* clearAction = new KAction(this);
83 clearAction->setText(i18n("Clear"));
84 clearAction->setIcon(KIcon("document-new"));
85 clearAction->setShortcut(Qt::CTRL + Qt::Key_W);
86 actionCollection()->addAction("clear", clearAction);
87 /*connect(clearAction, SIGNAL(triggered(bool)),
88 textArea, SLOT(clear()));*/
90 KStandardAction::quit(kapp, SLOT(quit()),
93 KStandardAction::open(this, SLOT(openFile()),
96 KStandardAction::save(this, SLOT(saveFile()),
99 KStandardAction::saveAs(this, SLOT(saveFileAs()),
102 KStandardAction::openNew(this, SLOT(newFile()),
108 void MainWindow::newFile()
110 KdenliveDoc *doc = new KdenliveDoc(KUrl(), 25, 720, 576);
111 TrackView *trackView = new TrackView(doc);
112 m_timelineArea->addTab(trackView, "New Project");
115 void MainWindow::activateDocument()
117 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
118 KdenliveDoc *currentDoc = currentTab->document();
119 connectDocument(currentDoc);
122 void MainWindow::saveFileAs(const QString &outputFileName)
124 KSaveFile file(outputFileName);
127 QByteArray outputByteArray;
128 //outputByteArray.append(textArea->toPlainText());
129 file.write(outputByteArray);
133 fileName = outputFileName;
136 void MainWindow::saveFileAs()
138 saveFileAs(KFileDialog::getSaveFileName());
141 void MainWindow::saveFile()
143 if(!fileName.isEmpty())
145 saveFileAs(fileName);
153 void MainWindow::openFile() //changed
155 openFile(KFileDialog::getOpenFileName(KUrl(), "application/vnd.kde.kdenlive"));
158 void MainWindow::openFile(const QString &inputFileName) //new
160 KdenliveDoc *doc = new KdenliveDoc(KUrl(inputFileName), 25, 720, 576);
161 TrackView *trackView = new TrackView(doc);
162 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, QIcon(), doc->documentName()));
163 connectDocument(doc);
167 void MainWindow::connectDocument(KdenliveDoc *doc) //changed
169 m_projectList->populate(doc->producersList());
170 //connect(doc, SIGNAL(addClip(QDomElement &)), m_projectList, SLOT(slotAddClip(QDomElement &)));
173 #include "mainwindow.moc"