1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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);
}
|