| 66 | } |
| 67 | |
| 68 | FileInfoWidget::FileInfoWidget(QWidget* parent, BinaryViewRef bv) |
| 69 | { |
| 70 | this->m_layout = new QGridLayout(); |
| 71 | this->m_layout->setContentsMargins(0, 0, 0, 0); |
| 72 | this->m_layout->setVerticalSpacing(1); |
| 73 | |
| 74 | const auto view = bv->GetParentView() ? bv->GetParentView() : bv; |
| 75 | const auto filePath = bv->GetFile()->GetOriginalFilename(); |
| 76 | this->addCopyableField("Path: ", filePath.c_str()); |
| 77 | |
| 78 | const auto fileSize = QString::number(view->GetLength(), 16).prepend("0x"); |
| 79 | this->addCopyableField("Size: ", fileSize); |
| 80 | |
| 81 | const auto bufferSize = fileSize.toUInt(nullptr, 16); |
| 82 | const auto fileBuffer = std::make_unique<char[]>(bufferSize); |
| 83 | view->Read(fileBuffer.get(), 0, bufferSize); |
| 84 | |
| 85 | const auto fileBytes = QByteArray(fileBuffer.get(), bufferSize); |
| 86 | this->addHashField("MD5: ", QCryptographicHash::Md5, fileBytes); |
| 87 | this->addHashField("SHA-1: ", QCryptographicHash::Sha1, fileBytes); |
| 88 | this->addHashField("SHA-256: ", QCryptographicHash::Sha256, fileBytes); |
| 89 | |
| 90 | const auto scaledWidth = UIContext::getScaledWindowSize(20, 20).width(); |
| 91 | this->m_layout->setColumnMinimumWidth(FileInfoWidget::m_maxColumns * 3 - 1, scaledWidth); |
| 92 | this->m_layout->setColumnStretch(FileInfoWidget::m_maxColumns * 3 - 1, 1); |
| 93 | setLayout(this->m_layout); |
| 94 | } |
nothing calls this directly
no test coverage detected