summaryrefslogtreecommitdiff
path: root/ui/addressdialog.h
blob: ae30639b89d49e44f32b8fe119776f6d6bf4a630 (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
66
67
68
69
70
#pragma once

#include <QtWidgets/QDialog>
#include <QtWidgets/QLabel>
#include <QtCore/QStringListModel>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QComboBox>
#include <QtCore/QTimer>
#include <QtCore/QThread>
#include "binaryninjaapi.h"
#include "uitypes.h"

class BINARYNINJAUIAPI GetSymbolsListThread: public QThread
{
	Q_OBJECT

	QStringList m_allSymbols;
	std::function<void()> m_completeFunc;
	std::mutex m_mutex;
	bool m_done;
	BinaryViewRef m_view;

protected:
	virtual void run() override;

public:
	GetSymbolsListThread(BinaryViewRef view, const std::function<void()>& completeFunc);
	void cancel();

	const QStringList& getSymbols() const { return m_allSymbols; }
};


class BINARYNINJAUIAPI AddressDialogWithPreview: public QDialog
{
	Q_OBJECT

	QComboBox* m_combo;
	QStringListModel* m_model;
	QLabel* m_previewText;
	BinaryViewRef m_view;
	uint64_t m_addr;
	uint64_t m_here;
	QCheckBox* m_checkBox;
	bool m_resultValid;
	QTimer* m_updateTimer;
	QStringList m_historyEntries;
	int m_historySize;
	GetSymbolsListThread* m_updateThread;
	QColor m_defaultColor;
	QFont m_defaultFont;
	QString m_prompt;
	bool m_initialTextSelection;

	void commitHistory();
	void customEvent(QEvent* event);

private Q_SLOTS:
	void updateTimerEvent();
	void accepted();
	void updateRelativeState(int state);
	void updatePreview();
	void updatePreview(QString data);

public:
	AddressDialogWithPreview(QWidget* parent, BinaryViewRef view, uint64_t here,
		const QString& title = "Go to Address", const QString& prompt = "Enter Expression");
	~AddressDialogWithPreview() { delete m_updateThread; }
	uint64_t getOffset() const { return m_addr; }
};