diff --git a/src/Cutter.cpp b/src/Cutter.cpp index 5a2d8ef2..05e789d8 100644 --- a/src/Cutter.cpp +++ b/src/Cutter.cpp @@ -565,7 +565,7 @@ QString CutterCore::getConfig(const QString &k) void CutterCore::setConfig(const QString &k, const QVariant &v) { - switch(v.type()) { + switch (v.type()) { case QVariant::Type::Bool: setConfig(k, v.toBool()); break; @@ -778,10 +778,10 @@ void CutterCore::startDebug() emit registersChanged(); if (!currentlyDebugging) { setConfig("asm.flags", false); + currentlyDebugging = true; emit changeDebugView(); emit flagsChanged(); emit refreshCodeViews(); - currentlyDebugging = true; } } @@ -798,11 +798,11 @@ void CutterCore::startEmulation() setConfig("asm.flags", false); // allows to view self-modifying code changes or other binary changes setConfig("io.cache", true); + currentlyDebugging = true; + currentlyEmulating = true; emit changeDebugView(); emit flagsChanged(); emit refreshCodeViews(); - currentlyDebugging = true; - currentlyEmulating = true; } } @@ -819,9 +819,9 @@ void CutterCore::attachDebug(int pid) if (!currentlyDebugging || !currentlyEmulating) { // prevent register flags from appearing during debug/emul setConfig("asm.flags", false); + currentlyDebugging = true; emit changeDebugView(); emit flagsChanged(); - currentlyDebugging = true; } } @@ -2034,12 +2034,28 @@ QList CutterCore::getColorThemes() return r; } -void CutterCore::setCutterPlugins(QList plugins) +RCoreTask *CutterCore::startTask(const QString &cmd) +{ + RCoreTask *task = r_core_task_new (core_, true, cmd.toLocal8Bit().constData(), nullptr, nullptr); + r_core_task_enqueue(core_, task); + return task; +} + +void CutterCore::joinTask(RCoreTask *task) +{ + r_core_task_join(core_, nullptr, task); +} +void CutterCore::deleteTask(RCoreTask *task) +{ + r_core_task_del(core_, task->id); +} + +void CutterCore::setCutterPlugins(QList plugins) { this->plugins = plugins; } -QList CutterCore::getCutterPlugins() +QList CutterCore::getCutterPlugins() { return plugins; } diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 27fde709..cffa83c0 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -267,10 +267,11 @@ void MainWindow::initUI() connect(core, &CutterCore::changeDefinedView, this, &MainWindow::changeDefinedView); updateTasksIndicator(); - connect(core->getAsyncTaskManager(), &AsyncTaskManager::tasksChanged, this, &MainWindow::updateTasksIndicator); + connect(core->getAsyncTaskManager(), &AsyncTaskManager::tasksChanged, this, + &MainWindow::updateTasksIndicator); /* Load plugins */ - QList plugins = Core()->getCutterPlugins(); + QList plugins = Core()->getCutterPlugins(); for (auto plugin : plugins) { CutterDockWidget *pluginDock = plugin->setupInterface(this); tabifyDockWidget(dashboardDock, pluginDock); @@ -337,7 +338,8 @@ void MainWindow::openNewFileFailed() mb.setIcon(QMessageBox::Critical); mb.setStandardButtons(QMessageBox::Ok); mb.setWindowTitle(tr("Cannot open file!")); - mb.setText(tr("Could not open the file! Make sure the file exists and that you have the correct permissions.")); + mb.setText( + tr("Could not open the file! Make sure the file exists and that you have the correct permissions.")); mb.exec(); } @@ -557,9 +559,9 @@ void MainWindow::restoreDocks() tabifyDockWidget(dashboardDock, vTablesDock); // Add Stack, Registers and Backtrace vertically stacked - addExtraWidget(stackDock); + splitDockWidget(sidebarDock, stackDock, Qt::Horizontal); splitDockWidget(stackDock, registersDock, Qt::Vertical); - splitDockWidget(stackDock, backtraceDock, Qt::Vertical); + tabifyDockWidget(stackDock, backtraceDock); // MemoryMap/Breakpoint widget goes in the center tabs tabifyDockWidget(dashboardDock, memoryMapDock); tabifyDockWidget(dashboardDock, breakpointDock); @@ -625,7 +627,7 @@ void MainWindow::showZenDocks() disassemblyDock, hexdumpDock, searchDock - }; + }; for (auto w : dockWidgets) { if (zenDocks.contains(w)) { w->show(); @@ -637,16 +639,16 @@ void MainWindow::showZenDocks() void MainWindow::showDebugDocks() { const QList debugDocks = { functionsDock, - stringsDock, - graphDock, - disassemblyDock, - hexdumpDock, - searchDock, - stackDock, - registersDock, - backtraceDock, - memoryMapDock, - breakpointDock + stringsDock, + graphDock, + disassemblyDock, + hexdumpDock, + searchDock, + stackDock, + registersDock, + backtraceDock, + memoryMapDock, + breakpointDock }; for (auto w : dockWidgets) { if (debugDocks.contains(w)) { @@ -954,7 +956,7 @@ void MainWindow::mousePressEvent(QMouseEvent *event) bool MainWindow::eventFilter(QObject *, QEvent *event) { if (event->type() == QEvent::MouseButtonPress) { - QMouseEvent *mouseEvent = static_cast(event); + QMouseEvent *mouseEvent = static_cast(event); if (mouseEvent->button() == Qt::ForwardButton || mouseEvent->button() == Qt::BackButton) { mousePressEvent(mouseEvent); return true; diff --git a/src/dialogs/preferences/GeneralOptionsWidget.cpp b/src/dialogs/preferences/GeneralOptionsWidget.cpp index 104287c1..46a815bd 100644 --- a/src/dialogs/preferences/GeneralOptionsWidget.cpp +++ b/src/dialogs/preferences/GeneralOptionsWidget.cpp @@ -9,16 +9,17 @@ #include "utils/Helpers.h" #include "utils/Configuration.h" -GeneralOptionsWidget::GeneralOptionsWidget(PreferencesDialog */*dialog*/, QWidget *parent) +GeneralOptionsWidget::GeneralOptionsWidget(PreferencesDialog *dialog, QWidget *parent) : QDialog(parent), ui(new Ui::GeneralOptionsWidget) { + Q_UNUSED(dialog); ui->setupUi(this); updateFontFromConfig(); updateThemeFromConfig(); - //connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(updateFontFromConfig())); + connect(Config(), &Configuration::fontsUpdated, this, &GeneralOptionsWidget::updateFontFromConfig); //connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateThemeFromConfig())); } diff --git a/src/widgets/BacktraceWidget.cpp b/src/widgets/BacktraceWidget.cpp index 4c75c5af..a8f1648a 100644 --- a/src/widgets/BacktraceWidget.cpp +++ b/src/widgets/BacktraceWidget.cpp @@ -18,12 +18,13 @@ BacktraceWidget::BacktraceWidget(MainWindow *main, QAction *action) : modelBacktrace->setHorizontalHeaderItem(2, new QStandardItem(tr("Frame Size"))); modelBacktrace->setHorizontalHeaderItem(3, new QStandardItem(tr("Func Name"))); modelBacktrace->setHorizontalHeaderItem(4, new QStandardItem(tr("Description"))); - viewBacktrace->setStyleSheet("QTableView {font-family: mono}"); + viewBacktrace->setFont(Config()->getFont()); viewBacktrace->setModel(modelBacktrace); ui->verticalLayout->addWidget(viewBacktrace); connect(Core(), &CutterCore::refreshAll, this, &BacktraceWidget::updateContents); connect(Core(), &CutterCore::seekChanged, this, &BacktraceWidget::updateContents); + connect(Config(), &Configuration::fontsUpdated, this, &BacktraceWidget::fontsUpdatedSlot); } BacktraceWidget::~BacktraceWidget() {} @@ -61,3 +62,8 @@ void BacktraceWidget::setBacktraceGrid() viewBacktrace->setModel(modelBacktrace); viewBacktrace->resizeColumnsToContents();; } + +void BacktraceWidget::fontsUpdatedSlot() +{ + viewBacktrace->setFont(Config()->getFont()); +} \ No newline at end of file diff --git a/src/widgets/BacktraceWidget.h b/src/widgets/BacktraceWidget.h index 512663cb..977d3c7a 100644 --- a/src/widgets/BacktraceWidget.h +++ b/src/widgets/BacktraceWidget.h @@ -25,6 +25,7 @@ public: private slots: void updateContents(); void setBacktraceGrid(); + void fontsUpdatedSlot(); private: std::unique_ptr ui; diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index 3644ae9e..00d1fa60 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -376,21 +376,21 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block) block.width, block.height); // Draw different background for selected instruction - bool paintedSelected = false; if (selected_instruction != RVA_INVALID) { int y = block.y + (2 * charWidth) + (db.header_text.lines.size() * charHeight); for (Instr &instr : db.instrs) { + if (instr.addr > selected_instruction) { + break; + } auto selected = instr.addr == selected_instruction; //auto traceCount = dbgfunctions->GetTraceRecordHitCount(instr.addr); auto traceCount = 0; if (selected && traceCount) { p.fillRect(QRect(block.x + charWidth, y, block.width - (10 + 2 * charWidth), int(instr.text.lines.size()) * charHeight), disassemblyTracedSelectionColor); - paintedSelected = true; } else if (selected) { p.fillRect(QRect(block.x + charWidth, y, block.width - (10 + 2 * charWidth), int(instr.text.lines.size()) * charHeight), disassemblySelectionColor); - paintedSelected = true; } else if (traceCount) { // Color depending on how often a sequence of code is executed int exponent = 1; @@ -407,10 +407,6 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block) QColor(disassemblyTracedColor.red(), disassemblyTracedColor.green(), std::max(0, std::min(256, disassemblyTracedColor.blue() + colorDiff)))); - paintedSelected = true; - } - if (paintedSelected) { - break; } y += int(instr.text.lines.size()) * charHeight; } @@ -420,11 +416,13 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block) if (PCInBlock) { int y = block.y + (2 * charWidth) + (db.header_text.lines.size() * charHeight); for (Instr &instr : db.instrs) { + if (instr.addr > PCAddr) { + break; + } auto PC = instr.addr == PCAddr; if (PC) { p.fillRect(QRect(block.x + charWidth, y, block.width - (10 + 2 * charWidth), int(instr.text.lines.size()) * charHeight), PCSelectionColor); - break; } y += int(instr.text.lines.size()) * charHeight; } @@ -677,8 +675,7 @@ void DisassemblerGraphView::seekPrev() { if (seekable->getSyncWithCore()) { Core()->seekPrev(); - } - else { + } else { seekable->seek(seekable->getPrevIndependentOffset()); } } diff --git a/src/widgets/GraphView.cpp b/src/widgets/GraphView.cpp index 75ec4751..60689397 100644 --- a/src/widgets/GraphView.cpp +++ b/src/widgets/GraphView.cpp @@ -127,8 +127,8 @@ void GraphView::adjustSize(int new_width, int new_height, QPoint mouse) int dx = newMaxX - originalRangeX; int dy = newMaxY - originalRangeY; - horizontalScrollBar()->setValue(topX + dx*((float)mouseLocal.x()/new_width)); - verticalScrollBar()->setValue(topY + dy*((float)mouseLocal.y()/new_height)); + horizontalScrollBar()->setValue(topX + dx * ((float)mouseLocal.x() / new_width)); + verticalScrollBar()->setValue(topY + dy * ((float)mouseLocal.y() / new_height)); } bool GraphView::event(QEvent *event) @@ -411,9 +411,9 @@ void GraphView::paintEvent(QPaintEvent *event) { Q_UNUSED(event); QPainter p(viewport()); - + p.setRenderHint(QPainter::Antialiasing); - + int render_offset_x = -horizontalScrollBar()->value() * current_scale; int render_offset_y = -verticalScrollBar()->value() * current_scale; int render_width = viewport()->size().width() / current_scale; @@ -864,8 +864,8 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) int y_delta = scroll_base_y - event->y(); scroll_base_x = event->x(); scroll_base_y = event->y(); - horizontalScrollBar()->setValue(horizontalScrollBar()->value() + x_delta * (1/current_scale)); - verticalScrollBar()->setValue(verticalScrollBar()->value() + y_delta * (1/current_scale)); + horizontalScrollBar()->setValue(horizontalScrollBar()->value() + x_delta * (1 / current_scale)); + verticalScrollBar()->setValue(verticalScrollBar()->value() + y_delta * (1 / current_scale)); } } @@ -912,7 +912,7 @@ void GraphView::wheelEvent(QWheelEvent *event) const QPoint delta = -event->angleDelta(); int x_delta = delta.x(); int y_delta = delta.y(); - horizontalScrollBar()->setValue(horizontalScrollBar()->value() + x_delta * (1/current_scale)); - verticalScrollBar()->setValue(verticalScrollBar()->value() + y_delta * (1/current_scale)); + horizontalScrollBar()->setValue(horizontalScrollBar()->value() + x_delta * (1 / current_scale)); + verticalScrollBar()->setValue(verticalScrollBar()->value() + y_delta * (1 / current_scale)); event->accept(); } diff --git a/src/widgets/RegistersWidget.cpp b/src/widgets/RegistersWidget.cpp index 44d1892a..66539bc8 100644 --- a/src/widgets/RegistersWidget.cpp +++ b/src/widgets/RegistersWidget.cpp @@ -29,12 +29,12 @@ void RegistersWidget::updateContents() setRegisterGrid(); } - void RegistersWidget::handleButton() - { +void RegistersWidget::handleButton() +{ int j = 0; int i = 0; int col = 0; - for (j = 0; jitemAtPosition(i, col)->widget(); QWidget *regValue = registerLayout->itemAtPosition(i, col + 1)->widget(); QLabel *regLabel = qobject_cast(regName); @@ -43,13 +43,13 @@ void RegistersWidget::updateContents() QString regValueString = regLine->text(); Core()->setRegister(regNameString, regValueString); i++; - if (i >= registerLen/numCols + 1) { + if (i >= registerLen / numCols + 1) { i = 0; col += 2; } } setRegisterGrid(); - } +} void RegistersWidget::setRegisterGrid() { @@ -66,16 +66,14 @@ void RegistersWidget::setRegisterGrid() // check if we already filled this grid space with label/value if (!registerLayout->itemAtPosition(i, col)) { registerLabel = new QLabel; - registerLabel->setStyleSheet("font-weight: bold; font-family: mono"); + registerLabel->setStyleSheet("font-weight: bold; font-family: mono;"); registerEditValue = new QLineEdit; - QFont font = registerEditValue->font(); - font.setWeight(QFont::Monospace); - registerEditValue->setFont(font); + registerEditValue->setFixedWidth(140); + registerEditValue->setFont(Config()->getFont()); // add label and register value to grid registerLayout->addWidget(registerLabel, i, col); registerLayout->addWidget(registerEditValue, i, col + 1); - } - else { + } else { QWidget *regNameWidget = registerLayout->itemAtPosition(i, col)->widget(); QWidget *regValueWidget = registerLayout->itemAtPosition(i, col + 1)->widget(); registerLabel = qobject_cast(regNameWidget); @@ -84,8 +82,7 @@ void RegistersWidget::setRegisterGrid() // decide to highlight QLine Box in case of change of register value if (regValue != registerEditValue->text() && registerEditValue->text() != 0) { registerEditValue->setStyleSheet("QLineEdit {border: 1px solid green;} QLineEdit:hover { border: 1px solid #3daee9; color: #eff0f1;}"); - } - else { + } else { // reset stylesheet registerEditValue->setStyleSheet(""); } @@ -95,7 +92,7 @@ void RegistersWidget::setRegisterGrid() registerEditValue->setText(regValue); i++; // decide if we should change column - if (i >= registerLen/numCols + 1) { + if (i >= registerLen / numCols + 1) { i = 0; col += 2; } diff --git a/src/widgets/RegistersWidget.ui b/src/widgets/RegistersWidget.ui index 79dcd8fd..cdadd8e2 100644 --- a/src/widgets/RegistersWidget.ui +++ b/src/widgets/RegistersWidget.ui @@ -13,22 +13,27 @@ Registers + + + true + 10 - 0 + 6 - 0 + 6 - 0 + 6 + diff --git a/src/widgets/StackWidget.cpp b/src/widgets/StackWidget.cpp index 78429747..651bf0cc 100644 --- a/src/widgets/StackWidget.cpp +++ b/src/widgets/StackWidget.cpp @@ -16,7 +16,7 @@ StackWidget::StackWidget(MainWindow *main, QAction *action) : modelStack->setHorizontalHeaderItem(0, new QStandardItem(tr("Offset"))); modelStack->setHorizontalHeaderItem(1, new QStandardItem(tr("Value"))); modelStack->setHorizontalHeaderItem(2, new QStandardItem(tr("Reference"))); - viewStack->setStyleSheet("QTableView {font-family: mono}"); + viewStack->setFont(Config()->getFont()); viewStack->setModel(modelStack); viewStack->verticalHeader()->hide(); viewStack->setSortingEnabled(true); @@ -24,6 +24,7 @@ StackWidget::StackWidget(MainWindow *main, QAction *action) : connect(Core(), &CutterCore::refreshAll, this, &StackWidget::updateContents); connect(Core(), &CutterCore::seekChanged, this, &StackWidget::updateContents); + connect(Config(), &Configuration::fontsUpdated, this, &StackWidget::fontsUpdatedSlot); } StackWidget::~StackWidget() {} @@ -56,3 +57,8 @@ void StackWidget::setStackGrid() viewStack->setModel(modelStack); viewStack->resizeColumnsToContents();; } + +void StackWidget::fontsUpdatedSlot() +{ + viewStack->setFont(Config()->getFont()); +} \ No newline at end of file diff --git a/src/widgets/StackWidget.h b/src/widgets/StackWidget.h index a83b9317..d712cf7f 100644 --- a/src/widgets/StackWidget.h +++ b/src/widgets/StackWidget.h @@ -25,6 +25,7 @@ public: private slots: void updateContents(); void setStackGrid(); + void fontsUpdatedSlot(); private: std::unique_ptr ui;