]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
Fix corruption when changing the project profile
[kdenlive] / src / mainwindow.cpp
index e4e2bf04a91c89ac2c457239002ddbb3afbd99b3..005ed0e61a625f444038803c6a7f692c11c5d21d 100644 (file)
@@ -81,6 +81,7 @@
 #include <KNotifyConfigWidget>
 #include <knewstuff2/engine.h>
 #include <knewstuff2/ui/knewstuffaction.h>
+#include <KToolBar>
 
 #include <QTextStream>
 #include <QTimer>
@@ -235,6 +236,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
 
 
     setupGUI();
+
     /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
     guiFactory()->addClient(sp);*/
 
@@ -392,8 +394,11 @@ void MainWindow::queryQuit()
         if (m_clipMonitor) m_clipMonitor->stop();
         delete m_effectStack;
         delete m_activeTimeline;
+#ifndef Q_WS_MAC
+        // This sometimes causes crash on exit on OS X for some reason.
         delete m_projectMonitor;
         delete m_clipMonitor;
+#endif
         delete m_activeDocument;
         delete m_shortcutRemoveFocus;
         Mlt::Factory::close();
@@ -679,17 +684,11 @@ void MainWindow::setupActions()
     m_statusProgressBar->setMaximumWidth(150);
     m_statusProgressBar->setVisible(false);
 
-    QWidget *w = new QWidget;
-
-    QHBoxLayout *layout = new QHBoxLayout;
-    w->setLayout(layout);
-    layout->setContentsMargins(5, 0, 5, 0);
-    QToolBar *toolbar = new QToolBar("statusToolBar", this);
-
-
+    KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
+    toolbar->setMovable(false);
     m_toolGroup = new QActionGroup(this);
-
-    QString style1 = "QToolButton {background-color: rgba(230, 230, 230, 220); border-style: inset; border:1px solid #999999;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:checked { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}";
+    statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
+    QString style1 = "QToolBar { border: 0px } QToolButton {background-color: rgba(230, 230, 230, 220); border-style: inset; border:1px solid #999999;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:checked { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}";
 
     m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
     m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
@@ -716,17 +715,18 @@ void MainWindow::setupActions()
     toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
 
     QWidget * actionWidget;
+    int max = toolbar->iconSizeDefault() + 2;
     actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     toolbar->setStyleSheet(style1);
     connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
@@ -738,8 +738,8 @@ void MainWindow::setupActions()
     connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
 
     actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     m_zoomSlider = new QSlider(Qt::Horizontal, this);
     m_zoomSlider->setMaximum(13);
@@ -747,22 +747,6 @@ void MainWindow::setupActions()
 
     m_zoomSlider->setMaximumWidth(150);
     m_zoomSlider->setMinimumWidth(100);
-
-#ifdef Q_WS_MAC
-    const int contentHeight = QFontMetrics(w->font()).height() + 14;
-#else
-    const int contentHeight = QFontMetrics(w->font()).height() + 8;
-#endif
-
-    QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
-    style.append("QSlider::handle:horizontal {  background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
-
-    m_zoomSlider->setStyleSheet(style);
-
-    //m_zoomSlider->height() + 5;
-    statusBar()->setMinimumHeight(contentHeight);
-
-
     toolbar->addWidget(m_zoomSlider);
 
     m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
@@ -788,34 +772,32 @@ void MainWindow::setupActions()
     m_buttonSnap->setCheckable(true);
     m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
     connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
-    layout->addWidget(toolbar);
-
 
     actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     actionWidget = toolbar->widgetForAction(m_buttonSnap);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     m_messageLabel = new StatusBarMessageLabel(this);
     m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
 
     statusBar()->addWidget(m_messageLabel, 10);
     statusBar()->addWidget(m_statusProgressBar, 0);
-    statusBar()->addPermanentWidget(w);
+    statusBar()->addPermanentWidget(toolbar);
     statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
     statusBar()->addPermanentWidget(m_timecodeFormat);
-    statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
+    //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
 
     collection->addAction("select_tool", m_buttonSelectTool);
     collection->addAction("razor_tool", m_buttonRazorTool);
@@ -1645,7 +1627,7 @@ void MainWindow::slotEditProjectSettings()
             m_effectStack->slotClipItemSelected(NULL, 0);
             m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
             m_clipMonitor->slotSetXml(NULL, 0);
-            m_activeDocument->setProfilePath(profile);
+            bool updateFps = m_activeDocument->setProfilePath(profile);
             KdenliveSettings::setCurrent_profile(profile);
             KdenliveSettings::setProject_fps(m_activeDocument->fps());
             setCaption(m_activeDocument->description(), m_activeDocument->isModified());
@@ -1659,7 +1641,7 @@ void MainWindow::slotEditProjectSettings()
             m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
             //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
             if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
-            m_activeTimeline->updateProjectFps();
+            if (updateFps) m_activeTimeline->updateProjectFps();
 
             // We need to desactivate & reactivate monitors to get a refresh
             //m_monitorManager->switchMonitors();