qt: use singleton in OpenDialog

This commit is contained in:
Fatih Uzunoglu 2021-12-09 23:01:43 +02:00 committed by Jean-Baptiste Kempf
parent 960a101ec8
commit 63033c7cb7
2 changed files with 10 additions and 16 deletions

View File

@ -36,16 +36,15 @@
# define DEBUG_QT 1
#endif
OpenDialog *OpenDialog::instance = NULL;
OpenDialog* OpenDialog::getInstance( qt_intf_t *p_intf,
bool b_rawInstance, int _action_flag, bool b_selectMode )
{
/* Creation */
if( !instance )
instance = new OpenDialog( nullptr, p_intf, b_selectMode,
_action_flag );
else if( !b_rawInstance )
const auto instance = Singleton<OpenDialog>::getInstance(nullptr,
p_intf,
b_selectMode,
_action_flag);
if( !b_rawInstance )
{
/* Request the instance but change small details:
- Button menu */

View File

@ -32,6 +32,7 @@
#include "widgets/native/qvlcframe.hpp"
#include "dialogs/open/open_panels.hpp"
#include "util/singleton.hpp"
/* Auto-generated from .ui files */
#include "ui_open.h"
@ -55,20 +56,16 @@ enum {
class QString;
class OpenDialog : public QVLCDialog
class OpenDialog : public QVLCDialog, public Singleton<OpenDialog>
{
friend Singleton<OpenDialog>;
Q_OBJECT
public:
static OpenDialog * getInstance(qt_intf_t *p_intf,
bool b_rawInstance = false, int _action_flag = 0,
bool b_selectMode = false );
static void killInstance()
{
delete instance;
instance = NULL;
}
void showTab( int = OPEN_FILE_TAB );
QString getMRL( bool b = true );
@ -87,8 +84,6 @@ private:
int _action_flag = 0 );
virtual ~OpenDialog();
static OpenDialog *instance;
QString optionsMRL;
QString storedMethod;
QStringList itemsMRL;