[vlc-devel] [PATCH 2/2] qt: drop Qt 4 support, set minimal Qt version as 5.5

Pierre Lamot pierre at videolabs.io
Fri Oct 20 17:13:05 CEST 2017


---
 configure.ac                                    | 17 ++++++-----------
 modules/gui/qt/components/info_panels.cpp       |  4 ----
 modules/gui/qt/components/interface_widgets.cpp |  8 +++-----
 modules/gui/qt/components/open_panels.cpp       |  6 ------
 modules/gui/qt/components/playlist/views.cpp    |  4 ----
 modules/gui/qt/dialogs/messages.cpp             |  4 ----
 modules/gui/qt/dialogs/plugins.cpp              | 18 ------------------
 modules/gui/qt/dialogs/toolbar.cpp              |  8 --------
 modules/gui/qt/dialogs_provider.cpp             |  7 -------
 modules/gui/qt/main_interface_win32.cpp         | 25 +++----------------------
 modules/gui/qt/main_interface_win32.hpp         |  2 --
 modules/gui/qt/qt.cpp                           | 24 +++++++-----------------
 modules/gui/qt/qt.hpp                           | 11 ++---------
 modules/gui/qt/util/timetooltip.cpp             |  2 +-
 14 files changed, 22 insertions(+), 118 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2012848d9a..01d0112571 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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"
 ])
diff --git a/modules/gui/qt/components/info_panels.cpp b/modules/gui/qt/components/info_panels.cpp
index 0789a5bd99..265fbbdd6f 100644
--- a/modules/gui/qt/components/info_panels.cpp
+++ b/modules/gui/qt/components/info_panels.cpp
@@ -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 );
 }
 
diff --git a/modules/gui/qt/components/interface_widgets.cpp b/modules/gui/qt/components/interface_widgets.cpp
index ea0b209db3..08079ec9c4 100644
--- a/modules/gui/qt/components/interface_widgets.cpp
+++ b/modules/gui/qt/components/interface_widgets.cpp
@@ -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;
diff --git a/modules/gui/qt/components/open_panels.cpp b/modules/gui/qt/components/open_panels.cpp
index 15f59c477b..cbdc8ce92c 100644
--- a/modules/gui/qt/components/open_panels.cpp
+++ b/modules/gui/qt/components/open_panels.cpp
@@ -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 */
diff --git a/modules/gui/qt/components/playlist/views.cpp b/modules/gui/qt/components/playlist/views.cpp
index e8b1a49d10..ecc6b9918d 100644
--- a/modules/gui/qt/components/playlist/views.cpp
+++ b/modules/gui/qt/components/playlist/views.cpp
@@ -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 );
diff --git a/modules/gui/qt/dialogs/messages.cpp b/modules/gui/qt/dialogs/messages.cpp
index 842bf98fa8..f550bfa23f 100644
--- a/modules/gui/qt/dialogs/messages.cpp
+++ b/modules/gui/qt/dialogs/messages.cpp
@@ -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) )
diff --git a/modules/gui/qt/dialogs/plugins.cpp b/modules/gui/qt/dialogs/plugins.cpp
index 9edcce9591..93c92b9fa6 100644
--- a/modules/gui/qt/dialogs/plugins.cpp
+++ b/modules/gui/qt/dialogs/plugins.cpp
@@ -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();
         }
diff --git a/modules/gui/qt/dialogs/toolbar.cpp b/modules/gui/qt/dialogs/toolbar.cpp
index 9e48eec990..1cc245aa9a 100644
--- a/modules/gui/qt/dialogs/toolbar.cpp
+++ b/modules/gui/qt/dialogs/toolbar.cpp
@@ -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 ) );
diff --git a/modules/gui/qt/dialogs_provider.cpp b/modules/gui/qt/dialogs_provider.cpp
index 495cd54972..ec393b5f4c 100644
--- a/modules/gui/qt/dialogs_provider.cpp
+++ b/modules/gui/qt/dialogs_provider.cpp
@@ -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;
 }
diff --git a/modules/gui/qt/main_interface_win32.cpp b/modules/gui/qt/main_interface_win32.cpp
index 0a9e93658d..637b643d00 100644
--- a/modules/gui/qt/main_interface_win32.cpp
+++ b/modules/gui/qt/main_interface_win32.cpp
@@ -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;
diff --git a/modules/gui/qt/main_interface_win32.hpp b/modules/gui/qt/main_interface_win32.hpp
index 676ddd9eb1..289d306716 100644
--- a/modules/gui/qt/main_interface_win32.hpp
+++ b/modules/gui/qt/main_interface_win32.hpp
@@ -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;
 
diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index 914671aa1e..834c137fc3 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -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 );
diff --git a/modules/gui/qt/qt.hpp b/modules/gui/qt/qt.hpp
index a4559961b8..7b30ea8072 100644
--- a/modules/gui/qt/qt.hpp
+++ b/modules/gui/qt/qt.hpp
@@ -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,
diff --git a/modules/gui/qt/util/timetooltip.cpp b/modules/gui/qt/util/timetooltip.cpp
index 0657210f1a..23d47b2528 100644
--- a/modules/gui/qt/util/timetooltip.cpp
+++ b/modules/gui/qt/util/timetooltip.cpp
@@ -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 );
-- 
2.14.2



More information about the vlc-devel mailing list