]> git.sesse.net Git - kdenlive/commitdiff
* Do not allow dvd buttons to overlap
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 29 May 2009 10:42:18 +0000 (10:42 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 29 May 2009 10:42:18 +0000 (10:42 +0000)
* Add zoom to allow more precise positionning of dvd buttons

svn path=/trunk/kdenlive/; revision=3444

src/dvdwizardmenu.cpp
src/dvdwizardmenu.h

index 9e9a003bf94d7892fca1b10b4374163c6d3e8792..8b940658a337d71dc13d935e2fb401cddf90c7ce 100644 (file)
@@ -37,6 +37,8 @@ DvdWizardMenu::DvdWizardMenu(const QString &profile, QWidget *parent) :
 
     m_view.add_button->setIcon(KIcon("document-new"));
     m_view.delete_button->setIcon(KIcon("trash-empty"));
+    m_view.zoom_button->setIcon(KIcon("zoom-in"));
+    m_view.unzoom_button->setIcon(KIcon("zoom-out"));
 
     m_view.add_button->setToolTip(i18n("Add new button"));
     m_view.delete_button->setToolTip(i18n("Delete current button"));
@@ -104,6 +106,8 @@ DvdWizardMenu::DvdWizardMenu(const QString &profile, QWidget *parent) :
 
     connect(m_view.add_button, SIGNAL(pressed()), this, SLOT(addButton()));
     connect(m_view.delete_button, SIGNAL(pressed()), this, SLOT(deleteButton()));
+    connect(m_view.zoom_button, SIGNAL(pressed()), this, SLOT(slotZoom()));
+    connect(m_view.unzoom_button, SIGNAL(pressed()), this, SLOT(slotUnZoom()));
     connect(m_scene, SIGNAL(selectionChanged()), this, SLOT(buttonChanged()));
     connect(m_scene, SIGNAL(changed(const QList<QRectF> &)), this, SIGNAL(completeChanged()));
 
@@ -604,3 +608,13 @@ void DvdWizardMenu::loadXml(QDomElement xml)
     }
 }
 
+void DvdWizardMenu::slotZoom()
+{
+    m_view.menu_preview->scale(2.0, 2.0);
+}
+
+void DvdWizardMenu::slotUnZoom()
+{
+    m_view.menu_preview->scale(0.5, 0.5);
+}
+
index d1ac8371707eb38cf2b3d85709d0c19ddb584545..a8496a3fbc66179dd77df8eb7b281e3a52fd5453 100644 (file)
@@ -90,22 +90,23 @@ protected:
     virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) {
         if (change == ItemPositionChange && scene()) {
 
-            /*   QList<QGraphicsItem *> list = collidingItems();
-               if (!list.isEmpty()) {
-                   for (int i = 0; i < list.count(); i++) {
-                if (list.at(i)->type() == Type) return pos();
-                   }
-               }
-            */
-            DvdScene *sc = static_cast < DvdScene * >(scene());
-            QRectF rect = QRectF(0, 0, sc->width(), sc->height());
             QPointF newPos = value.toPointF();
-            if (!rect.contains(newPos)) {
-                // Keep the item inside the scene rect.
-                newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
-                newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
-                return newPos;
+            QRectF sceneShape = sceneBoundingRect();
+            DvdScene *sc = static_cast < DvdScene * >(scene());
+            newPos.setX(qMax(newPos.x(), 0.0));
+            newPos.setY(qMax(newPos.y(), 0.0));
+            if (newPos.x() + sceneShape.width() > sc->width()) newPos.setX(sc->width() - sceneShape.width());
+            if (newPos.y() + sceneShape.height() > sc->height()) newPos.setY(sc->height() - sceneShape.height());
+
+            sceneShape.translate(newPos - pos());
+            QList<QGraphicsItem*> list = scene()->items(sceneShape, Qt::IntersectsItemShape);
+            list.removeAll(this);
+            if (!list.isEmpty()) {
+                for (int i = 0; i < list.count(); i++) {
+                    if (list.at(i)->type() == Type) return pos();
+                }
             }
+            return newPos;
         }
         return QGraphicsItem::itemChange(change, value);
     }
@@ -157,6 +158,8 @@ private slots:
     void updateColor();
     void updateColor(QColor c);
     void setBackToMenu(bool backToMenu);
+    void slotZoom();
+    void slotUnZoom();
 };
 
 #endif