summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorXusheng <xusheng@vector35.com>2023-09-19 13:03:03 +0800
committerXusheng <xusheng@vector35.com>2023-09-19 15:00:12 +0800
commitb1e5ac87b14610a577292a85319047426ff47a8e (patch)
tree6f61e76862c1be76ffbaaf279879dad0194092d2 /examples
parentbeb79f0a7aa38bdf6818056d8c21c6e599456be8 (diff)
Extract class CopyableLabel to an independent file. Fix https://github.com/Vector35/binaryninja/issues/525 and https://github.com/Vector35/binaryninja-api/issues/4630
Diffstat (limited to 'examples')
-rw-r--r--examples/triage/fileinfo.cpp39
1 files changed, 1 insertions, 38 deletions
diff --git a/examples/triage/fileinfo.cpp b/examples/triage/fileinfo.cpp
index 5ac32bc6..dbecaddc 100644
--- a/examples/triage/fileinfo.cpp
+++ b/examples/triage/fileinfo.cpp
@@ -1,49 +1,12 @@
#include "fileinfo.h"
#include "fontsettings.h"
#include "theme.h"
+#include "copyablelable.h"
#include <QClipboard>
#include <QApplication>
#include <QToolTip>
#include <QPainter>
-class CopyableLabel : public QLabel
-{
- QColor m_desiredColor {};
-
- public:
- CopyableLabel(const QString& text, const QColor& color) : QLabel(text), m_desiredColor(color)
- {
- this->setMouseTracking(true);
- auto style = QPalette(palette());
- style.setColor(QPalette::WindowText, m_desiredColor);
- setPalette(style);
- this->setToolTip("Click to Copy");
- }
-
- void enterEvent(QEnterEvent* event) override
- {
- auto font = this->font();
- font.setUnderline(true);
- this->setFont(font);
- this->setCursor(Qt::PointingHandCursor);
-
- }
-
- void leaveEvent(QEvent* event) override
- {
- auto font = this->font();
- font.setUnderline(false);
- this->setFont(font);
- this->setCursor(Qt::ArrowCursor);
- }
-
- void mousePressEvent(QMouseEvent* event) override
- {
- if (event->button() == Qt::LeftButton)
- QApplication::clipboard()->setText(this->text());
- }
-};
-
void FileInfoWidget::addCopyableField(const QString& name, const QVariant& value)
{
auto& [row, column] = this->m_fieldPosition;