mirror of
https://github.com/NohamR/Reclass.git
synced 2026-05-10 19:59:21 +00:00
Add support for Qt5
This commit is contained in:
@@ -59,7 +59,7 @@ static QString crumbFor(const rcx::NodeTree& t, uint64_t nodeId) {
|
||||
}
|
||||
std::reverse(parts.begin(), parts.end());
|
||||
if (parts.size() > 4)
|
||||
parts = {parts.front(), QStringLiteral("\u2026"), parts[parts.size() - 2], parts.back()};
|
||||
parts = QStringList{parts.front(), QStringLiteral("\u2026"), parts[parts.size() - 2], parts.back()};
|
||||
return parts.join(QStringLiteral(" \u00B7 "));
|
||||
}
|
||||
|
||||
@@ -863,7 +863,7 @@ void RcxController::applyCommand(const Command& command, bool isUndo) {
|
||||
} else if constexpr (std::is_same_v<T, cmd::WriteBytes>) {
|
||||
const QByteArray& bytes = isUndo ? c.oldBytes : c.newBytes;
|
||||
if (!m_doc->provider->writeBytes(c.addr, bytes))
|
||||
qWarning() << "WriteBytes failed at address" << Qt::hex << c.addr;
|
||||
qWarning() << "WriteBytes failed at address" << QString::number(c.addr, 16);
|
||||
// Patch snapshot so compose sees the new value immediately
|
||||
if (m_snapshotProv)
|
||||
m_snapshotProv->patchSnapshot(c.addr, bytes.constData(), bytes.size());
|
||||
|
||||
@@ -31,6 +31,12 @@ enum class NodeKind : uint8_t {
|
||||
Struct, Array
|
||||
};
|
||||
|
||||
} // namespace rcx (temporarily close for qHash)
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
inline uint qHash(rcx::NodeKind key, uint seed = 0) { return ::qHash(static_cast<uint8_t>(key), seed); }
|
||||
#endif
|
||||
namespace rcx { // reopen
|
||||
|
||||
// ── Kind flags (replaces repeated Hex/Padding switches) ──
|
||||
|
||||
enum KindFlags : uint32_t {
|
||||
|
||||
28
src/main.cpp
28
src/main.cpp
@@ -239,23 +239,23 @@ QIcon MainWindow::makeIcon(const QString& svgPath) {
|
||||
void MainWindow::createMenus() {
|
||||
// File
|
||||
auto* file = menuBar()->addMenu("&File");
|
||||
file->addAction("&New", QKeySequence::New, this, &MainWindow::newDocument);
|
||||
file->addAction("New &Tab", QKeySequence(Qt::CTRL | Qt::Key_T), this, &MainWindow::newFile);
|
||||
file->addAction(makeIcon(":/vsicons/folder-opened.svg"), "&Open...", QKeySequence::Open, this, &MainWindow::openFile);
|
||||
file->addAction("&New", this, &MainWindow::newDocument, QKeySequence::New);
|
||||
file->addAction("New &Tab", this, &MainWindow::newFile, QKeySequence(Qt::CTRL | Qt::Key_T));
|
||||
file->addAction(makeIcon(":/vsicons/folder-opened.svg"), "&Open...", this, &MainWindow::openFile, QKeySequence::Open);
|
||||
file->addSeparator();
|
||||
file->addAction(makeIcon(":/vsicons/save.svg"), "&Save", QKeySequence::Save, this, &MainWindow::saveFile);
|
||||
file->addAction(makeIcon(":/vsicons/save-as.svg"), "Save &As...", QKeySequence::SaveAs, this, &MainWindow::saveFileAs);
|
||||
file->addAction(makeIcon(":/vsicons/save.svg"), "&Save", this, &MainWindow::saveFile, QKeySequence::Save);
|
||||
file->addAction(makeIcon(":/vsicons/save-as.svg"), "Save &As...", this, &MainWindow::saveFileAs, QKeySequence::SaveAs);
|
||||
file->addSeparator();
|
||||
file->addAction(makeIcon(":/vsicons/export.svg"), "Export &C++ Header...", this, &MainWindow::exportCpp);
|
||||
file->addSeparator();
|
||||
m_mcpAction = file->addAction("Start &MCP Server", this, &MainWindow::toggleMcp);
|
||||
file->addSeparator();
|
||||
file->addAction(makeIcon(":/vsicons/close.svg"), "E&xit", QKeySequence(Qt::Key_Close), this, &QMainWindow::close);
|
||||
file->addAction(makeIcon(":/vsicons/close.svg"), "E&xit", this, &QMainWindow::close, QKeySequence(Qt::Key_Close));
|
||||
|
||||
// Edit
|
||||
auto* edit = menuBar()->addMenu("&Edit");
|
||||
edit->addAction(makeIcon(":/vsicons/arrow-left.svg"), "&Undo", QKeySequence::Undo, this, &MainWindow::undo);
|
||||
edit->addAction(makeIcon(":/vsicons/arrow-right.svg"), "&Redo", QKeySequence::Redo, this, &MainWindow::redo);
|
||||
edit->addAction(makeIcon(":/vsicons/arrow-left.svg"), "&Undo", this, &MainWindow::undo, QKeySequence::Undo);
|
||||
edit->addAction(makeIcon(":/vsicons/arrow-right.svg"), "&Redo", this, &MainWindow::redo, QKeySequence::Redo);
|
||||
edit->addSeparator();
|
||||
edit->addAction("&Type Aliases...", this, &MainWindow::showTypeAliasesDialog);
|
||||
|
||||
@@ -304,10 +304,10 @@ void MainWindow::createMenus() {
|
||||
|
||||
// Node
|
||||
auto* node = menuBar()->addMenu("&Node");
|
||||
node->addAction(makeIcon(":/vsicons/add.svg"), "&Add Field", QKeySequence(Qt::Key_Insert), this, &MainWindow::addNode);
|
||||
node->addAction(makeIcon(":/vsicons/remove.svg"), "&Remove Field", QKeySequence::Delete, this, &MainWindow::removeNode);
|
||||
node->addAction(makeIcon(":/vsicons/symbol-structure.svg"), "Change &Type", QKeySequence(Qt::Key_T), this, &MainWindow::changeNodeType);
|
||||
node->addAction(makeIcon(":/vsicons/edit.svg"), "Re&name", QKeySequence(Qt::Key_F2), this, &MainWindow::renameNodeAction);
|
||||
node->addAction(makeIcon(":/vsicons/add.svg"), "&Add Field", this, &MainWindow::addNode, QKeySequence(Qt::Key_Insert));
|
||||
node->addAction(makeIcon(":/vsicons/remove.svg"), "&Remove Field", this, &MainWindow::removeNode, QKeySequence::Delete);
|
||||
node->addAction(makeIcon(":/vsicons/symbol-structure.svg"), "Change &Type", this, &MainWindow::changeNodeType, QKeySequence(Qt::Key_T));
|
||||
node->addAction(makeIcon(":/vsicons/edit.svg"), "Re&name", this, &MainWindow::renameNodeAction, QKeySequence(Qt::Key_F2));
|
||||
node->addAction(makeIcon(":/vsicons/files.svg"), "D&uplicate", this, &MainWindow::duplicateNodeAction)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_D));
|
||||
|
||||
// Plugins
|
||||
@@ -659,7 +659,11 @@ void MainWindow::removeNode() {
|
||||
if (!primary || primary->isEditing()) return;
|
||||
QSet<int> indices = primary->selectedNodeIndices();
|
||||
if (indices.size() > 1) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
ctrl->batchRemoveNodes(indices.values());
|
||||
#else
|
||||
ctrl->batchRemoveNodes(indices.values().toVector());
|
||||
#endif
|
||||
} else if (indices.size() == 1) {
|
||||
ctrl->removeNode(*indices.begin());
|
||||
}
|
||||
|
||||
@@ -791,7 +791,7 @@ QJsonObject McpBridge::toolHexRead(const QJsonObject& args) {
|
||||
auto* prov = tab->doc->provider.get();
|
||||
if (!prov) return makeTextResult("No provider", true);
|
||||
|
||||
int64_t offset = args.value("offset").toInteger();
|
||||
int64_t offset = static_cast<int64_t>(args.value("offset").toDouble());
|
||||
int length = qMin(args.value("length").toInt(64), 4096);
|
||||
|
||||
if (args.value("baseRelative").toBool())
|
||||
@@ -873,7 +873,7 @@ QJsonObject McpBridge::toolHexWrite(const QJsonObject& args) {
|
||||
auto* doc = tab->doc;
|
||||
auto* prov = doc->provider.get();
|
||||
|
||||
int64_t offset = args.value("offset").toInteger();
|
||||
int64_t offset = static_cast<int64_t>(args.value("offset").toDouble());
|
||||
QString hexStr = args.value("hexBytes").toString().remove(' ');
|
||||
|
||||
if (args.value("baseRelative").toBool())
|
||||
|
||||
@@ -80,7 +80,7 @@ bool PluginManager::LoadPlugin(const QString& path)
|
||||
return false;
|
||||
}
|
||||
|
||||
qDebug() << "PluginManager: Loaded plugin:" << plugin->Name() << plugin->Version() << "by" << plugin->Author();
|
||||
qDebug() << "PluginManager: Loaded plugin:" << plugin->Name().c_str() << plugin->Version().c_str() << "by" << plugin->Author().c_str();
|
||||
|
||||
// Store plugin entry
|
||||
m_entries.append({library, plugin});
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include <tlhelp32.h>
|
||||
#include <psapi.h>
|
||||
#include <shellapi.h>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QtWin>
|
||||
#endif
|
||||
#elif defined(__linux__)
|
||||
#include <QDir>
|
||||
#include <QStyle>
|
||||
@@ -142,7 +145,11 @@ void ProcessPicker::enumerateProcesses()
|
||||
SHFILEINFOW sfi = {};
|
||||
if (SHGetFileInfoW(path, 0, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_SMALLICON)) {
|
||||
if (sfi.hIcon) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
info.icon = QIcon(QPixmap::fromImage(QImage::fromHICON(sfi.hIcon)));
|
||||
#else
|
||||
info.icon = QIcon(QtWin::fromHICON(sfi.hIcon));
|
||||
#endif
|
||||
DestroyIcon(sfi.hIcon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ void ProviderRegistry::unregisterProvider(const QString& identifier) {
|
||||
for (int i = 0; i < m_providers.size(); ++i) {
|
||||
if (m_providers[i].identifier == identifier) {
|
||||
qDebug() << "ProviderRegistry: Unregistered provider:" << identifier;
|
||||
m_providers.remove(i);
|
||||
m_providers.removeAt(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "iplugin.h"
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <functional>
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
void unregisterProvider(const QString& identifier);
|
||||
|
||||
// Get all registered providers
|
||||
const QVector<ProviderInfo>& providers() const { return m_providers; }
|
||||
const QList<ProviderInfo>& providers() const { return m_providers; }
|
||||
|
||||
// Find provider by identifier
|
||||
const ProviderInfo* findProvider(const QString& identifier) const;
|
||||
@@ -55,5 +55,5 @@ public:
|
||||
|
||||
private:
|
||||
ProviderRegistry() = default;
|
||||
QVector<ProviderInfo> m_providers;
|
||||
QList<ProviderInfo> m_providers;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user