Skip to content
Permalink
Browse files

Implemented ProblemsDialog

  • Loading branch information...
Dax89 committed May 11, 2019
1 parent 38bd160 commit 458caef2a53bc734f532bd70dd5c3ff6f28db61b
@@ -0,0 +1,21 @@
#include "problemsdialog.h"
#include "ui_problemsdialog.h"
#include <QStandardItemModel>
#include <redasm/redasm.h>

ProblemsDialog::ProblemsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ProblemsDialog)
{
ui->setupUi(this);

QStandardItemModel* m = new QStandardItemModel(ui->lvProblems);

for(const std::string& problem : REDasm::Context::problems())
m->appendRow(new QStandardItem(QString::fromStdString(problem)));

ui->lvProblems->setModel(m);
}

ProblemsDialog::~ProblemsDialog()
{
delete ui;
}
@@ -0,0 +1,22 @@
#ifndef PROBLEMSDIALOG_H
#define PROBLEMSDIALOG_H

#include <QDialog>

namespace Ui {
class ProblemsDialog;
}

class ProblemsDialog : public QDialog
{
Q_OBJECT

public:
explicit ProblemsDialog(QWidget *parent = nullptr);
~ProblemsDialog();

private:
Ui::ProblemsDialog *ui;
};

#endif // PROBLEMSDIALOG_H
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProblemsDialog</class>
<widget class="QDialog" name="ProblemsDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>580</width>
<height>357</height>
</rect>
</property>
<property name="windowTitle">
<string>Problems</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListView" name="lvProblems"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -1,6 +1,7 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "dialogs/signaturesdialog/signaturesdialog.h"
#include "dialogs/problemsdialog/problemsdialog.h"
#include "dialogs/settingsdialog/settingsdialog.h"
#include "dialogs/aboutdialog/aboutdialog.h"
#include "ui/redasmui.h"
@@ -47,8 +48,14 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
m_pbstatus->setText(QString::fromWCharArray(L"\u25cf"));
m_pbstatus->setVisible(false);

m_pbproblems = new QPushButton(this);
m_pbproblems->setFlat(true);
m_pbproblems->setFixedHeight(ui->statusBar->height() * 0.8);
m_pbproblems->setVisible(false);

ui->statusBar->addPermanentWidget(m_lblstatus, 70);
ui->statusBar->addPermanentWidget(m_lblprogress, 30);
ui->statusBar->addPermanentWidget(m_pbproblems);
ui->statusBar->addPermanentWidget(m_pbstatus);

this->setAcceptDrops(true);
@@ -75,6 +82,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
});

connect(m_pbstatus, &QPushButton::clicked, this, &MainWindow::changeDisassemblerStatus);
connect(m_pbproblems, &QPushButton::clicked, this, &MainWindow::showProblems);

qApp->installEventFilter(this);
}
@@ -414,8 +422,10 @@ void MainWindow::closeFile()
m_lblstatus->clear();
m_lblprogress->setVisible(false);
m_pbstatus->setVisible(false);
m_pbproblems->setVisible(false);
this->setStandardActionsEnabled(false);
this->setViewWidgetsVisible(false);
REDasm::Context::clearProblems();
}

void MainWindow::selectLoader(REDasm::LoadRequest &request)
@@ -491,6 +501,7 @@ void MainWindow::checkDisassemblerStatus()
{
ui->action_Close->setEnabled(false);
m_pbstatus->setVisible(false);
m_pbproblems->setVisible(false);
return;
}

@@ -506,11 +517,19 @@ void MainWindow::checkDisassemblerStatus()

m_pbstatus->setVisible(true);
m_lblprogress->setVisible(disassembler->busy());
m_pbproblems->setText(QString::number(REDasm::Context::problemsCount()) + " problem(s)");
m_pbproblems->setVisible(!disassembler->busy() && REDasm::Context::hasProblems());

this->setStandardActionsEnabled(!disassembler->busy());
ui->action_Close->setEnabled(true);
}

void MainWindow::showProblems()
{
ProblemsDialog dlgproblems(this);
dlgproblems.exec();
}

DisassemblerView *MainWindow::currentDisassemblerView() const { return dynamic_cast<DisassemblerView*>(ui->stackView->currentWidget()); }

REDasm::DisassemblerAPI *MainWindow::currentDisassembler() const
@@ -41,6 +41,7 @@ class MainWindow : public QMainWindow
void onAboutClicked();
void changeDisassemblerStatus();
void checkDisassemblerStatus();
void showProblems();
void closeFile();

private:
@@ -64,6 +65,7 @@ class MainWindow : public QMainWindow
QFileInfo m_fileinfo;
QStringList m_recents;
QPushButton* m_pbstatus;
QPushButton* m_pbproblems;
};

#endif // MAINWINDOW_H
@@ -57,6 +57,7 @@ DisassemblerTest::DisassemblerTest(): m_buffer(nullptr)
ctxsettings.tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation).toStdString();
ctxsettings.searchPath = QDir::currentPath().toStdString();
ctxsettings.logCallback =[](const std::string&) { };
ctxsettings.ignoreproblems = true;
REDasm::init(ctxsettings);
}

0 comments on commit 458caef

Please sign in to comment.
You can’t perform that action at this time.