X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fdvdwizardmenu.h;h=4f6b732415d4ebfa2f007d1770eacb0a03da2381;hb=ec4afadc6e994943318f7d53376448dbd402cb3d;hp=01a0c73ba25a9846e6ce101bdbb8c499f38bfd9c;hpb=76b841800707bca883291039fb7a278a845efe92;p=kdenlive diff --git a/src/dvdwizardmenu.h b/src/dvdwizardmenu.h index 01a0c73b..4f6b7324 100644 --- a/src/dvdwizardmenu.h +++ b/src/dvdwizardmenu.h @@ -26,8 +26,14 @@ #include #include #include +#include #include +#include + +#if KDE_IS_VERSION(4,7,0) +#include +#endif #include "ui_dvdwizardmenu_ui.h" @@ -35,7 +41,9 @@ class DvdScene : public QGraphicsScene { public: - DvdScene(QObject * parent = 0): QGraphicsScene(parent) {} + DvdScene(QObject * parent = 0): QGraphicsScene(parent) { + m_width = 0; m_height = 0; + } void setProfile(int width, int height) { m_width = width; m_height = height; @@ -56,44 +64,59 @@ class DvdButton : public QGraphicsTextItem { public: - DvdButton(const QString & text): QGraphicsTextItem(text), m_target(0) {} - enum { Type = UserType + 1 }; - void setTarget(int t) { + 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; } int target() const { return m_target; } + QString command() const { + return m_command; + } + bool backMenu() const { + return m_backToMenu; + } int type() const { // Enable the use of qgraphicsitem_cast with this item. - return Type; + return UserType + 1; + } + void setBackMenu(bool back) { + m_backToMenu = back; } private: int m_target; - + QString m_command; + bool m_backToMenu; protected: virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) { if (change == ItemPositionChange && scene()) { - - /* QList 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 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); } @@ -112,11 +135,15 @@ public: bool createMenu() const; void createBackgroundImage(const QString &img1); void createButtonImages(const QString &img1, const QString &img2, const QString &img3); - void setTargets(QStringList list); - QMap buttonsInfo(); + void setTargets(QStringList list, QStringList targetlist); + QMap 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; @@ -127,7 +154,9 @@ private: QGraphicsRectItem *m_safeRect; int m_width; int m_height; - QStringList m_targets; +#if KDE_IS_VERSION(4,7,0) + KMessageWidget *m_menuMessage; +#endif private slots: void buildButton(); @@ -135,7 +164,6 @@ private slots: void buildImage(); void checkBackground(); void checkBackgroundType(int ix); - void changeProfile(int ix); void updatePreview(); void buttonChanged(); void addButton(); @@ -143,6 +171,9 @@ private slots: void deleteButton(); void updateColor(); void updateColor(QColor c); + void setBackToMenu(bool backToMenu); + void slotZoom(); + void slotUnZoom(); }; #endif