summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2021-02-19 19:25:53 -0500
committerRusty Wagner <rusty.wagner@gmail.com>2021-03-16 20:40:13 -0400
commite43222c3e8da9f42d0d95207fa94335165a27d9d (patch)
treee8f64b54dafd7c75f48c95bd7c7e62fed0c904a2
parenta327eb06173d0aa814460842e5280a6bf1edddf1 (diff)
Compatibility with Qt 6
-rw-r--r--examples/triage/CMakeLists.txt6
-rw-r--r--examples/triage/byte.cpp8
-rw-r--r--examples/triage/entropy.cpp2
-rw-r--r--examples/triage/exports.cpp2
-rw-r--r--examples/triage/files.h4
-rw-r--r--examples/triage/imports.cpp2
-rw-r--r--examples/uinotification/CMakeLists.txt22
-rw-r--r--ui/action.h4
-rw-r--r--ui/addressdialog.h2
-rw-r--r--ui/featuremap.h6
-rw-r--r--ui/menus.h4
-rw-r--r--ui/progressindicator.h4
-rw-r--r--ui/reportwidget.h10
-rw-r--r--ui/typeview.h4
-rw-r--r--ui/viewframe.h6
15 files changed, 71 insertions, 15 deletions
diff --git a/examples/triage/CMakeLists.txt b/examples/triage/CMakeLists.txt
index 4b55bc8f..05dd03ce 100644
--- a/examples/triage/CMakeLists.txt
+++ b/examples/triage/CMakeLists.txt
@@ -1,8 +1,12 @@
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
+option(QT6 "Target Qt 6" OFF)
+
project(triage)
-set(CMAKE_OSX_ARCHITECTURES x86_64)
+if(NOT QT6)
+ set(CMAKE_OSX_ARCHITECTURES x86_64)
+endif()
file(GLOB SOURCES
*.cpp
diff --git a/examples/triage/byte.cpp b/examples/triage/byte.cpp
index 58835ed7..c3a91372 100644
--- a/examples/triage/byte.cpp
+++ b/examples/triage/byte.cpp
@@ -1064,8 +1064,8 @@ void ByteView::mousePressEvent(QMouseEvent* event)
{
if (event->button() != Qt::LeftButton)
return;
- int x = (event->x() - 2) / m_render.getFontWidth() - ((int)m_addrWidth + 2);
- int y = (event->y() - 2) / m_render.getFontHeight();
+ int x = (event->pos().x() - 2) / m_render.getFontWidth() - ((int)m_addrWidth + 2);
+ int y = (event->pos().y() - 2) / m_render.getFontHeight();
m_lastMouseX = x;
m_lastMouseY = y;
m_cursorAddr = addressFromLocation(x, y);
@@ -1081,8 +1081,8 @@ void ByteView::mouseMoveEvent(QMouseEvent* event)
{
if (event->buttons() != Qt::LeftButton)
return;
- int x = (event->x() - 2) / m_render.getFontWidth() - ((int)m_addrWidth + 2);
- int y = (event->y() - 2) / m_render.getFontHeight();
+ int x = (event->pos().x() - 2) / m_render.getFontWidth() - ((int)m_addrWidth + 2);
+ int y = (event->pos().y() - 2) / m_render.getFontHeight();
if ((x == m_lastMouseX) && (y == m_lastMouseY))
return;
m_lastMouseX = x;
diff --git a/examples/triage/entropy.cpp b/examples/triage/entropy.cpp
index 87849dcc..72ca0a92 100644
--- a/examples/triage/entropy.cpp
+++ b/examples/triage/entropy.cpp
@@ -111,7 +111,7 @@ void EntropyWidget::mousePressEvent(QMouseEvent* event)
{
if (event->button() != Qt::LeftButton)
return;
- float frac = (float)event->x() / (float)rect().width();
+ float frac = (float)event->pos().x() / (float)rect().width();
uint64_t offset = (uint64_t)(frac * m_width * m_blockSize);
m_view->navigateToFileOffset(offset);
}
diff --git a/examples/triage/exports.cpp b/examples/triage/exports.cpp
index 6d7a3de7..4ff46eec 100644
--- a/examples/triage/exports.cpp
+++ b/examples/triage/exports.cpp
@@ -247,7 +247,7 @@ void ExportsTreeView::closeFilter()
void ExportsTreeView::keyPressEvent(QKeyEvent* event)
{
- if ((event->text().size() == 1) && (event->text()[0] > ' ') && (event->text()[0] < 127))
+ if ((event->text().size() == 1) && (event->text()[0] > ' ') && (event->text()[0] <= '~'))
{
m_parent->showFilter(event->text());
event->accept();
diff --git a/examples/triage/files.h b/examples/triage/files.h
index 6919c614..9874691c 100644
--- a/examples/triage/files.h
+++ b/examples/triage/files.h
@@ -2,7 +2,11 @@
#include <QtWidgets/QWidget>
#include <QtWidgets/QTreeView>
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtWidgets/QFileSystemModel>
+#else
+#include <QtGui/QFileSystemModel>
+#endif
#include "action.h"
#include "menus.h"
diff --git a/examples/triage/imports.cpp b/examples/triage/imports.cpp
index 01e379f8..d15b2c40 100644
--- a/examples/triage/imports.cpp
+++ b/examples/triage/imports.cpp
@@ -273,7 +273,7 @@ void ImportsTreeView::closeFilter()
void ImportsTreeView::keyPressEvent(QKeyEvent* event)
{
- if ((event->text().size() == 1) && (event->text()[0] > ' ') && (event->text()[0] < 127))
+ if ((event->text().size() == 1) && (event->text()[0] > ' ') && (event->text()[0] <= '~'))
{
m_parent->showFilter(event->text());
event->accept();
diff --git a/examples/uinotification/CMakeLists.txt b/examples/uinotification/CMakeLists.txt
index 9858dd68..df9bdbdc 100644
--- a/examples/uinotification/CMakeLists.txt
+++ b/examples/uinotification/CMakeLists.txt
@@ -1,18 +1,32 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
+option(QT6 "Target Qt 6" OFF)
+
project(uinotification)
-set(CMAKE_OSX_ARCHITECTURES x86_64)
+if(NOT QT6)
+ set(CMAKE_OSX_ARCHITECTURES x86_64)
+endif()
-find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
+if(QT6)
+ find_package(Qt6 COMPONENTS Core Gui Widgets REQUIRED)
+else()
+ find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
+endif()
file(GLOB SOURCES
*.cpp
*.h)
add_library(uinotification SHARED ${SOURCES})
-target_link_libraries(uinotification binaryninjaapi binaryninjaui
- Qt5::Core Qt5::Gui Qt5::Widgets)
+
+if(QT6)
+ target_link_libraries(uinotification binaryninjaapi binaryninjaui
+ Qt6::Core Qt6::Gui Qt6::Widgets)
+else()
+ target_link_libraries(uinotification binaryninjaapi binaryninjaui
+ Qt5::Core Qt5::Gui Qt5::Widgets)
+endif()
set_target_properties(uinotification PROPERTIES
CXX_STANDARD 17
diff --git a/ui/action.h b/ui/action.h
index 45b09e1e..31d2e397 100644
--- a/ui/action.h
+++ b/ui/action.h
@@ -3,7 +3,11 @@
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include <QtGui/QIcon>
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtWidgets/QShortcut>
+#else
+#include <QtGui/QShortcut>
+#endif
#include <QtCore/QPointer>
#include <functional>
#include <map>
diff --git a/ui/addressdialog.h b/ui/addressdialog.h
index 0d8991b5..e3d02338 100644
--- a/ui/addressdialog.h
+++ b/ui/addressdialog.h
@@ -67,7 +67,7 @@ private Q_SLOTS:
void accepted();
void updateRelativeState(int state);
void updatePreview();
- void updatePreview(QString data);
+ void updatePreviewWithText(QString data);
public:
AddressDialogWithPreview(QWidget* parent, BinaryViewRef view, uint64_t here,
diff --git a/ui/featuremap.h b/ui/featuremap.h
index 939e46df..f8c38cdf 100644
--- a/ui/featuremap.h
+++ b/ui/featuremap.h
@@ -1,7 +1,11 @@
#pragma once
-#include <QtWidgets/QAction>
#include <QtGui/QColor>
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#include <QtWidgets/QAction>
+#else
+#include <QtGui/QAction>
+#endif
#include <QtGui/QImage>
#include <QtWidgets/QMenu>
#include <QtGui/QPainter>
diff --git a/ui/menus.h b/ui/menus.h
index 4ac751c3..4b0cc3a5 100644
--- a/ui/menus.h
+++ b/ui/menus.h
@@ -61,7 +61,11 @@ private Q_SLOTS:
void underMouseTimerEvent();
protected:
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEvent* event) override;
+#else
+ void enterEvent(QEnterEvent* event) override;
+#endif
void leaveEvent(QEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
};
diff --git a/ui/progressindicator.h b/ui/progressindicator.h
index 3d4d58ef..56976f31 100644
--- a/ui/progressindicator.h
+++ b/ui/progressindicator.h
@@ -104,7 +104,11 @@ Q_SIGNALS:
void clicked();
protected:
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEvent* event) override;
+#else
+ void enterEvent(QEnterEvent* event) override;
+#endif
void leaveEvent(QEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override { if (event->button() == Qt::LeftButton) Q_EMIT clicked(); }
void timerEvent(QTimerEvent * event) override;
diff --git a/ui/reportwidget.h b/ui/reportwidget.h
index 02572490..25ee7a30 100644
--- a/ui/reportwidget.h
+++ b/ui/reportwidget.h
@@ -3,15 +3,20 @@
#include <QtWidgets/QWidget>
#include <QtWidgets/QTextBrowser>
#include <QtWidgets/QScrollArea>
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtWebEngineWidgets/QWebEngineView>
#include <QtWebEngineWidgets/QWebEngineScript>
#include <QtWebEngineWidgets/QWebEngineScriptCollection>
#include <QtWebEngineWidgets/QWebEnginePage>
#include <QtWebEngineWidgets/QWebEngineSettings>
+#else
+#include <QtWidgets/QTextBrowser>
+#endif
#include "binaryninjaapi.h"
#include "action.h"
#include "theme.h"
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
class WebPage2 : public QWebEnginePage
{
Q_OBJECT
@@ -25,12 +30,17 @@ protected:
Q_SIGNALS:
void linkClicked(const QUrl&);
};
+#endif
class BINARYNINJAUIAPI ReportWidget: public QScrollArea, public UIActionHandler
{
Q_OBJECT
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QWebEngineView* m_contents;
+#else
+ QTextBrowser* m_contents;
+#endif
BinaryViewRef m_view;
std::string m_original;
std::string m_title;
diff --git a/ui/typeview.h b/ui/typeview.h
index 23985c59..40e41215 100644
--- a/ui/typeview.h
+++ b/ui/typeview.h
@@ -1,7 +1,11 @@
#pragma once
#include <QtWidgets/QAbstractScrollArea>
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtWidgets/QAction>
+#else
+#include <QtGui/QAction>
+#endif
#include <QtCore/QTimer>
#include <string>
#include <utility>
diff --git a/ui/viewframe.h b/ui/viewframe.h
index 07832b65..0f86aa2b 100644
--- a/ui/viewframe.h
+++ b/ui/viewframe.h
@@ -1,7 +1,11 @@
#pragma once
-#include <QtWidgets/QAction>
#include <QtWidgets/QGestureEvent>
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#include <QtWidgets/QAction>
+#else
+#include <QtGui/QAction>
+#endif
#include <QtWidgets/QLabel>
#include <QtCore/QPointer>
#include <QtWidgets/QVBoxLayout>