Commit 423f5d1b authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen Committed by Jean-Baptiste Kempf

Qt: Use the singleton class, to simplify the code

Use the generic singleton for Bookmarks, ErrorsDialog, extended dialog, GotoTime dialog, every help class, MediaInfo, Messages, OpenURL, Playlist, Plugin, Podcast configuration and VLM. Also fix some memleaks when quitting
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 120a9af2
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#include <QSpacerItem> #include <QSpacerItem>
#include <QPushButton> #include <QPushButton>
BookmarksDialog *BookmarksDialog::instance = NULL;
BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf ):QVLCFrame( _p_intf ) BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf ):QVLCFrame( _p_intf )
{ {
setWindowFlags( Qt::Tool ); setWindowFlags( Qt::Tool );
......
...@@ -29,27 +29,15 @@ ...@@ -29,27 +29,15 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QTreeView> #include <QTreeView>
#include <QTreeWidget> #include <QTreeWidget>
#include "util/singleton.hpp"
class BookmarksDialog : public QVLCFrame class BookmarksDialog : public QVLCFrame, public Singleton<BookmarksDialog>
{ {
Q_OBJECT; Q_OBJECT;
public:
static BookmarksDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance )
instance = new BookmarksDialog( p_intf );
return instance;
}
static void killInstance()
{
delete instance;
instance = NULL;
}
private: private:
BookmarksDialog( intf_thread_t * ); BookmarksDialog( intf_thread_t * );
virtual ~BookmarksDialog(); virtual ~BookmarksDialog();
static BookmarksDialog *instance;
QTreeWidget *bookmarksList; QTreeWidget *bookmarksList;
private slots: private slots:
...@@ -60,6 +48,8 @@ private slots: ...@@ -60,6 +48,8 @@ private slots:
void edit( QTreeWidgetItem *item, int column ); void edit( QTreeWidgetItem *item, int column );
void extract(); void extract();
void activateItem( QModelIndex index ); void activateItem( QModelIndex index );
friend class Singleton<BookmarksDialog>;
}; };
#endif #endif
......
...@@ -34,10 +34,8 @@ ...@@ -34,10 +34,8 @@
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QPushButton> #include <QPushButton>
ErrorsDialog *ErrorsDialog::instance = NULL; ErrorsDialog::ErrorsDialog( intf_thread_t *_p_intf )
: QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
ErrorsDialog::ErrorsDialog( QWidget *parent, intf_thread_t *_p_intf )
: QVLCDialog( parent, _p_intf )
{ {
setWindowTitle( qtr( "Errors" ) ); setWindowTitle( qtr( "Errors" ) );
setWindowRole( "vlc-errors" ); setWindowRole( "vlc-errors" );
......
...@@ -25,29 +25,23 @@ ...@@ -25,29 +25,23 @@
#define QVLC_ERRORS_DIALOG_H_ 1 #define QVLC_ERRORS_DIALOG_H_ 1
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "util/singleton.hpp"
class QPushButton; class QPushButton;
class QCheckBox; class QCheckBox;
class QGridLayout; class QGridLayout;
class QTextEdit; class QTextEdit;
class ErrorsDialog : public QVLCDialog class ErrorsDialog : public QVLCDialog, public Singleton<ErrorsDialog>
{ {
Q_OBJECT; Q_OBJECT;
public: public:
static ErrorsDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance)
instance = new ErrorsDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf );
return instance;
}
virtual ~ErrorsDialog() {};
void addError( const QString&, const QString& ); void addError( const QString&, const QString& );
/*void addWarning( QString, QString );*/ /*void addWarning( QString, QString );*/
private: private:
ErrorsDialog( QWidget *parent, intf_thread_t * ); virtual ~ErrorsDialog() {};
static ErrorsDialog *instance; ErrorsDialog( intf_thread_t * );
void add( bool, const QString&, const QString& ); void add( bool, const QString&, const QString& );
QCheckBox *stopShowing; QCheckBox *stopShowing;
...@@ -56,6 +50,8 @@ private slots: ...@@ -56,6 +50,8 @@ private slots:
void close(); void close();
void clear(); void clear();
void dontShow(); void dontShow();
friend class Singleton<ErrorsDialog>;
}; };
#endif #endif
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
#include <QTabWidget> #include <QTabWidget>
#include <QGridLayout> #include <QGridLayout>
ExtendedDialog *ExtendedDialog::instance = NULL;
ExtendedDialog::ExtendedDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf ) ExtendedDialog::ExtendedDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf )
{ {
setWindowFlags( Qt::Tool ); setWindowFlags( Qt::Tool );
......
...@@ -27,38 +27,28 @@ ...@@ -27,38 +27,28 @@
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "components/extended_panels.hpp" #include "components/extended_panels.hpp"
#include "util/singleton.hpp"
class QTabWidget; class QTabWidget;
class ExtendedDialog : public QVLCFrame class ExtendedDialog : public QVLCFrame, public Singleton<ExtendedDialog>
{ {
Q_OBJECT; Q_OBJECT;
public: public:
static ExtendedDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance)
instance = new ExtendedDialog( p_intf );
return instance;
}
static void killInstance()
{
delete instance;
instance = NULL;
}
void showTab( int i ); void showTab( int i );
int currentTab(); int currentTab();
private: private:
ExtendedDialog( intf_thread_t * ); ExtendedDialog( intf_thread_t * );
virtual ~ExtendedDialog(); virtual ~ExtendedDialog();
static ExtendedDialog *instance;
SyncControls *syncW; SyncControls *syncW;
ExtVideo *videoEffect; ExtVideo *videoEffect;
Equalizer *equal; Equalizer *equal;
QTabWidget *mainTabW; QTabWidget *mainTabW;
private slots: private slots:
void changedItem( int ); void changedItem( int );
friend class Singleton<ExtendedDialog>;
}; };
#endif #endif
......
...@@ -34,10 +34,8 @@ ...@@ -34,10 +34,8 @@
#include <QGroupBox> #include <QGroupBox>
#include <QDialogButtonBox> #include <QDialogButtonBox>
GotoTimeDialog *GotoTimeDialog::instance = NULL; GotoTimeDialog::GotoTimeDialog( intf_thread_t *_p_intf)
: QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
GotoTimeDialog::GotoTimeDialog( QWidget *parent, intf_thread_t *_p_intf)
: QVLCDialog( parent, _p_intf )
{ {
setWindowFlags( Qt::Tool ); setWindowFlags( Qt::Tool );
setWindowTitle( qtr( "Go to Time" ) ); setWindowTitle( qtr( "Go to Time" ) );
......
...@@ -25,28 +25,22 @@ ...@@ -25,28 +25,22 @@
#define QVLC_GOTOTIME_DIALOG_H_ 1 #define QVLC_GOTOTIME_DIALOG_H_ 1
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "util/singleton.hpp"
class QTimeEdit; class QTimeEdit;
class GotoTimeDialog : public QVLCDialog class GotoTimeDialog : public QVLCDialog, public Singleton<GotoTimeDialog>
{ {
Q_OBJECT; Q_OBJECT;
public:
static GotoTimeDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance)
instance = new GotoTimeDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf );
return instance;
}
virtual ~GotoTimeDialog();
private: private:
GotoTimeDialog( QWidget *, intf_thread_t * ); GotoTimeDialog( intf_thread_t * );
static GotoTimeDialog *instance; virtual ~GotoTimeDialog();
QTimeEdit *timeEdit; QTimeEdit *timeEdit;
private slots: private slots:
void close(); void close();
void cancel(); void cancel();
friend class Singleton<GotoTimeDialog>;
}; };
#endif #endif
...@@ -47,8 +47,6 @@ ...@@ -47,8 +47,6 @@
#include <assert.h> #include <assert.h>
HelpDialog *HelpDialog::instance = NULL;
HelpDialog::HelpDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) HelpDialog::HelpDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{ {
...@@ -80,10 +78,8 @@ void HelpDialog::close() ...@@ -80,10 +78,8 @@ void HelpDialog::close()
toggleVisible(); toggleVisible();
} }
AboutDialog *AboutDialog::instance = NULL; AboutDialog::AboutDialog( intf_thread_t *_p_intf)
: QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
AboutDialog::AboutDialog( QWidget *parent, intf_thread_t *_p_intf)
: QVLCDialog( parent, _p_intf )
{ {
setWindowTitle( qtr( "About" ) ); setWindowTitle( qtr( "About" ) );
setWindowRole( "vlc-about" ); setWindowRole( "vlc-about" );
...@@ -198,8 +194,6 @@ static void UpdateCallback( void *data, bool b_ret ) ...@@ -198,8 +194,6 @@ static void UpdateCallback( void *data, bool b_ret )
QApplication::postEvent( UDialog, event ); QApplication::postEvent( UDialog, event );
} }
UpdateDialog *UpdateDialog::instance = NULL;
UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{ {
setWindowTitle( qtr( "VLC media player updates" ) ); setWindowTitle( qtr( "VLC media player updates" ) );
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "qt4.hpp" #include "qt4.hpp"
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "util/singleton.hpp"
class QPushButton; class QPushButton;
class QTextBrowser; class QTextBrowser;
...@@ -39,50 +40,32 @@ class QEvent; ...@@ -39,50 +40,32 @@ class QEvent;
class QPushButton; class QPushButton;
class QTextEdit; class QTextEdit;
class HelpDialog : public QVLCFrame class HelpDialog : public QVLCFrame, public Singleton<HelpDialog>
{ {
Q_OBJECT; Q_OBJECT;
public:
static HelpDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance)
instance = new HelpDialog( p_intf );
return instance;
}
static void killInstance()
{ delete instance; instance = NULL;}
private: private:
HelpDialog( intf_thread_t * ); HelpDialog( intf_thread_t * );
virtual ~HelpDialog(); virtual ~HelpDialog();
static HelpDialog *instance;
public slots: public slots:
void close(); void close();
friend class Singleton<HelpDialog>;
}; };
class AboutDialog : public QVLCDialog class AboutDialog : public QVLCDialog, public Singleton<AboutDialog>
{ {
Q_OBJECT; Q_OBJECT;
public:
static AboutDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance)
instance = new AboutDialog( (QWidget *)p_intf->p_sys->p_mi,
p_intf );
return instance;
}
private: private:
AboutDialog( QWidget *, intf_thread_t * ); AboutDialog( intf_thread_t * );
virtual ~AboutDialog(); virtual ~AboutDialog();
static AboutDialog *instance;
public slots: public slots:
void close(); void close();
friend class Singleton<AboutDialog>;
}; };
#ifdef UPDATE_CHECK #ifdef UPDATE_CHECK
...@@ -90,27 +73,16 @@ public slots: ...@@ -90,27 +73,16 @@ public slots:
static const int UDOkEvent = QEvent::User + DialogEventType + 21; static const int UDOkEvent = QEvent::User + DialogEventType + 21;
static const int UDErrorEvent = QEvent::User + DialogEventType + 22; static const int UDErrorEvent = QEvent::User + DialogEventType + 22;
class UpdateDialog : public QVLCFrame class UpdateDialog : public QVLCFrame, public Singleton<UpdateDialog>
{ {
Q_OBJECT; Q_OBJECT;
public: public:
static UpdateDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance )
instance = new UpdateDialog( p_intf );
return instance;
}
static void killInstance()
{ delete instance; instance = NULL;}
void updateNotify( bool ); void updateNotify( bool );
private: private:
UpdateDialog( intf_thread_t * ); UpdateDialog( intf_thread_t * );
virtual ~UpdateDialog(); virtual ~UpdateDialog();
static UpdateDialog *instance;
update_t *p_update; update_t *p_update;
QPushButton *updateButton; QPushButton *updateButton;
QLabel *updateLabelTop; QLabel *updateLabelTop;
...@@ -122,6 +94,8 @@ private: ...@@ -122,6 +94,8 @@ private:
private slots: private slots:
void close(); void close();
void UpdateOrDownload(); void UpdateOrDownload();
friend class Singleton<UpdateDialog>;
}; };
#endif #endif
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
#include <QLineEdit> #include <QLineEdit>
#include <QLabel> #include <QLabel>
MediaInfoDialog *MediaInfoDialog::instance = NULL;
/* This Dialog has two main modes: /* This Dialog has two main modes:
- General Mode that shows the current Played item, and the stats - General Mode that shows the current Played item, and the stats
- Single mode that shows the info on ONE SINGLE Item on the playlist - Single mode that shows the info on ONE SINGLE Item on the playlist
......
...@@ -27,27 +27,16 @@ ...@@ -27,27 +27,16 @@
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "components/info_panels.hpp" #include "components/info_panels.hpp"
#include "util/singleton.hpp"
class QTabWidget; class QTabWidget;
class MediaInfoDialog : public QVLCFrame class MediaInfoDialog : public QVLCFrame, public Singleton<MediaInfoDialog>
{ {
Q_OBJECT; Q_OBJECT;
public: public:
MediaInfoDialog( intf_thread_t *, MediaInfoDialog( intf_thread_t *,
input_item_t * ); input_item_t * input = NULL );
static MediaInfoDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance) instance = new MediaInfoDialog( p_intf, NULL );
return instance;
}
static void killInstance()
{
delete instance;
instance = NULL;
}
void showTab( int ); void showTab( int );
#if 0 #if 0
...@@ -57,7 +46,6 @@ public: ...@@ -57,7 +46,6 @@ public:
private: private:
virtual ~MediaInfoDialog(); virtual ~MediaInfoDialog();
static MediaInfoDialog *instance;
bool isMainInputInfo; bool isMainInputInfo;
QTabWidget *infoTabW; QTabWidget *infoTabW;
...@@ -77,6 +65,8 @@ private slots: ...@@ -77,6 +65,8 @@ private slots:
void saveMeta(); void saveMeta();
void updateButtons( int i_tab ); void updateButtons( int i_tab );
friend class Singleton<MediaInfoDialog>;
}; };
#endif #endif
...@@ -41,8 +41,6 @@ ...@@ -41,8 +41,6 @@
#include <assert.h> #include <assert.h>
MessagesDialog *MessagesDialog::instance = NULL;
enum { enum {
MsgEvent_Type = QEvent::User + MsgEventType + 1, MsgEvent_Type = QEvent::User + MsgEventType + 1,
}; };
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define QVLC_MESSAGES_DIALOG_H_ 1 #define QVLC_MESSAGES_DIALOG_H_ 1
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "util/singleton.hpp"
class QTabWidget; class QTabWidget;
class QPushButton; class QPushButton;
...@@ -35,28 +36,13 @@ class QTextEdit; ...@@ -35,28 +36,13 @@ class QTextEdit;
class QTreeWidget; class QTreeWidget;
class QTreeWidgetItem; class QTreeWidgetItem;
class MessagesDialog : public QVLCFrame class MessagesDialog : public QVLCFrame, public Singleton<MessagesDialog>
{ {
Q_OBJECT; Q_OBJECT;
public:
static MessagesDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance)
instance = new MessagesDialog( p_intf );
return instance;
}
static void killInstance()
{
delete instance;
instance = NULL;
}
private: private:
MessagesDialog( intf_thread_t * ); MessagesDialog( intf_thread_t * );
virtual ~MessagesDialog(); virtual ~MessagesDialog();
static MessagesDialog *instance;
QTabWidget *mainTab; QTabWidget *mainTab;
QSpinBox *verbosityBox; QSpinBox *verbosityBox;
QLabel *verbosityLabel; QLabel *verbosityLabel;
...@@ -78,6 +64,8 @@ private: ...@@ -78,6 +64,8 @@ private:
void clear(); void clear();
void updateTree(); void updateTree();
void buildTree( QTreeWidgetItem *, vlc_object_t * ); void buildTree( QTreeWidgetItem *, vlc_object_t * );
friend class Singleton<MessagesDialog>;
}; };
#endif #endif
...@@ -40,24 +40,9 @@ ...@@ -40,24 +40,9 @@
#include <assert.h> #include <assert.h>
OpenUrlDialog *OpenUrlDialog::instance = NULL; OpenUrlDialog::OpenUrlDialog( intf_thread_t *_p_intf,
OpenUrlDialog* OpenUrlDialog::getInstance( QWidget *parent,
intf_thread_t *p_intf,
bool bClipboard )
{
/* Creation */
if( !instance )
instance = new OpenUrlDialog( parent, p_intf, bClipboard );
else
instance->bClipboard = bClipboard;
return instance;
}
OpenUrlDialog::OpenUrlDialog( QWidget *parent,
intf_thread_t *_p_intf,
bool _bClipboard ) : bool _bClipboard ) :
QVLCDialog( parent, _p_intf ), bClipboard( _bClipboard ) QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf ), bClipboard( _bClipboard )
{ {
setWindowTitle( qtr( "Open URL" ) ); setWindowTitle( qtr( "Open URL" ) );
setWindowRole( "vlc-open-url" ); setWindowRole( "vlc-open-url" );
......
...@@ -30,21 +30,20 @@ ...@@ -30,21 +30,20 @@
#include <vlc_common.h> #include <vlc_common.h>
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "util/singleton.hpp"
class ClickLineEdit; class ClickLineEdit;
class OpenUrlDialog : public QVLCDialog class OpenUrlDialog : public QVLCDialog, public Singleton<OpenUrlDialog>
{ {
Q_OBJECT Q_OBJECT
private: private:
OpenUrlDialog( QWidget *, intf_thread_t *, bool bClipboard = true ); OpenUrlDialog( intf_thread_t *, bool bClipboard = true );
QString lastUrl; QString lastUrl;
bool bClipboard, bShouldEnqueue; bool bClipboard, bShouldEnqueue;
ClickLineEdit *edit; ClickLineEdit *edit;
static OpenUrlDialog *instance;
private slots: private slots:
void enqueue(); void enqueue();
void play(); void play();
...@@ -52,16 +51,14 @@ private slots: ...@@ -52,16 +51,14 @@ private slots:
public: public:
virtual ~OpenUrlDialog() {} virtual ~OpenUrlDialog() {}
static OpenUrlDialog* getInstance( QWidget *parent,
intf_thread_t *p_intf,
bool bClipboard = true );
QString url() const; QString url() const;
bool shouldEnqueue() const; bool shouldEnqueue() const;
void showEvent( QShowEvent *ev ); void showEvent( QShowEvent *ev );
public slots: public slots:
virtual void close() { play(); }; virtual void close() { play(); };
friend class Singleton<OpenUrlDialog>;
}; };
#endif #endif
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
#include <QUrl> #include <QUrl>
#include <QHBoxLayout> #include <QHBoxLayout>
PlaylistDialog *PlaylistDialog::instance = NULL;
PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf )
: QVLCMW( _p_intf ) : QVLCMW( _p_intf )
{ {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "../components/playlist/playlist.hpp" #include "../components/playlist/playlist.hpp"
#include "util/singleton.hpp"
#include <QModelIndex> #include <QModelIndex>
...@@ -34,23 +35,12 @@ class PLSelector; ...@@ -34,23 +35,12 @@ class PLSelector;
class PLPanel; class PLPanel;
class QSettings; class QSettings;
class PlaylistDialog : public QVLCMW class PlaylistDialog : public QVLCMW, public Singleton<PlaylistDialog>
{ {
Q_OBJECT; Q_OBJECT;
private: private:
PlaylistWidget *playlistWidget; PlaylistWidget *playlistWidget;
public:
static PlaylistDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance) instance = new PlaylistDialog( p_intf );
return instance;
}
static void killInstance()
{
delete instance;
instance = NULL;
}
private: private:
PlaylistDialog( intf_thread_t * ); PlaylistDialog( intf_thread_t * );
virtual ~PlaylistDialog(); virtual ~PlaylistDialog();
...@@ -60,7 +50,7 @@ private: ...@@ -60,7 +50,7 @@ private:
void dragMoveEvent( QDragMoveEvent * ); void dragMoveEvent( QDragMoveEvent * );
void dragLeaveEvent( QDragLeaveEvent * ); void dragLeaveEvent( QDragLeaveEvent * );
static PlaylistDialog *instance; friend class Singleton<PlaylistDialog>;
}; };
......
...@@ -38,8 +38,6 @@ ...@@ -38,8 +38,6 @@
#include <QLineEdit> #include <QLineEdit>
#include <QLabel> #include <QLabel>
PluginDialog *PluginDialog::instance = NULL;
PluginDialog::PluginDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) PluginDialog::PluginDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{ {
setWindowTitle( qtr( "Plugins and extensions" ) ); setWindowTitle( qtr( "Plugins and extensions" ) );
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define QVLC_PLUGIN_DIALOG_H_ 1 #define QVLC_PLUGIN_DIALOG_H_ 1
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "util/singleton.hpp"
#include <QTreeWidget> #include <QTreeWidget>
#include <QStringList> #include <QStringList>
...@@ -32,31 +33,21 @@ class QTreeWidget; ...@@ -32,31 +33,21 @@ class QTreeWidget;
class QLineEdit; class QLineEdit;
class SearchLineEdit; class SearchLineEdit;
class PluginDialog : public QVLCFrame class PluginDialog : public QVLCFrame, public Singleton<PluginDialog>
{ {
Q_OBJECT; Q_OBJECT;
public:
static PluginDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance)
instance = new PluginDialog( p_intf );
return instance;
}
static void killInstance()
{
delete instance;
instance = NULL;
}
private: private:
PluginDialog( intf_thread_t * ); PluginDialog( intf_thread_t * );
virtual ~PluginDialog(); virtual ~PluginDialog();
static PluginDialog *instance;
void FillTree(); void FillTree();
QTreeWidget *treePlugins; QTreeWidget *treePlugins;
SearchLineEdit *edit; SearchLineEdit *edit;
private slots: private slots:
void search( const QString& ); void search( const QString& );
friend class Singleton<PluginDialog>;
}; };
class PluginTreeItem : public QTreeWidgetItem class PluginTreeItem : public QTreeWidgetItem
......
...@@ -26,10 +26,8 @@ ...@@ -26,10 +26,8 @@
#include "podcast_configuration.hpp" #include "podcast_configuration.hpp"
PodcastConfigDialog *PodcastConfigDialog::instance = NULL; PodcastConfigDialog::PodcastConfigDialog( intf_thread_t *_p_intf)
: QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
PodcastConfigDialog::PodcastConfigDialog( QWidget *parent, intf_thread_t *_p_intf)
: QVLCDialog( parent, _p_intf )
{ {
ui.setupUi( this ); ui.setupUi( this );
......
...@@ -26,28 +26,23 @@ ...@@ -26,28 +26,23 @@
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "ui/podcast_configuration.h" #include "ui/podcast_configuration.h"
#include "util/singleton.hpp"
class PodcastConfigDialog : public QVLCDialog class PodcastConfigDialog : public QVLCDialog, public Singleton<PodcastConfigDialog>
{ {
Q_OBJECT; Q_OBJECT;
public:
static PodcastConfigDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance )
instance = new PodcastConfigDialog( (QWidget *)p_intf->p_sys->p_mi,
p_intf );
return instance;
}
virtual ~PodcastConfigDialog();
private: private:
PodcastConfigDialog( QWidget *, intf_thread_t * ); PodcastConfigDialog( intf_thread_t * );
static PodcastConfigDialog *instance; virtual ~PodcastConfigDialog();
Ui::PodcastConfiguration ui; Ui::PodcastConfiguration ui;
public slots: public slots:
void accept(); void accept();
void add(); void add();
void remove(); void remove();
friend class Singleton<PodcastConfigDialog>;
}; };
#endif #endif
...@@ -55,9 +55,7 @@ ...@@ -55,9 +55,7 @@
#include <QFileDialog> #include <QFileDialog>
VLMDialog *VLMDialog::instance = NULL; VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
VLMDialog::VLMDialog( QWidget *parent, intf_thread_t *_p_intf ) : QVLCDialog( parent, _p_intf )
{ {
p_vlm = vlm_New( p_intf ); p_vlm = vlm_New( p_intf );
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "ui/vlm.h" #include "ui/vlm.h"
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "util/singleton.hpp"
#include <QDateTime> #include <QDateTime>
enum{ enum{
...@@ -67,24 +68,19 @@ class VLMAWidget; ...@@ -67,24 +68,19 @@ class VLMAWidget;
class VLMWrapper; class VLMWrapper;
class VLMDialog : public QVLCDialog class VLMDialog : public QVLCDialog, public Singleton<VLMDialog>
{ {
Q_OBJECT; Q_OBJECT;
public: public:
static VLMDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance)
instance = new VLMDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf );
return instance;
};
virtual ~VLMDialog();
void toggleVisible(); void toggleVisible();
VLMWrapper *vlmWrapper; VLMWrapper *vlmWrapper;
vlm_t *p_vlm; vlm_t *p_vlm;
private: private:
VLMDialog( QWidget *, intf_thread_t * ); VLMDialog( intf_thread_t * );
static VLMDialog *instance; virtual ~VLMDialog();
Ui::Vlm ui; Ui::Vlm ui;
QList<VLMAWidget *> vlmItems; QList<VLMAWidget *> vlmItems;
...@@ -111,6 +107,8 @@ private slots: ...@@ -111,6 +107,8 @@ private slots:
void selectOutput(); void selectOutput();
bool exportVLMConf(); bool exportVLMConf();
bool importVLMConf(); bool importVLMConf();
friend class Singleton<VLMDialog>;
}; };
class VLMWrapper class VLMWrapper
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "dialogs/toolbar.hpp" #include "dialogs/toolbar.hpp"
#include "dialogs/plugins.hpp" #include "dialogs/plugins.hpp"
#include "dialogs/external.hpp" #include "dialogs/external.hpp"
#include "dialogs/errors.hpp"
#include <QEvent> #include <QEvent>
#include <QApplication> #include <QApplication>
...@@ -452,8 +453,7 @@ void DialogsProvider::simpleMLAppendDialog() ...@@ -452,8 +453,7 @@ void DialogsProvider::simpleMLAppendDialog()
**/ **/
void DialogsProvider::openUrlDialog() void DialogsProvider::openUrlDialog()
{ {
OpenUrlDialog *oud = OpenUrlDialog::getInstance( p_intf->p_sys->p_mi, OpenUrlDialog *oud = OpenUrlDialog::getInstance( p_intf );
p_intf );
if( oud->exec() == QDialog::Accepted ) if( oud->exec() == QDialog::Accepted )
{ {
QString url = oud->url(); QString url = oud->url();
......
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