1 /***************************************************************************
2 * Copyright (C) 2009 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #ifndef DVDWIZARDMENU_H
22 #define DVDWIZARDMENU_H
24 #include <QWizardPage>
25 #include <QGraphicsScene>
26 #include <QGraphicsTextItem>
27 #include <QGraphicsPixmapItem>
28 #include <QGraphicsRectItem>
29 #include <QDomElement>
32 #include <kdeversion.h>
34 #if KDE_IS_VERSION(4,7,0)
35 #include <KMessageWidget>
38 #include "dvdwizardvob.h"
39 #include "ui_dvdwizardmenu_ui.h"
41 class DvdScene : public QGraphicsScene
45 DvdScene(QObject * parent = 0): QGraphicsScene(parent) {
46 m_width = 0; m_height = 0;
48 void setProfile(int width, int height) {
51 setSceneRect(0, 0, m_width, m_height);
53 int sceneWidth() const {
56 int sceneHeight() const {
64 class DvdButton : public QGraphicsTextItem
68 DvdButton(const QString & text): QGraphicsTextItem(text), m_target(0), m_command(QString("jump title 1")), m_backToMenu(false) {
69 setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
70 #if QT_VERSION >= 0x040600
71 setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
74 void setTarget(int t, QString c) {
81 QString command() const {
84 bool backMenu() const {
88 // Enable the use of qgraphicsitem_cast with this item.
91 void setBackMenu(bool back) {
102 virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) {
103 if (change == ItemPositionChange && scene()) {
104 QPointF newPos = value.toPointF();
105 QRectF sceneShape = sceneBoundingRect();
106 DvdScene *sc = static_cast < DvdScene * >(scene());
107 newPos.setX(qMax(newPos.x(), (qreal)0));
108 newPos.setY(qMax(newPos.y(), (qreal)0));
109 if (newPos.x() + sceneShape.width() > sc->width()) newPos.setX(sc->width() - sceneShape.width());
110 if (newPos.y() + sceneShape.height() > sc->height()) newPos.setY(sc->height() - sceneShape.height());
112 sceneShape.translate(newPos - pos());
113 QList<QGraphicsItem*> list = scene()->items(sceneShape, Qt::IntersectsItemShape);
114 list.removeAll(this);
115 if (!list.isEmpty()) {
116 for (int i = 0; i < list.count(); i++) {
117 if (list.at(i)->type() == Type) return pos();
122 return QGraphicsItem::itemChange(change, value);
128 class DvdWizardMenu : public QWizardPage
133 explicit DvdWizardMenu(DVDFORMAT format, QWidget * parent = 0);
134 virtual ~DvdWizardMenu();
135 virtual bool isComplete() const;
136 bool createMenu() const;
137 void createBackgroundImage(const QString &overlayMenu, const QString &img1);
138 void createButtonImages(const QString &img1, const QString &img2, const QString &img3, bool letterbox = false);
139 void setTargets(QStringList list, QStringList targetlist);
140 QMap <QString, QRect> buttonsInfo(bool letterbox = false);
141 bool loopMovie() const;
142 bool menuMovie() const;
143 QString menuMoviePath() const;
144 int menuMovieLength() const;
145 void changeProfile(DVDFORMAT format);
146 QDomElement toXml() const;
147 void loadXml(QDomElement xml);
148 void prepareUnderLines();
149 void resetUnderLines();
152 Ui::DvdWizardMenu_UI m_view;
155 QGraphicsPixmapItem *m_background;
156 QGraphicsRectItem *m_color;
157 QGraphicsRectItem *m_safeRect;
162 #if KDE_IS_VERSION(4,7,0)
163 KMessageWidget *m_menuMessage;
170 void checkBackground();
171 void checkBackgroundType(int ix);
172 void updatePreview();
173 void buttonChanged();
175 void setButtonTarget(int ix);
178 void updateColor(QColor c);
179 void updateUnderlineColor(QColor c);
180 void setBackToMenu(bool backToMenu);
183 void slotEnableShadows(int enable);