1 /*****************************************************************************
2 * extensions.hpp: Extensions manager for Qt: dialogs manager
3 ****************************************************************************
4 * Copyright (C) 2009-2010 VideoLAN and authors
7 * Authors: Jean-Philippe André < jpeg # videolan.org >
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef EXTENSIONS_HPP
25 #define EXTENSIONS_HPP
28 #include <vlc_extensions.h>
38 class ExtensionsDialogProvider;
39 class ExtensionDialog;
42 class ExtensionsDialogProvider : public QObject
44 /** This is the dialog provider for Extensions dialogs
45 * @todo Make this class be a public Singleton<EDP>
46 * @todo Add a setExtManager() function (with vlc_object_hold)
52 static ExtensionsDialogProvider *instance;
53 intf_thread_t *p_intf;
54 extensions_manager_t *p_extensions_manager;
57 ExtensionDialog* CreateExtDialog( extension_dialog_t *p_dialog );
58 int DestroyExtDialog( extension_dialog_t *p_dialog );
59 ExtensionDialog* UpdateExtDialog( extension_dialog_t *p_dialog );
62 ExtensionsDialogProvider( intf_thread_t *p_intf,
63 extensions_manager_t *p_mgr );
64 virtual ~ExtensionsDialogProvider();
66 static ExtensionsDialogProvider* getInstance( intf_thread_t *p_intf = NULL,
67 extensions_manager_t *p_mgr = NULL )
71 assert( p_intf != NULL && p_mgr != NULL );
72 instance = new ExtensionsDialogProvider( p_intf, p_mgr );
76 static void killInstance()
82 void ManageDialog( extension_dialog_t *p_dialog );
85 void SignalDialog( extension_dialog_t *p_dialog );
89 class ExtensionDialog : public QDialog
93 intf_thread_t *p_intf;
94 extensions_manager_t *p_extensions_manager;
95 extension_t *p_extension;
96 extension_dialog_t *p_dialog;
97 bool has_lock; ///< Indicates whether Qt thread owns the lock
99 QSignalMapper *clickMapper;
100 QSignalMapper *inputMapper;
101 QSignalMapper *selectMapper;
103 QWidget *CreateWidget( extension_widget_t *p_widget );
104 QWidget *UpdateWidget( extension_widget_t *p_widget );
105 void DestroyWidget( extension_widget_t *p_widget, bool b_cond = true );
108 virtual void closeEvent( QCloseEvent* );
111 int TriggerClick( QObject *object );
112 void SyncInput( QObject *object );
113 void SyncSelection( QObject *object );
114 void parentDestroyed();
117 void destroyDialog( extension_dialog_t *p_dialog );
120 ExtensionDialog( intf_thread_t *p_intf,
121 extensions_manager_t *p_mgr,
122 extension_dialog_t *p_dialog );
123 virtual ~ExtensionDialog();
125 void UpdateWidgets();
127 // FIXME: This totally sucks (access to has_lock)
128 friend class ExtensionsDialogProvider;
131 class WidgetMapper : public QObject
135 extension_widget_t *p_widget;
137 WidgetMapper( extension_widget_t *_p_widget ) :
138 QObject(NULL), p_widget(_p_widget) {}
140 extension_widget_t* getWidget() { return p_widget; }
143 #endif // EXTENSIONS_HPP