From 57d603d727098446a3518aca5f43423a184dc50d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Mon, 1 Sep 2008 19:44:55 +0000 Subject: [PATCH] * Fix crash on renderer stopping * No more tabs by default * small UI fixes svn path=/branches/KDE4/; revision=2388 --- src/effectstackview.cpp | 9 +++++++++ src/effectstackview.h | 2 ++ src/kdenlivedoc.h | 4 ++-- src/kdenlivesettings.kcfg | 5 +++++ src/mainwindow.cpp | 34 +++++++++++++++++++++++++++------- src/mainwindow.h | 3 ++- src/projectlist.cpp | 1 + src/projectlist.h | 3 +-- src/renderer.cpp | 3 ++- src/widgets/configmisc_ui.ui | 16 ++++++++++------ 10 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/effectstackview.cpp b/src/effectstackview.cpp index 09c92f5f..6c018c78 100644 --- a/src/effectstackview.cpp +++ b/src/effectstackview.cpp @@ -288,4 +288,13 @@ void EffectStackView::raiseWindow(QWidget* dock) { dock->raise(); } +void EffectStackView::clear() { + ui.effectlist->clear(); + ui.buttonDel->setEnabled(false); + ui.buttonSave->setEnabled(false); + ui.buttonReset->setEnabled(false); + ui.buttonUp->setEnabled(false); + ui.buttonDown->setEnabled(false); +} + #include "effectstackview.moc" diff --git a/src/effectstackview.h b/src/effectstackview.h index 7b15c54d..ebafffa3 100644 --- a/src/effectstackview.h +++ b/src/effectstackview.h @@ -29,6 +29,8 @@ class EffectStackView : public QWidget { public: EffectStackView(QWidget *parent = 0); void raiseWindow(QWidget*); + void clear(); + private: Ui::EffectStack_UI ui; ClipItem* clipref; diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index 4c03b250..d4f99a87 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -92,8 +92,6 @@ Q_OBJECT public: void setUrl(KUrl url); QDomElement documentInfoXml(); void setProfilePath(QString path); - /** Set to true if document needs saving, false otherwise */ - void setModified(bool mod); const QString&getFreeClipId(); /** does the document need saving */ bool isModified() const; @@ -136,6 +134,8 @@ private: public slots: void slotCreateTextClip(QString group, const QString &groupId); + /** Set to true if document needs saving, false otherwise */ + void setModified(bool mod = true); private slots: void slotAutoSave(); diff --git a/src/kdenlivesettings.kcfg b/src/kdenlivesettings.kcfg index 46fa1778..619f2b04 100644 --- a/src/kdenlivesettings.kcfg +++ b/src/kdenlivesettings.kcfg @@ -14,6 +14,11 @@ true + + + false + + 00:00:05:00 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d465ac41..e248910a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -105,7 +105,7 @@ MainWindow::MainWindow(QWidget *parent) m_timelineArea->setTabBarHidden(true); QToolButton *closeTabButton = new QToolButton; - connect(closeTabButton, SIGNAL(clicked()), this, SLOT(slotRemoveTab())); + connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument())); closeTabButton->setIcon(KIcon("tab-close")); closeTabButton->adjustSize(); closeTabButton->setToolTip(i18n("Close the current tab")); @@ -710,8 +710,8 @@ void MainWindow::setupActions() { KStandardAction::open(this, SLOT(openFile()), actionCollection()); - KStandardAction::save(this, SLOT(saveFile()), - actionCollection()); + m_saveAction = KStandardAction::save(this, SLOT(saveFile()), + actionCollection()); KStandardAction::saveAs(this, SLOT(saveFileAs()), actionCollection()); @@ -794,13 +794,14 @@ void MainWindow::newFile() { } void MainWindow::activateDocument() { + if (m_timelineArea->currentWidget() == NULL) return; TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget(); KdenliveDoc *currentDoc = currentTab->document(); connectDocumentInfo(currentDoc); connectDocument(currentTab, currentDoc); } -void MainWindow::slotRemoveTab() { +void MainWindow::closeCurrentDocument() { QWidget *w = m_timelineArea->currentWidget(); // closing current document int ix = m_timelineArea->currentIndex() + 1; @@ -808,10 +809,23 @@ void MainWindow::slotRemoveTab() { m_timelineArea->setCurrentIndex(ix); TrackView *tabToClose = (TrackView *) w; KdenliveDoc *docToClose = tabToClose->document(); + if (docToClose && docToClose->isModified()) { + switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) { + case KMessageBox::Yes : + // save document here. If saving fails, return false; + saveFile(); + break; + case KMessageBox::Cancel : + return; + default: + break; + } + } m_timelineArea->removeTab(m_timelineArea->indexOf(w)); if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true); delete docToClose; delete w; + if (m_timelineArea->count() == 0) m_activeDocument = NULL; } void MainWindow::saveFileAs(const QString &outputFileName) { @@ -861,7 +875,6 @@ void MainWindow::openLastFile() { void MainWindow::openFile(const KUrl &url) { // Check for backup file - QList staleFiles = KAutoSaveFile::staleFiles(url); if (!staleFiles.isEmpty()) { if (KMessageBox::questionYesNo(this, @@ -878,6 +891,7 @@ void MainWindow::openFile(const KUrl &url) { } } } + if (!KdenliveSettings::activatetabs()) closeCurrentDocument(); doOpenFile(url, NULL); } @@ -903,6 +917,7 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) { } void MainWindow::recoverFiles(QList staleFiles) { + if (!KdenliveSettings::activatetabs()) closeCurrentDocument(); foreach(KAutoSaveFile *stale, staleFiles) { /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) { // show an error message; we could not steal the lockfile @@ -984,7 +999,7 @@ void MainWindow::slotEditProjectSettings() { m_activeDocument->setProfilePath(profile); KdenliveSettings::setCurrent_profile(profile); KdenliveSettings::setProject_fps(m_activeDocument->fps()); - setCaption(m_activeDocument->description()); + setCaption(m_activeDocument->description(), m_activeDocument->isModified()); m_monitorManager->resetProfiles(m_activeDocument->timecode()); if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard()); m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description()); @@ -1046,6 +1061,7 @@ void MainWindow::slotUpdateMousePosition(int pos) { void MainWindow::slotUpdateDocumentState(bool modified) { setCaption(m_activeDocument->description(), modified); + m_saveAction->setEnabled(modified); if (modified) { m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link)); m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save")); @@ -1072,6 +1088,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha if (m_activeTimeline) { disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int))); disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int))); + disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified())); disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *))); disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool))); disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &))); @@ -1096,6 +1113,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects())); disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement))); disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor())); + effectStack->clear(); } m_activeDocument->setRenderer(NULL); disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *))); @@ -1106,6 +1124,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha m_monitorManager->resetProfiles(doc->timecode()); m_projectList->setDocument(doc); connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *))); + connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified())); connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor())); connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int))); connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int))); @@ -1159,7 +1178,8 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber())); //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio); - setCaption(doc->description()); + setCaption(doc->description(), doc->isModified()); + m_saveAction->setEnabled(doc->isModified()); m_activeDocument = doc; } diff --git a/src/mainwindow.h b/src/mainwindow.h index 4190e29b..6063959d 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -145,6 +145,7 @@ private: QAction *m_buttonRazorTool; QAction *m_buttonSnap; QActionGroup *m_toolGroup; + QAction *m_saveAction; QSlider *m_zoomSlider; StatusBarMessageLabel *m_messageLabel; @@ -197,7 +198,7 @@ private slots: void slotZoomIn(); void slotZoomOut(); void slotFitZoom(); - void slotRemoveTab(); + void closeCurrentDocument(); void slotDeleteTimelineClip(); void slotAddClipMarker(); void slotDeleteClipMarker(); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index ede62c7b..cc8e8f2d 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -167,6 +167,7 @@ void ProjectList::slotUpdateClipProperties(ProjectItem *clip, QMap clipUrl().path()); if (f.isValid()) f.setDescription(properties.value("description")); } + emit projectModified(); } } diff --git a/src/projectlist.h b/src/projectlist.h index 08b46510..7f931910 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -155,13 +155,12 @@ private slots: void slotUpdateClipProperties(ProjectItem *item, QMap properties); //void slotShowMenu(const QPoint &pos); - - signals: void clipSelected(DocClipBase *); void getFileProperties(const QDomElement&, const QString &); void receivedClipDuration(const QString &, int); void showClipProperties(DocClipBase *); + void projectModified(); }; #endif diff --git a/src/renderer.cpp b/src/renderer.cpp index a024bdf5..253a5545 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -935,7 +935,8 @@ void Render::clear() { void Render::stop() { if (m_mltConsumer && !m_mltConsumer->is_stopped()) { kDebug() << "///////////// RENDER STOPPED: " << m_name; - //m_mltConsumer->set("refresh", 0); + m_isBlocked = true; + m_mltConsumer->set("refresh", 0); m_mltConsumer->stop(); } kDebug() << "///////////// RENDER STOP2-------"; diff --git a/src/widgets/configmisc_ui.ui b/src/widgets/configmisc_ui.ui index 4a32b418..b0cc1a36 100644 --- a/src/widgets/configmisc_ui.ui +++ b/src/widgets/configmisc_ui.ui @@ -6,11 +6,11 @@ 0 0 369 - 285 + 308 - + Default Durations @@ -50,7 +50,7 @@ - + Default Profile @@ -136,7 +136,7 @@ - + Qt::Vertical @@ -161,8 +161,12 @@ Crash recovery (automatic backup) - - true + + + + + + Open projects in new tabs -- 2.39.2