Commit 143011b4 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Qt4: back-end for dialog_Progress

parent fcdea129
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QMessageBox> #include <QMessageBox>
#include <QProgressDialog>
#include <QMutex>
QVLCVariable::QVLCVariable (vlc_object_t *obj, const char *varname, int type) QVLCVariable::QVLCVariable (vlc_object_t *obj, const char *varname, int type)
: object (obj), name (qfu(varname)) : object (obj), name (qfu(varname))
...@@ -59,7 +61,8 @@ DialogHandler::DialogHandler (intf_thread_t *intf) ...@@ -59,7 +61,8 @@ DialogHandler::DialogHandler (intf_thread_t *intf)
: intf (intf), : intf (intf),
message (VLC_OBJECT(intf), "dialog-fatal", VLC_VAR_ADDRESS), message (VLC_OBJECT(intf), "dialog-fatal", VLC_VAR_ADDRESS),
login (VLC_OBJECT(intf), "dialog-login", VLC_VAR_ADDRESS), login (VLC_OBJECT(intf), "dialog-login", VLC_VAR_ADDRESS),
question (VLC_OBJECT(intf), "dialog-question", VLC_VAR_ADDRESS) question (VLC_OBJECT(intf), "dialog-question", VLC_VAR_ADDRESS),
progressBar (VLC_OBJECT(intf), "dialog-progress-bar", VLC_VAR_ADDRESS)
{ {
connect (&message, SIGNAL(pointerChanged(vlc_object_t *, void *)), connect (&message, SIGNAL(pointerChanged(vlc_object_t *, void *)),
SLOT(displayMessage(vlc_object_t *, void *)), SLOT(displayMessage(vlc_object_t *, void *)),
...@@ -70,6 +73,12 @@ DialogHandler::DialogHandler (intf_thread_t *intf) ...@@ -70,6 +73,12 @@ DialogHandler::DialogHandler (intf_thread_t *intf)
connect (&question, SIGNAL(pointerChanged(vlc_object_t *, void *)), connect (&question, SIGNAL(pointerChanged(vlc_object_t *, void *)),
SLOT(requestAnswer(vlc_object_t *, void *)), SLOT(requestAnswer(vlc_object_t *, void *)),
Qt::BlockingQueuedConnection); Qt::BlockingQueuedConnection);
connect (&progressBar, SIGNAL(pointerChanged(vlc_object_t *, void *)),
SLOT(startProgressBar(vlc_object_t *, void *)),
Qt::BlockingQueuedConnection);
connect (this,
SIGNAL(progressBarDestroyed(QWidget *)),
SLOT(stopProgressBar(QWidget *)));
dialog_Register (intf); dialog_Register (intf);
} }
...@@ -168,3 +177,69 @@ void DialogHandler::requestAnswer (vlc_object_t *, void *value) ...@@ -168,3 +177,69 @@ void DialogHandler::requestAnswer (vlc_object_t *, void *value)
delete box; delete box;
data->answer = answer; data->answer = answer;
} }
QVLCProgressDialog::QVLCProgressDialog (DialogHandler *parent,
struct dialog_progress_bar_t *data)
: QProgressDialog (qfu(data->message),
data->cancel ? ("&" + qfu(data->cancel)) : 0, 0, 1000),
cancelled (false),
handler (parent)
{
if (data->title != NULL)
setWindowTitle (qfu(data->title));
setMinimumDuration (0);
connect (this, SIGNAL(progressed(int)), SLOT(setValue(int)));
connect (this, SIGNAL(canceled(void)), SLOT(saveCancel(void)));
data->pf_update = update;
data->pf_check = check;
data->pf_destroy = destroy;
data->p_sys = this;
}
QVLCProgressDialog::~QVLCProgressDialog (void)
{
}
void QVLCProgressDialog::update (void *priv, float value)
{
QVLCProgressDialog *self = static_cast<QVLCProgressDialog *>(priv);
emit self->progressed ((int)(value * 1000.));
}
static QMutex cancel_mutex;
bool QVLCProgressDialog::check (void *priv)
{
QVLCProgressDialog *self = static_cast<QVLCProgressDialog *>(priv);
QMutexLocker locker (&cancel_mutex);
return self->cancelled;
}
void QVLCProgressDialog::destroy (void *priv)
{
QVLCProgressDialog *self = static_cast<QVLCProgressDialog *>(priv);
emit self->handler->progressBarDestroyed (self);
}
void QVLCProgressDialog::saveCancel (void)
{
QMutexLocker locker (&cancel_mutex);
cancelled = true;
}
void DialogHandler::startProgressBar (vlc_object_t *, void *value)
{
dialog_progress_bar_t *data = (dialog_progress_bar_t *)value;
QWidget *dlg = new QVLCProgressDialog (this, data);
dlg->show ();
}
void DialogHandler::stopProgressBar (QWidget *dlg)
{
delete dlg;
}
\ No newline at end of file
...@@ -42,10 +42,14 @@ signals: ...@@ -42,10 +42,14 @@ signals:
}; };
struct intf_thread_t; struct intf_thread_t;
class QProgressDialog;
class DialogHandler : public QObject class DialogHandler : public QObject
{ {
Q_OBJECT Q_OBJECT
friend class QVLCProgressDialog;
public: public:
DialogHandler (intf_thread_t *); DialogHandler (intf_thread_t *);
~DialogHandler (void); ~DialogHandler (void);
...@@ -55,11 +59,42 @@ private: ...@@ -55,11 +59,42 @@ private:
QVLCVariable message; QVLCVariable message;
QVLCVariable login; QVLCVariable login;
QVLCVariable question; QVLCVariable question;
QVLCVariable progressBar;
signals:
void progressBarDestroyed (QWidget *);
private slots: private slots:
void displayMessage (vlc_object_t *, void *); void displayMessage (vlc_object_t *, void *);
void requestLogin (vlc_object_t *, void *); void requestLogin (vlc_object_t *, void *);
void requestAnswer (vlc_object_t *, void *); void requestAnswer (vlc_object_t *, void *);
void startProgressBar (vlc_object_t *, void *);
void stopProgressBar (QWidget *);
};
/* Put here instead of .cpp because of MOC */
#include <QProgressDialog>
class QVLCProgressDialog : public QProgressDialog
{
Q_OBJECT
public:
QVLCProgressDialog (DialogHandler *parent,
struct dialog_progress_bar_t *);
virtual ~QVLCProgressDialog (void);
private:
DialogHandler *handler;
bool cancelled;
static void update (void *, float);
static bool check (void *);
static void destroy (void *);
private slots:
void saveCancel (void);
signals:
void progressed (int);
void destroyed (void);
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment