From 53a7d5a959e5fd6e9842e5ef965dd82f51670426 Mon Sep 17 00:00:00 2001 From: rrreeezzz Date: Sat, 5 May 2018 13:58:26 +0100 Subject: [PATCH] Button grayed out if no signatures/version info available #474 (#481) --- src/Cutter.cpp | 5 ++++ src/Cutter.h | 1 + src/widgets/Dashboard.cpp | 50 ++++++++++++++++++++------------------- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/Cutter.cpp b/src/Cutter.cpp index 6bbd63bc..53793f29 100644 --- a/src/Cutter.cpp +++ b/src/Cutter.cpp @@ -709,6 +709,11 @@ QJsonDocument CutterCore::getFileVersionInfo() return cmdj("iVj"); } +QJsonDocument CutterCore::getSignatureInfo() +{ + return cmdj("iCj"); +} + QStringList CutterCore::getStats() { QStringList stats; diff --git a/src/Cutter.h b/src/Cutter.h index a96027c3..595e74fd 100644 --- a/src/Cutter.h +++ b/src/Cutter.h @@ -397,6 +397,7 @@ public: QString getDecompiledCode(RVA addr); QString getDecompiledCode(QString addr); QJsonDocument getFileInfo(); + QJsonDocument getSignatureInfo(); QJsonDocument getFileVersionInfo(); QStringList getStats(); QString getSimpleGraph(QString function); diff --git a/src/widgets/Dashboard.cpp b/src/widgets/Dashboard.cpp index f9ea074b..607fb478 100644 --- a/src/widgets/Dashboard.cpp +++ b/src/widgets/Dashboard.cpp @@ -156,6 +156,15 @@ void Dashboard::updateContents() // Get stats for the graphs QStringList stats = Core()->getStats(); + + // Check if signature info and version info available + if (Core()->getSignatureInfo().isEmpty()){ + ui->certificateButton->setEnabled(false); + } + if (Core()->getFileVersionInfo().isEmpty()){ + ui->versioninfoButton->setEnabled(false); + } + } void Dashboard::on_certificateButton_clicked() @@ -168,32 +177,25 @@ void Dashboard::on_certificateButton_clicked() viewDialog = new QDialog(this); view = new QTreeView(viewDialog); model = new JsonModel(); - QJsonDocument qjsonCertificatesDoc = Core()->cmdj("iCj"); + QJsonDocument qjsonCertificatesDoc = Core()->getSignatureInfo(); qstrCertificates = qjsonCertificatesDoc.toJson(QJsonDocument::Compact); } - if (QString::compare("{}", qstrCertificates)) { - if (!viewDialog->isVisible()) { - std::string strCertificates = qstrCertificates.toUtf8().constData(); - model->loadJson(QByteArray::fromStdString(strCertificates)); - view->setModel(model); - view->expandAll(); - view->resize(900, 600); - QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - sizePolicy.setHorizontalStretch(0); - sizePolicy.setVerticalStretch(0); - sizePolicy.setHeightForWidth(view->sizePolicy().hasHeightForWidth()); - viewDialog->setSizePolicy(sizePolicy); - viewDialog->setMinimumSize(QSize(900, 600)); - viewDialog->setMaximumSize(QSize(900, 600)); - viewDialog->setSizeGripEnabled(false); - viewDialog->setWindowTitle("Certificates"); - viewDialog->show(); - } - } else { - QMessageBox msgBoxCertificateInf(QMessageBox::Information, "Certificate Information ", - "There is no certificate information", - QMessageBox::NoButton, this); - msgBoxCertificateInf.exec(); + if (!viewDialog->isVisible()) { + std::string strCertificates = qstrCertificates.toUtf8().constData(); + model->loadJson(QByteArray::fromStdString(strCertificates)); + view->setModel(model); + view->expandAll(); + view->resize(900, 600); + QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(view->sizePolicy().hasHeightForWidth()); + viewDialog->setSizePolicy(sizePolicy); + viewDialog->setMinimumSize(QSize(900, 600)); + viewDialog->setMaximumSize(QSize(900, 600)); + viewDialog->setSizeGripEnabled(false); + viewDialog->setWindowTitle("Certificates"); + viewDialog->show(); } }