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 QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
111 //connect(m_projectList, SIGNAL(getFileProperties(const KUrl &, uint)), m_clipMonitor->render, SLOT(getFileProperties(const KUrl &, uint)));
113 connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
115 connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)));
119 void MainWindow::setupActions()
121 KAction* clearAction = new KAction(this);
122 clearAction->setText(i18n("Clear"));
123 clearAction->setIcon(KIcon("document-new"));
124 clearAction->setShortcut(Qt::CTRL + Qt::Key_W);
125 actionCollection()->addAction("clear", clearAction);
126 /*connect(clearAction, SIGNAL(triggered(bool)),
127 textArea, SLOT(clear()));*/
129 KStandardAction::quit(kapp, SLOT(quit()),
132 KStandardAction::open(this, SLOT(openFile()),
135 KStandardAction::save(this, SLOT(saveFile()),
138 KStandardAction::saveAs(this, SLOT(saveFileAs()),
141 KStandardAction::openNew(this, SLOT(newFile()),
144 /*KStandardAction::undo(this, SLOT(undo()),
147 KStandardAction::redo(this, SLOT(redo()),
148 actionCollection());*/
150 KStandardAction::preferences(this, SLOT(slotPreferences()),
153 QAction * redo = m_commandStack->createRedoAction(actionCollection());
154 QAction * undo = m_commandStack->createUndoAction(actionCollection());
159 void MainWindow::newFile()
161 KdenliveDoc *doc = new KdenliveDoc(KUrl(), 25, 720, 576);
162 TrackView *trackView = new TrackView(doc);
163 m_timelineArea->addTab(trackView, "New Project");
164 if (m_timelineArea->count() == 1)
165 connectDocument(trackView, doc);
168 void MainWindow::activateDocument()
170 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
171 KdenliveDoc *currentDoc = currentTab->document();
172 connectDocument(currentTab, currentDoc);
175 void MainWindow::saveFileAs(const QString &outputFileName)
177 KSaveFile file(outputFileName);
180 QByteArray outputByteArray;
181 //outputByteArray.append(textArea->toPlainText());
182 file.write(outputByteArray);
186 fileName = outputFileName;
189 void MainWindow::saveFileAs()
191 saveFileAs(KFileDialog::getSaveFileName());
194 void MainWindow::saveFile()
196 if(!fileName.isEmpty())
198 saveFileAs(fileName);
206 void MainWindow::openFile() //changed
208 openFile(KFileDialog::getOpenFileName(KUrl(), "application/vnd.kde.kdenlive"));
211 void MainWindow::openFile(const QString &inputFileName) //new
213 KdenliveDoc *doc = new KdenliveDoc(KUrl(inputFileName), 25, 720, 576);
214 TrackView *trackView = new TrackView(doc);
215 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, QIcon(), doc->documentName()));
216 connectDocument(trackView, doc);
220 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
222 //m_projectMonitor->stop();
223 if (m_activeDocument) {
224 m_activeDocument->setProducers(m_projectList->producersList());
225 m_activeDocument->setRenderer(NULL);
227 m_projectList->setDocument(doc);
228 m_monitorManager->setTimecode(doc->timecode());
229 doc->setRenderer(m_projectMonitor->render);
230 m_activeDocument = doc;
234 void MainWindow::slotPreferences()
236 //An instance of your dialog could be already created and could be
237 // cached, in which case you want to display the cached dialog
238 // instead of creating another one
239 if ( KConfigDialog::showDialog( "settings" ) )
242 // KConfigDialog didn't find an instance of this dialog, so lets
244 KConfigDialog* dialog = new KConfigDialog(this, "settings",
245 KdenliveSettings::self());
247 QWidget *page1 = new QWidget;
248 Ui::ConfigMisc_UI* confWdg = new Ui::ConfigMisc_UI( );
249 confWdg->setupUi(page1);
251 dialog->addPage( page1, i18n("Misc"), "misc" );
253 //User edited the configuration - update your local copies of the
255 connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfiguration()) );
260 #include "mainwindow.moc"