Workaround for Qt5.8 WebEngine (#92)

This commit is contained in:
xpahos 2017-04-09 20:13:31 +03:00 committed by Duncan Ogilvie
parent 5390cff320
commit 08e6e4d13c
5 changed files with 4329 additions and 8 deletions

View File

@ -9,10 +9,20 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui WebKit WebKitWidgets)
set(QT_USE_MODULES Core Widgets Gui)
find_package(Qt5 REQUIRED COMPONENTS ${QT_USE_MODULES})
if (Qt5_VERSION_MINOR GREATER 7)
list(APPEND QT_USE_MODULES WebEngine WebEngineWidgets)
message("Using QT5 WebEngine instead WebKit")
add_definitions(-DUSE_WEBENGINE)
find_package(Qt5 REQUIRED COMPONENTS ${QT_USE_MODULES})
else (Qt5_VERSION_MINOR GREATER 7)
set(CMAKE_AUTOUIC ON)
list(APPEND QT_USE_MODULES WebKit WebKitWidgets)
find_package(Qt5 REQUIRED COMPONENTS ${QT_USE_MODULES})
endif(Qt5_VERSION_MINOR GREATER 7)
if(WIN32)
# use radare2 libraries from submodule on windows
@ -120,13 +130,40 @@ set(UI_FILES
widgets/commentswidget.ui
widgets/stringswidget.ui
widgets/flagswidget.ui
widgets/memwidget/memorywidget.ui
widgets/sdbdock.ui
dialogs/commentsdialog.ui
widgets/sidebar.ui
widgets/dashboard.ui
dialogs/xrefsdialog.ui)
if (Qt5_VERSION_MINOR GREATER 7)
list(APPEND UI_FILES webengine/widgets/memwidget/memorywidget.ui
webengine/widgets/dashboard.ui)
set(UI_FILES_OUT "")
# Workaround for Qt 5.8
# AutoUIC looking for ui files in the same directory as source code
# files. This code directly calls uic for headers generation.
foreach(it ${UI_FILES})
message("Preprocessing uic: ${it}")
get_filename_component(outfile ${it} NAME_WE)
get_filename_component(infile ${it} ABSOLUTE)
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
add_custom_command(OUTPUT ${outfile}
COMMAND ${Qt5Widgets_UIC_EXECUTABLE}
ARGS ${ui_options} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile} VERBATIM)
list(APPEND UI_FILES_OUT ${outfile})
endforeach()
set(UI_FILES ${UI_FILES_OUT})
else (Qt5_VERSION_MINOR GREATER 7)
list(APPEND UI_FILES widgets/memwidget/memorywidget.ui
widgets/dashboard.ui)
endif (Qt5_VERSION_MINOR GREATER 7)
set(QRC_FILES resources.qrc)
@ -137,5 +174,5 @@ add_definitions("-DAPP_VERSION=\"${IAITO_VERSION_FULL}\"")
add_executable(iaito ${UI_FILES} ${QRC_FILES} ${SOURCE_FILES} ${HEADER_FILES})
qt5_use_modules(iaito Core Widgets Gui WebKit WebKitWidgets)
qt5_use_modules(iaito ${QT_USE_MODULES})
target_link_libraries(iaito ${RADARE2_LIBRARIES})

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -11,11 +11,16 @@
#include <QScrollBar>
#include <QClipboard>
#include <QShortcut>
#include <QWebFrame>
#include <QMenu>
#include <QFont>
#include <QUrl>
#if defined(USE_WEBENGINE)
#include <QWebEnginePage>
#else
#include <QWebFrame>
#endif
MemoryWidget::MemoryWidget(MainWindow *main) :
QDockWidget(main),
ui(new Ui::MemoryWidget)
@ -66,6 +71,10 @@ MemoryWidget::MemoryWidget(MainWindow *main) :
graph_bar->setVisible(false);
// Hide graph webview scrollbars
#if defined(USE_WEBENGINE)
ui->graphWebView->page()->runJavaScript("document.body.style.overflow='hidden';");
#else
ui->graphWebView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
ui->graphWebView->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
@ -76,6 +85,7 @@ MemoryWidget::MemoryWidget(MainWindow *main) :
// Debug console
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
#endif
// Add margin to function name line edit
ui->fcnNameEdit->setTextMargins(5, 0, 0, 0);
@ -180,7 +190,11 @@ MemoryWidget::MemoryWidget(MainWindow *main) :
connect(this->disasTextEdit->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(disasmScrolled()));
connect(this->hexASCIIText->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hexScrolled()));
#if defined(USE_WEBENGINE)
connect(ui->graphWebView->page(), SIGNAL(loadFinished(bool)), this, SLOT(frameLoadFinished(bool)));
#else
connect(ui->graphWebView->page()->mainFrame(), SIGNAL(loadFinished(bool)), this, SLOT(frameLoadFinished(bool)));
#endif
}
/*
@ -1407,7 +1421,11 @@ void MemoryWidget::create_graph(QString off) {
ui->graphWebView->load(QUrl("qrc:/graph/html/graph/index.html#" + off));
QString port = this->main->core->config("http.port");
#if defined(USE_WEBENGINE)
ui->graphWebView->page()->runJavaScript(QString("r2.root=\"http://localhost:" + port + "\""));
#else
ui->graphWebView->page()->mainFrame()->evaluateJavaScript(QString("r2.root=\"http://localhost:" + port + "\""));
#endif
}
QString MemoryWidget::normalize_addr(QString addr) {
@ -1752,7 +1770,11 @@ void MemoryWidget::frameLoadFinished(bool ok) {
QSettings settings;
if (settings.value("dark").toBool()) {
QString js = "r2ui.graph_panel.render('dark');";
ui->graphWebView->page()->mainFrame()->evaluateJavaScript(js);
#if defined(USE_WEBENGINE)
ui->graphWebView->page()->runJavaScript(js, [](const QVariant &result){ qDebug() << result; });
#else
qDebug() << ui->graphWebView->page()->mainFrame()->evaluateJavaScript(js);
#endif
}
}
}

View File

@ -11,11 +11,16 @@
#include <QDockWidget>
#include <QTreeWidget>
#include <QTabWidget>
#include <QWebView>
#include <QUrl>
#include <QPlainTextEdit>
#include <QMouseEvent>
#if defined(USE_WEBENGINE)
#include <QWebEngineView>
#else
#include <QWebView>
#endif
class MainWindow;
namespace Ui {
@ -39,8 +44,13 @@ public:
QTreeWidget *xrefToTreeWidget_2;
QTreeWidget *xreFromTreeWidget_2;
QTabWidget *memTabWidget;
#if defined(USE_WEBENGINE)
QWebEngineView *graphWebView;
QWebEngineView *histoWebView;
#else
QWebView *graphWebView;
QWebView *histoWebView;
#endif
Highlighter *highlighter;
Highlighter *highlighter_5;