[vlc-devel] [PATCH 1/2] qt: provide compatibility mode for Qt 5.5

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


---
 configure.ac                                         |  2 +-
 modules/gui/qt/components/controller.cpp             |  6 ++++++
 modules/gui/qt/components/extended_panels.cpp        |  4 ++++
 modules/gui/qt/components/playlist/standardpanel.cpp | 10 +++++++++-
 modules/gui/qt/util/imagehelper.cpp                  | 13 +++++++++++++
 modules/gui/qt/util/input_slider.cpp                 |  4 +++-
 6 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 19f80b8608..2012848d9a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3655,7 +3655,7 @@ AC_ARG_ENABLE(qt, [
 ])
 have_qt5_x11="no"
 AS_IF([test "${enable_qt}" != "no"], [
-  PKG_CHECK_MODULES([QT], [Qt5Core >= 5.6.0 Qt5Widgets Qt5Gui Qt5Svg], [
+  PKG_CHECK_MODULES([QT], [Qt5Core >= 5.5.0 Qt5Widgets Qt5Gui Qt5Svg], [
       PKG_CHECK_MODULES([QT5_X11], [Qt5X11Extras], [
           have_qt5_x11="yes"
       ],[
diff --git a/modules/gui/qt/components/controller.cpp b/modules/gui/qt/components/controller.cpp
index f30e9cdc23..98c2754e2f 100644
--- a/modules/gui/qt/components/controller.cpp
+++ b/modules/gui/qt/components/controller.cpp
@@ -643,8 +643,14 @@ QFrame *AbstractController::telexFrame()
     QSignalMapper *contextButtonMapper = new QSignalMapper( this );
     QToolButton *contextButton = NULL;
     int i_iconminsize = __MAX( 16, telexOn->minimumHeight() );
+
+#if HAS_QT56
     qreal f_ratio = QApplication::primaryScreen()->devicePixelRatio();
     QPixmap iconPixmap( i_iconminsize * f_ratio, i_iconminsize * f_ratio );
+#else
+    QPixmap iconPixmap( i_iconminsize, i_iconminsize );
+#endif
+
     iconPixmap.fill( Qt::transparent );
     QPainter iconPixmapPainter( &iconPixmap );
     QLinearGradient iconPixmapPainterGradient( iconPixmap.rect().center() / 2,
diff --git a/modules/gui/qt/components/extended_panels.cpp b/modules/gui/qt/components/extended_panels.cpp
index a7160b124b..6136718f78 100644
--- a/modules/gui/qt/components/extended_panels.cpp
+++ b/modules/gui/qt/components/extended_panels.cpp
@@ -1157,8 +1157,12 @@ void Equalizer::build()
     for( i = 0 ; i < NB_PRESETS ; i ++ )
     {
         QGraphicsScene scene;
+#if HAS_QT56
         qreal f_ratio = QApplication::primaryScreen()->devicePixelRatio();
         QPixmap icon( 40 * f_ratio, 40 * f_ratio );
+#else
+        QPixmap icon( 40, 40 );
+#endif
         icon.fill( Qt::transparent );
         QPainter painter( &icon );
         for ( int j = 0; j < eqz_preset_10b[i].i_band; j++ )
diff --git a/modules/gui/qt/components/playlist/standardpanel.cpp b/modules/gui/qt/components/playlist/standardpanel.cpp
index 254dce3a19..3d6fe6e6a8 100644
--- a/modules/gui/qt/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt/components/playlist/standardpanel.cpp
@@ -560,14 +560,22 @@ bool StandardPLPanel::eventFilter ( QObject *obj, QEvent * event )
             QStylePainter painter( viewport );
 
             QPixmap dropzone = ImageHelper::loadSvgToPixmap(":/dropzone.svg", DROPZONE_SIZE, DROPZONE_SIZE);
-            qreal scale = dropzone.devicePixelRatio();
             QRect rect = viewport->geometry();
+#if HAS_QT56
+            qreal scale = dropzone.devicePixelRatio();
             QSize size = rect.size()  / 2 - dropzone.size() / (2 * scale);
+#else
+            QSize size = rect.size()  / 2 - dropzone.size() / 2;
+#endif
             rect.adjust( 0, size.height(), 0 , 0 );
             painter.drawItemPixmap( rect, Qt::AlignHCenter, dropzone );
             /* now select the zone just below the drop zone and let Qt center
                the text by itself */
+#if HAS_QT56
             rect.adjust( 0, dropzone.height() / scale + 10, 0, 0 );
+#else
+            rect.adjust( 0, dropzone.height() + 10, 0, 0 );
+#endif
             rect.setRight( viewport->geometry().width() );
             rect.setLeft( 0 );
             painter.drawItemText( rect,
diff --git a/modules/gui/qt/util/imagehelper.cpp b/modules/gui/qt/util/imagehelper.cpp
index 30ee346323..82d89874e3 100644
--- a/modules/gui/qt/util/imagehelper.cpp
+++ b/modules/gui/qt/util/imagehelper.cpp
@@ -21,17 +21,27 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "qt.hpp"
 #include <QApplication>
 #include <QPainter>
 #include <QScreen>
 #include <QSvgRenderer>
 #include "imagehelper.hpp"
 
+
 QPixmap ImageHelper::loadSvgToPixmap( const QString &path, qint32 i_width, qint32 i_height )
 {
+#if HAS_QT56
     qreal ratio = QApplication::primaryScreen()->devicePixelRatio();
 
     QPixmap pixmap( QSize( i_width, i_height ) * ratio );
+#else
+    QPixmap pixmap( QSize( i_width, i_height ) );
+#endif
 
     pixmap.fill( Qt::transparent );
 
@@ -42,6 +52,9 @@ QPixmap ImageHelper::loadSvgToPixmap( const QString &path, qint32 i_width, qint3
     renderer.render( &painter );
     painter.end();
 
+#if HAS_QT56
     pixmap.setDevicePixelRatio( ratio );
+#endif
+
     return pixmap;
 }
diff --git a/modules/gui/qt/util/input_slider.cpp b/modules/gui/qt/util/input_slider.cpp
index 5b488dc606..741eb26c1a 100644
--- a/modules/gui/qt/util/input_slider.cpp
+++ b/modules/gui/qt/util/input_slider.cpp
@@ -601,9 +601,11 @@ SoundSlider::SoundSlider( QWidget *_parent, float _i_step,
     const QBitmap mask( temp.createHeuristicMask() );
 
     pixGradient = QPixmap( pixOutside.size() );
-    pixGradient.setDevicePixelRatio(QApplication::primaryScreen()->devicePixelRatio());
     pixGradient2 = QPixmap( pixOutside.size() );
+#if HAS_QT56
+    pixGradient.setDevicePixelRatio(QApplication::primaryScreen()->devicePixelRatio());
     pixGradient2.setDevicePixelRatio(QApplication::primaryScreen()->devicePixelRatio());
+#endif
 
     /* Gradient building from the preferences */
     QLinearGradient gradient( PADDINGL, 2, width() - PADDINGR, 2 );
-- 
2.14.2



More information about the vlc-devel mailing list