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 m_commandStack = new KUndoStack(this);
40 projectListDock = new QDockWidget(i18n("Project Tree"), this);
41 projectListDock->setObjectName("project_tree");
42 m_projectList = new ProjectList(m_commandStack, this);
43 projectListDock->setWidget(m_projectList);
44 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
46 effectListDock = new QDockWidget(i18n("Effect List"), this);
47 effectListDock->setObjectName("effect_list");
48 effectList = new KListWidget(this);
49 effectListDock->setWidget(effectList);
50 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
52 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
53 effectStackDock->setObjectName("effect_stack");
54 effectStack = new KListWidget(this);
55 effectStackDock->setWidget(effectStack);
56 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
58 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
59 transitionConfigDock->setObjectName("transition");
60 transitionConfig = new KListWidget(this);
61 transitionConfigDock->setWidget(transitionConfig);
62 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
64 Mlt::Factory::init(NULL);
66 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
67 clipMonitorDock->setObjectName("clip_monitor");
68 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
69 clipMonitorDock->setWidget(m_clipMonitor);
70 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
72 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
73 projectMonitorDock->setObjectName("project_monitor");
74 m_projectMonitor = new Monitor("project", m_monitorManager, this);
75 projectMonitorDock->setWidget(m_projectMonitor);
76 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
79 tabifyDockWidget (projectListDock, effectListDock);
80 tabifyDockWidget (projectListDock, effectStackDock);
81 tabifyDockWidget (projectListDock, transitionConfigDock);
82 projectListDock->raise();
84 tabifyDockWidget (clipMonitorDock, projectMonitorDock);
86 connect(projectMonitorDock, SIGNAL(visibilityChanged (bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
87 connect(clipMonitorDock, SIGNAL(visibilityChanged (bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
88 connect(m_monitorManager, SIGNAL(connectMonitors ()), this, SLOT(slotConnectMonitors()));
89 connect(m_monitorManager, SIGNAL(raiseClipMonitor (bool)), this, SLOT(slotRaiseMonitor(bool)));
90 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
96 void MainWindow::slotRaiseMonitor(bool clipMonitor)
98 if (clipMonitor) clipMonitorDock->raise();
99 else projectMonitorDock->raise();
102 void MainWindow::slotConnectMonitors()
105 m_projectList->setRenderer(m_clipMonitor->render);
107 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
109 connect(m_projectList, SIGNAL(getFileProperties(const KUrl &, uint)), m_clipMonitor->render, SLOT(getFileProperties(const KUrl &, uint)));
111 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const KUrl &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const KUrl &, int, const QPixmap &, int, int)));
113 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 > &)));
117 void MainWindow::setupActions()
119 KAction* clearAction = new KAction(this);
120 clearAction->setText(i18n("Clear"));
121 clearAction->setIcon(KIcon("document-new"));
122 clearAction->setShortcut(Qt::CTRL + Qt::Key_W);
123 actionCollection()->addAction("clear", clearAction);
124 /*connect(clearAction, SIGNAL(triggered(bool)),
125 textArea, SLOT(clear()));*/
127 KStandardAction::quit(kapp, SLOT(quit()),
130 KStandardAction::open(this, SLOT(openFile()),
133 KStandardAction::save(this, SLOT(saveFile()),
136 KStandardAction::saveAs(this, SLOT(saveFileAs()),
139 KStandardAction::openNew(this, SLOT(newFile()),
142 /*KStandardAction::undo(this, SLOT(undo()),
145 KStandardAction::redo(this, SLOT(redo()),
146 actionCollection());*/
148 KStandardAction::preferences(this, SLOT(slotPreferences()),
151 QAction * redo = m_commandStack->createRedoAction(actionCollection());
152 QAction * undo = m_commandStack->createUndoAction(actionCollection());
157 void MainWindow::newFile()
159 KdenliveDoc *doc = new KdenliveDoc(KUrl(), 25, 720, 576);
160 TrackView *trackView = new TrackView(doc);
161 m_timelineArea->addTab(trackView, "New Project");
162 if (m_timelineArea->count() == 1)
163 connectDocument(trackView, doc);
166 void MainWindow::activateDocument()
168 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
169 KdenliveDoc *currentDoc = currentTab->document();
170 connectDocument(currentTab, currentDoc);
173 void MainWindow::saveFileAs(const QString &outputFileName)
175 KSaveFile file(outputFileName);
178 QByteArray outputByteArray;
179 //outputByteArray.append(textArea->toPlainText());
180 file.write(outputByteArray);
184 fileName = outputFileName;
187 void MainWindow::saveFileAs()
189 saveFileAs(KFileDialog::getSaveFileName());
192 void MainWindow::saveFile()
194 if(!fileName.isEmpty())
196 saveFileAs(fileName);
204 void MainWindow::openFile() //changed
206 openFile(KFileDialog::getOpenFileName(KUrl(), "application/vnd.kde.kdenlive"));
209 void MainWindow::openFile(const QString &inputFileName) //new
211 KdenliveDoc *doc = new KdenliveDoc(KUrl(inputFileName), 25, 720, 576);
212 TrackView *trackView = new TrackView(doc);
213 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, QIcon(), doc->documentName()));
214 connectDocument(trackView, doc);
218 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
220 //m_projectMonitor->stop();
221 if (m_activeDocument) {
222 m_activeDocument->setProducers(m_projectList->producersList());
223 m_activeDocument->setRenderer(NULL);
225 m_projectList->setDocument(doc);
226 m_monitorManager->setTimecode(doc->timecode());
227 doc->setRenderer(m_projectMonitor->render);
228 m_activeDocument = doc;
232 void MainWindow::slotPreferences()
234 //An instance of your dialog could be already created and could be
235 // cached, in which case you want to display the cached dialog
236 // instead of creating another one
237 if ( KConfigDialog::showDialog( "settings" ) )
240 // KConfigDialog didn't find an instance of this dialog, so lets
242 KConfigDialog* dialog = new KConfigDialog(this, "settings",
243 KdenliveSettings::self());
245 QWidget *page1 = new QWidget;
246 Ui::ConfigMisc_UI* confWdg = new Ui::ConfigMisc_UI( );
247 confWdg->setupUi(page1);
249 dialog->addPage( page1, i18n("Misc"), "misc" );
251 //User edited the configuration - update your local copies of the
253 connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfiguration()) );
258 #include "mainwindow.moc"