]> git.sesse.net Git - kdenlive/blob - src/dvdwizardmenu.h
[PATCH 1/2] Kill a bunch of unused member variables
[kdenlive] / src / dvdwizardmenu.h
1 /***************************************************************************
2  *   Copyright (C) 2009 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20
21 #ifndef DVDWIZARDMENU_H
22 #define DVDWIZARDMENU_H
23
24 #include <QWizardPage>
25 #include <QGraphicsScene>
26 #include <QGraphicsTextItem>
27 #include <QGraphicsPixmapItem>
28 #include <QGraphicsRectItem>
29
30 #include <KDebug>
31
32 #include "ui_dvdwizardmenu_ui.h"
33
34 class DvdScene : public QGraphicsScene
35 {
36
37 public:
38     DvdScene(QObject * parent = 0): QGraphicsScene(parent) {}
39     void setProfile(int width, int height) {
40         m_width = width;
41         m_height = height;
42         setSceneRect(0, 0, m_width, m_height);
43     }
44     int sceneWidth() const {
45         return m_width;
46     }
47     int sceneHeight() const {
48         return m_height;
49     }
50 private:
51     int m_width;
52     int m_height;
53 };
54
55 class DvdButton : public QGraphicsTextItem
56 {
57
58 public:
59     DvdButton(const QString & text): QGraphicsTextItem(text), m_target(0) {}
60     enum { Type = UserType + 1 };
61     void setTarget(int t) {
62         m_target = t;
63     }
64     int target() const {
65         return m_target;
66     }
67     int type() const {
68         // Enable the use of qgraphicsitem_cast with this item.
69         return Type;
70     }
71
72 private:
73     int m_target;
74
75
76 protected:
77
78     virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) {
79         if (change == ItemPositionChange && scene()) {
80
81             /*   QList<QGraphicsItem *> list = collidingItems();
82                if (!list.isEmpty()) {
83                    for (int i = 0; i < list.count(); i++) {
84                 if (list.at(i)->type() == Type) return pos();
85                    }
86                }
87             */
88             DvdScene *sc = static_cast < DvdScene * >(scene());
89             QRectF rect = QRectF(0, 0, sc->width(), sc->height());
90             QPointF newPos = value.toPointF();
91             if (!rect.contains(newPos)) {
92                 // Keep the item inside the scene rect.
93                 newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
94                 newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
95                 return newPos;
96             }
97         }
98         return QGraphicsItem::itemChange(change, value);
99     }
100
101 };
102
103
104 class DvdWizardMenu : public QWizardPage
105 {
106     Q_OBJECT
107
108 public:
109     explicit DvdWizardMenu(const QString &profile, QWidget * parent = 0);
110     virtual ~DvdWizardMenu();
111     virtual bool isComplete() const;
112     bool createMenu() const;
113     void createBackgroundImage(const QString &img1);
114     void createButtonImages(const QString &img1, const QString &img2, const QString &img3);
115     void setTargets(QStringList list);
116     QMap <int, QRect> buttonsInfo();
117     bool menuMovie() const;
118     QString menuMoviePath() const;
119     bool isPalMenu() const;
120
121 private:
122     Ui::DvdWizardMenu_UI m_view;
123     bool m_isPal;
124     DvdScene *m_scene;
125     QGraphicsPixmapItem *m_background;
126     QGraphicsRectItem *m_color;
127     QGraphicsRectItem *m_safeRect;
128     int m_width;
129     int m_height;
130     QStringList m_targets;
131
132 private slots:
133     void buildButton();
134     void buildColor();
135     void buildImage();
136     void checkBackground();
137     void checkBackgroundType(int ix);
138     void changeProfile(int ix);
139     void updatePreview();
140     void buttonChanged();
141     void addButton();
142     void setButtonTarget(int ix);
143     void deleteButton();
144     void updateColor();
145     void updateColor(QColor c);
146 };
147
148 #endif
149