From dbd8992d8c6e519ed755f29a751eb30fabea8525 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Thu, 4 Jul 2019 10:36:10 -0400 Subject: Add autocompletion on type dialog --- ui/addressdialog.h | 2 +- ui/typedialog.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 ui/typedialog.h diff --git a/ui/addressdialog.h b/ui/addressdialog.h index 5f23a452..ae30639b 100644 --- a/ui/addressdialog.h +++ b/ui/addressdialog.h @@ -47,7 +47,7 @@ class BINARYNINJAUIAPI AddressDialogWithPreview: public QDialog QStringList m_historyEntries; int m_historySize; GetSymbolsListThread* m_updateThread; - QColor m_defaultColor; + QColor m_defaultColor; QFont m_defaultFont; QString m_prompt; bool m_initialTextSelection; diff --git a/ui/typedialog.h b/ui/typedialog.h new file mode 100644 index 00000000..0404372d --- /dev/null +++ b/ui/typedialog.h @@ -0,0 +1,61 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include "binaryninjaapi.h" +#include "uitypes.h" + + +class BINARYNINJAUIAPI GetTypesListThread: public QThread +{ + Q_OBJECT + + QStringList m_allTypes; + std::function m_completeFunc; + std::mutex m_mutex; + bool m_done; + BinaryViewRef m_view; + +protected: + virtual void run() override; + +public: + GetTypesListThread(BinaryViewRef view, const std::function& completeFunc); + void cancel(); + + const QStringList& getTypes() const { return m_allTypes; } +}; + +class BINARYNINJAUIAPI TypeDialog: public QDialog +{ + Q_OBJECT + + QComboBox* m_combo; + QStringListModel* m_model; + QLabel* m_previewText; + BinaryViewRef m_view; + bool m_resultValid; + QStringList m_historyEntries; + int m_historySize; + GetTypesListThread* m_updateThread; + QFont m_defaultFont; + QString m_prompt; + bool m_initialTextSelection; + BinaryNinja::QualifiedNameAndType m_type; + + void commitHistory(); + void customEvent(QEvent* event); + +private Q_SLOTS: + void accepted(); + +public: + TypeDialog(QWidget* parent, BinaryViewRef view, const QString& title = "Specify Type", + const QString& prompt = "Enter Type Name", const QString& existing=""); + ~TypeDialog() { delete m_updateThread; } + BinaryNinja::QualifiedNameAndType getType() const { return m_type; } +}; \ No newline at end of file -- cgit v1.3.1