]> git.sesse.net Git - kdenlive/blob - src/dvdwizardvob.h
Rewrote DVD creation, should now support correctly 4:3 and 16:9 menus, letterbox...
[kdenlive] / src / dvdwizardvob.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 DVDWIZARDVOB_H
22 #define DVDWIZARDVOB_H
23
24 #include "ui_dvdwizardvob_ui.h"
25
26 #include <kdeversion.h>
27 #include <kcapacitybar.h>
28 #include <KUrl>
29
30 #if KDE_IS_VERSION(4,7,0)
31 #include <KMessageWidget>
32 #endif
33
34 #include <QWizardPage>
35 #include <QStyledItemDelegate>
36 #include <QPainter>
37
38 enum DVDFORMAT { PAL, PAL_WIDE, NTSC, NTSC_WIDE };
39
40 class DvdViewDelegate : public QStyledItemDelegate
41 {
42     Q_OBJECT
43 public:
44     DvdViewDelegate(QWidget *parent) : QStyledItemDelegate(parent) {}
45
46     void paint(QPainter *painter, const QStyleOptionViewItem &option,
47                const QModelIndex &index) const {
48         if (index.column() == 0) {
49             painter->save();
50             QStyleOptionViewItemV4 opt(option);
51             QRect r1 = option.rect;
52             QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
53             const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
54             style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
55
56             QPixmap pixmap = qVariantValue<QPixmap>(index.data(Qt::DecorationRole));
57             QPoint pixmapPoint(r1.left() + textMargin, r1.top() + (r1.height() - pixmap.height()) / 2);
58             painter->drawPixmap(pixmapPoint, pixmap);
59             int decoWidth = pixmap.width() + 2 * textMargin;
60
61             QFont font = painter->font();
62             font.setBold(true);
63             painter->setFont(font);
64             int mid = (int)((r1.height() / 2));
65             r1.adjust(decoWidth, 0, 0, -mid);
66             QRect r2 = option.rect;
67             r2.adjust(decoWidth, mid, 0, 0);
68             painter->drawText(r1, Qt::AlignLeft | Qt::AlignBottom, KUrl(index.data().toString()).fileName());
69             font.setBold(false);
70             painter->setFont(font);
71             QString subText = index.data(Qt::UserRole).toString();
72             QRectF bounding;
73             painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText, &bounding);
74             painter->restore();
75         } else QStyledItemDelegate::paint(painter, option, index);
76     }
77 };
78
79
80 class DvdWizardVob : public QWizardPage
81 {
82     Q_OBJECT
83
84 public:
85     explicit DvdWizardVob(QWidget * parent = 0);
86     virtual ~DvdWizardVob();
87     virtual bool isComplete() const;
88     QStringList selectedUrls() const;
89     void setUrl(const QString &url);
90     QString introMovie() const;
91     DVDFORMAT dvdFormat() const;
92     const QString dvdProfile() const;
93     int duration(int ix) const;
94     QStringList durations() const;
95     QStringList chapters() const;
96     void setProfile(const QString& profile);
97     void clear();
98     void updateChapters(QMap <QString, QString> chaptersdata);
99     void setIntroMovie(const QString& path);
100     static QString getDvdProfile(DVDFORMAT format);
101
102 private:
103     Ui::DvdWizardVob_UI m_view;
104     QString m_errorMessage;
105     KCapacityBar *m_capacityBar;
106 #if KDE_IS_VERSION(4,7,0)
107     KMessageWidget *m_warnMessage;
108 #endif
109
110 public slots:
111     void slotAddVobFile(KUrl url = KUrl(), const QString &chapters = QString());
112     void slotCheckProfiles();
113
114 private slots:
115     void slotCheckVobList();
116     void slotDeleteVobFile();
117     void slotItemUp();
118     void slotItemDown();
119     void changeFormat();
120 };
121
122 #endif
123