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

Qt4: move QVLCVariable out of external dialogs

parent 692ee11c
......@@ -21,6 +21,7 @@ nodist_SOURCES_qt4 = \
input_manager.moc.cpp \
actions_manager.moc.cpp \
recents.moc.cpp \
variables.moc.cpp \
dialogs/playlist.moc.cpp \
dialogs/bookmarks.moc.cpp \
dialogs/mediainfo.moc.cpp \
......@@ -195,6 +196,7 @@ SOURCES_qt4 = qt4.cpp \
input_manager.cpp \
actions_manager.cpp \
recents.cpp \
variables.cpp \
dialogs/playlist.cpp \
dialogs/bookmarks.cpp \
dialogs/preferences.cpp \
......@@ -241,6 +243,7 @@ noinst_HEADERS = \
input_manager.hpp \
actions_manager.hpp \
recents.hpp \
variables.hpp \
dialogs/playlist.hpp \
dialogs/bookmarks.hpp \
dialogs/mediainfo.hpp \
......
......@@ -36,29 +36,6 @@
#include <QProgressDialog>
#include <QMutex>
QVLCVariable::QVLCVariable (vlc_object_t *obj, const char *varname, int type)
: object (obj), name (qfu(varname))
{
var_Create (object, qtu(name), type);
var_AddCallback (object, qtu(name), callback, this);
}
QVLCVariable::~QVLCVariable (void)
{
var_DelCallback (object, qtu(name), callback, this);
var_Destroy (object, qtu(name));
}
int QVLCVariable::callback (vlc_object_t *object, const char *,
vlc_value_t, vlc_value_t cur, void *data)
{
QVLCVariable *self = (QVLCVariable *)data;
emit self->pointerChanged (object, cur.p_address);
return VLC_SUCCESS;
}
DialogHandler::DialogHandler (intf_thread_t *intf)
: intf (intf),
message (VLC_OBJECT(intf), "dialog-fatal", VLC_VAR_ADDRESS),
......
......@@ -23,23 +23,7 @@
#include <QObject>
#include <vlc_common.h>
class QVLCVariable : public QObject
{
Q_OBJECT
private:
static int callback (vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void *);
vlc_object_t *object;
QString name;
public:
QVLCVariable (vlc_object_t *, const char *, int);
virtual ~QVLCVariable (void);
signals:
void pointerChanged (vlc_object_t *, void *);
};
#include "variables.hpp"
struct intf_thread_t;
class QProgressDialog;
......@@ -56,10 +40,10 @@ public:
private:
intf_thread_t *intf;
QVLCVariable message;
QVLCVariable login;
QVLCVariable question;
QVLCVariable progressBar;
QVLCPointer message;
QVLCPointer login;
QVLCPointer question;
QVLCPointer progressBar;
signals:
void progressBarDestroyed (QWidget *);
......
/*****************************************************************************
* variables.cpp : VLC variable class
****************************************************************************
* Copyright (C) 2009 Rémi Denis-Courmont
* Copyright (C) 2006 the VideoLAN team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "qt4.hpp"
#include "variables.hpp"
QVLCVariable::QVLCVariable (vlc_object_t *obj, const char *varname, int type,
bool inherit)
: object (obj), name (qfu(varname))
{
vlc_object_hold (object);
if (inherit)
type |= VLC_VAR_DOINHERIT;
var_Create (object, qtu(name), type);
var_AddCallback (object, qtu(name), callback, this);
}
QVLCVariable::~QVLCVariable (void)
{
var_DelCallback (object, qtu(name), callback, this);
var_Destroy (object, qtu(name));
vlc_object_release (object);
}
int QVLCVariable::callback (vlc_object_t *object, const char *,
vlc_value_t old, vlc_value_t cur, void *data)
{
QVLCVariable *self = static_cast<QVLCVariable *>(data);
self->trigger (self->object, old, cur);
return VLC_SUCCESS;
}
QVLCPointer::QVLCPointer (vlc_object_t *obj, const char *varname, bool inherit)
: QVLCVariable (obj, varname, VLC_VAR_ADDRESS, inherit)
{
}
void QVLCPointer::trigger (vlc_object_t *obj, vlc_value_t old, vlc_value_t cur)
{
emit pointerChanged (obj, old.p_address, cur.p_address);
emit pointerChanged (obj, cur.p_address);
}
/*****************************************************************************
* external.hpp : Dialogs from other LibVLC core and other plugins
****************************************************************************
* Copyright (C) 2009 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef QVLC_VARIABLES_H_
#define QVLC_VARIABLES_H_ 1
#include <QObject>
#include <vlc_common.h>
class QVLCVariable : public QObject
{
Q_OBJECT
private:
static int callback (vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void *);
vlc_object_t *object;
QString name;
virtual void trigger (vlc_object_t *, vlc_value_t, vlc_value_t) = 0;
public:
QVLCVariable (vlc_object_t *, const char *, int, bool);
virtual ~QVLCVariable (void);
};
class QVLCPointer : public QVLCVariable
{
Q_OBJECT
private:
virtual void trigger (vlc_object_t *, vlc_value_t, vlc_value_t);
public:
QVLCPointer (vlc_object_t *, const char *, bool inherit = false);
signals:
void pointerChanged (vlc_object_t *, void *, void *);
void pointerChanged (vlc_object_t *, void *);
};
#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