00001 /***************************************************************************** 00002 * extensions.hpp: Extensions manager for Qt: dialogs manager 00003 **************************************************************************** 00004 * Copyright (C) 2009-2010 VideoLAN and authors 00005 * $Id: dafb12e10e81758ffbc113e0f110ee5f8f580cfe $ 00006 * 00007 * Authors: Jean-Philippe André < jpeg # videolan.org > 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00022 *****************************************************************************/ 00023 00024 #ifndef EXTENSIONS_HPP 00025 #define EXTENSIONS_HPP 00026 00027 #include "qt4.hpp" 00028 #include <vlc_extensions.h> 00029 00030 #include "assert.h" 00031 00032 #include <QDialog> 00033 class QObject; 00034 class QGridLayout; 00035 class QSignalMapper; 00036 class QCloseEvent; 00037 00038 class ExtensionsDialogProvider; 00039 class ExtensionDialog; 00040 class WidgetMapper; 00041 00042 class ExtensionsDialogProvider : public QObject 00043 { 00044 /** This is the dialog provider for Extensions dialogs 00045 * @todo Make this class be a public Singleton<EDP> 00046 * @todo Add a setExtManager() function (with vlc_object_hold) 00047 **/ 00048 00049 Q_OBJECT 00050 00051 private: 00052 static ExtensionsDialogProvider *instance; 00053 intf_thread_t *p_intf; 00054 extensions_manager_t *p_extensions_manager; 00055 00056 private slots: 00057 ExtensionDialog* CreateExtDialog( extension_dialog_t *p_dialog ); 00058 int DestroyExtDialog( extension_dialog_t *p_dialog ); 00059 ExtensionDialog* UpdateExtDialog( extension_dialog_t *p_dialog ); 00060 00061 public: 00062 ExtensionsDialogProvider( intf_thread_t *p_intf, 00063 extensions_manager_t *p_mgr ); 00064 virtual ~ExtensionsDialogProvider(); 00065 00066 static ExtensionsDialogProvider* getInstance( intf_thread_t *p_intf = NULL, 00067 extensions_manager_t *p_mgr = NULL ) 00068 { 00069 if( !instance ) 00070 { 00071 assert( p_intf != NULL && p_mgr != NULL ); 00072 instance = new ExtensionsDialogProvider( p_intf, p_mgr ); 00073 } 00074 return instance; 00075 } 00076 static void killInstance() 00077 { 00078 delete instance; 00079 instance = NULL; 00080 } 00081 00082 void ManageDialog( extension_dialog_t *p_dialog ); 00083 00084 signals: 00085 void SignalDialog( extension_dialog_t *p_dialog ); 00086 }; 00087 00088 00089 class ExtensionDialog : public QDialog 00090 { 00091 Q_OBJECT 00092 private: 00093 intf_thread_t *p_intf; 00094 extensions_manager_t *p_extensions_manager; 00095 extension_t *p_extension; 00096 extension_dialog_t *p_dialog; 00097 bool has_lock; ///< Indicates whether Qt thread owns the lock 00098 QGridLayout *layout; 00099 QSignalMapper *clickMapper; 00100 QSignalMapper *inputMapper; 00101 QSignalMapper *selectMapper; 00102 00103 QWidget *CreateWidget( extension_widget_t *p_widget ); 00104 QWidget *UpdateWidget( extension_widget_t *p_widget ); 00105 void DestroyWidget( extension_widget_t *p_widget, bool b_cond = true ); 00106 00107 protected: 00108 virtual void closeEvent( QCloseEvent* ); 00109 00110 private slots: 00111 int TriggerClick( QObject *object ); 00112 void SyncInput( QObject *object ); 00113 void SyncSelection( QObject *object ); 00114 void parentDestroyed(); 00115 00116 signals: 00117 void destroyDialog( extension_dialog_t *p_dialog ); 00118 00119 public: 00120 ExtensionDialog( intf_thread_t *p_intf, 00121 extensions_manager_t *p_mgr, 00122 extension_dialog_t *p_dialog ); 00123 virtual ~ExtensionDialog(); 00124 00125 void UpdateWidgets(); 00126 00127 // FIXME: This totally sucks (access to has_lock) 00128 friend class ExtensionsDialogProvider; 00129 }; 00130 00131 class WidgetMapper : public QObject 00132 { 00133 Q_OBJECT 00134 private: 00135 extension_widget_t *p_widget; 00136 public: 00137 WidgetMapper( extension_widget_t *_p_widget ) : 00138 QObject(NULL), p_widget(_p_widget) {} 00139 ~WidgetMapper() {} 00140 extension_widget_t* getWidget() { return p_widget; } 00141 }; 00142 00143 #endif // EXTENSIONS_HPP
1.5.6