]> git.sesse.net Git - vlc/blob - modules/gui/qt4/qt4.hpp
qt4: a few stability fixes when working as a dialogs provider, needs a lot more ...
[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 class QApplication;
34 class QMenu;
35 class MainInterface;
36 class DialogsProvider;
37 class VideoWidget;
38
39 struct intf_sys_t
40 {
41     QApplication *p_app;
42     MainInterface *p_mi;
43     playlist_t *p_playlist;
44     msg_subscription_t *p_sub; ///< Subscription to the message bank
45
46     VideoWidget *p_video;
47     int i_saved_height, i_saved_width;
48
49     QMenu * p_popup_menu;
50 };
51
52 #define THEPL p_intf->p_sys->p_playlist
53 #define QPL_LOCK vlc_mutex_lock( &THEPL->object_lock );
54 #define QPL_UNLOCK vlc_mutex_unlock( &THEPL->object_lock );
55
56 #define THEDP DialogsProvider::getInstance()
57 #define THEMIM MainInputManager::getInstance( p_intf )
58
59 #define qfu( i ) QString::fromUtf8( i )
60 #define qtr( i ) QString::fromUtf8( _(i) )
61 #define qtu( i ) i.toUtf8().data()
62 #define qta( i ) i.toAscii().data()
63
64 #define CONNECT( a, b, c, d ) connect( a, SIGNAL( b ), c, SLOT(d) )
65 #define BUTTONACT( b, a ) connect( b, SIGNAL( clicked() ), this, SLOT(a) )
66 #define ON_TIMEOUT( act ) CONNECT( THEDP->fixed_timer, timeout(), this, act )
67
68 #define BUTTON_SET( button, text, tooltip )  \
69     button->setText( text );                 \
70     button->setToolTip( tooltip );
71
72 #define BUTTON_SET_ACT( button, text, tooltip, thisslot ) \
73     BUTTON_SET( button, text, tooltip );                  \
74     BUTTONACT( button, thisslot );
75
76 #define BUTTON_SET_IMG( button, text, image, tooltip )    \
77     BUTTON_SET( button, text, tooltip );                  \
78     button->setIcon( QIcon( ":/pixmaps/"#image ) );
79
80 #define BUTTON_SET_ACT_I( button, text, image, tooltip, thisslot ) \
81     BUTTON_SET_IMG( button, text, image, tooltip );                \
82     BUTTONACT( button, thisslot );
83
84 static int DialogEvent_Type = QEvent::User + 1;
85 static int PLUndockEvent_Type = QEvent::User + 2;
86 static int PLDockEvent_Type = QEvent::User + 3;
87 static int SetVideoOnTopEvent_Type = QEvent::User + 4;
88
89 class DialogEvent : public QEvent
90 {
91 public:
92     DialogEvent( int _i_dialog, int _i_arg, intf_dialog_args_t *_p_arg ) :
93                  QEvent( (QEvent::Type)(DialogEvent_Type) )
94     {
95         i_dialog = _i_dialog;
96         i_arg = _i_arg;
97         p_arg = _p_arg;
98     };
99     virtual ~DialogEvent() {};
100
101     int i_arg, i_dialog;
102     intf_dialog_args_t *p_arg;
103 };
104
105 /* Ugly to put it here, but don't want more files ... */
106 #include <QFrame>
107 class BasePlaylistWidget : public QFrame
108 {
109 public:
110     BasePlaylistWidget( intf_thread_t *_p_i ) : p_intf( _p_i)  {};
111     virtual ~BasePlaylistWidget() {};
112 protected:
113     intf_thread_t *p_intf;
114 };
115
116 #endif