]> git.sesse.net Git - vlc/blob - modules/gui/qt4/qt4.hpp
Qt4 - PlaylistWidget use a much nicer QSplitter. Removes also too much class inherita...
[vlc] / modules / gui / qt4 / qt4.hpp
1 /*****************************************************************************
2  * qt4.hpp : QT4 interface
3  ****************************************************************************
4  * Copyright (C) 2006-2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef _QVLC_H_
25 #define _QVLC_H_
26
27 #include <vlc/vlc.h>
28 #include <vlc_interface.h>
29 #include <vlc_playlist.h>
30
31 #include <QEvent>
32
33 /* Add define for duration, VLC_META_ENGINE doesn't include it */
34 #define VLC_META_ENGINE_DURATION   0x00000002
35 #define VLC_META_DURATION          N_("Duration")
36
37
38 class QApplication;
39 class QMenu;
40 class MainInterface;
41 class DialogsProvider;
42 class VideoWidget;
43
44 struct intf_sys_t
45 {
46     QApplication *p_app;
47     MainInterface *p_mi;
48     playlist_t *p_playlist;
49     msg_subscription_t *p_sub; ///< Subscription to the message bank
50
51     VideoWidget *p_video;
52     int i_saved_height, i_saved_width;
53
54     QMenu * p_popup_menu;
55 };
56
57 #define THEPL p_intf->p_sys->p_playlist
58 #define QPL_LOCK vlc_mutex_lock( &THEPL->object_lock );
59 #define QPL_UNLOCK vlc_mutex_unlock( &THEPL->object_lock );
60
61 #define THEDP DialogsProvider::getInstance()
62 #define THEMIM MainInputManager::getInstance( p_intf )
63
64 #define qfu( i ) QString::fromUtf8( i )
65 #define qtr( i ) QString::fromUtf8( _(i) )
66 #define qtu( i ) i.toUtf8().data()
67 #define qta( i ) i.toAscii().data()
68
69 #define CONNECT( a, b, c, d ) connect( a, SIGNAL( b ), c, SLOT(d) )
70 #define BUTTONACT( b, a ) connect( b, SIGNAL( clicked() ), this, SLOT(a) )
71 #define ON_TIMEOUT( act ) CONNECT( THEDP->fixed_timer, timeout(), this, act )
72
73 #define BUTTON_SET( button, text, tooltip )  \
74     button->setText( text );                 \
75     button->setToolTip( tooltip );
76
77 #define BUTTON_SET_ACT( button, text, tooltip, thisslot ) \
78     BUTTON_SET( button, text, tooltip );                  \
79     BUTTONACT( button, thisslot );
80
81 #define BUTTON_SET_IMG( button, text, image, tooltip )    \
82     BUTTON_SET( button, text, tooltip );                  \
83     button->setIcon( QIcon( ":/pixmaps/"#image ) );
84
85 #define BUTTON_SET_ACT_I( button, text, image, tooltip, thisslot ) \
86     BUTTON_SET_IMG( button, text, image, tooltip );                \
87     BUTTONACT( button, thisslot );
88
89 static int DialogEvent_Type = QEvent::User + 1;
90 static int PLUndockEvent_Type = QEvent::User + 2;
91 static int PLDockEvent_Type = QEvent::User + 3;
92 static int SetVideoOnTopEvent_Type = QEvent::User + 4;
93
94 class DialogEvent : public QEvent
95 {
96 public:
97     DialogEvent( int _i_dialog, int _i_arg, intf_dialog_args_t *_p_arg ) :
98                  QEvent( (QEvent::Type)(DialogEvent_Type) )
99     {
100         i_dialog = _i_dialog;
101         i_arg = _i_arg;
102         p_arg = _p_arg;
103     };
104     virtual ~DialogEvent() {};
105
106     int i_arg, i_dialog;
107     intf_dialog_args_t *p_arg;
108 };
109
110 /* Ugly to put it here, but don't want more files ... */
111 #if 0
112 #include <QFrame>
113 class BasePlaylistWidget : public QFrame
114 {
115 public:
116     BasePlaylistWidget( intf_thread_t *_p_i ) : p_intf( _p_i)  {};
117     virtual ~BasePlaylistWidget() {};
118 protected:
119     intf_thread_t *p_intf;
120 };
121 #endif
122 #endif