RPL Viewer Prep [1]: Move RplBlock/FunctionDlg menus from UI into C++ Bug Number: n/a Release notes (y/n): no For Release Nums: 5.2 This is one of two or three commits to prepare to deploy the full implementation of the RplBlockDlg and RplFunctionDlg as "tabs" in a new RplViewerDlg. THIS commit deals with the problem that Qt Designer UI files provide a HARD-CODED deployment of the menubar content (QMenus and their QAction menu items). This poses the following two problems: (1) The full implementations of these two Rpl dialogs are being moved from QMainWindow-based classes to QFrame-based classes. Qt Designer (and the generated UI files) support the definition of menus only for a QMainWindow-based class. (2) The RplViewerDlg will need to _dynamically_ install these menus when switching between RplObj-based tabs (Blocks and Functions). This isn't only to account for the differences between RPL Blocks (Rules, Goals, Methods) and RPL Functions. It's also because we are trying to preserve the _logical_ encapsulation around these implementations; we want "both sides" of the Qt signal/slot connections from a menu's actions to the QFrame-based class implementations to remain intact. QMenu and menu QAction construction of the menus for these two dialogs was extracted from the UI files, and moved to these modules. (The process of doing this is further described below): QtRpl/RplBlockMenus.hpp QtRpl/RplBlockMenus.cpp QtRpl/RplFunctionMenus.hpp QtRpl/RplFunctionMenus.cpp The "handles" (pointers) to the generated QMenu and QAction instances are made available as public data members in this class. The two RPL dialogs dynamically instantiate an instance, and directly access those handles through a pointer to that instance. This is similar to the coupling of the dialog class to the Qt Designer UI generated code. For example, the RplBlockDlg now maintains these TWO pointers: Ui_RplBlockDlgWidgets* _ui; RplBlockMenus* _mu; References to those QMenus and QActions within the dialog class need to change from "_ui-> ..." to "_mu->...". (The dialog's _widgets_ are still accessed using the _ui pointer). The following provides some information about the automated process used to change the appropriate "_ui" references to "_mu" references in the RplBlockDlg and RplFunctionDlg dialog classes. The Qt 5.5.1 "uic" compiler translates Qt Designer UI files into C++ files. The menu and widget layouts for RplBlockDlg and RplFunctionDlg are defined in these UI files: QtRpl/RplBlockDlgWidgets.ui QtRpl/RplFunctionDlgWidgets.ui The generated C++ files (not in git source control) are: QtRpl/qt/ui_RplBlockDlgWidgets.h QtRpl/qt/ui_RplFunctionDlgWidgets.h The following sequence of unix commands (making use of the "sed" utility) create a modified copy of RplBlockDlg.cpp. (An analogous set of commands was applied to RplFunctionDlg.cpp). (I did this on our linux machine, Alamosa, but something like this would work also in a GIT MINGW64 command line window). #---------------------------------------------- # rm actions* # rm RplBlockDlg-MU.cpp # # grep "addaction name=" RplBlockDlgWidgets.ui | grep -v separator > actions1.txt # sed 's|.*name=.\(_[A-Za-z0-9]*\).*|\1|' actions1.txt > actions2.txt # # cp RplBlockDlg.cpp RplBlockDlg-MU.cpp # sed "s/\(.*\)/sed -i \'s|\\\(ui\\\)\\\( *-> *\\\)\\\(\1\\\)|mu\\2\\3|\' RplBlockDlg-MU.cpp/" actions2.txt > actionsSedCmd.txt # # source actionsSedCmd.txt #---------------------------------------------- As a separate process, the code to create the QMenus and menu QActions from the generated "ui_Rpl...h" files was copied off to the new Rpl...Menu C++ modules, and cleaned up. (See the four new files added in this commit). ---