* qte_main.c : QT Embedded wrapper for gte_main
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: qte_main.cpp,v 1.1 2003/01/19 22:16:13 jpsaman Exp $
+ * $Id: qte_main.cpp,v 1.7 2003/06/09 19:56:26 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
}
#include <qapplication.h>
+#include <qpainter.h>
extern "C"
{
typedef struct qte_thread_t
{
- VLC_COMMON_MEMBERS
+ VLC_COMMON_MEMBERS
QApplication* p_qte_application;
+ QWidget* p_qte_widget;
+ bool b_gui_server;
} qte_thread_t;
/*****************************************************************************
* Module descriptor
*****************************************************************************/
+#define STANDALONE_TEXT N_("Run as standalone Qt/Embedded Gui Server")
+#define STANDALONE_LONGTEXT N_("Use this option to run as standalone Qt/Embedded Gui Server. " \
+ "This option is equivalent to the -qws option from normal Qt.")
+
vlc_module_begin();
- set_description( _("Qt Embedded helper module") );
- set_capability( "qte_main", 90 );
+ set_description( _("Qt Embedded GUI helper") );
+ set_capability( "gui-helper", 90 );
+ add_bool( "qte-guiserver", 0, NULL, STANDALONE_TEXT, STANDALONE_LONGTEXT, VLC_FALSE );
add_shortcut( "qte" );
set_callbacks( Open, Close );
vlc_module_end();
p_qte_main = (qte_thread_t *) vlc_object_create( p_this, sizeof(qte_thread_t) );
- /* Launch the gtk_main() thread. It will not return until it has
- * called gdk_threads_enter(), which ensures us thread safety. */
+ /* Launch the QApplication::exec() thread. It will not return until the
+ * application is properly initialized, which ensures us thread safety. */
if( vlc_thread_create( p_qte_main, "qte_main", QteMain,
VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) )
{
var_Destroy( p_this->p_libvlc, "qte" );
return;
}
-
p_qte_main->p_qte_application->quit();
- vlc_thread_join( p_qte_main );
+
+ /* Cleanup allocated classes. */
+ delete p_qte_main->p_qte_widget;
+ delete p_qte_main->p_qte_application;
vlc_object_destroy( p_qte_main );
p_qte_main = NULL;
*****************************************************************************/
static void QteMain( qte_thread_t *p_this )
{
- int argc = 0;
+ int i_argc = 1;
+ char *p_args[] = {"-qws", NULL};
+ char **pp_args = p_args;
+
+ p_this->b_gui_server = VLC_FALSE;
+ if( config_GetInt( p_this, "qte-guiserver" ) )
+ {
+ msg_Dbg( p_this, "Running as Qt Embedded standalone GuiServer" );
+ p_this->b_gui_server = VLC_TRUE;
+ }
- msg_Dbg( p_this, "qte_main: enter" );
- QApplication* pApp = new QApplication(argc, NULL);
+ /* Run as standalone GuiServer or as GuiClient. */
+ QApplication* pApp = new QApplication(i_argc, NULL,
+ (p_this->b_gui_server ? (QApplication::GuiServer):(QApplication::GuiClient)) );
if(pApp)
{
p_this->p_qte_application = pApp;
}
- msg_Dbg( p_this, "qte_main: qte application created" );
+ QWidget* pWidget = new QWidget();
+ if(pWidget)
+ {
+ p_this->p_qte_widget = pWidget;
+ }
+
+ if (p_this->b_gui_server) {
+ p_this->p_qte_application->desktop()->setFixedSize(240, 320);
+ }
/* signal the creation of the window */
- vlc_thread_ready( p_this );
- msg_Dbg( p_this, "qte_main: qte application thread ready" );
+ p_this->p_qte_application->setMainWidget(p_this->p_qte_widget);
+ p_this->p_qte_widget->show();
+ vlc_thread_ready( p_this );
p_this->p_qte_application->exec();
- msg_Dbg( p_this, "qte_main: leaving" );
}