Qt: Fix errors when compiling for Qt4.
authorJens Kilian <jens.kilian@advantest.com>
Thu, 31 Aug 2017 06:28:02 +0000 (08:28 +0200)
committerMichael Mann <mmann78@netscape.net>
Thu, 31 Aug 2017 12:02:41 +0000 (12:02 +0000)
This allows Wireshark to be built on RedHat EL 7.2, with Qt 4.8.5.

Bug: 13909
Change-Id: Ia39a288cc342afa2bd0217cb59dac84c3227086c
Reviewed-on: https://code.wireshark.org/review/23322
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
ui/qt/main_window.cpp
ui/qt/main_window.h
ui/qt/rtp_player_dialog.cpp
ui/qt/uat_frame.cpp
ui/qt/widgets/drag_drop_toolbar.cpp
ui/qt/wireless_timeline.cpp
ui/qt/wireshark_application.cpp

index cd5a2ca53e4bc4efd0c2a301b67b541567cd1388..906c5bc981b5bca4fae2e06d28c36ec209ee23c7 100644 (file)
@@ -220,6 +220,7 @@ static void plugin_if_mainwindow_update_toolbars(gconstpointer user_data)
     }
 }
 
+#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
 static void mainwindow_add_toolbar(const iface_toolbar *toolbar_entry)
 {
     if (gbl_cur_main_window_ && toolbar_entry)
@@ -235,6 +236,7 @@ static void mainwindow_remove_toolbar(const gchar *menu_title)
         gbl_cur_main_window_->removeInterfaceToolbar(menu_title);
     }
 }
+#endif
 
 QMenu* MainWindow::findOrAddMenu(QMenu *parent_menu, QString& menu_text) {
     QList<QAction *> actions = parent_menu->actions();
index a2ad55fafa34831e0ba884edcb5dddb632fcf0a7..1e3ff04847115b6919d00694111de95f7bce78eb 100644 (file)
@@ -77,6 +77,9 @@ namespace Ui {
     class MainWindow;
 }
 
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_DECLARE_METATYPE(QToolBar *)
+#endif
 Q_DECLARE_METATYPE(ts_type)
 Q_DECLARE_METATYPE(ts_precision)
 
index aa413b9caddb875963d411e3b222761c850232b2..df7f29d90a4ea3f9c25888c4582bbb53ae2ee773 100644 (file)
@@ -94,6 +94,11 @@ enum {
     graph_data_col_ = src_port_col_ // QCPGraph
 };
 
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_DECLARE_METATYPE(RtpAudioStream *)
+Q_DECLARE_METATYPE(QCPGraph *)
+#endif
+
 #ifdef QT_MULTIMEDIA_LIB
 static const double wf_graph_normal_width_ = 0.5;
 static const double wf_graph_selected_width_ = 2.0;
index 699af26aa50ba4e083a409db30b64db0f1bf3d64..95aab9530f6fb2235af7511aedc901d9d75e48a9 100644 (file)
@@ -36,6 +36,7 @@
 #include <QLineEdit>
 #include <QKeyEvent>
 #include <QTreeWidgetItemIterator>
+#include <QUrl>
 
 #include <QDebug>
 
index 04f6c7d09645f8746c97db80f4b31f34f995c059..1b3cd47387187a058a449f25183bc3307deb9188 100644 (file)
@@ -29,7 +29,9 @@
 #include <QLayout>
 #include <QMimeData>
 #include <QMouseEvent>
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 #include <QWindow>
+#endif
 
 #define drag_drop_toolbar_action_ "drag_drop_toolbar_action_"
 
@@ -97,9 +99,13 @@ bool DragDropToolBar::eventFilter(QObject * obj, QEvent * event)
                     elem->property(drag_drop_toolbar_action_).toByteArray());
             drag->setMimeData(mimeData);
 
+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
             qreal dpr = window()->windowHandle()->devicePixelRatio();
             QPixmap pixmap(elem->size() * dpr);
             pixmap.setDevicePixelRatio(dpr);
+#else
+            QPixmap pixmap(elem->size());
+#endif
             elem->render(&pixmap);
             drag->setPixmap(pixmap);
 
index e2f734617c8be9b19b2c50107b36f8ad3c637fd6..1bcfea5bbffe82ffadc26383058dd21095f7858d 100644 (file)
@@ -114,7 +114,11 @@ static void accumulate_rgb(float rgb[TIMELINE_HEIGHT][3], int height, int dfilte
 
 void WirelessTimeline::mousePressEvent(QMouseEvent *event)
 {
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
     start_x = last_x = event->localPos().x();
+#else
+    start_x = last_x = event->posF().x();
+#endif
 }
 
 
@@ -123,8 +127,13 @@ void WirelessTimeline::mouseMoveEvent(QMouseEvent *event)
     if (event->buttons() == Qt::NoButton)
         return;
 
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
     qreal offset = event->localPos().x() - last_x;
     last_x = event->localPos().x();
+#else
+    qreal offset = event->posF().x() - last_x;
+    last_x = event->posF().x();
+#endif
 
     qreal shift = ((qreal) (end_tsf - start_tsf))/width() * offset;
     start_tsf -= shift;
@@ -140,14 +149,19 @@ void WirelessTimeline::mouseMoveEvent(QMouseEvent *event)
 
 void WirelessTimeline::mouseReleaseEvent(QMouseEvent *event)
 {
-    qreal offset = event->localPos().x() - start_x;
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+    QPointF localPos = event->localPos();
+#else
+    QPointF localPos = event->posF();
+#endif
+    qreal offset = localPos.x() - start_x;
 
     /* if this was a drag, ignore it */
     if (std::abs(offset) > 3)
         return;
 
     /* this was a click */
-    guint num = find_packet(event->localPos().x());
+    guint num = find_packet(localPos.x());
     if (num == 0)
         return;
 
@@ -474,7 +488,10 @@ WirelessTimeline::paintEvent(QPaintEvent *qpe)
     QPainter p(this);
 
     // painting is done in device pixels in the x axis, get the ratio here
-    float ratio = p.device()->devicePixelRatio();
+    float ratio = 1.0;
+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
+    ratio = p.device()->devicePixelRatio();
+#endif
 
     unsigned int packet;
     double zoom;
index 2e7d3b58e9e5787cf4aa7a4a5e45b65c5122661f..feb95725f15f448903cc1ec806fddfe4d75ce6c4 100644 (file)
@@ -81,6 +81,7 @@
 #endif /* _WIN32 */
 
 #include <QAction>
+#include <QApplication>
 #include <QDesktopServices>
 #include <QDir>
 #include <QEvent>
@@ -847,7 +848,7 @@ WiresharkApplication::WiresharkApplication(int &argc,  char **argv) :
     qApp->setStyleSheet(app_style_sheet);
 
     // If our window text is lighter than the window background, assume the theme is dark.
-    QPalette gui_pal = QGuiApplication::palette();
+    QPalette gui_pal = qApp->palette();
     prefs_set_gui_theme_is_dark(gui_pal.windowText().color().value() > gui_pal.window().color().value());
 
 #ifdef HAVE_SOFTWARE_UPDATE