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