qt: playlist: use item title if available
[vlc.git] / modules / gui / qt / qt.hpp
bloba283a02e63b34af09725513e4e52d8a4d2c08cdd
1 /*****************************************************************************
2 * qt.hpp : Qt interface
3 ****************************************************************************
4 * Copyright (C) 2006-2009 the VideoLAN team
6 * Authors: Clément Stenac <zorglub@videolan.org>
7 * Jean-Baptiste Kempf <jb@videolan.org>
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.
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.
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 *****************************************************************************/
24 #ifndef QVLC_H_
25 #define QVLC_H_
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
31 #include <vlc_common.h>
32 #include <vlc_interface.h> /* intf_thread_t */
33 #include <vlc_playlist.h> /* vlc_playlist_t */
34 #include <vlc_player.h> /* vlc_player_t */
36 #include <qconfig.h>
38 #ifdef QT_STATIC
39 #define QT_STATICPLUGIN
40 #endif
42 #define QT_NO_CAST_TO_ASCII
43 #include <QString>
44 #include <QUrl>
46 #if ( QT_VERSION < QT_VERSION_CHECK(5, 11, 0) )
47 # error Update your Qt version to at least 5.11.0
48 #endif
51 enum {
52 IMEventTypeOffset = 0,
53 MsgEventTypeOffset = 100
56 enum{
57 NOTIFICATION_NEVER = 0,
58 NOTIFICATION_MINIMIZED = 1,
59 NOTIFICATION_ALWAYS = 2,
62 namespace vlc {
63 class Compositor;
65 namespace playlist {
66 class PlaylistControllerModel;
70 class PlayerController;
71 struct intf_sys_t
73 vlc_thread_t thread;
75 class QVLCApp *p_app; /* Main Qt Application */
76 class MainInterface *p_mi; /* Main Interface, NULL if DialogProvider Mode */
77 class QSettings *mainSettings; /* Qt State settings not messing main VLC ones */
79 QUrl filepath; /* Last path used in dialogs */
81 unsigned voutWindowType; /* Type of vout_window_t provided */
82 bool b_isDialogProvider; /* Qt mode or Skins mode */
84 vlc_playlist_t *p_playlist; /* playlist */
85 vlc_player_t *p_player; /* player */
86 vlc::playlist::PlaylistControllerModel* p_mainPlaylistController;
87 PlayerController* p_mainPlayerController;
88 vlc::Compositor* p_compositor;
90 #ifdef _WIN32
91 bool disable_volume_keys;
92 #endif
95 /**
96 * This class may be used for scope-bound locking/unlocking
97 * of a player_t*. As hinted, the player is locked when
98 * the object is created, and unlocked when the object is
99 * destroyed.
101 struct vlc_player_locker {
102 vlc_player_locker( vlc_player_t* p_player )
103 : p_player( p_player )
105 vlc_player_Lock( p_player );
108 ~vlc_player_locker()
110 vlc_player_Unlock( p_player );
113 private:
114 vlc_player_t* p_player;
117 #define THEDP DialogsProvider::getInstance()
118 #define THEMIM p_intf->p_sys->p_mainPlayerController
119 #define THEMPL p_intf->p_sys->p_mainPlaylistController
121 #define qfu( i ) QString::fromUtf8( i )
122 #define qfue( i ) QString::fromUtf8( i ).replace( "&", "&&" ) /* for actions/buttons */
123 #define qtr( i ) QString::fromUtf8( vlc_gettext(i) )
124 #define qtu( i ) ((i).toUtf8().constData())
126 #define CONNECT( a, b, c, d ) \
127 connect( a, SIGNAL(b), c, SLOT(d) )
128 #define DCONNECT( a, b, c, d ) \
129 connect( a, SIGNAL(b), c, SLOT(d), Qt::DirectConnection )
130 #define BUTTONACT( b, a ) connect( b, SIGNAL(clicked()), this, SLOT(a) )
132 #define BUTTON_SET( button, text, tooltip ) \
133 button->setText( text ); \
134 button->setToolTip( tooltip );
136 #define BUTTON_SET_ACT( button, text, tooltip, thisslot ) \
137 BUTTON_SET( button, text, tooltip ); \
138 BUTTONACT( button, thisslot );
140 #define BUTTON_SET_IMG( button, text, image, tooltip ) \
141 BUTTON_SET( button, text, tooltip ); \
142 button->setIcon( QIcon( ":/"#image ".svg") );
144 #define BUTTON_SET_ACT_I( button, text, image, tooltip, thisslot ) \
145 BUTTON_SET_IMG( button, text, image, tooltip ); \
146 BUTTONACT( button, thisslot );
148 /* for widgets which must not follow the RTL auto layout changes */
149 #define RTL_UNAFFECTED_WIDGET setLayoutDirection( Qt::LeftToRight );
151 #define getSettings() p_intf->p_sys->mainSettings
153 static inline QString QVLCUserDir( vlc_userdir_t type )
155 char *dir = config_GetUserDir( type );
156 if( !dir )
157 return "";
158 QString res = qfu( dir );
159 free( dir );
160 return res;
163 /* After this day of the year, the usual VLC cone is replaced by another cone
164 * wearing a Father Xmas hat.
165 * Note this icon doesn't represent an endorsment of Coca-Cola company.
167 #define QT_XMAS_JOKE_DAY 354
169 #endif