]> git.sesse.net Git - kdenlive/blob - src/renderwidget.h
Comment out names of unused parameters [PATCH by Ray Lehtiniemi]
[kdenlive] / src / renderwidget.h
1 /***************************************************************************
2  *   Copyright (C) 2008 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 RENDERWIDGET_H
22 #define RENDERWIDGET_H
23
24 #include <QPushButton>
25 #include <QPainter>
26 #include <QItemDelegate>
27
28 #include "definitions.h"
29 #include "ui_renderwidget_ui.h"
30
31 class QDomElement;
32
33
34 // RenderViewDelegate is used to draw the progress bars.
35 class RenderViewDelegate : public QItemDelegate {
36     Q_OBJECT
37 public:
38     RenderViewDelegate(QWidget *parent) : QItemDelegate(parent) {}
39
40     void paint(QPainter *painter, const QStyleOptionViewItem &option,
41                const QModelIndex &index) const {
42         if (index.column() == 0) {
43             QItemDelegate::paint(painter, option, index);
44             return;
45         } else if (index.column() == 1) {
46             QRect r1 = option.rect;
47             painter->save();
48             if (option.state & (QStyle::State_Selected)) {
49                 painter->setPen(option.palette.color(QPalette::HighlightedText));
50                 painter->fillRect(r1, option.palette.highlight());
51             } else painter->setPen(option.palette.color(QPalette::Text));
52             QFont font = painter->font();
53             font.setBold(true);
54             painter->setFont(font);
55             int mid = (int)((r1.height() / 2));
56             r1.setBottom(r1.y() + mid);
57             QRect r2 = option.rect;
58             r2.setTop(r2.y() + mid);
59             painter->drawText(r1, Qt::AlignLeft | Qt::AlignBottom , index.data().toString());
60             font.setBold(false);
61             painter->setFont(font);
62             painter->setPen(option.palette.color(QPalette::Mid));
63             painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , index.data(Qt::UserRole).toString());
64             painter->restore();
65             return;
66         }
67         // Set up a QStyleOptionProgressBar to precisely mimic the
68         // environment of a progress bar.
69         QStyleOptionProgressBar progressBarOption;
70         progressBarOption.state = option.state;
71         progressBarOption.direction = QApplication::layoutDirection();
72         QRect rect = option.rect;
73         if (option.state & (QStyle::State_Selected)) {
74             painter->setPen(option.palette.color(QPalette::HighlightedText));
75             painter->fillRect(rect, option.palette.highlight());
76         }
77
78         int mid = rect.height() / 2;
79         rect.setTop(rect.top() + mid / 2);
80         rect.setHeight(mid);
81         progressBarOption.rect = rect;
82         progressBarOption.fontMetrics = QApplication::fontMetrics();
83         progressBarOption.minimum = 0;
84         progressBarOption.maximum = 100;
85         progressBarOption.textAlignment = Qt::AlignCenter;
86         progressBarOption.textVisible = true;
87
88         // Set the progress and text values of the style option.
89         int progress = index.data(Qt::UserRole).toInt();
90         progressBarOption.progress = progress < 0 ? 0 : progress;
91         progressBarOption.text = QString().sprintf("%d%%", progressBarOption.progress);
92
93         // Draw the progress bar onto the view.
94         QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter);
95     }
96 };
97
98
99 // RenderScriptDelegate is used to draw the script items.
100 class RenderScriptDelegate : public QItemDelegate {
101     Q_OBJECT
102 public:
103     RenderScriptDelegate(QWidget *parent) : QItemDelegate(parent) {}
104
105     void paint(QPainter *painter, const QStyleOptionViewItem &option,
106                const QModelIndex &index) const {
107         if (index.column() == 0) {
108             QRect r1 = option.rect;
109             painter->save();
110             if (option.state & (QStyle::State_Selected)) {
111                 painter->setPen(option.palette.color(QPalette::HighlightedText));
112                 painter->fillRect(r1, option.palette.highlight());
113             } else painter->setPen(option.palette.color(QPalette::Text));
114             QFont font = painter->font();
115             font.setBold(true);
116             painter->setFont(font);
117             int mid = (int)((r1.height() / 2));
118             r1.setBottom(r1.y() + mid);
119             r1.setLeft(r1.left() + 3);
120             QRect r2 = option.rect;
121             r2.setTop(r2.y() + mid);
122             r2.setLeft(r2.left() + 3);
123             painter->drawText(r1, Qt::AlignLeft | Qt::AlignBottom , index.data().toString());
124             font.setBold(false);
125             painter->setFont(font);
126             painter->setPen(option.palette.color(QPalette::Mid));
127             painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , index.data(Qt::UserRole).toString());
128             painter->restore();
129             return;
130         } else QItemDelegate::paint(painter, option, index);
131     }
132 };
133
134 class RenderWidget : public QDialog {
135     Q_OBJECT
136
137 public:
138     explicit RenderWidget(const QString &projectfolder, QWidget * parent = 0);
139     void setGuides(QDomElement guidesxml, double duration);
140     void focusFirstVisibleItem();
141     void setProfile(MltVideoProfile profile);
142     void setRenderJob(const QString &dest, int progress = 0);
143     void setRenderStatus(const QString &dest, int status, const QString &error);
144     void setDocumentPath(const QString path);
145     void reloadProfiles();
146
147 private slots:
148     void slotUpdateButtons(KUrl url);
149     void slotUpdateButtons();
150     void slotExport(bool scriptExport = false);
151     void refreshView();
152     void refreshParams();
153     void slotSaveProfile();
154     void slotEditProfile();
155     void slotDeleteProfile(bool refresh = true);
156     void slotUpdateGuideBox();
157     void slotCheckStartGuidePosition();
158     void slotCheckEndGuidePosition();
159     void showInfoPanel();
160     void slotAbortCurrentJob();
161     void slotStartScript();
162     void slotDeleteScript();
163     void slotGenerateScript();
164     void parseScriptFiles();
165     void slotCheckScript();
166     void slotCheckJob();
167     void slotEditItem(QListWidgetItem *item);
168
169 private:
170     Ui::RenderWidget_UI m_view;
171     MltVideoProfile m_profile;
172     QString m_projectFolder;
173     void parseProfiles(QString meta = QString(), QString group = QString(), QString profile = QString());
174     void parseFile(QString exportFile, bool editable);
175     void updateButtons();
176     KUrl filenameWithExtension(KUrl url, QString extension);
177
178 signals:
179     void doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double, bool, const QString &);
180     void abortProcess(const QString &url);
181     void openDvdWizard(const QString &url, const QString &profile);
182 };
183
184
185 #endif
186