summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2019-04-07 14:44:51 -0400
committerPeter LaFosse <peter@vector35.com>2019-04-07 18:19:49 -0400
commita1f23181e284c102d6def1b4a13c29b989c5c097 (patch)
treeb7735fd57b056e6f1ef4b64017d31082d373397c
parent66bf94824afd329202c38d68a4904dedad562fda (diff)
Add autocomplete and preview to 'Go To Address' dialog
-rw-r--r--ui/addressdialog.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/ui/addressdialog.h b/ui/addressdialog.h
new file mode 100644
index 00000000..aa242656
--- /dev/null
+++ b/ui/addressdialog.h
@@ -0,0 +1,68 @@
+#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;
+
+ void commitHistory();
+ void customEvent(QEvent* event);
+
+private Q_SLOTS:
+ void updateTimerEvent();
+ void accepted();
+ void updateRelativeState(int state);
+ void updatePreview(QString text);
+
+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; }
+};