qt4.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * qt4.hpp : QT4 interface
00003  ****************************************************************************
00004  * Copyright (C) 2006-2009 the VideoLAN team
00005  * $Id: 64f58212b70815b1c5abb2edfcff5cc2f75a1e5c $
00006  *
00007  * Authors: Clément Stenac <zorglub@videolan.org>
00008  *          Jean-Baptiste Kempf <jb@videolan.org>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef QVLC_H_
00026 #define QVLC_H_
00027 
00028 #ifdef HAVE_CONFIG_H
00029 # include "config.h"
00030 #endif
00031 
00032 #include <vlc_common.h>    /* VLC_COMMON_MEMBERS for vlc_interface.h */
00033 #include <vlc_interface.h> /* intf_thread_t */
00034 #include <vlc_playlist.h>  /* playlist_t */
00035 
00036 #define QT_NO_CAST_TO_ASCII
00037 #include <QString>
00038 
00039 #if ( QT_VERSION < 0x040400 )
00040 # error Update your Qt version to at least 4.4.0
00041 #endif
00042 #if QT_VERSION == 0x040500
00043 # error Please update Qt version to 4.5.1. 4.5.0 is too buggy
00044 #endif
00045 
00046 #define HAS_QT45 ( QT_VERSION >= 0x040500 )
00047 
00048 enum {
00049     DialogEventType = 0,
00050     IMEventType     = 100,
00051     PLEventType     = 200,
00052     MsgEventType    = 300,
00053 };
00054 
00055 class QVLCApp;
00056 class QMenu;
00057 class MainInterface;
00058 class QSettings;
00059 
00060 struct intf_sys_t
00061 {
00062     vlc_thread_t thread;
00063 
00064     QVLCApp *p_app;          /* Main Qt Application */
00065     MainInterface *p_mi;     /* Main Interface, NULL if DialogProvider Mode */
00066 
00067     QSettings *mainSettings; /* Qt State settings not messing main VLC ones */
00068 
00069     bool b_isDialogProvider; /* Qt mode or Skins mode */
00070 
00071     int  i_screenHeight;     /* Detection of Small screens */
00072 
00073     playlist_t *p_playlist;  /* Core Playlist discussion */
00074 
00075     QString filepath;        /* Last path used in dialogs */
00076 
00077 };
00078 
00079 #define THEPL p_intf->p_sys->p_playlist
00080 #define QPL_LOCK playlist_Lock( THEPL );
00081 #define QPL_UNLOCK playlist_Unlock( THEPL );
00082 
00083 #define THEDP DialogsProvider::getInstance()
00084 #define THEMIM MainInputManager::getInstance( p_intf )
00085 #define THEAM ActionsManager::getInstance( p_intf )
00086 
00087 #define qfu( i ) QString::fromUtf8( i )
00088 #define qtr( i ) QString::fromUtf8( vlc_gettext(i) )
00089 #define qtu( i ) ((i).toUtf8().constData())
00090 
00091 #define CONNECT( a, b, c, d ) \
00092         connect( a, SIGNAL( b ), c, SLOT(d) )
00093 #define DCONNECT( a, b, c, d ) \
00094         connect( a, SIGNAL( b ), c, SLOT(d), Qt::DirectConnection )
00095 #define BUTTONACT( b, a ) connect( b, SIGNAL( clicked() ), this, SLOT(a) )
00096 
00097 #define BUTTON_SET( button, text, tooltip )  \
00098     button->setText( text );                 \
00099     button->setToolTip( tooltip );
00100 
00101 #define BUTTON_SET_ACT( button, text, tooltip, thisslot ) \
00102     BUTTON_SET( button, text, tooltip );                  \
00103     BUTTONACT( button, thisslot );
00104 
00105 #define BUTTON_SET_IMG( button, text, image, tooltip )    \
00106     BUTTON_SET( button, text, tooltip );                  \
00107     button->setIcon( QIcon( ":/"#image ) );
00108 
00109 #define BUTTON_SET_ACT_I( button, text, image, tooltip, thisslot ) \
00110     BUTTON_SET_IMG( button, text, image, tooltip );                \
00111     BUTTONACT( button, thisslot );
00112 
00113 #define VISIBLE(i) (i && i->isVisible())
00114 
00115 #define TOGGLEV( x ) { if( x->isVisible() ) x->hide();          \
00116             else  x->show(); }
00117 
00118 #define getSettings() p_intf->p_sys->mainSettings
00119 
00120 static inline QString QVLCUserDir( vlc_userdir_t type )
00121 {
00122     char *dir = config_GetUserDir( type );
00123     if( !dir )
00124         abort();
00125     QString res = qfu( dir );
00126     free( dir );
00127     return res;
00128 }
00129 
00130 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6