summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclee <[email protected]>2007-03-29 09:31:13 +0000
committerclee <[email protected]>2007-03-29 09:31:13 +0000
commitceb981ea2c7406fac18dee17382976428a12b374 (patch)
treed8f421576aff6d75e0e4e82e2a3833437af2233b
parent42b83d67aac7b196b636f8d3b77be5017676fa3b (diff)
Importing the first (very much not-yet-ready-for-primetime) version of the Qt4 GUI for HandBrake into trunk.
Note: This is NOT fit for release yet. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@462 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--qt4/encodewidget.cpp39
-rw-r--r--qt4/encodewidget.h22
-rw-r--r--qt4/encodewidget.ui215
-rw-r--r--qt4/faderwidget.cpp86
-rw-r--r--qt4/faderwidget.h63
-rw-r--r--qt4/main.cpp11
-rw-r--r--qt4/qhandbrake.cpp128
-rw-r--r--qt4/qhandbrake.h30
-rw-r--r--qt4/qhandbrakewizard.cpp81
-rw-r--r--qt4/qhandbrakewizard.h44
-rw-r--r--qt4/qtHB.pro16
-rw-r--r--qt4/scanwidget.cpp151
-rw-r--r--qt4/scanwidget.h39
-rw-r--r--qt4/scanwidget.ui168
14 files changed, 1093 insertions, 0 deletions
diff --git a/qt4/encodewidget.cpp b/qt4/encodewidget.cpp
new file mode 100644
index 000000000..af22b80e5
--- /dev/null
+++ b/qt4/encodewidget.cpp
@@ -0,0 +1,39 @@
+#include <QtGui>
+
+#include "encodewidget.h"
+
+EncodeWidget::EncodeWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+
+ convertButton->setDisabled( true );
+
+ connect(convertButton, SIGNAL(clicked()), this, SIGNAL(convert()));
+}
+
+void EncodeWidget::setModel( QStandardItemModel *m )
+{
+ titleTree->setModel( m );
+ titleTree->setSelectionMode( QAbstractItemView::NoSelection );
+ titleTree->setRootIsDecorated( false );
+ titleTree->setFocusPolicy( Qt::NoFocus );
+
+ connect(titleTree->model(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), SLOT(changed()));
+}
+
+void EncodeWidget::changed()
+{
+ bool enable = false;
+
+ for( int row = 0; row < titleTree->model()->rowCount(); ++row )
+ {
+ QStandardItem *si = qobject_cast<QStandardItemModel *>(titleTree->model())->item( row, 0 );
+ if( si->checkState() == Qt::Checked )
+ {
+ enable = true;
+ }
+ }
+
+ convertButton->setEnabled( enable );
+}
diff --git a/qt4/encodewidget.h b/qt4/encodewidget.h
new file mode 100644
index 000000000..869dea5e1
--- /dev/null
+++ b/qt4/encodewidget.h
@@ -0,0 +1,22 @@
+#ifndef ENCODEWIDGET_H
+#define ENCODEWIDGET_H
+
+#include <QtGui>
+
+#include "ui_encodewidget.h"
+
+class EncodeWidget : public QWidget, private Ui::EncodeWidget
+{
+ Q_OBJECT
+public:
+ EncodeWidget( QWidget *parent = 0 );
+
+signals:
+ void convert();
+
+public slots:
+ void setModel( QStandardItemModel *m );
+ void changed();
+};
+
+#endif // ENCODEWIDGET_H
diff --git a/qt4/encodewidget.ui b/qt4/encodewidget.ui
new file mode 100644
index 000000000..e4a92aa5d
--- /dev/null
+++ b/qt4/encodewidget.ui
@@ -0,0 +1,215 @@
+<ui version="4.0" >
+ <class>EncodeWidget</class>
+ <widget class="QWidget" name="EncodeWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>440</height>
+ </rect>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>320</width>
+ <height>440</height>
+ </size>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="mainLabel" >
+ <property name="font" >
+ <font>
+ <family>sans</family>
+ <pointsize>14</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text" >
+ <string>Select DVD features</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="Line" name="line" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTreeView" name="titleTree" />
+ </item>
+ <item>
+ <widget class="QLabel" name="settingsLabel" >
+ <property name="font" >
+ <font>
+ <pointsize>14</pointsize>
+ <weight>75</weight>
+ <italic>false</italic>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text" >
+ <string>Settings</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>12</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="saveLabel" >
+ <property name="text" >
+ <string>Save converted files to:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="formatLabel" >
+ <property name="text" >
+ <string>File format:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="aspectLabel" >
+ <property name="text" >
+ <string>Picture format:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="audioLabel" >
+ <property name="text" >
+ <string>Preferred audio:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" >
+ <widget class="QLabel" name="subtitleLabel" >
+ <property name="text" >
+ <string>Preferred subtitles:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QComboBox" name="saveComboBox" />
+ </item>
+ <item row="1" column="1" >
+ <widget class="QComboBox" name="formatComboBox" />
+ </item>
+ <item row="2" column="1" >
+ <widget class="QComboBox" name="aspectComboBox" >
+ <item>
+ <property name="text" >
+ <string>Widescreen</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Fullscreen</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QComboBox" name="audioComboBox" />
+ </item>
+ <item row="4" column="1" >
+ <widget class="QComboBox" name="subtitleComboBox" />
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="statusLabel" >
+ <property name="text" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="titleProgress" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="openOtherButton" >
+ <property name="text" >
+ <string>Open another DVD...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="convertButton" >
+ <property name="text" >
+ <string>Convert</string>
+ </property>
+ <property name="autoDefault" >
+ <bool>true</bool>
+ </property>
+ <property name="default" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/qt4/faderwidget.cpp b/qt4/faderwidget.cpp
new file mode 100644
index 000000000..c8d95e82a
--- /dev/null
+++ b/qt4/faderwidget.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2006 Trolltech AS. All rights reserved.
+**
+** This file is part of the documentation of Qt. It was originally
+** published as part of Qt Quarterly.
+**
+** This file may be used under the terms of the GNU General Public License
+** version 2.0 as published by the Free Software Foundation or under the
+** terms of the Qt Commercial License Agreement. The respective license
+** texts for these are provided with the open source and commercial
+** editions of Qt.
+**
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://www.trolltech.com/products/qt/licensing.html or contact the
+** sales department at [email protected].
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "faderwidget.h"
+
+FaderWidget::FaderWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ if (parent) {
+ startColor = endColor = parent->palette().window().color();
+ } else {
+ startColor = endColor = Qt::white;
+ }
+
+ currentAlpha = 0;
+ duration = 333;
+ fadeOut = false;
+
+ timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), this, SLOT(update()));
+
+ setAttribute(Qt::WA_DeleteOnClose);
+ resize(parent->size());
+}
+
+void FaderWidget::start()
+{
+ currentAlpha = 255;
+ fadeOut = false;
+ timer->start(33);
+ show();
+}
+
+void FaderWidget::startFadeOut()
+{
+ currentAlpha = 0;
+ fadeOut = true;
+ timer->start(33);
+ show();
+}
+
+void FaderWidget::paintEvent(QPaintEvent * /* event */)
+{
+ QPainter painter(this);
+ QColor semiTransparentColor = startColor;
+ semiTransparentColor.setAlpha(currentAlpha);
+ painter.fillRect(rect(), semiTransparentColor);
+
+ if (fadeOut) {
+ currentAlpha += 255 * timer->interval() / duration;
+ if (currentAlpha >= 255) {
+ timer->stop();
+ emit done( (QWidget *)parent() );
+ close();
+ }
+ } else {
+ currentAlpha -= 255 * timer->interval() / duration;
+ if (currentAlpha <= 0) {
+ timer->stop();
+ emit done( (QWidget *)parent() );
+ close();
+ }
+ }
+}
diff --git a/qt4/faderwidget.h b/qt4/faderwidget.h
new file mode 100644
index 000000000..168d81c5e
--- /dev/null
+++ b/qt4/faderwidget.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2006 Trolltech AS. All rights reserved.
+**
+** This file is part of the documentation of Qt. It was originally
+** published as part of Qt Quarterly.
+**
+** This file may be used under the terms of the GNU General Public License
+** version 2.0 as published by the Free Software Foundation or under the
+** terms of the Qt Commercial License Agreement. The respective license
+** texts for these are provided with the open source and commercial
+** editions of Qt.
+**
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://www.trolltech.com/products/qt/licensing.html or contact the
+** sales department at [email protected].
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
+#ifndef FADERWIDGET_H
+#define FADERWIDGET_H
+
+#include <QWidget>
+
+class QTimer;
+
+class FaderWidget : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor fadeColor READ fadeColor WRITE setFadeColor)
+ Q_PROPERTY(int fadeDuration READ fadeDuration WRITE setFadeDuration)
+
+public:
+ FaderWidget(QWidget *parent);
+
+ QColor fadeColor() const { return startColor; }
+ void setFadeColor(const QColor &newColor) { startColor = newColor; }
+
+ int fadeDuration() const { return duration; }
+ void setFadeDuration(int milliseconds) { duration = milliseconds; }
+
+ void start();
+ void startFadeOut();
+
+signals:
+ void done(QWidget *w);
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private:
+ QTimer *timer;
+ QColor startColor, endColor;
+ bool fadeOut;
+ int currentAlpha;
+ int duration;
+};
+
+#endif
diff --git a/qt4/main.cpp b/qt4/main.cpp
new file mode 100644
index 000000000..9cb07179e
--- /dev/null
+++ b/qt4/main.cpp
@@ -0,0 +1,11 @@
+#include <QtGui>
+
+#include "qhandbrakewizard.h"
+
+int main(int argc, char **argv) {
+ QApplication app(argc, argv);
+ QHandBrakeWizard *wizard = new QHandBrakeWizard();
+
+ wizard->show();
+ return app.exec();
+}
diff --git a/qt4/qhandbrake.cpp b/qt4/qhandbrake.cpp
new file mode 100644
index 000000000..ba08975de
--- /dev/null
+++ b/qt4/qhandbrake.cpp
@@ -0,0 +1,128 @@
+#include "qhandbrake.h"
+
+QHandBrake::QHandBrake( QObject *parent ) : QObject( parent )
+{
+ hbHandle = hb_init_express( HB_DEBUG_NONE, 1 );
+ hbTitle = NULL;
+}
+
+QHandBrake::~QHandBrake()
+{
+ hb_close( &hbHandle );
+}
+
+QString displayDuration( const QTime t )
+{
+ return QString( "%1 %2, %3 %4, %5 %6").arg(t.hour()).arg(t.hour() == 1 ? "hour" : "hours").arg(t.minute()).arg(t.minute() == 1 ? "minute" : "minutes").arg(t.second()).arg(t.second() == 1 ? "second" : "seconds");
+}
+
+QStandardItemModel *QHandBrake::titleListModel()
+{
+ hb_list_t *hbTitles;
+ int i, titleCount;
+
+ hbTitles = hb_get_titles( hbHandle );
+ titleCount = hb_list_count( hbTitles );
+ titleModel = new QStandardItemModel( titleCount, 2, this );
+
+ titleModel->setHorizontalHeaderItem( 0, new QStandardItem("Title") );
+ titleModel->setHorizontalHeaderItem( 1, new QStandardItem("Duration") );
+
+ for( i = 0; i < titleCount; ++i )
+ {
+ hb_title_t *t = ( hb_title_t * )hb_list_item( hbTitles, i );
+
+ QTime d = QTime( t->hours, t->minutes, t->seconds );
+ QString s = QString( "Title %1" ).arg( t->index );
+ QStandardItem *siTitle = new QStandardItem( s );
+ QStandardItem *siDuration = new QStandardItem( displayDuration( d ) );
+ titleModel->setItem( i, 0, siTitle );
+ titleModel->setItem( i, 1, siDuration );
+
+ siTitle->setCheckable( true );
+ siTitle->setEditable( false );
+ siTitle->setData( i, Qt::UserRole );
+
+ siDuration->setEditable( false );
+ }
+
+ return titleModel;
+}
+
+void QHandBrake::startScan( const QString sDevice )
+{
+ hb_state_t s;
+ int titleCurrent = 0;
+ int titleCount = 0;
+
+ if( sDevice.isEmpty() )
+ {
+ qDebug("Passed an empty device/path");
+ return;
+ }
+
+ hb_scan( hbHandle, sDevice.toLocal8Bit(), 0 );
+
+ do {
+ hb_get_state( hbHandle, &s );
+ qApp->processEvents();
+ if( s.state == HB_STATE_SCANNING )
+ {
+ titleCurrent = s.param.scanning.title_cur;
+ titleCount = s.param.scanning.title_count;
+
+ if( titleCurrent > 0 )
+ {
+ emit scanProgress( titleCurrent, titleCount );
+ qApp->processEvents();
+ }
+ }
+ } while( s.state != HB_STATE_SCANDONE );
+
+ if( hb_list_count( hb_get_titles( hbHandle ) ) )
+ {
+ emit scanProgress( titleCount, titleCount );
+ }
+ else
+ {
+ qDebug("Scanning failed");
+ return;
+ }
+}
+
+void QHandBrake::encode()
+{
+ if( hbHandle == NULL )
+ {
+ qDebug("Encode called too early");
+ return;
+ }
+
+ int i;
+ hb_list_t *titles = hb_get_titles( hbHandle );
+
+ for( i = 0; i < titleModel->rowCount(); ++i )
+ {
+ QStandardItem *si = titleModel->item( i, 0 );
+ if( si->checkState() == Qt::Checked )
+ {
+ hbTitle = ( hb_title_t * )hb_list_item( titles, si->data( Qt::UserRole ).toInt() );
+ hb_job_t *job = hbTitle->job;
+ // FIXME hardcoded params here! need to fix
+ job->pixel_ratio = 1;
+ job->vcodec = HB_VCODEC_FFMPEG;
+ job->vquality = -1.0;
+ job->vbitrate = 1600;
+ job->acodec = HB_ACODEC_LAME;
+ job->audios[0] = -1;
+ job->mux = HB_MUX_MP4;
+ job->subtitle = -1;
+ job->pass = 0;
+ job->file = strdup("/tmp/foo.mp4");
+ hb_add( hbHandle, job );
+ }
+ }
+
+ fprintf(stderr, "Calling hb_start...\n");
+ hb_start( hbHandle );
+}
diff --git a/qt4/qhandbrake.h b/qt4/qhandbrake.h
new file mode 100644
index 000000000..35e4dcb6e
--- /dev/null
+++ b/qt4/qhandbrake.h
@@ -0,0 +1,30 @@
+#ifndef QHANDBRAKE_H
+#define QHANDBRAKE_H
+
+#include <QtGui>
+#include "hb.h"
+
+class QHandBrake : public QObject {
+ Q_OBJECT
+
+public:
+ QHandBrake(QObject *parent = 0);
+ ~QHandBrake();
+
+ QStandardItemModel *titleListModel();
+
+signals:
+ void scanProgress(int cur, int total);
+
+public slots:
+ void startScan(const QString sDevice);
+ void encode();
+
+private:
+ hb_handle_t *hbHandle;
+ hb_title_t *hbTitle;
+
+ QStandardItemModel *titleModel;
+};
+
+#endif // QHANDBRAKE_H
diff --git a/qt4/qhandbrakewizard.cpp b/qt4/qhandbrakewizard.cpp
new file mode 100644
index 000000000..c6de00c95
--- /dev/null
+++ b/qt4/qhandbrakewizard.cpp
@@ -0,0 +1,81 @@
+#include <QtGui>
+#include <QtDBus>
+
+#include "qhandbrakewizard.h"
+#include "qhandbrake.h"
+#include "faderwidget.h"
+#include "scanwidget.h"
+#include "encodewidget.h"
+
+
+#define HAL_SERVICE "org.freedesktop.Hal"
+#define HAL_PATH_MANAGER "/org/freedesktop/Hal/Manager"
+#define HAL_PATH_DEVICE "/org/freedesktop/Hal/Device"
+#define HAL_OBJECT_MANAGER "org.freedesktop.Hal.Manager"
+#define HAL_OBJECT_DEVICE "org.freedesktop.Hal.Device"
+
+
+Magic::Magic(QWidget *w, QHandBrakeWizard *q, QObject *p)
+ : QObject(p)
+{
+ m = w;
+ qm = q;
+}
+
+bool Magic::eventFilter(QObject *o, QEvent *e)
+{
+ if( e->type() == QEvent::Show ) {
+ qm->fadeInWidget( m );
+ return false;
+ }
+ return QObject::eventFilter(o, e);
+}
+
+void QHandBrakeWizard::fadeInWidget(QWidget *w)
+{
+ if( faderWidget ) { faderWidget->close(); }
+ faderWidget = new FaderWidget( w );
+ faderWidget->start();
+}
+
+QHandBrakeWizard::QHandBrakeWizard(QStackedWidget *parent)
+ : QStackedWidget(parent)
+{
+ qhb = new QHandBrake(this);
+
+ scanWidget = new ScanWidget;
+ encodeWidget = new EncodeWidget;
+
+ scanWidget->setObjectName("scanWidget");
+ encodeWidget->setObjectName("encodeWidget");
+
+ scanWidget->installEventFilter(new Magic(scanWidget, this, this));
+ encodeWidget->installEventFilter(new Magic(encodeWidget, this, this));
+
+ addWidget(scanWidget);
+
+ connect(scanWidget, SIGNAL(scanDVD(const QString)), qhb, SLOT(startScan(const QString)));
+ connect(scanWidget, SIGNAL(scanningDone()), SLOT(activateEncodePage()));
+ connect(qhb, SIGNAL(scanProgress(int, int)), scanWidget, SLOT(setProgress(int, int)));
+ connect(encodeWidget, SIGNAL(convert()), qhb, SLOT(encode()));
+
+ if( QDBusConnection::systemBus().isConnected() )
+ {
+ QDBusConnection::systemBus().connect( HAL_SERVICE, HAL_PATH_MANAGER, HAL_OBJECT_MANAGER, "DeviceAdded", scanWidget, SLOT( updateVolumeList( QString ) ) );
+ QDBusConnection::systemBus().connect( HAL_SERVICE, HAL_PATH_MANAGER, HAL_OBJECT_MANAGER, "DeviceRemoved", scanWidget, SLOT( updateVolumeList( QString ) ) );
+ }
+}
+
+void QHandBrakeWizard::activateScanPage()
+{
+ setCurrentWidget(scanWidget);
+}
+
+void QHandBrakeWizard::activateEncodePage()
+{
+ addWidget(encodeWidget);
+
+ encodeWidget->setModel( qhb->titleListModel() );
+
+ setCurrentWidget(encodeWidget);
+}
diff --git a/qt4/qhandbrakewizard.h b/qt4/qhandbrakewizard.h
new file mode 100644
index 000000000..ea4de6263
--- /dev/null
+++ b/qt4/qhandbrakewizard.h
@@ -0,0 +1,44 @@
+#ifndef QHANDBRAKEWIZARD_H
+#define QHANDBRAKEWIZARD_H
+
+#include <QtGui>
+
+typedef class QHandBrake;
+typedef class FaderWidget;
+typedef class ScanWidget;
+typedef class EncodeWidget;
+
+class QHandBrakeWizard : public QStackedWidget
+{
+ Q_OBJECT
+public:
+ QHandBrakeWizard(QStackedWidget *parent = 0);
+
+public slots:
+ void activateScanPage();
+ void activateEncodePage();
+
+ void fadeInWidget(QWidget *);
+
+private:
+ QPointer<QHandBrake> qhb;
+ QPointer<FaderWidget> faderWidget;
+ QPointer<ScanWidget> scanWidget;
+ QPointer<EncodeWidget> encodeWidget;
+};
+
+class Magic : public QObject
+{
+ Q_OBJECT
+public:
+ Magic(QWidget *w, QHandBrakeWizard *q, QObject *p = 0);
+
+protected:
+ bool eventFilter(QObject *o, QEvent *e);
+ QWidget *m;
+
+ friend class QHandBrakeWizard;
+ QHandBrakeWizard *qm;
+};
+
+#endif // QHANDBRAKEWIZARD_H
diff --git a/qt4/qtHB.pro b/qt4/qtHB.pro
new file mode 100644
index 000000000..6b9528a33
--- /dev/null
+++ b/qt4/qtHB.pro
@@ -0,0 +1,16 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Sat Oct 14 04:46:08 2006
+######################################################################
+
+TEMPLATE = app
+TARGET = qtHB
+CONFIG += qdbus release
+DEPENDPATH += .
+INCLUDEPATH += . ../libhb ../contrib/include
+LIBS += ../libhb/libhb.a ../contrib/lib/libx264.a ../contrib/lib/liba52.a ../contrib/lib/libavformat.a ../contrib/lib/libavcodec.a ../contrib/lib/libavutil.a ../contrib/lib/libmpeg2.a ../contrib/lib/libdvdread.a ../contrib/lib/libdvdcss.a ../contrib/lib/libfaac.a ../contrib/lib/libmp3lame.a -lz -lpthread -lvorbis -lvorbisenc -logg -lsamplerate -lxvidcore
+
+
+# Input
+HEADERS += qhandbrake.h scanwidget.h encodewidget.h qhandbrakewizard.h faderwidget.h
+FORMS += scanwidget.ui encodewidget.ui
+SOURCES += main.cpp qhandbrake.cpp scanwidget.cpp encodewidget.cpp qhandbrakewizard.cpp faderwidget.cpp
diff --git a/qt4/scanwidget.cpp b/qt4/scanwidget.cpp
new file mode 100644
index 000000000..21cb06cf3
--- /dev/null
+++ b/qt4/scanwidget.cpp
@@ -0,0 +1,151 @@
+#include <QtGui>
+#include <QtDBus>
+
+#include "scanwidget.h"
+
+#define HAL_SERVICE "org.freedesktop.Hal"
+#define HAL_PATH_MANAGER "/org/freedesktop/Hal/Manager"
+#define HAL_PATH_DEVICE "/org/freedesktop/Hal/Device"
+#define HAL_OBJECT_MANAGER "org.freedesktop.Hal.Manager"
+#define HAL_OBJECT_DEVICE "org.freedesktop.Hal.Device"
+
+ClickedField::ClickedField(QRadioButton *b, QObject *parent)
+ : QObject(parent)
+{
+ rb = b;
+}
+
+bool ClickedField::eventFilter(QObject *o, QEvent *e)
+{
+ if (e->type() == QEvent::FocusIn) {
+ rb->setChecked( true );
+ return false;
+ }
+ return QObject::eventFilter(o, e);
+}
+
+ScanWidget::ScanWidget( QWidget *parent )
+ : QWidget( parent )
+{
+ setupUi(this);
+
+ deviceRadioButton->setChecked( true );
+ devices = new QMap<QString, QString>;
+
+ deviceComboBox->installEventFilter( new ClickedField(deviceRadioButton, this) );
+ folderLineEdit->installEventFilter( new ClickedField(folderRadioButton, this) );
+ folderPushButton->installEventFilter( new ClickedField(folderRadioButton, this) );
+
+ progress->setMaximum( 1 );
+
+ updateVolumeList("bar");
+
+ connect( scanButton, SIGNAL( clicked() ), this, SLOT( goScan() ) );
+ connect( folderPushButton, SIGNAL( clicked() ), this, SLOT( setFolder() ) );
+}
+
+QMap<QString, QString> *ScanWidget::volumeList()
+{
+ if( devices->count() > 0 )
+ {
+ return devices;
+ }
+
+ if( !QDBusConnection::systemBus().isConnected() ) {
+ qDebug("Cannot connect to D-BUS session bus.");
+ return devices;
+ }
+
+ QDBusInterface hal( HAL_SERVICE, HAL_PATH_MANAGER , HAL_OBJECT_MANAGER, QDBusConnection::systemBus() );
+ if (!hal.isValid() ) {
+ qDebug( "Couldn't find HAL. Is HAL running?" );
+ return devices;
+ }
+
+ QDBusReply<QStringList> reply = hal.call( "FindDeviceStringMatch", "volume.disc.type", "dvd_rom" );
+ if( !reply.isValid() ) {
+ qDebug( "Couldn't call FindDeviceStringMatch." );
+ return devices;
+ }
+
+ if( reply.value().count() > 0 ) {
+ foreach ( QString udi, reply.value() ) {
+ QDBusInterface halDev( HAL_SERVICE, udi, HAL_OBJECT_DEVICE, QDBusConnection::systemBus() );
+ QDBusReply<bool> isVideo = halDev.call( "GetProperty", "volume.disc.is_videodvd" );
+ if( !isVideo.value() ) {
+ qDebug("This is a DVD, but not video");
+ continue;
+ }
+ QDBusReply<QString> d = halDev.call( "GetProperty", "block.device" );
+ QDBusReply<QString> v = halDev.call( "GetProperty", "volume.label" );
+ QRegExp rx("_S(\\d+)_D(\\d+)");
+ QString label = v.value();
+ rx.indexIn(label);
+ if (rx.numCaptures() > 0) {
+ label = label.replace(rx, QString(" Season %1 Disc %2").arg(rx.cap(1)).arg(rx.cap(2)));
+ } else {
+ label = label.replace("_", " ");
+ }
+ devices->insert( d.value(), label );
+ }
+ }
+ else
+ {
+ devices->insert( "none detected", "Insert a DVD..." );
+ }
+
+ return devices;
+}
+
+void ScanWidget::updateVolumeList(QString)
+{
+ if( devices->count() > 0 )
+ {
+ devices->clear();
+ deviceComboBox->clear();
+ }
+ QStringList d;
+ QMapIterator<QString, QString> i( *volumeList() );
+ while (i.hasNext()) {
+ i.next();
+ d << QString("%1 (%2)").arg(i.value()).arg(i.key());
+ }
+ deviceComboBox->addItems(d);
+}
+
+void ScanWidget::goScan()
+{
+ scanButton->setDisabled( true );
+
+ if( deviceRadioButton->isChecked() )
+ {
+ QRegExp rx(".*\\((.*)\\)");
+ rx.indexIn(deviceComboBox->currentText());
+ emit scanDVD( rx.cap(1) );
+ }
+ else if( folderRadioButton->isChecked() )
+ {
+ emit scanDVD( folderLineEdit->text() );
+ }
+}
+
+void ScanWidget::setProgress( int value, int maximum )
+{
+ if( progress->maximum() == 1 )
+ {
+ progress->setMaximum( maximum );
+ }
+
+ progress->setValue( value );
+
+ if( value == maximum )
+ {
+ emit scanningDone();
+ }
+}
+
+void ScanWidget::setFolder()
+{
+ QString folderPath = QFileDialog::getExistingDirectory();
+ folderLineEdit->setText( folderPath );
+}
diff --git a/qt4/scanwidget.h b/qt4/scanwidget.h
new file mode 100644
index 000000000..717c3f221
--- /dev/null
+++ b/qt4/scanwidget.h
@@ -0,0 +1,39 @@
+#ifndef CHOOSEDVD_H
+#define CHOOSEDVD_H
+
+#include <QtGui>
+
+#include "ui_scanwidget.h"
+
+class ClickedField : public QObject
+{
+ Q_OBJECT
+public:
+ ClickedField(QRadioButton *b, QObject *parent = 0);
+protected:
+ bool eventFilter(QObject *, QEvent *);
+ QRadioButton *rb;
+};
+
+class ScanWidget : public QWidget, private Ui::ScanWidget
+{
+ Q_OBJECT
+public:
+ ScanWidget(QWidget *parent = 0);
+ QMap<QString, QString> *volumeList();
+
+signals:
+ void scanDVD(const QString path);
+ void scanningDone();
+
+public slots:
+ void goScan();
+ void updateVolumeList(QString);
+ void setProgress(int value, int maximum);
+ void setFolder();
+
+private:
+ QMap<QString, QString> *devices;
+};
+
+#endif // CHOOSEDRIVE_H
diff --git a/qt4/scanwidget.ui b/qt4/scanwidget.ui
new file mode 100644
index 000000000..0d3e72c93
--- /dev/null
+++ b/qt4/scanwidget.ui
@@ -0,0 +1,168 @@
+<ui version="4.0" >
+ <class>ScanWidget</class>
+ <widget class="QWidget" name="ScanWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>320</width>
+ <height>300</height>
+ </size>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="mainLabel" >
+ <property name="text" >
+ <string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-size:14pt; font-weight:600;">Select DVD source&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="Line" name="line" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>6</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="0" column="0" >
+ <widget class="QRadioButton" name="deviceRadioButton" >
+ <property name="text" >
+ <string>DVD device</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QLineEdit" name="folderLineEdit" />
+ </item>
+ <item row="1" column="0" >
+ <widget class="QRadioButton" name="folderRadioButton" >
+ <property name="text" >
+ <string>DVD folder / image</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" >
+ <widget class="QPushButton" name="folderPushButton" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font" >
+ <font>
+ <pointsize>8</pointsize>
+ </font>
+ </property>
+ <property name="text" >
+ <string>Browse...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="2" >
+ <widget class="QComboBox" name="deviceComboBox" />
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="progress" >
+ <property name="value" >
+ <number>24</number>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="scanButton" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Scan</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>