5 #include <KApplication>
8 #include <KActionCollection>
9 #include <KStandardAction>
10 #include <KFileDialog>
11 #include <KMessageBox>
13 #include <KIO/NetAccess>
16 #include <KConfigDialog>
19 #include <mlt++/Mlt.h>
21 #include "mainwindow.h"
22 #include "trackview.h"
23 #include "kdenlivesettings.h"
24 #include "ui_configmisc_ui.h"
26 MainWindow::MainWindow(QWidget *parent)
27 : KXmlGuiWindow(parent),
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 projectListDock = new QDockWidget(i18n("Project Tree"), this);
37 projectListDock->setObjectName("project_tree");
38 m_projectList = new ProjectList(NULL, this);
39 projectListDock->setWidget(m_projectList);
40 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
42 effectListDock = new QDockWidget(i18n("Effect List"), this);
43 effectListDock->setObjectName("project_tree");
44 effectList = new KListWidget(this);
45 effectListDock->setWidget(effectList);
46 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
48 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
49 effectStackDock->setObjectName("project_tree");
50 effectStack = new KListWidget(this);
51 effectStackDock->setWidget(effectStack);
52 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
54 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
55 transitionConfigDock->setObjectName("project_tree");
56 transitionConfig = new KListWidget(this);
57 transitionConfigDock->setWidget(transitionConfig);
58 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
60 Mlt::Factory::init(NULL);
62 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
63 clipMonitorDock->setObjectName("project_tree");
64 m_clipMonitor = new Monitor("clip", this);
65 clipMonitorDock->setWidget(m_clipMonitor);
66 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
68 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
69 projectMonitorDock->setObjectName("project_tree");
70 m_projectMonitor = new Monitor("project", this);
71 projectMonitorDock->setWidget(m_projectMonitor);
72 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
75 tabifyDockWidget (effectListDock, projectListDock);
76 tabifyDockWidget (effectListDock, effectStackDock);
77 tabifyDockWidget (effectListDock, transitionConfigDock);
79 tabifyDockWidget (clipMonitorDock, projectMonitorDock);
81 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_projectMonitor, SLOT(slotSetXml(const QDomElement &)));
83 connect(m_projectList, SIGNAL(getFileProperties(const KUrl &, uint)), m_projectMonitor->render, SLOT(getFileProperties(const KUrl &, uint)));
85 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const KUrl &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const KUrl &, int, const QPixmap &, int, int)));
87 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 > &)));
91 void MainWindow::setupActions()
93 KAction* clearAction = new KAction(this);
94 clearAction->setText(i18n("Clear"));
95 clearAction->setIcon(KIcon("document-new"));
96 clearAction->setShortcut(Qt::CTRL + Qt::Key_W);
97 actionCollection()->addAction("clear", clearAction);
98 /*connect(clearAction, SIGNAL(triggered(bool)),
99 textArea, SLOT(clear()));*/
101 KStandardAction::quit(kapp, SLOT(quit()),
104 KStandardAction::open(this, SLOT(openFile()),
107 KStandardAction::save(this, SLOT(saveFile()),
110 KStandardAction::saveAs(this, SLOT(saveFileAs()),
113 KStandardAction::openNew(this, SLOT(newFile()),
116 KStandardAction::openNew(this, SLOT(newFile()),
119 KStandardAction::preferences(this, SLOT(slotPreferences()),
125 void MainWindow::newFile()
127 KdenliveDoc *doc = new KdenliveDoc(KUrl(), 25, 720, 576);
128 TrackView *trackView = new TrackView(doc);
129 m_timelineArea->addTab(trackView, "New Project");
132 void MainWindow::activateDocument()
134 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
135 KdenliveDoc *currentDoc = currentTab->document();
136 connectDocument(currentDoc);
139 void MainWindow::saveFileAs(const QString &outputFileName)
141 KSaveFile file(outputFileName);
144 QByteArray outputByteArray;
145 //outputByteArray.append(textArea->toPlainText());
146 file.write(outputByteArray);
150 fileName = outputFileName;
153 void MainWindow::saveFileAs()
155 saveFileAs(KFileDialog::getSaveFileName());
158 void MainWindow::saveFile()
160 if(!fileName.isEmpty())
162 saveFileAs(fileName);
170 void MainWindow::openFile() //changed
172 openFile(KFileDialog::getOpenFileName(KUrl(), "application/vnd.kde.kdenlive"));
175 void MainWindow::openFile(const QString &inputFileName) //new
177 KdenliveDoc *doc = new KdenliveDoc(KUrl(inputFileName), 25, 720, 576);
178 TrackView *trackView = new TrackView(doc);
179 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, QIcon(), doc->documentName()));
180 connectDocument(doc);
184 void MainWindow::connectDocument(KdenliveDoc *doc) //changed
186 m_projectList->populate(doc->producersList());
187 //connect(doc, SIGNAL(addClip(QDomElement &)), m_projectList, SLOT(slotAddClip(QDomElement &)));
191 void MainWindow::slotPreferences()
193 //An instance of your dialog could be already created and could be
194 // cached, in which case you want to display the cached dialog
195 // instead of creating another one
196 if ( KConfigDialog::showDialog( "settings" ) )
199 // KConfigDialog didn't find an instance of this dialog, so lets
201 KConfigDialog* dialog = new KConfigDialog(this, "settings",
202 KdenliveSettings::self());
204 QWidget *page1 = new QWidget;
205 Ui::ConfigMisc_UI* confWdg = new Ui::ConfigMisc_UI( );
206 confWdg->setupUi(page1);
208 dialog->addPage( page1, i18n("Misc"), "misc" );
210 //User edited the configuration - update your local copies of the
212 connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfiguration()) );
217 #include "mainwindow.moc"