Commit 1bf74fe7 authored by zorglub's avatar zorglub
Browse files

Initial layout

parent 56674e0f
SOURCES_qt4 = qt4.cpp
EXTRA_DIST += \
qt4.hpp
TOUI = file_open
TOUI = ui/file_open
UIH := $(TOUI:%=%.h)
TOMOC = main_interface
TOMOC = main_interface dialogs_provider dialogs/playlist
MOCCPP := $(TOMOC:%=%.moc.cpp)
if ENABLE_QT4
......@@ -14,8 +9,6 @@ if ENABLE_QT4
BUILT_SOURCES += $(UIH)
BUILT_SOURCES += $(MOCCPP)
nodist_SOURCES_qt4 = $(UIH) $(MOCCPP)
$(MOCCPP): %.moc.cpp: %.hpp
@echo "MOC $< -> $@"
moc -o $@ $<
......@@ -25,3 +18,19 @@ $(UIH): %.h: %.ui
uic -tr _ -o $@ $<
endif
SOURCES_qt4 = qt4.cpp \
main_interface.cpp \
dialogs_provider.cpp \
dialogs/playlist.cpp \
main_interface.moc.cpp \
dialogs_provider.moc.cpp \
dialogs/playlist.moc.cpp
$(NULL)
# Why do I have to put it manually ??
EXTRA_DIST += \
qt4.hpp \
main_interface.hpp \
dialogs_provider.hpp
/*****************************************************************************
* playlist.cpp : Playlist dialog
****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* 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. *****************************************************************************/
#include "dialogs/playlist.hpp"
#include "util/qvlcframe.hpp"
#include "qt4.hpp"
PlaylistDialog *PlaylistDialog::instance = NULL;
PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCFrame( p_intf )
{
}
PlaylistDialog::~PlaylistDialog()
{
}
/*****************************************************************************
* playlist.hpp: Playlist dialog
****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* 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 _PLAYLIST_DIALOG_H_
#define _PLAYLIST_DIALOG_H_
#include "util/qvlcframe.hpp"
class PlaylistDialog : public QVLCFrame
{
Q_OBJECT;
public:
static PlaylistDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance) instance = new PlaylistDialog( p_intf );
return instance;
}
virtual ~PlaylistDialog();
private:
PlaylistDialog( intf_thread_t * );
intf_thread_t *p_intf;
static PlaylistDialog *instance;
public slots:
};
#endif
/*****************************************************************************
* main_inteface.cpp : Main interface
****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* 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. *****************************************************************************/
#include "dialogs_provider.hpp"
#include "qt4.hpp"
#include <QEvent>
#include "dialogs/playlist.hpp"
DialogsProvider* DialogsProvider::instance = NULL;
DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) : QObject(),
p_intf( _p_intf )
{
fprintf( stderr, "QT DP" );
}
DialogsProvider::~DialogsProvider()
{
}
void DialogsProvider::customEvent( QEvent *event )
{
if( event->type() == DialogEvent_Type )
{
DialogEvent *de = dynamic_cast<DialogEvent*>(event);
switch( de->i_dialog )
{
case INTF_DIALOG_FILE:
case INTF_DIALOG_DISC:
case INTF_DIALOG_NET:
case INTF_DIALOG_CAPTURE:
openDialog( de->i_dialog ); break;
case INTF_DIALOG_PLAYLIST:
playlistDialog(); break;
case INTF_DIALOG_MESSAGES:
messagesDialog(); break;
case INTF_DIALOG_PREFS:
prefsDialog(); break;
case INTF_DIALOG_POPUPMENU:
case INTF_DIALOG_AUDIOPOPUPMENU:
case INTF_DIALOG_VIDEOPOPUPMENU:
case INTF_DIALOG_MISCPOPUPMENU:
popupMenu( de->i_dialog ); break;
case INTF_DIALOG_VLM:
case INTF_DIALOG_INTERACTION:
case INTF_DIALOG_BOOKMARKS:
case INTF_DIALOG_FILEINFO:
case INTF_DIALOG_WIZARD:
default:
fprintf( stderr, "Unimplemented dialog\n");
}
fprintf( stderr, "Showing dialog\n");
}
}
void DialogsProvider::playlistDialog()
{
PlaylistDialog::getInstance( p_intf )->toggleVisible();
}
void DialogsProvider::openDialog( int i_dialog )
{
}
void DialogsProvider::prefsDialog()
{
}
void DialogsProvider::messagesDialog()
{
}
void DialogsProvider::popupMenu( int i_dialog )
{
}
/*****************************************************************************
* dialogs_provider.hpp : Dialogs provider
****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* 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 _DIALOGS_PROVIDER_H_
#define _DIALOGS_PROVIDER_H_
#include <QObject>
#include <vlc/vlc.h>
class QEvent;
class DialogsProvider : public QObject
{
Q_OBJECT;
public:
static DialogsProvider *getInstance( intf_thread_t *p_intf )
{
if( !instance) instance = new DialogsProvider( p_intf );
return instance;
}
virtual ~DialogsProvider();
protected:
void customEvent( QEvent *);
private:
DialogsProvider( intf_thread_t * );
intf_thread_t *p_intf;
static DialogsProvider *instance;
public slots:
void playlistDialog();
void prefsDialog();
void messagesDialog();
void openDialog( int );
void popupMenu( int );
};
#endif
/*****************************************************************************
* main_inteface.cpp : Main interface
****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* 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. *****************************************************************************/
#include "main_interface.hpp"
MainInterface::MainInterface( intf_thread_t *p_intf ) : QWidget( NULL )
{
fprintf( stderr, "QT Main interface" );
}
MainInterface::~MainInterface()
{
}
/*****************************************************************************
* main_interface.hpp : Main Interface
****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* 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 _MAIN_INTERFACE_H_
#define _MAIN_INTERFACE_H_
#include <vlc/intf.h>
#include <QWidget>
class MainInterface : public QWidget
{
Q_OBJECT;
public:
MainInterface( intf_thread_t *);
virtual ~MainInterface();
};
#endif
/*****************************************************************************
* qt4.cpp : QT4 interface
****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* 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. *****************************************************************************/
#include <QApplication>
#include "qt4.hpp"
#include "dialogs_provider.hpp"
#include "main_interface.hpp"
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static int OpenDialogs ( vlc_object_t * );
static void Run ( intf_thread_t * );
static void Init ( intf_thread_t * );
static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
set_shortname( (char*)"QT" );
set_description( (char*)_("QT interface") );
set_category( CAT_INTERFACE) ;
set_subcategory( SUBCAT_INTERFACE_MAIN );
set_capability( "interface", 100 );
set_callbacks( Open, Close );
add_submodule();
set_description( "Dialogs provider" );
set_capability( "dialogs provider", 51 );
set_callbacks( OpenDialogs, Close );
vlc_module_end();
/*****************************************************************************
* Module callbacks
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
p_intf->pf_run = Run;
p_intf->p_sys = (intf_sys_t *)malloc(sizeof( intf_sys_t ) );
memset( p_intf->p_sys, 0, sizeof( intf_sys_t ) );
p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
return VLC_SUCCESS;
}
static int OpenDialogs( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
Open( p_this );
p_intf->pf_show_dialog = ShowDialog;
return VLC_SUCCESS;
}
static void Close( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
vlc_mutex_lock( &p_intf->object_lock );
p_intf->b_dead = VLC_TRUE;
vlc_mutex_unlock( &p_intf->object_lock );
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
free( p_intf->p_sys );
}
/*****************************************************************************
* Initialize the interface or the dialogs provider
*****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
if( p_intf->pf_show_dialog )
{
if( vlc_thread_create( p_intf, "QT dialogs", Init, 0, VLC_TRUE ) )
{
msg_Err( p_intf, "failed to create QT dialogs thread" );
}
}
else
{
Init( p_intf );
}
}
static void Init( intf_thread_t *p_intf )
{
char *argv[] = { "" };
int argc = 1;
QApplication *app = new QApplication( argc, argv , true );
p_intf->p_sys->p_app = app;
/* Normal interface */
if( !p_intf->pf_show_dialog )
{
MainInterface *p_mi = new MainInterface( p_intf );
p_intf->p_sys->p_mi = p_mi;
p_mi->show();
}
if( p_intf->pf_show_dialog )
vlc_thread_ready( p_intf );
app->exec();
}
/*****************************************************************************
* Callback to show a dialog
*****************************************************************************/
static void ShowDialog( intf_thread_t *p_intf, int i_dialog_event, int i_arg,
intf_dialog_args_t *p_arg )
{
DialogEvent *event = new DialogEvent( i_dialog_event, i_arg, p_arg );
QApplication::postEvent( DialogsProvider::getInstance( p_intf ),
static_cast<QEvent*>(event) );
}
/*****************************************************************************
* qt4.hpp : QT4 interface
****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* 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 _QVLC_H_
#define _QVLC_H_
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <QEvent>
class QApplication;
class MainInterface;
class DialogsProvider;
struct intf_sys_t
{
QApplication *p_app;
MainInterface *p_mi;
msg_subscription_t *p_sub; ///< Subscription to the message bank
};
static int DialogEvent_Type = QEvent::User + 1;
class DialogEvent : public QEvent
{
public:
DialogEvent( int _i_dialog, int _i_arg, intf_dialog_args_t *_p_arg ) :
QEvent( (QEvent::Type)(DialogEvent_Type) )
{
i_dialog = _i_dialog;
i_arg = _i_arg;
p_arg = _p_arg;
};
virtual ~DialogEvent() {};
int i_arg, i_dialog;
intf_dialog_args_t *p_arg;
};
#endif
/*****************************************************************************
* directslider.hpp : A slider that goes where you click
****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
* with precious help from ahigerd on #qt@freenode
*
* 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 _DIRECTSLIDER_H_
#define _DIRECTSLIDER_H_
#include <QSlider>
#include <QMouseEvent>
class DirectSlider : public QSlider
{
public:
DirectSlider( QWidget *_parent ) : QSlider( _parent ) {};
DirectSlider( Qt::Orientation q,QWidget *_parent ) : QSlider( q,_parent )
{};
virtual ~DirectSlider() {};
void mousePressEvent(QMouseEvent* event)
{
if(event->button() == Qt::LeftButton)
{
int pos = (int)(minimum() +
(double)(event->x())/width()*(maximum()-minimum()) );
setSliderPosition( pos );
QSlider::mousePressEvent(event);
}
}
};
#endif
/*****************************************************************************
* qvlcframe.hpp : A few helpers
****************************************************************************
* Copyright (C) 2000-2006 the VideoLAN team
* $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* 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.