]> git.sesse.net Git - kdenlive/blobdiff - src/dvdwizardmenu.h
Prepare checking of removed / deleted files in a project:
[kdenlive] / src / dvdwizardmenu.h
index 68ba88fdc0f664ad1e5a721965e0690eb5e7e7ac..6a9d44cacad2e24b50981ade60361a60321befde 100644 (file)
@@ -26,6 +26,7 @@
 #include <QGraphicsTextItem>
 #include <QGraphicsPixmapItem>
 #include <QGraphicsRectItem>
+#include <QDomElement>
 
 #include <KDebug>
 
@@ -56,8 +57,12 @@ class DvdButton : public QGraphicsTextItem
 {
 
 public:
-    DvdButton(const QString & text): QGraphicsTextItem(text), m_target(0), m_command(QString("jump title 1")), m_backToMenu(false) {}
-    enum { Type = UserType + 1 };
+    DvdButton(const QString & text): QGraphicsTextItem(text), m_target(0), m_command(QString("jump title 1")), m_backToMenu(false) {
+        setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
+#if QT_VERSION >= 0x040600
+        setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
+#endif
+    }
     void setTarget(int t, QString c) {
         m_target = t;
         m_command = c;
@@ -73,7 +78,7 @@ public:
     }
     int type() const {
         // Enable the use of qgraphicsitem_cast with this item.
-        return Type;
+        return UserType + 1;
     }
     void setBackMenu(bool back) {
         m_backToMenu = back;
@@ -88,23 +93,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(), (qreal)0));
+            newPos.setY(qMax(newPos.y(), (qreal)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);
     }
@@ -125,9 +130,13 @@ public:
     void createButtonImages(const QString &img1, const QString &img2, const QString &img3);
     void setTargets(QStringList list, QStringList targetlist);
     QMap <QString, QRect> buttonsInfo();
+    bool loopMovie() const;
     bool menuMovie() const;
     QString menuMoviePath() const;
     bool isPalMenu() const;
+    void changeProfile(bool isPal);
+    QDomElement toXml() const;
+    void loadXml(QDomElement xml);
 
 private:
     Ui::DvdWizardMenu_UI m_view;
@@ -145,7 +154,6 @@ private slots:
     void buildImage();
     void checkBackground();
     void checkBackgroundType(int ix);
-    void changeProfile(int ix);
     void updatePreview();
     void buttonChanged();
     void addButton();
@@ -154,6 +162,8 @@ private slots:
     void updateColor();
     void updateColor(QColor c);
     void setBackToMenu(bool backToMenu);
+    void slotZoom();
+    void slotUnZoom();
 };
 
 #endif