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>
32 #include "ui_dvdwizardmenu_ui.h"
34 class DvdScene : public QGraphicsScene
38 DvdScene(QObject * parent = 0): QGraphicsScene(parent) {}
39 void setProfile(int width, int height) {
42 setSceneRect(0, 0, m_width, m_height);
44 int sceneWidth() const {
47 int sceneHeight() const {
55 class DvdButton : public QGraphicsTextItem
59 DvdButton(const QString & text): QGraphicsTextItem(text), m_target(0), m_command(QString("title 1")) {}
60 enum { Type = UserType + 1 };
61 void setTarget(int t, QString c) {
68 QString command() const {
72 // Enable the use of qgraphicsitem_cast with this item.
82 virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) {
83 if (change == ItemPositionChange && scene()) {
85 /* QList<QGraphicsItem *> list = collidingItems();
86 if (!list.isEmpty()) {
87 for (int i = 0; i < list.count(); i++) {
88 if (list.at(i)->type() == Type) return pos();
92 DvdScene *sc = static_cast < DvdScene * >(scene());
93 QRectF rect = QRectF(0, 0, sc->width(), sc->height());
94 QPointF newPos = value.toPointF();
95 if (!rect.contains(newPos)) {
96 // Keep the item inside the scene rect.
97 newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
98 newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
102 return QGraphicsItem::itemChange(change, value);
108 class DvdWizardMenu : public QWizardPage
113 explicit DvdWizardMenu(const QString &profile, QWidget * parent = 0);
114 virtual ~DvdWizardMenu();
115 virtual bool isComplete() const;
116 bool createMenu() const;
117 void createBackgroundImage(const QString &img1);
118 void createButtonImages(const QString &img1, const QString &img2, const QString &img3);
119 void setTargets(QStringList list, QStringList targetlist);
120 QMap <QString, QRect> buttonsInfo();
121 bool menuMovie() const;
122 QString menuMoviePath() const;
123 bool isPalMenu() const;
126 Ui::DvdWizardMenu_UI m_view;
129 QGraphicsPixmapItem *m_background;
130 QGraphicsRectItem *m_color;
131 QGraphicsRectItem *m_safeRect;
139 void checkBackground();
140 void checkBackgroundType(int ix);
141 void changeProfile(int ix);
142 void updatePreview();
143 void buttonChanged();
145 void setButtonTarget(int ix);
148 void updateColor(QColor c);