summaryrefslogtreecommitdiff
path: root/ui/reportwidget.h
blob: 414fb41204fbddac10c1432dd2b2795a63bca065 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once

#include <QtWidgets/QWidget>
#include <QtWidgets/QTextBrowser>
#include <QtWidgets/QScrollArea>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
	#include <QtWebEngineWidgets/QWebEngineView>
	#include <QtWebEngineWidgets/QWebEngineScript>
	#include <QtWebEngineWidgets/QWebEngineScriptCollection>
	#include <QtWebEngineWidgets/QWebEnginePage>
	#include <QtWebEngineWidgets/QWebEngineSettings>
#else
	#include <QtWidgets/QTextBrowser>
#endif
#include "binaryninjaapi.h"
#include "action.h"
#include "theme.h"

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
class WebPage2 : public QWebEnginePage
{
	Q_OBJECT

  public:
	WebPage2(QObject* parent = nullptr) : QWebEnginePage(parent) {}

  protected:
	virtual bool acceptNavigationRequest(const QUrl& url, QWebEnginePage::NavigationType type, bool isMainFrame);

  Q_SIGNALS:
	void linkClicked(const QUrl&);
};
#endif

class BINARYNINJAUIAPI ReportWidget : public QScrollArea, public UIActionHandler
{
	Q_OBJECT

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
	QWebEngineView* m_contents;
#else
	QTextBrowser* m_contents;
#endif
	BinaryViewRef m_view;
	std::string m_original;
	std::string m_title;
	BNReportType m_type;
	std::string m_plaintext;

  private Q_SLOTS:
	void onLinkClicked(QUrl url);

  public:
	ReportWidget(QWidget* parent, BinaryViewRef view, const std::string& contents, BNReportType type,
	    const std::string& title, const std::string& plaintext = "");
	std::string getContents() const { return m_original; }
	std::string getTitle() const { return m_title; }
	BNReportType getType() const { return m_type; }
	std::string getPlainText() const { return m_plaintext; }

	void save();
	void saveAs();

	ReportWidget* duplicate();
};