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 projectListDock->setObjectName("project_tree");
33 m_projectList = new ProjectList(NULL, this);
34 projectListDock->setWidget(m_projectList);
35 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
37 effectListDock = new QDockWidget(i18n("Effect List"), this);
38 effectListDock->setObjectName("project_tree");
39 effectList = new KListWidget(this);
40 effectListDock->setWidget(effectList);
41 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
43 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
44 effectStackDock->setObjectName("project_tree");
45 effectStack = new KListWidget(this);
46 effectStackDock->setWidget(effectStack);
47 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
49 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
50 transitionConfigDock->setObjectName("project_tree");
51 transitionConfig = new KListWidget(this);
52 transitionConfigDock->setWidget(transitionConfig);
53 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
55 Mlt::Factory::init(NULL);
57 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
58 clipMonitorDock->setObjectName("project_tree");
59 m_clipMonitor = new Monitor("clip", this);
60 clipMonitorDock->setWidget(m_clipMonitor);
61 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
63 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
64 projectMonitorDock->setObjectName("project_tree");
65 m_projectMonitor = new Monitor("project", this);
66 projectMonitorDock->setWidget(m_projectMonitor);
67 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
70 tabifyDockWidget (effectListDock, projectListDock);
71 tabifyDockWidget (effectListDock, effectStackDock);
72 tabifyDockWidget (effectListDock, transitionConfigDock);
74 tabifyDockWidget (clipMonitorDock, projectMonitorDock);
76 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_projectMonitor, SLOT(slotSetXml(const QDomElement &)));
78 connect(m_projectList, SIGNAL(getFileProperties(const KUrl &, uint)), m_projectMonitor->render, SLOT(getFileProperties(const KUrl &, uint)));
80 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const KUrl &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const KUrl &, int, const QPixmap &, int, int)));
82 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 > &)));
86 void MainWindow::setupActions()
88 KAction* clearAction = new KAction(this);
89 clearAction->setText(i18n("Clear"));
90 clearAction->setIcon(KIcon("document-new"));
91 clearAction->setShortcut(Qt::CTRL + Qt::Key_W);
92 actionCollection()->addAction("clear", clearAction);
93 /*connect(clearAction, SIGNAL(triggered(bool)),
94 textArea, SLOT(clear()));*/
96 KStandardAction::quit(kapp, SLOT(quit()),
99 KStandardAction::open(this, SLOT(openFile()),
102 KStandardAction::save(this, SLOT(saveFile()),
105 KStandardAction::saveAs(this, SLOT(saveFileAs()),
108 KStandardAction::openNew(this, SLOT(newFile()),
114 void MainWindow::newFile()
116 KdenliveDoc *doc = new KdenliveDoc(KUrl(), 25, 720, 576);
117 TrackView *trackView = new TrackView(doc);
118 m_timelineArea->addTab(trackView, "New Project");
121 void MainWindow::activateDocument()
123 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
124 KdenliveDoc *currentDoc = currentTab->document();
125 connectDocument(currentDoc);
128 void MainWindow::saveFileAs(const QString &outputFileName)
130 KSaveFile file(outputFileName);
133 QByteArray outputByteArray;
134 //outputByteArray.append(textArea->toPlainText());
135 file.write(outputByteArray);
139 fileName = outputFileName;
142 void MainWindow::saveFileAs()
144 saveFileAs(KFileDialog::getSaveFileName());
147 void MainWindow::saveFile()
149 if(!fileName.isEmpty())
151 saveFileAs(fileName);
159 void MainWindow::openFile() //changed
161 openFile(KFileDialog::getOpenFileName(KUrl(), "application/vnd.kde.kdenlive"));
164 void MainWindow::openFile(const QString &inputFileName) //new
166 KdenliveDoc *doc = new KdenliveDoc(KUrl(inputFileName), 25, 720, 576);
167 TrackView *trackView = new TrackView(doc);
168 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, QIcon(), doc->documentName()));
169 connectDocument(doc);
173 void MainWindow::connectDocument(KdenliveDoc *doc) //changed
175 m_projectList->populate(doc->producersList());
176 //connect(doc, SIGNAL(addClip(QDomElement &)), m_projectList, SLOT(slotAddClip(QDomElement &)));
179 #include "mainwindow.moc"