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>
39 class ExtensionsDialogProvider;
40 class ExtensionDialog;
43 class ExtensionsDialogProvider : public QObject
45 /** This is the dialog provider for Extensions dialogs
46 * @todo Make this class be a public Singleton<EDP>
47 * @todo Add a setExtManager() function (with vlc_object_hold)
53 static ExtensionsDialogProvider *instance;
54 intf_thread_t *p_intf;
55 extensions_manager_t *p_extensions_manager;
58 ExtensionDialog* CreateExtDialog( extension_dialog_t *p_dialog );
59 int DestroyExtDialog( extension_dialog_t *p_dialog );
60 ExtensionDialog* UpdateExtDialog( extension_dialog_t *p_dialog );
63 ExtensionsDialogProvider( intf_thread_t *p_intf,
64 extensions_manager_t *p_mgr );
65 virtual ~ExtensionsDialogProvider();
67 static ExtensionsDialogProvider* getInstance( intf_thread_t *p_intf = NULL,
68 extensions_manager_t *p_mgr = NULL )
72 assert( p_intf != NULL && p_mgr != NULL );
73 instance = new ExtensionsDialogProvider( p_intf, p_mgr );
77 static void killInstance()
83 void ManageDialog( extension_dialog_t *p_dialog );
86 void SignalDialog( extension_dialog_t *p_dialog );
90 class ExtensionDialog : public QDialog
94 intf_thread_t *p_intf;
95 extensions_manager_t *p_extensions_manager;
96 extension_t *p_extension;
97 extension_dialog_t *p_dialog;
98 bool has_lock; ///< Indicates whether Qt thread owns the lock
100 QSignalMapper *clickMapper;
101 QSignalMapper *inputMapper;
102 QSignalMapper *selectMapper;
104 QWidget *CreateWidget( extension_widget_t *p_widget );
105 QWidget *UpdateWidget( extension_widget_t *p_widget );
106 void DestroyWidget( extension_widget_t *p_widget, bool b_cond = true );
109 virtual void closeEvent( QCloseEvent* );
110 virtual void keyPressEvent( QKeyEvent* );
113 int TriggerClick( QObject *object );
114 void SyncInput( QObject *object );
115 void SyncSelection( QObject *object );
116 void parentDestroyed();
119 void destroyDialog( extension_dialog_t *p_dialog );
122 ExtensionDialog( intf_thread_t *p_intf,
123 extensions_manager_t *p_mgr,
124 extension_dialog_t *p_dialog );
125 virtual ~ExtensionDialog();
127 void UpdateWidgets();
129 // FIXME: This totally sucks (access to has_lock)
130 friend class ExtensionsDialogProvider;
133 class WidgetMapper : public QObject
137 extension_widget_t *p_widget;
139 WidgetMapper( extension_widget_t *_p_widget ) :
140 QObject(NULL), p_widget(_p_widget) {}
142 extension_widget_t* getWidget() { return p_widget; }
145 #endif // EXTENSIONS_HPP