X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmainwindow.cpp;h=3ff94d36b0ea53e738910ea7fdc2a3aac89ea5a9;hb=5e07370d2e189d73d43bb7dc9be562a8cbc2720f;hp=e3ece7e5b4ed2c544afe37512bc43551eec8fa06;hpb=c8ebcc09c284b5aa5b918e8103db2d812d1e8029;p=kdenlive diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e3ece7e5..3ff94d36 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -142,6 +142,11 @@ EffectsList MainWindow::transitions; QMap MainWindow::m_lumacache; +static bool sortByNames(const QPair &a, const QPair &b) +{ + return a.first < b.first; +} + MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) : KXmlGuiWindow(parent), m_activeDocument(NULL), @@ -582,35 +587,43 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & actionCollection()->addAssociatedWidget(m_clipMonitor->container()); actionCollection()->addAssociatedWidget(m_projectMonitor->container()); - QMap viewActions; + QList > viewActions; + QPair pair; KAction *showTimeline = new KAction(i18n("Timeline"), this); showTimeline->setCheckable(true); showTimeline->setChecked(true); connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool))); - viewActions.insert(showTimeline->text(), showTimeline); + + KMenu *viewMenu = static_cast(factory()->container("dockwindows", this)); + pair.first = showTimeline->text(); + pair.second = showTimeline; + viewActions.append(pair); QList docks = findChildren(); for (int i = 0; i < docks.count(); i++) { QDockWidget* dock = docks.at(i); + QAction * a = dock->toggleViewAction(); + if (!a) continue; KAction* dockInformations = new KAction(this); - dockInformations->setText(dock->windowTitle()); + dockInformations->setText(a->text()); dockInformations->setCheckable(true); dockInformations->setChecked(!dock->isHidden()); - connect(dockInformations,SIGNAL(toggled(bool)), dock, SLOT(setVisible(bool))); - viewActions.insert(dockInformations->text(), dockInformations); - } - - - KMenu *viewMenu = static_cast(factory()->container("dockwindows", this)); - //const QList viewActions = createPopupMenu()->actions(); - QMap::const_iterator i = viewActions.constBegin(); - while (i != viewActions.constEnd()) { - viewMenu->addAction(guiActions->addAction(i.key(), i.value())); - ++i; + // HACK: since QActions cannot be used in KActionCategory to allow shortcut, we create a duplicate KAction of the dock QAction and link them + connect(a,SIGNAL(toggled(bool)), dockInformations, SLOT(setChecked(bool))); + connect(dockInformations,SIGNAL(triggered(bool)), a, SLOT(trigger())); + pair.first = dockInformations->text(); + pair.second = dockInformations; + viewActions.append(pair); } + // Sort dock view action by name + qSort(viewActions.begin(), viewActions.end(), sortByNames); + // Populate view menu + for (int i = 0; i < viewActions.count(); i++) + viewMenu->addAction(guiActions->addAction(viewActions.at(i).first, viewActions.at(i).second)); + // Populate encoding profiles - KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata"); + KConfig conf("encodingprofiles.rc", KConfig::CascadeConfig, "appdata"); if (KdenliveSettings::proxyparams().isEmpty() || KdenliveSettings::proxyextension().isEmpty()) { KConfigGroup group(&conf, "proxy"); QMap< QString, QString > values = group.entryMap(); @@ -633,6 +646,17 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & KdenliveSettings::setV4l_extension(data.section(';', 1, 1)); } } + if (KdenliveSettings::grab_parameters().isEmpty() || KdenliveSettings::grab_extension().isEmpty()) { + KConfigGroup group(&conf, "screengrab"); + QMap< QString, QString > values = group.entryMap(); + QMapIterator i(values); + if (i.hasNext()) { + i.next(); + QString data = i.value(); + KdenliveSettings::setGrab_parameters(data.section(';', 0, 0)); + KdenliveSettings::setGrab_extension(data.section(';', 1, 1)); + } + } if (KdenliveSettings::decklink_parameters().isEmpty() || KdenliveSettings::decklink_extension().isEmpty()) { KConfigGroup group(&conf, "decklink"); QMap< QString, QString > values = group.entryMap(); @@ -1988,6 +2012,7 @@ bool MainWindow::closeCurrentDocument(bool saveChanges) if (docToClose == m_activeDocument) { delete m_activeDocument; m_activeDocument = NULL; + m_monitorManager->setDocument(m_activeDocument); m_effectStack->clear(); m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false); } else { @@ -2086,13 +2111,23 @@ void MainWindow::openFile(const KUrl &url) // Opening a compressed project file, we need to process it kDebug()<<"Opening archive, processing"; QPointer ar = new ArchiveWidget(url); - if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile())); + if (ar->exec() == QDialog::Accepted) { + openFile(KUrl(ar->extractedProjectFile())); + } + else if (!m_startUrl.isEmpty()) { + // we tried to open an invalid file from command line, init new project + newFile(false); + } delete ar; return; } if (!url.fileName().endsWith(".kdenlive")) { // This is not a Kdenlive project file, abort loading KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path())); + if (!m_startUrl.isEmpty()) { + // we tried to open an invalid file from command line, init new project + newFile(false); + } return; } @@ -2155,7 +2190,6 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) progressDialog.progressBar()->setMaximum(4); progressDialog.show(); progressDialog.progressBar()->setValue(0); - qApp->processEvents(); bool openBackup; KdenliveDoc *doc = new KdenliveDoc(stale ? KUrl(stale->fileName()) : url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap (), QMap (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, &openBackup, this, &progressDialog); @@ -2163,7 +2197,7 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) progressDialog.progressBar()->setValue(1); progressDialog.progressBar()->setMaximum(4); progressDialog.setLabelText(i18n("Loading project")); - qApp->processEvents(); + progressDialog.repaint(); if (stale == NULL) { QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex(); @@ -2178,13 +2212,13 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) connectDocumentInfo(doc); progressDialog.progressBar()->setValue(2); - qApp->processEvents(); + progressDialog.repaint(); bool ok; TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this); connectDocument(trackView, doc); progressDialog.progressBar()->setValue(3); - qApp->processEvents(); + progressDialog.repaint(); m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description())); if (!ok) { @@ -2402,7 +2436,6 @@ void MainWindow::slotUpdateProjectProfile(const QString &profile) KdenliveSettings::setCurrent_profile(profile); KdenliveSettings::setProject_fps(m_activeDocument->fps()); setCaption(m_activeDocument->description(), m_activeDocument->isModified()); - m_activeDocument->clipManager()->clearUnusedProducers(); m_monitorManager->resetProfiles(m_activeDocument->timecode()); m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList()); @@ -2417,6 +2450,7 @@ void MainWindow::slotUpdateProjectProfile(const QString &profile) m_commandStack->activeStack()->clear(); //Update the mouse position display so it will display in DF/NDF format by default based on the project setting. slotUpdateMousePosition(0); + m_projectList->slotReloadClip(); // We need to desactivate & reactivate monitors to get a refresh //m_monitorManager->switchMonitors(); } @@ -2671,6 +2705,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha m_saveAction->setEnabled(doc->isModified()); m_normalEditTool->setChecked(true); m_activeDocument = doc; + m_monitorManager->setDocument(m_activeDocument); m_activeTimeline->updateProjectFps(); m_activeDocument->checkProjectClips(); #ifndef Q_WS_MAC @@ -2867,8 +2902,11 @@ void MainWindow::slotAddClipMarker() CommentedTime marker(pos, i18n("Marker"), KdenliveSettings::default_marker_type()); QPointer d = new MarkerDialog(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this); - if (d->exec() == QDialog::Accepted) + if (d->exec() == QDialog::Accepted) { m_activeTimeline->projectView()->slotAddClipMarker(id, QList () << d->newMarker()); + QString hash = clip->getClipHash(); + if (!hash.isEmpty()) m_activeDocument->cacheImage(hash + '#' + QString::number(d->newMarker().time().frames(m_activeDocument->fps())), d->markerImage()); + } delete d; } @@ -2954,6 +2992,8 @@ void MainWindow::slotEditClipMarker() m_activeDocument->timecode(), i18n("Edit Marker"), this); if (d->exec() == QDialog::Accepted) { m_activeTimeline->projectView()->slotAddClipMarker(id, QList () <newMarker()); + QString hash = clip->getClipHash(); + if (!hash.isEmpty()) m_activeDocument->cacheImage(hash + '#' + QString::number(d->newMarker().time().frames(m_activeDocument->fps())), d->markerImage()); if (d->newMarker().time() != pos) { // remove old marker oldMarker.setMarkerType(-1); @@ -3332,14 +3372,25 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip) //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId()); return; } + + // Check if we already have a properties dialog opened for that clip + QList list = findChildren(); + for (int i = 0; i < list.size(); ++i) { + if (list.at(i)->clipId() == clip->getId()) { + // We have one dialog, show it + list.at(i)->raise(); + return; + } + } // any type of clip but a title ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this); if (clip->clipType() == AV || clip->clipType() == VIDEO || clip->clipType() == PLAYLIST || clip->clipType() == SLIDESHOW) { // request clip thumbnails - m_activeDocument->clipManager()->requestThumbs(QString('?' + clip->getId()), QList() << clip->getClipThumbFrame()); connect(m_activeDocument->clipManager(), SIGNAL(gotClipPropertyThumbnail(const QString&,QImage)), dia, SLOT(slotGotThumbnail(const QString&,QImage))); + connect(dia, SIGNAL(requestThumb(const QString, QList )), m_activeDocument->clipManager(), SLOT(slotRequestThumbs(QString,QList))); + m_activeDocument->clipManager()->slotRequestThumbs(QString('?' + clip->getId()), QList() << clip->getClipThumbFrame()); } connect(dia, SIGNAL(addMarkers(const QString &, QList )), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, QList ))); @@ -3891,12 +3942,11 @@ void MainWindow::slotUpdateClipType(QAction *action) void MainWindow::slotDvdWizard(const QString &url) { // We must stop the monitors since we create a new on in the dvd wizard - m_clipMonitor->stop(); - m_projectMonitor->stop(); - QPointer w = new DvdWizard(url, this); + m_monitorManager->activateMonitor(Kdenlive::dvdMonitor); + QPointer w = new DvdWizard(m_monitorManager, url, this); w->exec(); - m_projectMonitor->start(); delete w; + m_monitorManager->activateMonitor(Kdenlive::clipMonitor); } void MainWindow::slotShowTimeline(bool show) @@ -4074,12 +4124,17 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS QString scriptPath; QString playlistPath; if (scriptExport) { - bool ok; QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/"; - QString path = m_renderWidget->getFreeScriptName(); - scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok); - if (!ok || scriptPath.isEmpty()) return; - scriptPath.prepend(scriptsFolder); + QString path = m_renderWidget->getFreeScriptName(m_activeDocument->url()); + QPointer getUrl = new KUrlRequesterDialog(path, i18n("Create Render Script"), this); + getUrl->fileDialog()->setMode(KFile::File); + getUrl->fileDialog()->setOperationMode(KFileDialog::Saving); + if (getUrl->exec() == QDialog::Rejected) { + delete getUrl; + return; + } + scriptPath = getUrl->selectedUrl().path(); + delete getUrl; QFile f(scriptPath); if (f.exists()) { if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes) @@ -4128,7 +4183,7 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS // Always insert a guide in pos 0 QDomElement chapter = doc.createElement("chapter"); chapters.insertBefore(chapter, QDomNode()); - chapter.setAttribute("title", i18n("Start")); + chapter.setAttribute("title", i18nc("the first in a list of chapters", "Start")); chapter.setAttribute("time", "0"); } // save chapters file