Commit 1c221a77 authored by Pierre Lamot's avatar Pierre Lamot Committed by Jean-Baptiste Kempf

qt: drop Qt 4 support, set minimal Qt version to 5.5

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent eaa55ce3
...@@ -3668,20 +3668,15 @@ AS_IF([test "${enable_qt}" != "no"], [ ...@@ -3668,20 +3668,15 @@ AS_IF([test "${enable_qt}" != "no"], [
AC_PATH_PROGS(RCC, [rcc-qt5 rcc], rcc, ["${QT_HOST_PATH}" "${QT_PATH}/bin"]) AC_PATH_PROGS(RCC, [rcc-qt5 rcc], rcc, ["${QT_HOST_PATH}" "${QT_PATH}/bin"])
AC_PATH_PROGS(UIC, [uic-qt5 uic], uic, ["${QT_HOST_PATH}" "${QT_PATH}/bin"]) AC_PATH_PROGS(UIC, [uic-qt5 uic], uic, ["${QT_HOST_PATH}" "${QT_PATH}/bin"])
], [ ], [
PKG_CHECK_MODULES([QT], [QtCore QtGui >= 4.8.0],, [ AS_IF([test -n "${enable_qt}"],[
AS_IF([test -n "${enable_qt}"],[ AC_MSG_ERROR([${QT_PKG_ERRORS}.])
AC_MSG_ERROR([${QT_PKG_ERRORS}.]) ],[
],[ AC_MSG_WARN([${QT_PKG_ERRORS}.])
AC_MSG_WARN([${QT_PKG_ERRORS}.])
])
enable_qt="no"
]) ])
QT_PATH="$(eval $PKG_CONFIG --variable=exec_prefix QtCore)" enable_qt="no"
AC_PATH_PROGS(MOC, [moc-qt4 moc], moc, ["${QT_PATH}/bin"])
AC_PATH_PROG(RCC, rcc, rcc, ["${QT_PATH}/bin"])
AC_PATH_PROGS(UIC, [uic-qt4 uic], uic, ["${QT_PATH}/bin"])
]) ])
]) ])
AS_IF([test "${enable_qt}" != "no"], [ AS_IF([test "${enable_qt}" != "no"], [
ALIASES="${ALIASES} qvlc" ALIASES="${ALIASES} qvlc"
]) ])
......
...@@ -479,11 +479,7 @@ InfoPanel::InfoPanel( QWidget *parent ) : QWidget( parent ) ...@@ -479,11 +479,7 @@ InfoPanel::InfoPanel( QWidget *parent ) : QWidget( parent )
InfoTree = new QTreeWidget(this); InfoTree = new QTreeWidget(this);
InfoTree->setColumnCount( 1 ); InfoTree->setColumnCount( 1 );
InfoTree->header()->hide(); InfoTree->header()->hide();
#if HAS_QT5
InfoTree->header()->setSectionResizeMode(QHeaderView::ResizeToContents); InfoTree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
#else
InfoTree->header()->setResizeMode(QHeaderView::ResizeToContents);
#endif
layout->addWidget(InfoTree, 1, 0 ); layout->addWidget(InfoTree, 1, 0 );
} }
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
# include <QWindow> # include <QWindow>
#endif #endif
#if defined(_WIN32) && HAS_QT5 #if defined(_WIN32)
#include <QWindow> #include <QWindow>
#include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformnativeinterface.h>
#endif #endif
...@@ -198,7 +198,7 @@ QSize VideoWidget::physicalSize() const ...@@ -198,7 +198,7 @@ QSize VideoWidget::physicalSize() const
return QSize( x_attributes.width, x_attributes.height ); return QSize( x_attributes.width, x_attributes.height );
} }
#endif #endif
#if defined(_WIN32) && HAS_QT5 #if defined(_WIN32)
HWND hwnd; HWND hwnd;
RECT rect; RECT rect;
...@@ -215,11 +215,9 @@ QSize VideoWidget::physicalSize() const ...@@ -215,11 +215,9 @@ QSize VideoWidget::physicalSize() const
# if HAS_QT56 # if HAS_QT56
/* Android-like scaling */ /* Android-like scaling */
current_size *= devicePixelRatioF(); current_size *= devicePixelRatioF();
# elif HAS_QT54 # else
/* OSX-like scaling */ /* OSX-like scaling */
current_size *= devicePixelRatio(); current_size *= devicePixelRatio();
# else
# warning "No HiDPI support"
# endif # endif
return current_size; return current_size;
......
...@@ -279,15 +279,9 @@ void FileOpenPanel::updateMRL() ...@@ -279,15 +279,9 @@ void FileOpenPanel::updateMRL()
} }
else else
{ {
#if HAS_QT5
QList<QUrl> urls = dialogBox->selectedUrls(); QList<QUrl> urls = dialogBox->selectedUrls();
foreach( const QUrl &url, urls ) foreach( const QUrl &url, urls )
fileList.append( url.toEncoded() ); fileList.append( url.toEncoded() );
#else
fileList = dialogBox->selectedFiles();
for( int i = 0; i < fileList.count(); i++ )
fileList[i] = toURI( fileList[i] );
#endif
} }
/* Options */ /* Options */
......
...@@ -431,11 +431,7 @@ PlTreeView::PlTreeView( QAbstractItemModel *, QWidget *parent ) : QTreeView( par ...@@ -431,11 +431,7 @@ PlTreeView::PlTreeView( QAbstractItemModel *, QWidget *parent ) : QTreeView( par
viewport()->setAttribute( Qt::WA_Hover ); viewport()->setAttribute( Qt::WA_Hover );
header()->setSortIndicator( -1 , Qt::AscendingOrder ); header()->setSortIndicator( -1 , Qt::AscendingOrder );
header()->setSortIndicatorShown( true ); header()->setSortIndicatorShown( true );
#if HAS_QT5
header()->setSectionsClickable( true ); header()->setSectionsClickable( true );
#else
header()->setClickable( true );
#endif
header()->setContextMenuPolicy( Qt::CustomContextMenu ); header()->setContextMenuPolicy( Qt::CustomContextMenu );
setSelectionBehavior( QAbstractItemView::SelectRows ); setSelectionBehavior( QAbstractItemView::SelectRows );
......
...@@ -340,11 +340,7 @@ void MessagesDialog::MsgCallback( void *self, int type, const vlc_log_t *item, ...@@ -340,11 +340,7 @@ void MessagesDialog::MsgCallback( void *self, int type, const vlc_log_t *item,
{ {
MessagesDialog *dialog = (MessagesDialog *)self; MessagesDialog *dialog = (MessagesDialog *)self;
char *str; char *str;
#if HAS_QT5
int verbosity = dialog->verbosity.load(); int verbosity = dialog->verbosity.load();
#else
int verbosity = dialog->verbosity;
#endif
if( verbosity < 0 || verbosity < (type - VLC_MSG_ERR) if( verbosity < 0 || verbosity < (type - VLC_MSG_ERR)
|| unlikely(vasprintf( &str, format, ap ) == -1) ) || unlikely(vasprintf( &str, format, ap ) == -1) )
......
...@@ -117,11 +117,7 @@ PluginTab::PluginTab( intf_thread_t *p_intf_ ) ...@@ -117,11 +117,7 @@ PluginTab::PluginTab( intf_thread_t *p_intf_ )
layout->addWidget( treePlugins, 0, 0, 1, -1 ); layout->addWidget( treePlugins, 0, 0, 1, -1 );
/* Users cannot move the columns around but we need to sort */ /* Users cannot move the columns around but we need to sort */
#if HAS_QT5
treePlugins->header()->setSectionsMovable( false ); treePlugins->header()->setSectionsMovable( false );
#else
treePlugins->header()->setMovable( false );
#endif
treePlugins->header()->setSortIndicatorShown( true ); treePlugins->header()->setSortIndicatorShown( true );
// treePlugins->header()->setResizeMode( QHeaderView::ResizeToContents ); // treePlugins->header()->setResizeMode( QHeaderView::ResizeToContents );
treePlugins->setAlternatingRowColors( true ); treePlugins->setAlternatingRowColors( true );
...@@ -1046,11 +1042,7 @@ void ExtensionItemDelegate::paint( QPainter *painter, ...@@ -1046,11 +1042,7 @@ void ExtensionItemDelegate::paint( QPainter *painter,
const QStyleOptionViewItem &option, const QStyleOptionViewItem &option,
const QModelIndex &index ) const const QModelIndex &index ) const
{ {
#if HAS_QT5
QStyleOptionViewItem opt = option; QStyleOptionViewItem opt = option;
#else
QStyleOptionViewItemV4 opt = option;
#endif
initStyleOption( &opt, index ); initStyleOption( &opt, index );
// Draw background // Draw background
...@@ -1132,11 +1124,7 @@ void AddonItemDelegate::paint( QPainter *painter, ...@@ -1132,11 +1124,7 @@ void AddonItemDelegate::paint( QPainter *painter,
const QStyleOptionViewItem &option, const QStyleOptionViewItem &option,
const QModelIndex &index ) const const QModelIndex &index ) const
{ {
#if HAS_QT5
QStyleOptionViewItem newopt = option; QStyleOptionViewItem newopt = option;
#else
QStyleOptionViewItemV4 newopt = option;
#endif
int i_state = index.data( AddonsListModel::StateRole ).toInt(); int i_state = index.data( AddonsListModel::StateRole ).toInt();
int i_type = index.data( AddonsListModel::TypeRole ).toInt(); int i_type = index.data( AddonsListModel::TypeRole ).toInt();
...@@ -1259,15 +1247,9 @@ void AddonItemDelegate::paint( QPainter *painter, ...@@ -1259,15 +1247,9 @@ void AddonItemDelegate::paint( QPainter *painter,
progressbar->setGeometry( progressbar->setGeometry(
newopt.rect.adjusted( adjustment.width(), adjustment.height(), newopt.rect.adjusted( adjustment.width(), adjustment.height(),
-adjustment.width(), -adjustment.height() ) ); -adjustment.width(), -adjustment.height() ) );
#if HAS_QT5
painter->drawPixmap( newopt.rect.left() + adjustment.width(), painter->drawPixmap( newopt.rect.left() + adjustment.width(),
newopt.rect.top() + adjustment.height(), newopt.rect.top() + adjustment.height(),
progressbar->grab() ); progressbar->grab() );
#else
painter->drawPixmap( newopt.rect.left() + adjustment.width(),
newopt.rect.top() + adjustment.height(),
QPixmap::grabWidget( progressbar ) );
#endif
} }
painter->restore(); painter->restore();
} }
......
...@@ -316,11 +316,7 @@ void PreviewWidget::paintEvent( QPaintEvent * ) ...@@ -316,11 +316,7 @@ void PreviewWidget::paintEvent( QPaintEvent * )
QPixmap pixmaps[3]; QPixmap pixmaps[3];
for( int i=0; i<3; i++ ) for( int i=0; i<3; i++ )
{ {
#if HAS_QT5
pixmaps[i] = bars[i]->grab( bars[i]->contentsRect() ); pixmaps[i] = bars[i]->grab( bars[i]->contentsRect() );
#else
pixmaps[i] = QPixmap::grabWidget( bars[i], bars[i]->contentsRect() );
#endif
for( int j=0; j < bars[i]->layout()->count(); j++ ) for( int j=0; j < bars[i]->layout()->count(); j++ )
{ {
QLayoutItem *item = bars[i]->layout()->itemAt( j ); QLayoutItem *item = bars[i]->layout()->itemAt( j );
...@@ -578,11 +574,7 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) ...@@ -578,11 +574,7 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent )
if( widget == NULL ) continue; if( widget == NULL ) continue;
#if HAS_QT5
widgetItem->setIcon( QIcon( widget->grab() ) ); widgetItem->setIcon( QIcon( widget->grab() ) );
#else
widgetItem->setIcon( QIcon( QPixmap::grabWidget( widget ) ) );
#endif
widgetItem->setToolTip( widgetItem->text() ); widgetItem->setToolTip( widgetItem->text() );
widget->hide(); widget->hide();
widgetItem->setData( Qt::UserRole, QVariant( i ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) );
......
...@@ -121,17 +121,10 @@ QStringList DialogsProvider::getOpenURL( QWidget *parent, ...@@ -121,17 +121,10 @@ QStringList DialogsProvider::getOpenURL( QWidget *parent,
QString *selectedFilter ) QString *selectedFilter )
{ {
QStringList res; QStringList res;
#if HAS_QT5
QList<QUrl> urls = QFileDialog::getOpenFileUrls( parent, caption, QUrl::fromUserInput( dir ), filter, selectedFilter ); QList<QUrl> urls = QFileDialog::getOpenFileUrls( parent, caption, QUrl::fromUserInput( dir ), filter, selectedFilter );
foreach( const QUrl& url, urls ) foreach( const QUrl& url, urls )
res.append( url.toEncoded() ); res.append( url.toEncoded() );
#else
QStringList files = QFileDialog::getOpenFileNames( parent, caption, dir, filter, selectedFilter );
foreach ( const QString& file, files )
res.append( toURI( toNativeSeparators( file ) ) );
#endif
return res; return res;
} }
......
...@@ -37,10 +37,8 @@ ...@@ -37,10 +37,8 @@
#include <assert.h> #include <assert.h>
#if HAS_QT5 #include <QWindow>
# include <QWindow> #include <qpa/qplatformnativeinterface.h>
# include <qpa/qplatformnativeinterface.h>
#endif
#define WM_APPCOMMAND 0x0319 #define WM_APPCOMMAND 0x0319
...@@ -106,32 +104,21 @@ MainInterfaceWin32::~MainInterfaceWin32() ...@@ -106,32 +104,21 @@ MainInterfaceWin32::~MainInterfaceWin32()
HWND MainInterfaceWin32::WinId( QWidget *w ) HWND MainInterfaceWin32::WinId( QWidget *w )
{ {
#if HAS_QT5
if( w && w->windowHandle() ) if( w && w->windowHandle() )
return static_cast<HWND>(QGuiApplication::platformNativeInterface()-> return static_cast<HWND>(QGuiApplication::platformNativeInterface()->
nativeResourceForWindow("handle", w->windowHandle())); nativeResourceForWindow("handle", w->windowHandle()));
else else
return 0; return 0;
#else
return winId();
#endif
} }
#if !HAS_QT5
static const int PremultipliedAlpha = QPixmap::PremultipliedAlpha;
static HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0)
{
return p.toWinHBITMAP((enum QBitmap::HBitmapFormat)hbitmapFormat);
}
#else
Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0); Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0);
enum HBitmapFormat enum HBitmapFormat
{ {
NoAlpha, NoAlpha,
PremultipliedAlpha, PremultipliedAlpha,
Alpha Alpha
}; };
#endif
void MainInterfaceWin32::createTaskBarButtons() void MainInterfaceWin32::createTaskBarButtons()
{ {
...@@ -228,12 +215,10 @@ void MainInterfaceWin32::createTaskBarButtons() ...@@ -228,12 +215,10 @@ void MainInterfaceWin32::createTaskBarButtons()
changeThumbbarButtons( THEMIM->getIM()->playingStatus() ); changeThumbbarButtons( THEMIM->getIM()->playingStatus() );
} }
#if HAS_QT5
bool MainInterfaceWin32::nativeEvent(const QByteArray &, void *message, long *result) bool MainInterfaceWin32::nativeEvent(const QByteArray &, void *message, long *result)
{ {
return winEvent( static_cast<MSG*>( message ), result ); return winEvent( static_cast<MSG*>( message ), result );
} }
#endif
bool MainInterfaceWin32::winEvent ( MSG * msg, long * result ) bool MainInterfaceWin32::winEvent ( MSG * msg, long * result )
{ {
...@@ -346,12 +331,8 @@ void MainInterfaceWin32::toggleUpdateSystrayMenuWhenVisible() ...@@ -346,12 +331,8 @@ void MainInterfaceWin32::toggleUpdateSystrayMenuWhenVisible()
* but ignore the ones always on top * but ignore the ones always on top
* and the ones which can't be activated */ * and the ones which can't be activated */
HWND winId; HWND winId;
#if HAS_QT5
QWindow *window = windowHandle(); QWindow *window = windowHandle();
winId = static_cast<HWND>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window)); winId = static_cast<HWND>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window));
#else
winId = internalWinId();
#endif
WINDOWINFO wi; WINDOWINFO wi;
HWND hwnd; HWND hwnd;
......
...@@ -36,9 +36,7 @@ public: ...@@ -36,9 +36,7 @@ public:
virtual ~MainInterfaceWin32(); virtual ~MainInterfaceWin32();
private: private:
#if HAS_QT5
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
#endif
virtual bool winEvent( MSG *, long * ); virtual bool winEvent( MSG *, long * );
virtual void toggleUpdateSystrayMenuWhenVisible() Q_DECL_OVERRIDE; virtual void toggleUpdateSystrayMenuWhenVisible() Q_DECL_OVERRIDE;
......
...@@ -53,18 +53,14 @@ ...@@ -53,18 +53,14 @@
#ifdef _WIN32 /* For static builds */ #ifdef _WIN32 /* For static builds */
#include <QtPlugin> #include <QtPlugin>
#if HAS_QT5
#ifdef QT_STATICPLUGIN #ifdef QT_STATICPLUGIN
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
Q_IMPORT_PLUGIN(QSvgIconPlugin) Q_IMPORT_PLUGIN(QSvgIconPlugin)
Q_IMPORT_PLUGIN(QSvgPlugin) Q_IMPORT_PLUGIN(QSvgPlugin)
#if !HAS_QT56 #if !HAS_QT56
Q_IMPORT_PLUGIN(AccessibleFactory) Q_IMPORT_PLUGIN(AccessibleFactory)
#endif
#endif #endif
#else
Q_IMPORT_PLUGIN(qjpeg)
Q_IMPORT_PLUGIN(qtaccessiblewidgets)
#endif #endif
#endif #endif
...@@ -604,7 +600,6 @@ static void *ThreadPlatform( void *obj, char *platform_name ) ...@@ -604,7 +600,6 @@ static void *ThreadPlatform( void *obj, char *platform_name )
/* Check window type from the Qt platform back-end */ /* Check window type from the Qt platform back-end */
p_sys->voutWindowType = VOUT_WINDOW_TYPE_INVALID; p_sys->voutWindowType = VOUT_WINDOW_TYPE_INVALID;
#if HAS_QT5
QString platform = app.platformName(); QString platform = app.platformName();
if( platform == qfu("xcb") ) if( platform == qfu("xcb") )
p_sys->voutWindowType = VOUT_WINDOW_TYPE_XID; p_sys->voutWindowType = VOUT_WINDOW_TYPE_XID;
...@@ -616,11 +611,6 @@ static void *ThreadPlatform( void *obj, char *platform_name ) ...@@ -616,11 +611,6 @@ static void *ThreadPlatform( void *obj, char *platform_name )
p_sys->voutWindowType = VOUT_WINDOW_TYPE_NSOBJECT; p_sys->voutWindowType = VOUT_WINDOW_TYPE_NSOBJECT;
else else
msg_Err( p_intf, "unknown Qt platform: %s", qtu(platform) ); msg_Err( p_intf, "unknown Qt platform: %s", qtu(platform) );
#elif defined (Q_WS_WIN) || defined (Q_WS_PM)
p_sys->voutWindowType = VOUT_WINDOW_TYPE_HWND;
#elif defined (Q_WS_MAC)
p_sys->voutWindowType = VOUT_WINDOW_TYPE_NSOBJECT;
#endif
var_Create( THEPL, "qt4-iface", VLC_VAR_ADDRESS ); var_Create( THEPL, "qt4-iface", VLC_VAR_ADDRESS );
var_SetAddress( THEPL, "qt4-iface", p_intf ); var_SetAddress( THEPL, "qt4-iface", p_intf );
......
...@@ -42,19 +42,12 @@ ...@@ -42,19 +42,12 @@
#define QT_NO_CAST_TO_ASCII #define QT_NO_CAST_TO_ASCII
#include <QString> #include <QString>
#if ( QT_VERSION < 0x040800 ) #if ( QT_VERSION < 0x050500 )
# error Update your Qt version to at least 4.8.0 # error Update your Qt version to at least 5.5.0
#endif #endif
#define HAS_QT5 ( QT_VERSION >= 0x050000 )
#define HAS_QT54 ( QT_VERSION >= 0x050400 )
#define HAS_QT56 ( QT_VERSION >= 0x050600 ) #define HAS_QT56 ( QT_VERSION >= 0x050600 )
/* Q_DECL_OVERRIDE is a Qt5 feature, add empty define to not break with Qt4 */
#if !HAS_QT5 && !defined(Q_DECL_OVERRIDE)
# define Q_DECL_OVERRIDE
#endif
enum { enum {
DialogEventTypeOffset = 0, DialogEventTypeOffset = 0,
IMEventTypeOffset = 100, IMEventTypeOffset = 100,
......
...@@ -68,7 +68,7 @@ void TimeTooltip::adjustPosition() ...@@ -68,7 +68,7 @@ void TimeTooltip::adjustPosition()
// The desired label position is just above the target // The desired label position is just above the target
QPoint position( mTarget.x() - size.width() / 2, QPoint position( mTarget.x() - size.width() / 2,
#if defined( Q_OS_WIN ) && HAS_QT5 #if defined( Q_OS_WIN )
mTarget.y() - 2 * size.height() - TIP_HEIGHT / 2 ); mTarget.y() - 2 * size.height() - TIP_HEIGHT / 2 );
#else #else
mTarget.y() - size.height() + TIP_HEIGHT / 2 ); mTarget.y() - size.height() + TIP_HEIGHT / 2 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment