6 #include <KApplication>
9 #include <KActionCollection>
10 #include <KStandardAction>
11 #include <KFileDialog>
12 #include <KMessageBox>
14 #include <KIO/NetAccess>
17 #include <KConfigDialog>
20 #include <mlt++/Mlt.h>
22 #include "mainwindow.h"
23 #include "kdenlivesettings.h"
24 #include "ui_configmisc_ui.h"
26 MainWindow::MainWindow(QWidget *parent)
27 : KXmlGuiWindow(parent),
28 fileName(QString()), m_activeDocument(NULL)
30 m_timelineArea = new KTabWidget(this);
31 m_timelineArea->setHoverCloseButton(true);
32 m_timelineArea->setTabReorderingEnabled(true);
33 connect(m_timelineArea, SIGNAL(currentChanged (int)), this, SLOT(activateDocument()));
34 setCentralWidget(m_timelineArea);
36 m_monitorManager = new MonitorManager();
38 projectListDock = new QDockWidget(i18n("Project Tree"), this);
39 projectListDock->setObjectName("project_tree");
40 m_projectList = new ProjectList(this);
41 projectListDock->setWidget(m_projectList);
42 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
44 effectListDock = new QDockWidget(i18n("Effect List"), this);
45 effectListDock->setObjectName("effect_list");
46 effectList = new KListWidget(this);
47 effectListDock->setWidget(effectList);
48 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
50 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
51 effectStackDock->setObjectName("effect_stack");
52 effectStack = new KListWidget(this);
53 effectStackDock->setWidget(effectStack);
54 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
56 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
57 transitionConfigDock->setObjectName("transition");
58 transitionConfig = new KListWidget(this);
59 transitionConfigDock->setWidget(transitionConfig);
60 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
62 Mlt::Factory::init(NULL);
64 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
65 clipMonitorDock->setObjectName("clip_monitor");
66 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
67 clipMonitorDock->setWidget(m_clipMonitor);
68 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
70 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
71 projectMonitorDock->setObjectName("project_monitor");
72 m_projectMonitor = new Monitor("project", m_monitorManager, this);
73 projectMonitorDock->setWidget(m_projectMonitor);
74 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
77 tabifyDockWidget (projectListDock, effectListDock);
78 tabifyDockWidget (projectListDock, effectStackDock);
79 tabifyDockWidget (projectListDock, transitionConfigDock);
80 projectListDock->raise();
82 tabifyDockWidget (clipMonitorDock, projectMonitorDock);
84 connect(projectMonitorDock, SIGNAL(visibilityChanged (bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
85 connect(clipMonitorDock, SIGNAL(visibilityChanged (bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
86 connect(m_monitorManager, SIGNAL(connectMonitors ()), this, SLOT(slotConnectMonitors()));
87 connect(m_monitorManager, SIGNAL(raiseClipMonitor (bool)), this, SLOT(slotRaiseMonitor(bool)));
88 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
94 void MainWindow::slotRaiseMonitor(bool clipMonitor)
96 if (clipMonitor) clipMonitorDock->raise();
97 else projectMonitorDock->raise();
100 void MainWindow::slotConnectMonitors()
103 m_projectList->setRenderer(m_clipMonitor->render);
105 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
107 connect(m_projectList, SIGNAL(getFileProperties(const KUrl &, uint)), m_clipMonitor->render, SLOT(getFileProperties(const KUrl &, uint)));
109 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const KUrl &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const KUrl &, int, const QPixmap &, int, int)));
111 connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(const QMap < QString, QString > &, const QMap < QString, QString > &)));
115 void MainWindow::setupActions()
117 KAction* clearAction = new KAction(this);
118 clearAction->setText(i18n("Clear"));
119 clearAction->setIcon(KIcon("document-new"));
120 clearAction->setShortcut(Qt::CTRL + Qt::Key_W);
121 actionCollection()->addAction("clear", clearAction);
122 /*connect(clearAction, SIGNAL(triggered(bool)),
123 textArea, SLOT(clear()));*/
125 KStandardAction::quit(kapp, SLOT(quit()),
128 KStandardAction::open(this, SLOT(openFile()),
131 KStandardAction::save(this, SLOT(saveFile()),
134 KStandardAction::saveAs(this, SLOT(saveFileAs()),
137 KStandardAction::openNew(this, SLOT(newFile()),
140 KStandardAction::openNew(this, SLOT(newFile()),
143 KStandardAction::preferences(this, SLOT(slotPreferences()),
149 void MainWindow::newFile()
151 KdenliveDoc *doc = new KdenliveDoc(KUrl(), 25, 720, 576);
152 TrackView *trackView = new TrackView(doc);
153 m_timelineArea->addTab(trackView, "New Project");
154 if (m_timelineArea->count() == 1)
155 connectDocument(trackView, doc);
158 void MainWindow::activateDocument()
160 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
161 KdenliveDoc *currentDoc = currentTab->document();
162 connectDocument(currentTab, currentDoc);
165 void MainWindow::saveFileAs(const QString &outputFileName)
167 KSaveFile file(outputFileName);
170 QByteArray outputByteArray;
171 //outputByteArray.append(textArea->toPlainText());
172 file.write(outputByteArray);
176 fileName = outputFileName;
179 void MainWindow::saveFileAs()
181 saveFileAs(KFileDialog::getSaveFileName());
184 void MainWindow::saveFile()
186 if(!fileName.isEmpty())
188 saveFileAs(fileName);
196 void MainWindow::openFile() //changed
198 openFile(KFileDialog::getOpenFileName(KUrl(), "application/vnd.kde.kdenlive"));
201 void MainWindow::openFile(const QString &inputFileName) //new
203 KdenliveDoc *doc = new KdenliveDoc(KUrl(inputFileName), 25, 720, 576);
204 TrackView *trackView = new TrackView(doc);
205 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, QIcon(), doc->documentName()));
206 connectDocument(trackView, doc);
210 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
212 //m_projectMonitor->stop();
213 if (m_activeDocument) {
214 m_activeDocument->setProducers(m_projectList->producersList());
215 m_activeDocument->setRenderer(NULL);
217 m_projectList->setDocument(doc);
218 m_monitorManager->setTimecode(doc->timecode());
219 doc->setRenderer(m_projectMonitor->render);
220 m_activeDocument = doc;
224 void MainWindow::slotPreferences()
226 //An instance of your dialog could be already created and could be
227 // cached, in which case you want to display the cached dialog
228 // instead of creating another one
229 if ( KConfigDialog::showDialog( "settings" ) )
232 // KConfigDialog didn't find an instance of this dialog, so lets
234 KConfigDialog* dialog = new KConfigDialog(this, "settings",
235 KdenliveSettings::self());
237 QWidget *page1 = new QWidget;
238 Ui::ConfigMisc_UI* confWdg = new Ui::ConfigMisc_UI( );
239 confWdg->setupUi(page1);
241 dialog->addPage( page1, i18n("Misc"), "misc" );
243 //User edited the configuration - update your local copies of the
245 connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfiguration()) );
250 #include "mainwindow.moc"