Commit 2a2773ed authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Qt4: move dialog handler to a separate file

parent 7cba3abb
......@@ -27,6 +27,7 @@ nodist_SOURCES_qt4 = \
dialogs/extended.moc.cpp \
dialogs/messages.moc.cpp \
dialogs/errors.moc.cpp \
dialogs/external.moc.cpp \
dialogs/plugins.moc.cpp \
dialogs/preferences.moc.cpp \
dialogs/interaction.moc.cpp \
......@@ -201,6 +202,7 @@ SOURCES_qt4 = qt4.cpp \
dialogs/extended.cpp \
dialogs/messages.cpp \
dialogs/errors.cpp \
dialogs/external.cpp \
dialogs/plugins.cpp \
dialogs/interaction.cpp \
dialogs/sout.cpp \
......@@ -246,6 +248,7 @@ noinst_HEADERS = \
dialogs/extended.hpp \
dialogs/messages.hpp \
dialogs/errors.hpp \
dialogs/external.hpp \
dialogs/plugins.hpp \
dialogs/preferences.hpp \
dialogs/interaction.hpp \
......
/*****************************************************************************
* external.hpp : Dialogs from other LibVLC core and other plugins
****************************************************************************
* Copyright (C) 2009 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
//#include "qt4.hpp"
#include "external.hpp"
#include "errors.hpp"
#include <vlc_dialog.h>
#include <QMessageBox>
DialogHandler::DialogHandler (intf_thread_t *intf)
{
this->intf = intf;
connect (this, SIGNAL(message(const struct dialog_fatal_t *)),
this, SLOT(displayMessage(const struct dialog_fatal_t *)),
Qt::BlockingQueuedConnection);
var_Create (intf, "dialog-fatal", VLC_VAR_ADDRESS);
var_AddCallback (intf, "dialog-fatal", MessageCallback, this);
dialog_Register (intf);
}
DialogHandler::~DialogHandler (void)
{
dialog_Unregister (intf);
}
int DialogHandler::MessageCallback (vlc_object_t *obj, const char *var,
vlc_value_t, vlc_value_t value,
void *data)
{
DialogHandler *self = (DialogHandler *)data;
const dialog_fatal_t *dialog = (const dialog_fatal_t *)value.p_address;
emit self->message (dialog);
return VLC_SUCCESS;
}
void DialogHandler::displayMessage (const struct dialog_fatal_t *dialog)
{
if (dialog->modal)
QMessageBox::critical (NULL, qfu(dialog->title), qfu(dialog->message),
QMessageBox::Ok);
else
if (config_GetInt (intf, "qt-error-dialogs"))
ErrorsDialog::getInstance (intf)->addError(qfu(dialog->title),
qfu(dialog->message));
}
/*****************************************************************************
* external.hpp : Dialogs from other LibVLC core and other plugins
****************************************************************************
* Copyright (C) 2009 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VLC_QT4_DIALOGS_EXTERNAL_H_
# define VLC_QT4_DIALOGS_EXTERNAL_H 1
#include <QObject>
#include <vlc_common.h>
struct intf_thread_t;
class DialogHandler : public QObject
{
Q_OBJECT
public:
DialogHandler (intf_thread_t *);
~DialogHandler (void);
private:
intf_thread_t *intf;
static int MessageCallback( vlc_object_t *, const char *, vlc_value_t,
vlc_value_t, void * );
private slots:
void displayMessage (const struct dialog_fatal_t *);
signals:
void message (const struct dialog_fatal_t *);
};
#endif
......@@ -39,6 +39,7 @@
#include "components/interface_widgets.hpp"
#include "components/controller.hpp"
#include "components/playlist/playlist.hpp"
#include "dialogs/external.hpp"
#include "menus.hpp"
#include "recents.hpp"
......@@ -56,14 +57,11 @@
#include <QLabel>
#include <QGroupBox>
#include <QPushButton>
#include <QMessageBox>
#include <assert.h>
#include <vlc_keys.h> /* Wheel event */
#include <vlc_vout.h>
#include <vlc_dialog.h>
#include "dialogs/errors.hpp"
/* Callback prototypes */
static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
......@@ -198,6 +196,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* END CONNECTS ON IM */
dialogHandler = new DialogHandler (p_intf);
/************
* Callbacks
......@@ -206,13 +205,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
var_AddCallback( p_intf, "interaction", InteractCallback, this );
interaction_Register( p_intf );
connect( this, SIGNAL(fatalDialog( const struct dialog_fatal_t * )),
this, SLOT(displayFatalDialog( const struct dialog_fatal_t * )),
Qt::BlockingQueuedConnection );
var_Create( p_intf, "dialog-fatal", VLC_VAR_ADDRESS );
var_AddCallback( p_intf, "dialog-fatal", DialogCallback, this );
dialog_Register( p_intf );
var_AddCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf );
/* Register callback for the intf-popupmenu variable */
......@@ -289,6 +281,8 @@ MainInterface::~MainInterface()
{
msg_Dbg( p_intf, "Destroying the main interface" );
delete dialogHandler;
/* Unsure we hide the videoWidget before destroying it */
if( videoIsActive ) videoWidget->hide();
......@@ -332,9 +326,6 @@ MainInterface::~MainInterface()
interaction_Unregister( p_intf );
var_DelCallback( p_intf, "interaction", InteractCallback, this );
dialog_Unregister( p_intf );
var_DelCallback( p_intf, "dialog-fatal", DialogCallback, this );
p_intf->p_sys->p_mi = NULL;
}
......@@ -1235,29 +1226,6 @@ static int InteractCallback( vlc_object_t *p_this,
return VLC_SUCCESS;
}
int MainInterface::DialogCallback( vlc_object_t *p_this,
const char *type, vlc_value_t previous,
vlc_value_t value, void *data )
{
MainInterface *self = (MainInterface *)data;
const dialog_fatal_t *dialog = (const dialog_fatal_t *)value.p_address;
(void) previous;
emit self->fatalDialog (dialog);
return VLC_SUCCESS;
}
void MainInterface::displayFatalDialog (const dialog_fatal_t *dialog)
{
if (dialog->modal)
QMessageBox::critical (NULL, qfu(dialog->title), qfu(dialog->message),
QMessageBox::Ok);
else
if (config_GetInt (p_intf, "qt-error-dialogs"))
ErrorsDialog::getInstance (p_intf)->addError(qfu(dialog->title),
qfu(dialog->message));
}
/*****************************************************************************
* PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
* We don't show the menu directly here because we don't want the
......
......@@ -49,7 +49,7 @@ class FullscreenControllerWidget;
class SpeedControlWidget;
class QMenu;
class QSize;
struct dialog_fatal_t;
class DialogHandler;
enum {
CONTROLS_VISIBLE = 0x1,
......@@ -108,6 +108,7 @@ private:
ControlsWidget *controls;
InputControlsWidget *inputC;
FullscreenControllerWidget *fullscreenControls;
DialogHandler *dialogHandler;
void handleMainUi( QSettings* );
void askForPrivacy();
......@@ -151,11 +152,6 @@ private:
virtual void wheelEvent( QWheelEvent * );
virtual void resizeEvent( QResizeEvent * event );
static int DialogCallback( vlc_object_t *, const char *, vlc_value_t,
vlc_value_t, void * );
private slots:
void displayFatalDialog( const struct dialog_fatal_t * );
public slots:
void undockPlaylist();
void dockPlaylist( pl_dock_e i_pos = PL_BOTTOM );
......@@ -194,7 +190,6 @@ signals:
void askUpdate();
void minimalViewToggled( bool );
void fullscreenInterfaceToggled( bool );
void fatalDialog( const struct dialog_fatal_t * );
};
#endif
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