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 *****************************************************************************/
31 #include <vlc_common.h>
32 #include <vlc_interface.h> /* intf_thread_t */
33 #include <vlc_playlist_legacy.h> /* playlist_t */
38 #define QT_STATICPLUGIN
41 #define QT_NO_CAST_TO_ASCII
45 #if ( QT_VERSION < 0x050900 )
46 # error Update your Qt version to at least 5.9.0
49 #define HAS_QT56 ( QT_VERSION >= 0x050600 )
50 #define HAS_QT510 ( QT_VERSION >= 0x051000 )
53 DialogEventTypeOffset
= 0,
54 IMEventTypeOffset
= 100,
55 PLEventTypeOffset
= 200,
56 MsgEventTypeOffset
= 300,
60 NOTIFICATION_NEVER
= 0,
61 NOTIFICATION_MINIMIZED
= 1,
62 NOTIFICATION_ALWAYS
= 2,
69 class QVLCApp
*p_app
; /* Main Qt Application */
70 class MainInterface
*p_mi
; /* Main Interface, NULL if DialogProvider Mode */
71 class QSettings
*mainSettings
; /* Qt State settings not messing main VLC ones */
72 class PLModel
*pl_model
;
74 QUrl filepath
; /* Last path used in dialogs */
76 unsigned voutWindowType
; /* Type of vout_window_t provided */
77 bool b_isDialogProvider
; /* Qt mode or Skins mode */
78 playlist_t
*p_playlist
; /* playlist */
80 bool disable_volume_keys
;
84 #define THEPL p_intf->p_sys->p_playlist
87 * This class may be used for scope-bound locking/unlocking
88 * of a playlist_t*. As hinted, the playlist is locked when
89 * the object is created, and unlocked when the object is
93 struct vlc_playlist_locker
{
94 vlc_playlist_locker( playlist_t
* p_playlist
)
95 : p_playlist( p_playlist
)
97 playlist_Lock( p_playlist
);
100 ~vlc_playlist_locker()
102 playlist_Unlock( p_playlist
);
106 playlist_t
* p_playlist
;
109 #define THEDP DialogsProvider::getInstance()
110 #define THEMIM MainInputManager::getInstance( p_intf )
111 #define THEAM ActionsManager::getInstance( p_intf )
113 #define qfu( i ) QString::fromUtf8( i )
114 #define qfue( i ) QString::fromUtf8( i ).replace( "&", "&&" ) /* for actions/buttons */
115 #define qtr( i ) QString::fromUtf8( vlc_gettext(i) )
116 #define qtu( i ) ((i).toUtf8().constData())
118 #define CONNECT( a, b, c, d ) \
119 connect( a, SIGNAL(b), c, SLOT(d) )
120 #define DCONNECT( a, b, c, d ) \
121 connect( a, SIGNAL(b), c, SLOT(d), Qt::DirectConnection )
122 #define BUTTONACT( b, a ) connect( b, SIGNAL(clicked()), this, SLOT(a) )
124 #define BUTTON_SET( button, text, tooltip ) \
125 button->setText( text ); \
126 button->setToolTip( tooltip );
128 #define BUTTON_SET_ACT( button, text, tooltip, thisslot ) \
129 BUTTON_SET( button, text, tooltip ); \
130 BUTTONACT( button, thisslot );
132 #define BUTTON_SET_IMG( button, text, image, tooltip ) \
133 BUTTON_SET( button, text, tooltip ); \
134 button->setIcon( QIcon( ":/"#image ".svg") );
136 #define BUTTON_SET_ACT_I( button, text, image, tooltip, thisslot ) \
137 BUTTON_SET_IMG( button, text, image, tooltip ); \
138 BUTTONACT( button, thisslot );
140 /* for widgets which must not follow the RTL auto layout changes */
141 #define RTL_UNAFFECTED_WIDGET setLayoutDirection( Qt::LeftToRight );
143 #define getSettings() p_intf->p_sys->mainSettings
145 static inline QString
QVLCUserDir( vlc_userdir_t type
)
147 char *dir
= config_GetUserDir( type
);
150 QString res
= qfu( dir
);
155 /* After this day of the year, the usual VLC cone is replaced by another cone
156 * wearing a Father Xmas hat.
157 * Note this icon doesn't represent an endorsment of Coca-Cola company.
159 #define QT_XMAS_JOKE_DAY 354