From a1f23181e284c102d6def1b4a13c29b989c5c097 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Sun, 7 Apr 2019 14:44:51 -0400 Subject: Add autocomplete and preview to 'Go To Address' dialog --- ui/addressdialog.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 ui/addressdialog.h 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 +#include +#include +#include +#include +#include +#include +#include "binaryninjaapi.h" +#include "uitypes.h" + +class BINARYNINJAUIAPI GetSymbolsListThread: public QThread +{ + Q_OBJECT + + QStringList m_allSymbols; + std::function m_completeFunc; + std::mutex m_mutex; + bool m_done; + BinaryViewRef m_view; + +protected: + virtual void run() override; + +public: + GetSymbolsListThread(BinaryViewRef view, const std::function& 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; } +}; -- cgit v1.3.1