Proof of concept for having the context actions statically defined in the module.
Needs work for correctly placing the items in menu and on toolbar. Old system still needs to be removed left in place to keep app useable.
This commit is contained in:
parent
7f09d5fe07
commit
601d071d0f
21 changed files with 303 additions and 70 deletions
|
|
@ -26,12 +26,43 @@ void QueryToolModule::init()
|
|||
ma.setIcon(QIcon(":/icons/folder.png"));
|
||||
registerStaticAction(ma);
|
||||
}
|
||||
|
||||
{
|
||||
auto ca = makeContextAction<QueryTool>(tr("Save SQL"), &QueryTool::save);
|
||||
ca->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
|
||||
// ca->setMenuLocation(MenuPath("File/Save"));
|
||||
// ca->setToolbarLocation(ToolbarLocation("main", "save"));
|
||||
// how we tell the system we want this to become a menu button with this as it's default action
|
||||
registerContextAction(ca);
|
||||
}
|
||||
// {
|
||||
// auto ca = makeContextAction<QueryTool>(tr("Save SQL as"), &QueryTool::saveAs);
|
||||
// ca->setMenuLocation(MenuPath("File/Save"));
|
||||
// ca->setToolbarLocation(ToolbarLocation("main", "save"));
|
||||
// // how we tell the system we want this to become a secondary action for the previous button?
|
||||
// registerContextAction(ca);
|
||||
// }
|
||||
// {
|
||||
// auto ca = makeContextAction<QueryTool>(tr("Save copy of SQL as"), &QueryTool::saveCopyAs);
|
||||
// ca->setMenuLocation(MenuPath("File/Save"));
|
||||
// ca->setToolbarLocation(ToolbarLocation("main", "save"));
|
||||
// // how we tell the system we want this to become a secondary action for the previous button?
|
||||
// registerContextAction(ca);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
void QueryToolModule::staticAction_new(IPluginContentWidgetContext* context)
|
||||
{
|
||||
auto *ct = new QueryTool(context, nullptr);
|
||||
context->addContentWidget(this, ct);
|
||||
auto *ct = new QueryTool(context, this);
|
||||
|
||||
// Should we let constructor of PluginContentWidget do this?
|
||||
// Saves a line but what if we don't want it.
|
||||
context->addContentWidget(ct);
|
||||
|
||||
// should content widget now to which module it belongs?
|
||||
// That way the context would not need to keep track of this.
|
||||
|
||||
ct->newdoc();
|
||||
}
|
||||
|
||||
|
|
@ -41,9 +72,11 @@ void QueryToolModule::staticAction_open(IPluginContentWidgetContext* context)
|
|||
QString file_name = QFileDialog::getOpenFileName(context->container(),
|
||||
tr("Open sql query"), home_dir, tr("SQL files (*.sql *.txt)"));
|
||||
if ( ! file_name.isEmpty()) {
|
||||
auto *ct = new QueryTool(context, nullptr);
|
||||
context->addContentWidget(this, ct);
|
||||
ct->load(file_name);
|
||||
auto *ct = new QueryTool(context, this);
|
||||
context->addContentWidget(ct);
|
||||
if (!ct->load(file_name)) {
|
||||
// TODO load has failed remove widget or never add it?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue