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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
#pragma once
#include <QtCore/QObject>
#include <QtCore/QSettings>
#include <QtWidgets/QDockWidget>
#include <map>
#include "binaryninjaapi.h"
#include "action.h"
#include "uitypes.h"
class ContextMenuManager;
class DockHandler;
class Menu;
class View;
class ViewFrame;
struct BINARYNINJAUIAPI DockProperties
{
DockProperties() { };
DockProperties(QDockWidget* dw, bool vis, Qt::DockWidgetArea dar, Qt::Orientation dor, bool dvis, bool vs) :
dockWidget(dw), visibleState(vis), defaultArea(dar), defaultOrientation(dor), defaultVisibility(dvis),
viewSensitive(vs), neverBeenVisible(true), sizeStash(0, 0), actionOnShow(nullptr) { }
DockProperties(const DockProperties &dp) :
dockWidget(dp.dockWidget), visibleState(dp.visibleState), defaultArea(dp.defaultArea),
defaultOrientation(dp.defaultOrientation), defaultVisibility(dp.defaultVisibility),
viewSensitive(dp.viewSensitive), neverBeenVisible(dp.neverBeenVisible), sizeStash(dp.sizeStash), actionOnShow(dp.actionOnShow) { }
QDockWidget* dockWidget;
bool visibleState;
Qt::DockWidgetArea defaultArea;
Qt::Orientation defaultOrientation;
bool defaultVisibility;
bool viewSensitive;
bool neverBeenVisible;
QSize sizeStash;
std::function<void()> actionOnShow;
};
struct DockSizePrefs
{
DockSizePrefs() { }
QList<QDockWidget*> docks;
QList<int> hDockSizes;
QList<int> vDockSizes;
bool nonUniformVisibility = false;
};
class BINARYNINJAUIAPI DockContextHandler
{
protected:
QString m_name;
UIActionHandler m_actionHandler;
ContextMenuManager* m_contextMenuManager = nullptr;
Menu* m_menu = nullptr;
QWidget* m_parentWindow;
public:
DockContextHandler(QWidget* widget, const QString& name);
virtual ~DockContextHandler();
QWidget* getParentWindow() { return m_parentWindow; }
virtual void focusInput() { };
virtual void notifyViewChanged(ViewFrame* /*frame*/) { };
virtual bool shouldBeVisible(ViewFrame* /*frame*/) { return true; };
virtual void updateFonts() { };
virtual void updateTheme() { };
};
class BINARYNINJAUIAPI DockHandler: public QObject
{
Q_OBJECT
int m_windowIndex = 0;
ViewFrame* m_viewFrame = nullptr;
View* m_view = nullptr;
BinaryViewRef m_data;
std::map<QString, DockProperties> m_docks;
bool m_resizeDocksRequest = false;
bool m_shouldResizeDocks = false;
std::map<Qt::DockWidgetArea, bool> m_enableHiddenGroupSave;
public:
explicit DockHandler(QObject* parent, int windowIndex);
void close();
void notifyRestoredFromState();
void reset(bool initial = false);
void reset(const QString& name);
void resizeDocksOnShow(bool resizeDocks) { m_resizeDocksRequest = resizeDocks; }
bool addDockWidget(const QString& name, QWidget* primaryWidget, Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, Qt::Orientation orientation = Qt::Horizontal, bool defaultVisibility = false);
QDockWidget* getDockWidget(const QString& name);
ViewFrame* getViewFrame() { return m_viewFrame; }
bool isVisible(const QString& name);
void setVisible(const QString& name, bool visible);
void saveState(QSettings& settings, const QString& windowStateName);
void restoreState(QSettings& settings, const QString& windowStateName);
void saveDockSizes(bool nullFrame = false);
void restoreDockSizes();
bool shouldResizeDocks();
void updateFonts();
void addActionOnShow(const QString& name, const std::function<void()>& action);
static DockHandler* getActiveDockHandler();
public Q_SLOTS:
void viewChanged(ViewFrame* frame);
void topLevelChanged(bool topLevel);
};
|