Button grayed out if no signatures/version info available #474 (#481)

This commit is contained in:
rrreeezzz 2018-05-05 13:58:26 +01:00 committed by xarkes
parent eef5022469
commit 53a7d5a959
3 changed files with 32 additions and 24 deletions

View File

@ -709,6 +709,11 @@ QJsonDocument CutterCore::getFileVersionInfo()
return cmdj("iVj"); return cmdj("iVj");
} }
QJsonDocument CutterCore::getSignatureInfo()
{
return cmdj("iCj");
}
QStringList CutterCore::getStats() QStringList CutterCore::getStats()
{ {
QStringList stats; QStringList stats;

View File

@ -397,6 +397,7 @@ public:
QString getDecompiledCode(RVA addr); QString getDecompiledCode(RVA addr);
QString getDecompiledCode(QString addr); QString getDecompiledCode(QString addr);
QJsonDocument getFileInfo(); QJsonDocument getFileInfo();
QJsonDocument getSignatureInfo();
QJsonDocument getFileVersionInfo(); QJsonDocument getFileVersionInfo();
QStringList getStats(); QStringList getStats();
QString getSimpleGraph(QString function); QString getSimpleGraph(QString function);

View File

@ -156,6 +156,15 @@ void Dashboard::updateContents()
// Get stats for the graphs // Get stats for the graphs
QStringList stats = Core()->getStats(); 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() void Dashboard::on_certificateButton_clicked()
@ -168,32 +177,25 @@ void Dashboard::on_certificateButton_clicked()
viewDialog = new QDialog(this); viewDialog = new QDialog(this);
view = new QTreeView(viewDialog); view = new QTreeView(viewDialog);
model = new JsonModel(); model = new JsonModel();
QJsonDocument qjsonCertificatesDoc = Core()->cmdj("iCj"); QJsonDocument qjsonCertificatesDoc = Core()->getSignatureInfo();
qstrCertificates = qjsonCertificatesDoc.toJson(QJsonDocument::Compact); qstrCertificates = qjsonCertificatesDoc.toJson(QJsonDocument::Compact);
} }
if (QString::compare("{}", qstrCertificates)) { if (!viewDialog->isVisible()) {
if (!viewDialog->isVisible()) { std::string strCertificates = qstrCertificates.toUtf8().constData();
std::string strCertificates = qstrCertificates.toUtf8().constData(); model->loadJson(QByteArray::fromStdString(strCertificates));
model->loadJson(QByteArray::fromStdString(strCertificates)); view->setModel(model);
view->setModel(model); view->expandAll();
view->expandAll(); view->resize(900, 600);
view->resize(900, 600); QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); sizePolicy.setHorizontalStretch(0);
sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0);
sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(view->sizePolicy().hasHeightForWidth());
sizePolicy.setHeightForWidth(view->sizePolicy().hasHeightForWidth()); viewDialog->setSizePolicy(sizePolicy);
viewDialog->setSizePolicy(sizePolicy); viewDialog->setMinimumSize(QSize(900, 600));
viewDialog->setMinimumSize(QSize(900, 600)); viewDialog->setMaximumSize(QSize(900, 600));
viewDialog->setMaximumSize(QSize(900, 600)); viewDialog->setSizeGripEnabled(false);
viewDialog->setSizeGripEnabled(false); viewDialog->setWindowTitle("Certificates");
viewDialog->setWindowTitle("Certificates"); viewDialog->show();
viewDialog->show();
}
} else {
QMessageBox msgBoxCertificateInf(QMessageBox::Information, "Certificate Information ",
"There is no certificate information",
QMessageBox::NoButton, this);
msgBoxCertificateInf.exec();
} }
} }