1212#include " models/problems.h"
1313#include " models/segments.h"
1414#include " models/strings.h"
15- #include " support/actions.h"
16- #include " support/surfacerenderer.h"
17- // #include "rdui/qtui.h"
1815#include " statusbar.h"
16+ #include " support/actions.h"
1917#include " support/settings.h"
18+ #include " support/surfacerenderer.h"
2019#include " support/utils.h"
2120#include " views/welcome.h"
2221#include < QDragMoveEvent>
2524#include < QMessageBox>
2625#include < QMimeData>
2726
27+ #define MW_GET_ACTION (x ) m_ui.mw_actions.action(ui::MWActionType::x)
28+ #define MW_GET_MENU (x ) m_ui.mw_actions.menu(ui::MWActionType::x)
29+
2830namespace {
2931
3032void on_log (RDLogLevel level, const char * tag, const char * msg,
@@ -58,67 +60,68 @@ MainWindow::MainWindow(const RDInitParams& params, QWidget* parent)
5860
5961 this ->show_welcome_view ();
6062
61- connect (m_ui.act_fileexit , &QAction::triggered, this , &MainWindow::close);
62- connect (m_ui.act_fileopen , &QAction::triggered, this ,
63+ connect (MW_GET_ACTION (FILE_EXIT ), &QAction::triggered, this ,
64+ &MainWindow::close);
65+ connect (MW_GET_ACTION (FILE_OPEN ), &QAction::triggered, this ,
6366 &MainWindow::select_file);
64- connect (m_ui. act_filesave , &QAction::triggered, this ,
67+ connect (MW_GET_ACTION ( FILE_SAVE ) , &QAction::triggered, this ,
6568 &MainWindow::save_project);
66- connect (m_ui. act_filesaveas , &QAction::triggered, this ,
69+ connect (MW_GET_ACTION ( FILE_SAVE_AS ) , &QAction::triggered, this ,
6770 &MainWindow::save_project_as);
68- connect (m_ui. act_fileclose , &QAction::triggered, this ,
71+ connect (MW_GET_ACTION ( FILE_CLOSE ) , &QAction::triggered, this ,
6972 &MainWindow::show_welcome_view);
70- connect (m_ui. act_fileexportdb , &QAction::triggered, this ,
73+ connect (MW_GET_ACTION ( FILE_EXPORT_DATABASE ) , &QAction::triggered, this ,
7174 &MainWindow::export_db);
72- connect (m_ui. act_fileexportinput , &QAction::triggered, this ,
75+ connect (MW_GET_ACTION ( FILE_EXPORT_INPUT ) , &QAction::triggered, this ,
7376 &MainWindow::export_input);
74- connect (m_ui. act_fileexportpatch , &QAction::triggered, this ,
77+ connect (MW_GET_ACTION ( FILE_EXPORT_PATCH ) , &QAction::triggered, this ,
7578 &MainWindow::export_input_patch);
76- connect (m_ui. act_viewsegments , &QAction::triggered, this ,
79+ connect (MW_GET_ACTION ( VIEW_SEGMENTS ) , &QAction::triggered, this ,
7780 &MainWindow::show_segments);
78- connect (m_ui. act_viewmappings , &QAction::triggered, this ,
81+ connect (MW_GET_ACTION ( VIEW_MAPPINGS ) , &QAction::triggered, this ,
7982 &MainWindow::show_mappings);
80- connect (m_ui. act_viewsegmentregs , &QAction::triggered, this ,
83+ connect (MW_GET_ACTION ( VIEW_SEGMENT_REGS ) , &QAction::triggered, this ,
8184 &MainWindow::show_segment_regs);
82- connect (m_ui. act_viewstrings , &QAction::triggered, this ,
85+ connect (MW_GET_ACTION ( VIEW_STRINGS ) , &QAction::triggered, this ,
8386 &MainWindow::show_strings);
84- connect (m_ui. act_viewtypedefs , &QAction::triggered, this ,
87+ connect (MW_GET_ACTION ( VIEW_TYPEDEFS ) , &QAction::triggered, this ,
8588 &MainWindow::show_typedefs);
86- connect (m_ui. act_viewexported , &QAction::triggered, this ,
89+ connect (MW_GET_ACTION ( VIEW_EXPORTED ) , &QAction::triggered, this ,
8790 &MainWindow::show_exported);
88- connect (m_ui. act_viewimported , &QAction::triggered, this ,
91+ connect (MW_GET_ACTION ( VIEW_IMPORTED ) , &QAction::triggered, this ,
8992 &MainWindow::show_imported);
9093
91- connect (m_ui. act_viewmemorymap , &QAction::triggered, this , [&]() {
94+ connect (MW_GET_ACTION ( VIEW_MEMORY_MAP ) , &QAction::triggered, this , [&]() {
9295 ContextView* ctxview = this ->context_view ();
9396 if (!ctxview) return ;
9497
9598 auto * dlgmemorymap = new MemoryMapDialog (ctxview->context (), this );
9699 dlgmemorymap->show ();
97100 });
98101
99- connect (m_ui. act_toolsflc , &QAction::triggered, this , [&]() {
102+ connect (MW_GET_ACTION ( TOOLS_FLC ) , &QAction::triggered, this , [&]() {
100103 ContextView* ctxview = this ->context_view ();
101104 if (!ctxview) return ;
102105 auto * dlgflc = new FLCDialog (ctxview->context (), this );
103106 dlgflc->show ();
104107 });
105108
106- connect (m_ui. act_devdecoder , &QAction::triggered, this , [&]() {
109+ connect (MW_GET_ACTION ( TOOLS_DEV_DECODER ) , &QAction::triggered, this , [&]() {
107110 auto * dlgdecoder = new DecoderDialog (this );
108111 dlgdecoder->show ();
109112 });
110113
111- connect (m_ui. act_devgraphs , &QAction::triggered, this , [&]() {
114+ connect (MW_GET_ACTION ( TOOLS_DEV_GRAPHS ) , &QAction::triggered, this , [&]() {
112115 ContextView* ctxview = this ->context_view ();
113116 if (!ctxview) return ;
114117 auto * dlggraphdots = new DevGraphsDialog (ctxview->context (), this );
115118 dlggraphdots->show ();
116119 });
117120
118- connect (m_ui. act_toolsproblems , &QAction::triggered, this ,
121+ connect (MW_GET_ACTION ( ANALYSIS_PROBLEMS ) , &QAction::triggered, this ,
119122 &MainWindow::show_problems);
120123
121- connect (m_ui. act_winrestoredefault , &QAction::triggered, this ,
124+ connect (MW_GET_ACTION ( WINDOW_RESTORE_DEFAULT ) , &QAction::triggered, this ,
122125 [&]() { REDasmSettings{}.restore_state (this ); });
123126
124127 connect (statusbar::problems_button (), &QPushButton::clicked, this ,
@@ -169,23 +172,24 @@ void MainWindow::load_window_state() {
169172}
170173
171174void MainWindow::load_recents () {
172- m_ui.mnurecents ->clear ();
175+ QMenu* mnurecents = MW_GET_MENU (FILE_RECENTS );
176+ mnurecents->clear ();
173177
174178 REDasmSettings settings;
175179 QStringList recents = settings.recent_files ();
176- m_ui. mnurecents ->setEnabled (!recents.empty ());
180+ mnurecents->setEnabled (!recents.empty ());
177181
178182 for (int i = 0 ; i < REDasmSettings::MAX_RECENT_FILES ; i++) {
179183 if (i >= recents.length ()) {
180- QAction* action = m_ui. mnurecents ->addAction (QString{});
184+ QAction* action = mnurecents->addAction (QString{});
181185 action->setVisible (false );
182186 continue ;
183187 }
184188
185189 if (!QFileInfo ().exists (recents[i])) continue ;
186190
187- QAction* action = m_ui. mnurecents -> addAction (
188- QString (" %1 - %2" ).arg (i).arg (recents[i]));
191+ QAction* action =
192+ mnurecents-> addAction ( QString (" %1 - %2" ).arg (i).arg (recents[i]));
189193 action->setData (recents[i]);
190194
191195 connect (action, &QAction::triggered, this ,
@@ -194,8 +198,8 @@ void MainWindow::load_recents() {
194198
195199 if (recents.empty ()) return ;
196200
197- m_ui. mnurecents ->addSeparator ();
198- QAction* action = m_ui. mnurecents ->addAction (tr (" Clear" ));
201+ mnurecents->addSeparator ();
202+ QAction* action = mnurecents->addAction (tr (" Clear" ));
199203
200204 connect (action, &QAction::triggered, this ,
201205 [=]() { this ->clear_recents (); });
@@ -289,31 +293,33 @@ bool MainWindow::can_close() const {
289293}
290294
291295void MainWindow::enable_context_actions (bool e) { // NOLINT
292- m_ui.mnuexport ->menuAction ()->setVisible (e);
293-
294- m_ui.act_filesave ->setVisible (e);
295- m_ui.act_filesaveas ->setVisible (e);
296- m_ui.act_fileclose ->setVisible (e);
297- m_ui.act_view ->setVisible (e);
298-
299- m_ui.act_goto ->setVisible (e);
296+ MW_GET_MENU (FILE_EXPORT )->menuAction ()->setVisible (e);
297+
298+ MW_GET_ACTION (FILE_SAVE )->setVisible (e);
299+ MW_GET_ACTION (FILE_SAVE_AS )->setVisible (e);
300+ MW_GET_ACTION (FILE_CLOSE )->setVisible (e);
301+
302+ MW_GET_MENU (VIEW )->menuAction ()->setVisible (e);
303+ MW_GET_ACTION (VIEW_SEGMENT_REGS )->setVisible (e);
304+ MW_GET_ACTION (VIEW_SEGMENTS )->setVisible (e);
305+ MW_GET_ACTION (VIEW_MAPPINGS )->setVisible (e);
306+ MW_GET_ACTION (VIEW_STRINGS )->setVisible (e);
307+ MW_GET_ACTION (VIEW_TYPEDEFS )->setVisible (e);
308+ MW_GET_ACTION (VIEW_IMPORTED )->setVisible (e);
309+ MW_GET_ACTION (VIEW_EXPORTED )->setVisible (e);
310+
311+ MW_GET_MENU (ANALYSIS )->menuAction ()->setVisible (e);
312+ MW_GET_ACTION (ANALYSIS_GOTO )->setVisible (e);
313+ MW_GET_ACTION (ANALYSIS_REANALYZE )->setVisible (e);
314+ MW_GET_ACTION (ANALYSIS_REBASE )->setVisible (e);
315+ MW_GET_ACTION (ANALYSIS_PROBLEMS )->setVisible (e);
316+
317+ MW_GET_ACTION (TOOLS_FLC )->setVisible (e);
318+ MW_GET_ACTION (TOOLS_DEV_GRAPHS )->setVisible (e);
300319
301320 m_ui.act_tbseparator1 ->setVisible (e);
302321 m_ui.act_tbseparator2 ->setVisible (e);
303322 m_ui.act_tbseparator3 ->setVisible (e);
304- m_ui.act_tbseparator4 ->setVisible (e);
305-
306- m_ui.act_toolsflc ->setVisible (e);
307- m_ui.act_toolsreanalyze ->setVisible (e);
308- m_ui.act_toolsproblems ->setVisible (e);
309- m_ui.act_devgraphs ->setVisible (e);
310- m_ui.act_viewsegmentregs ->setVisible (e);
311- m_ui.act_viewsegments ->setVisible (e);
312- m_ui.act_viewmappings ->setVisible (e);
313- m_ui.act_viewstrings ->setVisible (e);
314- m_ui.act_viewtypedefs ->setVisible (e);
315- m_ui.act_viewimported ->setVisible (e);
316- m_ui.act_viewexported ->setVisible (e);
317323
318324 if (!e) {
319325 statusbar::set_status_text (QString{});
0 commit comments