1 /*****************************************************************************
2 * qt.hpp : Qt interface
3 ****************************************************************************
4 * Copyright (C) 2006-2009 the VideoLAN team
5 * $Id: e59583ab712116f8590fa6465206e6505c0b51fc $
6 *
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
24
25 #ifndef QVLC_H_
26 #define QVLC_H_
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc_common.h> /* VLC_COMMON_MEMBERS for vlc_interface.h */
33 #include <vlc_interface.h> /* intf_thread_t */
34 #include <vlc_playlist.h> /* playlist_t */
35
36 #include <qconfig.h>
37
38 #ifdef QT_STATIC
39 #define QT_STATICPLUGIN
40 #endif
41
42 #define QT_NO_CAST_TO_ASCII
43 #include <QString>
44 #include <QUrl>
45
46 #if ( QT_VERSION < 0x050500 )
47 # error Update your Qt version to at least 5.5.0
48 #endif
49
50 #define HAS_QT56 ( QT_VERSION >= 0x050600 )
51 #define HAS_QT510 ( QT_VERSION >= 0x051000 )
52
53 enum {
54 DialogEventTypeOffset = 0,
55 IMEventTypeOffset = 100,
56 PLEventTypeOffset = 200,
57 MsgEventTypeOffset = 300,
58 };
59
60 enum{
61 NOTIFICATION_NEVER = 0,
62 NOTIFICATION_MINIMIZED = 1,
63 NOTIFICATION_ALWAYS = 2,
64 };
65
66 struct intf_sys_t
67 {
68 vlc_thread_t thread;
69
70 class QVLCApp *p_app; /* Main Qt Application */
71 class MainInterface *p_mi; /* Main Interface, NULL if DialogProvider Mode */
72 class QSettings *mainSettings; /* Qt State settings not messing main VLC ones */
73 class PLModel *pl_model;
74
75 QUrl filepath; /* Last path used in dialogs */
76
77 unsigned voutWindowType; /* Type of vout_window_t provided */
78 bool b_isDialogProvider; /* Qt mode or Skins mode */
79 playlist_t *p_playlist; /* playlist */
80 #ifdef _WIN32
81 bool disable_volume_keys;
82 #endif
83 };
84
85 #define THEPL p_intf->p_sys->p_playlist
86
87 /**
88 * This class may be used for scope-bound locking/unlocking
89 * of a playlist_t*. As hinted, the playlist is locked when
90 * the object is created, and unlocked when the object is
91 * destroyed.
92 */
93
94 struct vlc_playlist_locker {
vlc_playlist_lockervlc_playlist_locker95 vlc_playlist_locker( playlist_t* p_playlist )
96 : p_playlist( p_playlist )
97 {
98 playlist_Lock( p_playlist );
99 }
100
~vlc_playlist_lockervlc_playlist_locker101 ~vlc_playlist_locker()
102 {
103 playlist_Unlock( p_playlist );
104 }
105
106 private:
107 playlist_t* p_playlist;
108 };
109
110 #define THEDP DialogsProvider::getInstance()
111 #define THEMIM MainInputManager::getInstance( p_intf )
112 #define THEAM ActionsManager::getInstance( p_intf )
113
114 #define qfu( i ) QString::fromUtf8( i )
115 #define qfue( i ) QString::fromUtf8( i ).replace( "&", "&&" ) /* for actions/buttons */
116 #define qtr( i ) QString::fromUtf8( vlc_gettext(i) )
117 #define qtu( i ) ((i).toUtf8().constData())
118
119 #define CONNECT( a, b, c, d ) \
120 connect( a, SIGNAL(b), c, SLOT(d) )
121 #define DCONNECT( a, b, c, d ) \
122 connect( a, SIGNAL(b), c, SLOT(d), Qt::DirectConnection )
123 #define BUTTONACT( b, a ) connect( b, SIGNAL(clicked()), this, SLOT(a) )
124
125 #define BUTTON_SET( button, text, tooltip ) \
126 button->setText( text ); \
127 button->setToolTip( tooltip );
128
129 #define BUTTON_SET_ACT( button, text, tooltip, thisslot ) \
130 BUTTON_SET( button, text, tooltip ); \
131 BUTTONACT( button, thisslot );
132
133 #define BUTTON_SET_IMG( button, text, image, tooltip ) \
134 BUTTON_SET( button, text, tooltip ); \
135 button->setIcon( QIcon( ":/"#image ".svg") );
136
137 #define BUTTON_SET_ACT_I( button, text, image, tooltip, thisslot ) \
138 BUTTON_SET_IMG( button, text, image, tooltip ); \
139 BUTTONACT( button, thisslot );
140
141 /* for widgets which must not follow the RTL auto layout changes */
142 #define RTL_UNAFFECTED_WIDGET setLayoutDirection( Qt::LeftToRight );
143
144 #define getSettings() p_intf->p_sys->mainSettings
145
QVLCUserDir(vlc_userdir_t type)146 static inline QString QVLCUserDir( vlc_userdir_t type )
147 {
148 char *dir = config_GetUserDir( type );
149 if( !dir )
150 return "";
151 QString res = qfu( dir );
152 free( dir );
153 return res;
154 }
155
156 /* After this day of the year, the usual VLC cone is replaced by another cone
157 * wearing a Father Xmas hat.
158 * Note this icon doesn't represent an endorsment of Coca-Cola company.
159 */
160 #define QT_XMAS_JOKE_DAY 354
161
162 #endif
163