]> git.sesse.net Git - kdenlive/blobdiff - src/monitorscene.cpp
* Allow to edit transparent background for images in group properties
[kdenlive] / src / monitorscene.cpp
index eec47da33f49cb73a2b0a96cf6d8295469cbe13b..ebf248f7c372fa210f45cdcc787d268159343eb7 100644 (file)
 
 #include "monitorscene.h"
 #include "renderer.h"
-#include "onmonitoritems/onmonitorrectitem.h"
 #include "kdenlivesettings.h"
 
 #include <QGraphicsView>
 #include <QGraphicsPixmapItem>
 #include <QGraphicsSceneMouseEvent>
 
+
 MonitorScene::MonitorScene(Render *renderer, QObject* parent) :
         QGraphicsScene(parent),
         m_renderer(renderer),
@@ -85,18 +85,13 @@ void MonitorScene::setEnabled(bool enabled)
 void MonitorScene::slotUpdateBackground()
 {
     if (m_view && m_view->isVisible()) {
-        if (m_lastUpdate.msecsTo(QTime::currentTime()) > 100) {
+        if (m_lastUpdate.msecsTo(QTime::currentTime()) > 50) {
             m_background->setPixmap(QPixmap::fromImage(m_backgroundImage));
             m_lastUpdate = QTime::currentTime();
         }
     }
 }
 
-void MonitorScene::slotSetDirectUpdate(bool directUpdate)
-{
-    KdenliveSettings::setMonitorscene_directupdate(directUpdate);
-}
-
 void MonitorScene::slotSetBackgroundImage(const QImage &image)
 {
     if (m_view && m_view->isVisible()) {
@@ -132,63 +127,34 @@ void MonitorScene::slotZoomOriginal()
         m_view->centerOn(m_frameBorder);
 }
 
-void MonitorScene::slotZoomOut()
+void MonitorScene::slotZoomOut(int by)
 {
-    slotZoom(qMax(0, (int)(m_zoom * 100 - 1)));
-}
-
-void MonitorScene::slotZoomIn()
-{
-    int newzoom = (100 * m_zoom + 0.5);
-    newzoom++;
-    slotZoom(qMin(300, newzoom));
-}
-
-void MonitorScene::addItem(QGraphicsItem* item)
-{
-    QGraphicsScene::addItem(item);
-
-    OnMonitorRectItem *rect = qgraphicsitem_cast<OnMonitorRectItem*>(item);
-    if (rect) {
-        connect(this, SIGNAL(mousePressed(QGraphicsSceneMouseEvent*)), rect, SLOT(slotMousePressed(QGraphicsSceneMouseEvent*)));
-        connect(this, SIGNAL(mouseReleased(QGraphicsSceneMouseEvent*)), rect, SLOT(slotMouseReleased(QGraphicsSceneMouseEvent*)));
-        connect(this, SIGNAL(mouseMoved(QGraphicsSceneMouseEvent*)), rect, SLOT(slotMouseMoved(QGraphicsSceneMouseEvent*)));
-        connect(rect, SIGNAL(actionFinished()), this, SIGNAL(actionFinished()));
-        connect(rect, SIGNAL(setCursor(const QCursor &)), this, SLOT(slotSetCursor(const QCursor &)));
-    }
+    slotZoom(qMax(0, (int)(m_zoom * 100 - by)));
 }
 
-void MonitorScene::slotSetCursor(const QCursor &cursor)
+void MonitorScene::slotZoomIn(int by)
 {
-    if (m_view)
-        m_view->setCursor(cursor);
+    slotZoom(qMin(300, (int)(m_zoom * 100 + by + 0.5)));
 }
 
-
-void MonitorScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
+void MonitorScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
 {
-    emit mousePressed(event);
+    QGraphicsScene::mousePressEvent(event);
 
-    if (!event->isAccepted() && m_enabled)
-        QGraphicsScene::mousePressEvent(event);
+    if (!event->isAccepted() && event->buttons() & Qt::LeftButton && event->modifiers() == Qt::ControlModifier)
+        m_view->setDragMode(QGraphicsView::ScrollHandDrag);
 }
 
 void MonitorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
 {
-    emit mouseMoved(event);
-
-    if (!event->isAccepted() && m_enabled)
-        QGraphicsScene::mouseMoveEvent(event);
+    QGraphicsScene::mouseMoveEvent(event);
 }
 
-void MonitorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+void MonitorScene::mouseReleaseEvent(QGraphicsSceneMouseEventevent)
 {
-    emit mouseReleased(event);
-
-    if (!event->isAccepted() && m_enabled)
-        QGraphicsScene::mouseReleaseEvent(event);
+    QGraphicsScene::mouseReleaseEvent(event);
+    m_view->setDragMode(QGraphicsView::NoDrag);
 }
-
 void MonitorScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
 {
     Q_UNUSED(event);
@@ -197,5 +163,18 @@ void MonitorScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
         emit addKeyframe();
 }
 
+void MonitorScene::wheelEvent(QGraphicsSceneWheelEvent* event)
+{
+    if (event->modifiers() == Qt::ControlModifier) {
+        if (event->delta() > 0)
+            slotZoomIn(5);
+        else
+            slotZoomOut(5);
+    } else {
+        QGraphicsScene::wheelEvent(event);
+    }
+
+    event->accept();
+}
 
 #include "monitorscene.moc"