diff options
| author | Jordan Wiens <jordan@psifertex.com> | 2022-08-31 16:36:25 -0400 |
|---|---|---|
| committer | Jordan Wiens <jordan@psifertex.com> | 2022-08-31 16:36:25 -0400 |
| commit | 2f6ebaa0042f6a02b9fcbf49b742fc25887bfdb4 (patch) | |
| tree | 0683be564db58cee2fbc27d2d669289d903fc890 /examples | |
| parent | 3252ebb4ae52285bc717f88e04da18985b561bb6 (diff) | |
update triage view copying fields
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/triage/fileinfo.cpp | 26 | ||||
| -rw-r--r-- | examples/triage/fileinfo.h | 1 |
2 files changed, 20 insertions, 7 deletions
diff --git a/examples/triage/fileinfo.cpp b/examples/triage/fileinfo.cpp index ddb94897..5ac32bc6 100644 --- a/examples/triage/fileinfo.cpp +++ b/examples/triage/fileinfo.cpp @@ -17,23 +17,24 @@ class CopyableLabel : public QLabel auto style = QPalette(palette()); style.setColor(QPalette::WindowText, m_desiredColor); setPalette(style); - this->setToolTip("Copy"); + this->setToolTip("Click to Copy"); } void enterEvent(QEnterEvent* event) override { auto font = this->font(); - font.setBold(true); + font.setUnderline(true); this->setFont(font); - QToolTip::showText(event->globalPosition().toPoint(), this->toolTip()); + this->setCursor(Qt::PointingHandCursor); + } void leaveEvent(QEvent* event) override { auto font = this->font(); - font.setBold(false); + font.setUnderline(false); this->setFont(font); - QToolTip::hideText(); + this->setCursor(Qt::ArrowCursor); } void mousePressEvent(QMouseEvent* event) override @@ -43,6 +44,17 @@ class CopyableLabel : public QLabel } }; +void FileInfoWidget::addCopyableField(const QString& name, const QVariant& value) +{ + auto& [row, column] = this->m_fieldPosition; + + const auto valueLabel = new CopyableLabel(value.toString(), getThemeColor(AlphanumericHighlightColor)); + valueLabel->setFont(getMonospaceFont(this)); + + this->m_layout->addWidget(new QLabel(name), row, column); + this->m_layout->addWidget(valueLabel, row++, column + 1); +} + void FileInfoWidget::addField(const QString& name, const QVariant& value) { auto& [row, column] = this->m_fieldPosition; @@ -76,10 +88,10 @@ FileInfoWidget::FileInfoWidget(QWidget* parent, BinaryViewRef bv) const auto view = bv->GetParentView() ? bv->GetParentView() : bv; const auto filePath = bv->GetFile()->GetOriginalFilename(); - this->addField("Path: ", filePath.c_str()); + this->addCopyableField("Path: ", filePath.c_str()); const auto fileSize = QString::number(view->GetLength(), 16).prepend("0x"); - this->addField("Size: ", fileSize); + this->addCopyableField("Size: ", fileSize); const auto bufferSize = fileSize.toUInt(nullptr, 16); const auto fileBuffer = std::make_unique<char[]>(bufferSize); diff --git a/examples/triage/fileinfo.h b/examples/triage/fileinfo.h index 14a7ec3c..1896188a 100644 --- a/examples/triage/fileinfo.h +++ b/examples/triage/fileinfo.h @@ -12,6 +12,7 @@ class FileInfoWidget : public QWidget QGridLayout* m_layout {}; void addField(const QString& name, const QVariant& value); + void addCopyableField(const QString& name, const QVariant& value); void addHashField(const QString& hashName, const QCryptographicHash::Algorithm& algorithm, const QByteArray& data); public: |
