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 "trackview.h"
24 #include "kdenlivesettings.h"
25 #include "ui_configmisc_ui.h"
27 MainWindow::MainWindow(QWidget *parent)
28 : KXmlGuiWindow(parent),
29 fileName(QString()), m_activeDocument(NULL)
31 m_timelineArea = new KTabWidget(this);
32 m_timelineArea->setHoverCloseButton(true);
33 m_timelineArea->setTabReorderingEnabled(true);
34 connect(m_timelineArea, SIGNAL(currentChanged (int)), this, SLOT(activateDocument()));
35 setCentralWidget(m_timelineArea);
37 m_monitorManager = new MonitorManager();
39 projectListDock = new QDockWidget(i18n("Project Tree"), this);
40 projectListDock->setObjectName("project_tree");
41 m_projectList = new ProjectList(this);
42 projectListDock->setWidget(m_projectList);
43 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
45 effectListDock = new QDockWidget(i18n("Effect List"), this);
46 effectListDock->setObjectName("effect_list");
47 effectList = new KListWidget(this);
48 effectListDock->setWidget(effectList);
49 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
51 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
52 effectStackDock->setObjectName("effect_stack");
53 effectStack = new KListWidget(this);
54 effectStackDock->setWidget(effectStack);
55 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
57 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
58 transitionConfigDock->setObjectName("transition");
59 transitionConfig = new KListWidget(this);
60 transitionConfigDock->setWidget(transitionConfig);
61 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
63 Mlt::Factory::init(NULL);
65 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
66 clipMonitorDock->setObjectName("clip_monitor");
67 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
68 clipMonitorDock->setWidget(m_clipMonitor);
69 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
71 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
72 projectMonitorDock->setObjectName("project_monitor");
73 m_projectMonitor = new Monitor("project", m_monitorManager, this);
74 projectMonitorDock->setWidget(m_projectMonitor);
75 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
78 tabifyDockWidget (projectListDock, effectListDock);
79 tabifyDockWidget (projectListDock, effectStackDock);
80 tabifyDockWidget (projectListDock, transitionConfigDock);
81 projectListDock->raise();
83 tabifyDockWidget (clipMonitorDock, projectMonitorDock);
85 connect(projectMonitorDock, SIGNAL(visibilityChanged (bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
86 connect(clipMonitorDock, SIGNAL(visibilityChanged (bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
89 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
90 connect(m_monitorManager, SIGNAL(connectMonitors ()), this, SLOT(slotConnectMonitors()));
91 connect(m_monitorManager, SIGNAL(raiseClipMonitor (bool)), this, SLOT(slotRaiseMonitor(bool)));
95 void MainWindow::slotRaiseMonitor(bool clipMonitor)
97 if (clipMonitor) clipMonitorDock->raise();
98 else projectMonitorDock->raise();
101 void MainWindow::slotConnectMonitors()
104 m_projectList->setRenderer(m_clipMonitor->render);
106 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
108 connect(m_projectList, SIGNAL(getFileProperties(const KUrl &, uint)), m_clipMonitor->render, SLOT(getFileProperties(const KUrl &, uint)));
110 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const KUrl &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const KUrl &, int, const QPixmap &, int, int)));
112 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 > &)));
116 void MainWindow::setupActions()
118 KAction* clearAction = new KAction(this);
119 clearAction->setText(i18n("Clear"));
120 clearAction->setIcon(KIcon("document-new"));
121 clearAction->setShortcut(Qt::CTRL + Qt::Key_W);
122 actionCollection()->addAction("clear", clearAction);
123 /*connect(clearAction, SIGNAL(triggered(bool)),
124 textArea, SLOT(clear()));*/
126 KStandardAction::quit(kapp, SLOT(quit()),
129 KStandardAction::open(this, SLOT(openFile()),
132 KStandardAction::save(this, SLOT(saveFile()),
135 KStandardAction::saveAs(this, SLOT(saveFileAs()),
138 KStandardAction::openNew(this, SLOT(newFile()),
141 KStandardAction::openNew(this, SLOT(newFile()),
144 KStandardAction::preferences(this, SLOT(slotPreferences()),
150 void MainWindow::newFile()
152 KdenliveDoc *doc = new KdenliveDoc(KUrl(), 25, 720, 576);
153 TrackView *trackView = new TrackView(doc);
154 m_timelineArea->addTab(trackView, "New Project");
155 if (m_timelineArea->count() == 1)
156 connectDocument(doc);
159 void MainWindow::activateDocument()
161 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
162 KdenliveDoc *currentDoc = currentTab->document();
163 connectDocument(currentDoc);
166 void MainWindow::saveFileAs(const QString &outputFileName)
168 KSaveFile file(outputFileName);
171 QByteArray outputByteArray;
172 //outputByteArray.append(textArea->toPlainText());
173 file.write(outputByteArray);
177 fileName = outputFileName;
180 void MainWindow::saveFileAs()
182 saveFileAs(KFileDialog::getSaveFileName());
185 void MainWindow::saveFile()
187 if(!fileName.isEmpty())
189 saveFileAs(fileName);
197 void MainWindow::openFile() //changed
199 openFile(KFileDialog::getOpenFileName(KUrl(), "application/vnd.kde.kdenlive"));
202 void MainWindow::openFile(const QString &inputFileName) //new
204 KdenliveDoc *doc = new KdenliveDoc(KUrl(inputFileName), 25, 720, 576);
205 TrackView *trackView = new TrackView(doc);
206 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, QIcon(), doc->documentName()));
207 connectDocument(doc);
211 void MainWindow::connectDocument(KdenliveDoc *doc) //changed
213 if (m_activeDocument) m_activeDocument->setProducers(m_projectList->producersList());
214 m_projectList->setDocument(doc);
215 m_activeDocument = doc;
219 void MainWindow::slotPreferences()
221 //An instance of your dialog could be already created and could be
222 // cached, in which case you want to display the cached dialog
223 // instead of creating another one
224 if ( KConfigDialog::showDialog( "settings" ) )
227 // KConfigDialog didn't find an instance of this dialog, so lets
229 KConfigDialog* dialog = new KConfigDialog(this, "settings",
230 KdenliveSettings::self());
232 QWidget *page1 = new QWidget;
233 Ui::ConfigMisc_UI* confWdg = new Ui::ConfigMisc_UI( );
234 confWdg->setupUi(page1);
236 dialog->addPage( page1, i18n("Misc"), "misc" );
238 //User edited the configuration - update your local copies of the
240 connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfiguration()) );
245 #include "mainwindow.moc"