[vlc-devel] commit: Qt4: move QVLCVariable out of external dialogs ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sat May 16 12:01:46 CEST 2009
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat May 16 12:23:51 2009 +0300| [d15c20521f57f372561002be96dd7d5d200e587e] | committer: Rémi Denis-Courmont
Qt4: move QVLCVariable out of external dialogs
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d15c20521f57f372561002be96dd7d5d200e587e
---
modules/gui/qt4/Modules.am | 3 ++
modules/gui/qt4/dialogs/external.cpp | 23 ------------
modules/gui/qt4/dialogs/external.hpp | 26 +++-----------
modules/gui/qt4/variables.cpp | 67 ++++++++++++++++++++++++++++++++++
modules/gui/qt4/variables.hpp | 56 ++++++++++++++++++++++++++++
5 files changed, 131 insertions(+), 44 deletions(-)
diff --git a/modules/gui/qt4/Modules.am b/modules/gui/qt4/Modules.am
index ce0f73e..a863447 100644
--- a/modules/gui/qt4/Modules.am
+++ b/modules/gui/qt4/Modules.am
@@ -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 \
diff --git a/modules/gui/qt4/dialogs/external.cpp b/modules/gui/qt4/dialogs/external.cpp
index 4153470..af2818f 100644
--- a/modules/gui/qt4/dialogs/external.cpp
+++ b/modules/gui/qt4/dialogs/external.cpp
@@ -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),
diff --git a/modules/gui/qt4/dialogs/external.hpp b/modules/gui/qt4/dialogs/external.hpp
index d2894ef..dda635b 100644
--- a/modules/gui/qt4/dialogs/external.hpp
+++ b/modules/gui/qt4/dialogs/external.hpp
@@ -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 *);
diff --git a/modules/gui/qt4/variables.cpp b/modules/gui/qt4/variables.cpp
new file mode 100644
index 0000000..6dc2895
--- /dev/null
+++ b/modules/gui/qt4/variables.cpp
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * 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);
+}
diff --git a/modules/gui/qt4/variables.hpp b/modules/gui/qt4/variables.hpp
new file mode 100644
index 0000000..af6e65b
--- /dev/null
+++ b/modules/gui/qt4/variables.hpp
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * 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
More information about the vlc-devel
mailing list