gui: qt: use float for rate
[vlc.git] / modules / gui / qt / qt.hpp
blobd7645dc24416929597e443efb786a3f548e1a889
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_legacy.h> /* playlist_t */
35 #include <qconfig.h>
37 #ifdef QT_STATIC
38 #define QT_STATICPLUGIN
39 #endif
41 #define QT_NO_CAST_TO_ASCII
42 #include <QString>
43 #include <QUrl>
45 #if ( QT_VERSION < 0x050900 )
46 # error Update your Qt version to at least 5.9.0
47 #endif
49 #define HAS_QT56 ( QT_VERSION >= 0x050600 )
50 #define HAS_QT510 ( QT_VERSION >= 0x051000 )
52 enum {
53 DialogEventTypeOffset = 0,
54 IMEventTypeOffset = 100,
55 PLEventTypeOffset = 200,
56 MsgEventTypeOffset = 300,
59 enum{
60 NOTIFICATION_NEVER = 0,
61 NOTIFICATION_MINIMIZED = 1,
62 NOTIFICATION_ALWAYS = 2,
65 struct intf_sys_t
67 vlc_thread_t thread;
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 */
79 #ifdef _WIN32
80 bool disable_volume_keys;
81 #endif
84 #define THEPL p_intf->p_sys->p_playlist
86 /**
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
90 * destroyed.
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 );
105 private:
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 );
148 if( !dir )
149 return "";
150 QString res = qfu( dir );
151 free( dir );
152 return res;
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
161 #endif