Basic concept of MenuAction is working
Module can register action Window adds this action to its menu Clicking the menu item for the action has the expected result But menu structure still needs work (everything is now put into one dropdown menu)
This commit is contained in:
parent
f130c426a1
commit
dc8a052544
12 changed files with 220 additions and 28 deletions
|
|
@ -65,17 +65,64 @@ namespace DatabaseWindow_details {
|
|||
using namespace DatabaseWindow_details;
|
||||
|
||||
|
||||
DatabaseWindow::DatabaseWindow(MasterController *master, QWidget *parent)
|
||||
LMainWindow::LMainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
m_fileMenu = new QMenu("File T", this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void LMainWindow::initModuleMenus()
|
||||
{
|
||||
menuBar()->addMenu(m_fileMenu);
|
||||
addModuleMenuActions();
|
||||
}
|
||||
|
||||
void LMainWindow::addModuleMenuActions()
|
||||
{
|
||||
auto reg = PluginRegister::getInstance();
|
||||
auto mods = reg->modules();
|
||||
for (auto && mod : mods) {
|
||||
auto items = mod.second->menuActions();
|
||||
for (auto && item : items) {
|
||||
addMenuAction(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LMainWindow::addMenuAction(const MenuAction &ma)
|
||||
{
|
||||
qDebug() << "add action " << ma.text();
|
||||
//auto ac =
|
||||
m_fileMenu->addAction(ma.icon(), ma.text(),
|
||||
[ma, this] ()
|
||||
{
|
||||
ma.perform(m_context);
|
||||
},
|
||||
ma.shortCut());
|
||||
|
||||
|
||||
// auto ac = new QAction(this);
|
||||
// ac->
|
||||
|
||||
|
||||
}
|
||||
|
||||
DatabaseWindow::DatabaseWindow(MasterController *master, QWidget *parent)
|
||||
: LMainWindow(parent)
|
||||
, ui(new Ui::DatabaseWindow)
|
||||
, m_context(new DatabaseWindowContentContext(this))
|
||||
, m_masterController(master)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tabWidget->setDocumentMode(true);
|
||||
|
||||
m_context = new DatabaseWindowContentContext(this);
|
||||
|
||||
connect(&loadWatcher, &QFutureWatcher<LoadCatalog::Result>::finished,
|
||||
this, &DatabaseWindow::catalogLoaded);
|
||||
|
||||
initModuleMenus();
|
||||
}
|
||||
|
||||
DatabaseWindow::~DatabaseWindow()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue