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");
}
QJsonDocument CutterCore::getSignatureInfo()
{
return cmdj("iCj");
}
QStringList CutterCore::getStats()
{
QStringList stats;

View File

@ -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);

View File

@ -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();
}
}