]> git.sesse.net Git - kdenlive/blobdiff - src/monitorscene.cpp
Do not allow to change x position of first point in curve widget, as this is not...
[kdenlive] / src / monitorscene.cpp
index 6a2cde78134b7dc6a1d7841da06433f3806124ee..857caab990d0a56ee7b64c9bfda77f659efc5ada 100644 (file)
@@ -36,7 +36,7 @@ MonitorScene::MonitorScene(Render *renderer, QObject* parent) :
         m_backgroundImage(QImage()),
         m_enabled(true),
         m_modified(false),
-        m_directUpdate(false)
+        m_zoom(1.0)
 {
     setBackgroundBrush(QBrush(QColor(KdenliveSettings::window_background().name())));
 
@@ -73,8 +73,12 @@ void MonitorScene::setUp()
         m_view = NULL;
 
     m_view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
+}
 
-    slotUpdateBackground(true);
+void MonitorScene::resetProfile()
+{
+    const QRectF border(0, 0, m_renderer->renderWidth(), m_renderer->renderHeight());
+    m_frameBorder->setRect(border);
 }
 
 void MonitorScene::setEnabled(bool enabled)
@@ -82,15 +86,11 @@ void MonitorScene::setEnabled(bool enabled)
     m_enabled = enabled;
 }
 
-void MonitorScene::slotUpdateBackground(bool fit)
+void MonitorScene::slotUpdateBackground()
 {
     if (m_view && m_view->isVisible()) {
         if (m_lastUpdate.elapsed() > 200) {
             m_background->setPixmap(QPixmap::fromImage(m_backgroundImage, Qt::ThresholdDither));
-            if (fit) {
-                m_view->fitInView(m_frameBorder, Qt::KeepAspectRatio);
-                m_view->centerOn(m_frameBorder);
-            }
             m_lastUpdate.start();
         }
     }
@@ -98,23 +98,59 @@ void MonitorScene::slotUpdateBackground(bool fit)
 
 void MonitorScene::slotSetDirectUpdate(bool directUpdate)
 {
-    m_directUpdate = directUpdate;
+    KdenliveSettings::setMonitorscene_directupdate(directUpdate);
+}
+
+void MonitorScene::slotSetBackgroundImage(const QImage &image)
+{
+    if (m_view && m_view->isVisible()) {
+        m_backgroundImage = image;
+        slotUpdateBackground();
+    }
 }
 
-bool MonitorScene::getDirectUpdate()
+
+void MonitorScene::slotZoom(int value)
 {
-    return m_directUpdate;
+    if (m_view) {
+        m_zoom = value / 100.0;
+        m_view->resetTransform();
+        m_view->scale(m_zoom, m_zoom);
+        emit zoomChanged(value);
+    }
 }
 
-void MonitorScene::slotSetBackgroundImage(QImage image)
+void MonitorScene::slotZoomFit()
 {
-    m_backgroundImage = image;
-    slotUpdateBackground();
+    if (m_view) {
+        m_view->fitInView(m_frameBorder, Qt::KeepAspectRatio);
+        m_view->centerOn(m_frameBorder);
+        m_zoom = m_view->matrix().m11();
+        emit zoomChanged((int)(m_zoom * 100));
+    }
 }
 
+void MonitorScene::slotZoomOriginal()
+{
+    slotZoom(100);
+    if (m_view)
+        m_view->centerOn(m_frameBorder);
+}
+
+void MonitorScene::slotZoomOut()
+{
+    slotZoom(qMax(0, (int)(m_zoom * 100 - 1)));
+}
+
+void MonitorScene::slotZoomIn()
+{
+    slotZoom(qMin(300, (int)(m_zoom * 100 + 1)));
+}
+
+
 resizeModes MonitorScene::getResizeMode(QGraphicsRectItem *item, QPoint pos)
 {
-    if(!m_view)
+    if (!m_view)
         return NoResize;
 
     QRectF rect = item->rect().normalized();
@@ -183,6 +219,11 @@ void MonitorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
     if (!m_enabled)
         return;
 
+    /*if (event->buttons() != Qt::NoButton && (event->screenPos() - m_screenClickPoint).manhattanLength() < QApplication::startDragDistance()) {
+        event->accept();
+        return;
+    }*/
+
     QPointF mousePos = event->scenePos();
 
     if (m_selectedItem && event->buttons() & Qt::LeftButton) {
@@ -266,7 +307,7 @@ void MonitorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
         bool itemFound = false;
         QList<QGraphicsItem *> itemList = items(QRectF(mousePos, QSizeF(4, 4)).toRect());
 
-        foreach (const QGraphicsItem* item, itemList) {
+        foreach(const QGraphicsItem* item, itemList) {
             if (item->zValue() >= 0 && item->flags() &QGraphicsItem::ItemIsMovable) {
                 // Rect
                 if (item->type() == 3) {
@@ -305,7 +346,7 @@ void MonitorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
 
         QGraphicsScene::mouseMoveEvent(event);
     }
-    if (m_modified && m_directUpdate) {
+    if (m_modified && KdenliveSettings::monitorscene_directupdate()) {
         emit actionFinished();
         m_modified = false;
     }