Start making adjustment for qt6 compatibility. (#2463)

* Introduce cmake option for using Qt6, build doesn't work fully yet.
* Recursive mutex, QActionGroup, QComboBox::AdjustToMinimumContentsLength
* Cleanup dock locking
This commit is contained in:
karliss 2020-11-30 09:42:13 +02:00 committed by GitHub
parent ef9b1328f4
commit f9bde4a2ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 66 additions and 93 deletions

View File

@ -25,6 +25,7 @@ option(CUTTER_ENABLE_DEPENDENCY_DOWNLOADS "Enable downloading of dependencies. S
option(CUTTER_PACKAGE_DEPENDENCIES "During install step include the third party dependencies." OFF)
option(CUTTER_PACKAGE_R2GHIDRA "Compile and install r2ghidra during install step." OFF)
option(CUTTER_PACKAGE_R2DEC "Compile and install r2dec during install step." OFF)
OPTION(CUTTER_QT6 "Use QT6" OFF)
if(NOT CUTTER_ENABLE_PYTHON)
set(CUTTER_ENABLE_PYTHON_BINDINGS OFF)
@ -55,7 +56,12 @@ 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 Svg Network)
if (CUTTER_QT6)
set(QT_PREFIX Qt6)
else()
set(QT_PREFIX Qt5)
endif()
find_package(${QT_PREFIX} REQUIRED COMPONENTS Core Widgets Gui Svg Network)
include(CutterInstallDirs)
@ -219,7 +225,7 @@ if(CUTTER_ENABLE_CRASH_REPORTS)
endif()
endif()
target_link_libraries(Cutter PUBLIC Qt5::Core Qt5::Widgets Qt5::Gui PRIVATE Qt5::Svg Qt5::Network)
target_link_libraries(Cutter PUBLIC ${QT_PREFIX}::Core ${QT_PREFIX}::Widgets ${QT_PREFIX}::Gui PRIVATE ${QT_PREFIX}::Svg ${QT_PREFIX}::Network)
target_link_libraries(Cutter PUBLIC ${RADARE2_TARGET})
if(CUTTER_ENABLE_PYTHON)
if (WIN32)

View File

@ -47,7 +47,12 @@ void RichTextPainter::paintRichText(QPainter *painter, T x, T y, T w, T h, T xin
painter->setPen(pen);
break;
}
painter->drawText(typename Metrics<T>::Rect(x + xinc, y, w - xinc, h), Qt::TextBypassShaping, curRichText.text);
int flags = 0;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
flags = Qt::TextBypassShaping;
#endif
painter->drawText(typename Metrics<T>::Rect(x + xinc, y, w - xinc, h), flags, curRichText.text);
if (curRichText.highlight && curRichText.highlightColor.alpha()) {
highlightPen.setColor(curRichText.highlightColor);
highlightPen.setWidth(curRichText.highlightWidth);

View File

@ -165,8 +165,11 @@ static void cutterREventCallback(REvent *, int type, void *user, void *data)
core->handleREvent(type, data);
}
CutterCore::CutterCore(QObject *parent) :
QObject(parent), coreMutex(QMutex::Recursive)
CutterCore::CutterCore(QObject *parent):
QObject(parent)
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
, coreMutex(QMutex::Recursive)
#endif
{
}

View File

@ -715,7 +715,11 @@ private:
* NEVER use this directly! Always use the CORE_LOCK(); macro and access it like core->...
*/
RCore *core_ = nullptr;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QMutex coreMutex;
#else
QRecursiveMutex coreMutex;
#endif
int coreLockDepth = 0;
void *coreBed = nullptr;

View File

@ -74,6 +74,7 @@
#include "widgets/CallGraph.h"
// Qt Headers
#include <QActionGroup>
#include <QApplication>
#include <QComboBox>
#include <QCompleter>
@ -124,7 +125,6 @@ MainWindow::MainWindow(QWidget *parent) :
core(Core()),
ui(new Ui::MainWindow)
{
panelLock = false;
tabsOnTop = false;
configuration = Config();
@ -233,7 +233,7 @@ void MainWindow::initUI()
ioModesController.setIOMode(IOModesController::Mode::READ_ONLY);
setAvailableIOModeOptions();
});
connect(ui->actionSaveLayout, &QAction::triggered, this, &MainWindow::saveNamedLayout);
connect(ui->actionManageLayouts, &QAction::triggered, this, &MainWindow::manageLayouts);
connect(ui->actionDocumentation, &QAction::triggered, this, &MainWindow::documentationClicked);
@ -256,6 +256,8 @@ void MainWindow::initUI()
ui->menuPlugins->setEnabled(false);
}
connect(ui->actionUnlock, &QAction::toggled, this, [this](bool unlock){ lockDocks(!unlock); });
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
ui->actionGrouped_dock_dragging->setVisible(false);
#endif
@ -745,8 +747,7 @@ void MainWindow::readSettings()
QSettings settings;
responsive = settings.value("responsive").toBool();
panelLock = settings.value("panelLock").toBool();
setPanelLock();
lockDocks(settings.value("panelLock").toBool());
tabsOnTop = settings.value("tabsOnTop").toBool();
setTabLocation();
bool dockGroupedDragging = settings.value("docksGroupedDragging", false).toBool();
@ -760,7 +761,7 @@ void MainWindow::saveSettings()
{
QSettings settings;
settings.setValue("panelLock", panelLock);
settings.setValue("panelLock", !ui->actionUnlock->isChecked());
settings.setValue("tabsOnTop", tabsOnTop);
settings.setValue("docksGroupedDragging", ui->actionGrouped_dock_dragging->isChecked());
settings.setValue("geometry", saveGeometry());
@ -769,24 +770,6 @@ void MainWindow::saveSettings()
saveLayouts(settings);
}
void MainWindow::setPanelLock()
{
if (panelLock) {
for (QDockWidget *dockWidget : findChildren<QDockWidget *>()) {
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
}
ui->actionLock->setChecked(false);
} else {
for (QDockWidget *dockWidget : findChildren<QDockWidget *>()) {
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
}
ui->actionLock->setChecked(true);
}
}
void MainWindow::setTabLocation()
{
if (tabsOnTop) {
@ -803,15 +786,20 @@ void MainWindow::refreshAll()
core->triggerRefreshAll();
}
void MainWindow::lockUnlock_Docks(bool what)
void MainWindow::lockDocks(bool lock)
{
if (what) {
if (ui->actionUnlock->isChecked() == lock) {
ui->actionUnlock->setChecked(!lock);
}
if (lock) {
for (QDockWidget *dockWidget : findChildren<QDockWidget *>()) {
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
}
} else {
for (QDockWidget *dockWidget : findChildren<QDockWidget *>()) {
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
dockWidget->setFeatures(QDockWidget::DockWidgetClosable |
QDockWidget::DockWidgetMovable |
QDockWidget::DockWidgetFloatable);
}
}
@ -1452,26 +1440,6 @@ void MainWindow::saveLayouts(QSettings &settings)
settings.endArray();
}
void MainWindow::on_actionLock_triggered()
{
panelLock = !panelLock;
setPanelLock();
}
void MainWindow::on_actionLockUnlock_triggered()
{
if (ui->actionLockUnlock->isChecked()) {
for (QDockWidget *dockWidget : findChildren<QDockWidget *>()) {
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
}
ui->actionLockUnlock->setIcon(QIcon(":/lock"));
} else {
for (QDockWidget *dockWidget : findChildren<QDockWidget *>()) {
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
}
ui->actionLockUnlock->setIcon(QIcon(":/unlock"));
}
}
void MainWindow::on_actionDefault_triggered()
{

View File

@ -141,18 +141,13 @@ public slots:
void refreshAll();
void seekToFunctionLastInstruction();
void seekToFunctionStart();
void setPanelLock();
void setTabLocation();
void on_actionLock_triggered();
void on_actionLockUnlock_triggered();
void on_actionTabs_triggered();
void on_actionAnalyze_triggered();
void lockUnlock_Docks(bool what);
void lockDocks(bool lock);
void on_actionRun_Script_triggered();
@ -220,7 +215,6 @@ private slots:
private:
CutterCore *core;
bool panelLock;
bool tabsOnTop;
ut64 hexdumpTopOffset;
ut64 hexdumpBottomOffset;

View File

@ -105,12 +105,17 @@
<addaction name="separator"/>
<addaction name="actionZoomReset"/>
</widget>
<widget class="QMenu" name="menuLayouts">
<property name="title">
<string>Layouts</string>
</property>
</widget>
<addaction name="actionRefresh_contents"/>
<addaction name="separator"/>
<addaction name="actionDefault"/>
<addaction name="actionReset_settings"/>
<addaction name="separator"/>
<addaction name="actionLock"/>
<addaction name="actionUnlock"/>
<addaction name="actionTabs_on_Top"/>
<addaction name="actionGrouped_dock_dragging"/>
<addaction name="separator"/>
@ -118,11 +123,6 @@
<addaction name="separator"/>
<addaction name="actionManageLayouts"/>
<addaction name="actionSaveLayout"/>
<widget class="QMenu" name="menuLayouts">
<property name="title">
<string>Layouts</string>
</property>
</widget>
<addaction name="menuLayouts"/>
</widget>
<widget class="QMenu" name="menuHelp">
@ -137,7 +137,6 @@
<property name="title">
<string>Edit</string>
</property>
<addaction name="actionSearch"/>
<addaction name="actionBackward"/>
<addaction name="actionForward"/>
<addaction name="separator"/>
@ -353,7 +352,7 @@
<string>Redo Seek</string>
</property>
</action>
<action name="actionLock">
<action name="actionUnlock">
<property name="checkable">
<bool>true</bool>
</property>
@ -366,23 +365,12 @@
<property name="toolTip">
<string>Toggle panel locks</string>
</property>
<property name="iconVisibleInMenu">
<bool>false</bool>
</property>
</action>
<action name="actionLockUnlock">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:/unlock</normaloff>:/unlock</iconset>
<normaloff>:/lock</normaloff><normalon>:/unlock</normalon>:/unlock</iconset>
</property>
<property name="text">
<string>Lock/Unlock</string>
</property>
<property name="toolTip">
<string>Lock/Unlock</string>
<property name="iconVisibleInMenu">
<bool>false</bool>
</property>
</action>
<action name="actionTheme">
@ -758,9 +746,9 @@
</property>
</action>
<action name="actionExtraDecompiler">
<property name="text">
<string>Add Decompiler</string>
</property>
<property name="text">
<string>Add Decompiler</string>
</property>
</action>
<action name="actionExtraDisassembly">
<property name="text">

View File

@ -70,7 +70,7 @@ QString XrefsDialog::normalizeAddr(const QString &addr) const
QString ret = addr;
if (addr.length() < 10) {
ret = ret.mid(3).rightJustified(8, QLatin1Char('0'));
ret.prepend(QLatin1Literal("0x"));
ret.prepend(QStringLiteral("0x"));
}
return ret;
}

View File

@ -591,7 +591,7 @@ QKeySequence DisassemblyContextMenu::getCommentSequence() const
QKeySequence DisassemblyContextMenu::getCopyAddressSequence() const
{
return {Qt::CTRL + Qt::SHIFT + Qt::Key_C};
return {Qt::CTRL | Qt::SHIFT | Qt::Key_C};
}
QKeySequence DisassemblyContextMenu::getSetToCodeSequence() const
@ -606,7 +606,7 @@ QKeySequence DisassemblyContextMenu::getSetAsStringSequence() const
QKeySequence DisassemblyContextMenu::getSetAsStringAdvanced() const
{
return {Qt::SHIFT + Qt::Key_A};
return {Qt::SHIFT | Qt::Key_A};
}
QKeySequence DisassemblyContextMenu::getSetToDataSequence() const
@ -631,7 +631,7 @@ QKeySequence DisassemblyContextMenu::getRenameSequence() const
QKeySequence DisassemblyContextMenu::getRenameUsedHereSequence() const
{
return {Qt::SHIFT + Qt::Key_N};
return {Qt::SHIFT | Qt::Key_N};
}
QKeySequence DisassemblyContextMenu::getRetypeSequence() const

View File

@ -5,6 +5,7 @@
#include <QMenu>
#include <QShortcut>
#include <QActionGroup>
CommentsModel::CommentsModel(QList<CommentDescription> *comments,
QList<CommentGroup> *nestedComments,

View File

@ -8,6 +8,8 @@
#include <cmath>
#include <QStandardPaths>
#include <QActionGroup>
static const int KEY_ZOOM_IN = Qt::Key_Plus + Qt::ControlModifier;
static const int KEY_ZOOM_OUT = Qt::Key_Minus + Qt::ControlModifier;

View File

@ -16,6 +16,7 @@
#include <QJsonArray>
#include <QJsonObject>
#include <QInputDialog>
#include <QActionGroup>
namespace {

View File

@ -20,6 +20,7 @@
#include <QJsonArray>
#include <QRegularExpression>
#include <QToolTip>
#include <QActionGroup>
static constexpr uint64_t MAX_COPY_SIZE = 128 * 1024 * 1024;
static constexpr int MAX_LINE_WIDTH_PRESET = 32;

View File

@ -124,7 +124,7 @@
<item>
<widget class="QComboBox" name="parseEndianComboBox">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
@ -201,7 +201,7 @@
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
<enum>QComboBox::AdjustToContents</enum>
</property>
<property name="frame">
<bool>false</bool>
@ -224,7 +224,7 @@
<item>
<widget class="QComboBox" name="parseBitsComboBox">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
@ -260,15 +260,15 @@
<pointsize>13</pointsize>
</font>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText">
<string/>
</property>