]> git.sesse.net Git - kdenlive/blob - src/dvdwizardvob.h
Merge branch 'master' into feature/pkey
[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 class DvdViewDelegate : public QStyledItemDelegate
39 {
40     Q_OBJECT
41 public:
42     DvdViewDelegate(QWidget *parent) : QStyledItemDelegate(parent) {}
43
44     void paint(QPainter *painter, const QStyleOptionViewItem &option,
45                const QModelIndex &index) const {
46         if (index.column() == 0) {
47             painter->save();
48             QStyleOptionViewItemV4 opt(option);
49             QRect r1 = option.rect;
50             QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
51             const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
52             style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
53
54             QPixmap pixmap = qVariantValue<QPixmap>(index.data(Qt::DecorationRole));
55             QPoint pixmapPoint(r1.left() + textMargin, r1.top() + (r1.height() - pixmap.height()) / 2);
56             painter->drawPixmap(pixmapPoint, pixmap);
57             int decoWidth = pixmap.width() + 2 * textMargin;
58
59             QFont font = painter->font();
60             font.setBold(true);
61             painter->setFont(font);
62             int mid = (int)((r1.height() / 2));
63             r1.adjust(decoWidth, 0, 0, -mid);
64             QRect r2 = option.rect;
65             r2.adjust(decoWidth, mid, 0, 0);
66             painter->drawText(r1, Qt::AlignLeft | Qt::AlignBottom, KUrl(index.data().toString()).fileName());
67             font.setBold(false);
68             painter->setFont(font);
69             QString subText = index.data(Qt::UserRole).toString();
70             QRectF bounding;
71             painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText, &bounding);
72             painter->restore();
73         } else QStyledItemDelegate::paint(painter, option, index);
74     }
75 };
76
77
78 class DvdWizardVob : public QWizardPage
79 {
80     Q_OBJECT
81
82 public:
83     explicit DvdWizardVob(const QString &profile, QWidget * parent = 0);
84     virtual ~DvdWizardVob();
85     virtual bool isComplete() const;
86     QStringList selectedUrls() const;
87     void setUrl(const QString &url);
88     QString introMovie() const;
89     bool isPal() const;
90     bool isWide() const;
91     int duration(int ix) const;
92     QStringList durations() const;
93     QStringList chapters() const;
94     void setProfile(const QString& profile);
95     void clear();
96     void updateChapters(QMap <QString, QString> chaptersdata);
97     void setIntroMovie(const QString& path);
98
99 private:
100     Ui::DvdWizardVob_UI m_view;
101     QString m_errorMessage;
102     KCapacityBar *m_capacityBar;
103 #if KDE_IS_VERSION(4,7,0)
104     KMessageWidget *m_warnMessage;
105 #endif
106
107 public slots:
108     void slotAddVobFile(KUrl url = KUrl(), const QString &chapters = QString());
109     void slotCheckProfiles();
110
111 private slots:
112     void slotCheckVobList();
113     void slotDeleteVobFile();
114     void slotItemUp();
115     void slotItemDown();
116     void changeFormat();
117 };
118
119 #endif
120