From ab7b675788f4d3a529670b3b84ae7d45548543b6 Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Wed, 27 Sep 2023 12:57:29 -0400 Subject: Optimize settings UI to minimize loading time. --- ui/settingsview.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ui/settingsview.h b/ui/settingsview.h index 3570cdcd..2b59332f 100644 --- a/ui/settingsview.h +++ b/ui/settingsview.h @@ -168,16 +168,17 @@ class BINARYNINJAUIAPI SettingsEditor : public QWidget bool m_requiresRestart = false; bool m_settingModified = false; + int m_minHeight; + int m_maxAdjustedWidth; + public: SettingsEditor( QWidget* parent, SettingsRef settings, BinaryViewRef view, BNSettingsScope scope, const Json::Value* setting); ~SettingsEditor(); - QSize sizeHint() const override; void setSetting(const Json::Value* value, bool updateSchema = false); Q_SIGNALS: - void geometryChanged(); void settingChanged(); void allSettingsChanged(); void showIdentifiers(bool enable); @@ -211,6 +212,7 @@ class BINARYNINJAUIAPI SettingsEditor : public QWidget public Q_SLOTS: void updateScope(BinaryViewRef, BNSettingsScope); void updateSize(); + void notifyGeometryChanged(); void updateViewMode(bool enabled); private: @@ -247,14 +249,15 @@ class BINARYNINJAUIAPI SettingsDelegate : public QStyledItemDelegate QTreeView* m_treeView; std::function m_hoverAction = nullptr; - std::function m_defaultSelectionAction = nullptr; + std::function m_defaultSelectionAction = nullptr; + QString m_defaultGroupSelection; public: SettingsDelegate(QWidget* parent, SettingsRef settings, SettingsFilterProxyModel* filterModel, const std::function& hoverAction = nullptr); ~SettingsDelegate(); - void setDefaultSelection(const std::function& selectionAction); + void setDefaultSelection(const QString& group, const std::function& selectionAction); void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; @@ -265,9 +268,6 @@ class BINARYNINJAUIAPI SettingsDelegate : public QStyledItemDelegate void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override; void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override; - protected: - bool eventFilter(QObject* object, QEvent* event) override; - public: Q_SIGNALS: void refreshAllSettings() const; @@ -279,15 +279,15 @@ class BINARYNINJAUIAPI SettingsDelegate : public QStyledItemDelegate void performHoverAction(QModelIndex index) const; public Q_SLOTS: + void notifyUpdateModel(); void updateFonts(); void updateModel(); void updateScope(BinaryViewRef, BNSettingsScope); - void updateSize(); + void notifyResizeEvent(); void updateViewMode(bool enabled) const; private Q_SLOTS: void commitEditorData(); - void editorGeometryChanged(); }; @@ -422,6 +422,7 @@ class BINARYNINJAUIAPI SettingsView : public QWidget QCheckBox* m_viewMode = nullptr; SearchFilter* m_search = nullptr; bool m_outlineNavEnabled = true; + int m_nextGroupIdx = 0; public: SettingsView(QWidget* parent); @@ -430,6 +431,7 @@ class BINARYNINJAUIAPI SettingsView : public QWidget SettingsRef getSettings() { return m_settings; } + void openPersistentEditors(int numToOpen = 0, bool update = true); void init(std::string schema, bool uiScopeSelection); void refreshAllSettings(); void refreshCurrentScope(); -- cgit v1.3.1