mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-14 17:09:11 +02:00
see #2488 fixed new object menu issues
This commit is contained in:
@@ -1807,6 +1807,5 @@ void FWWindow::addNewObjectMenu(QMenu *m)
|
||||
void FWWindow::showNewObjectMenu()
|
||||
{
|
||||
m_mainWindow->newObjectAction->menu()->popup(QCursor::pos());
|
||||
// m_mainWindow->newObjectAction->parentWidget()->mapToGlobal(QPoint(0,0)));
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,8 @@ ObjectManipulator::ObjectManipulator(QWidget *parent):
|
||||
// used in duplicateWithDependencies()
|
||||
dedup_marker_global_counter = time(NULL);
|
||||
|
||||
popup_menu = NULL;
|
||||
|
||||
// buildNewObjectMenu();
|
||||
|
||||
}
|
||||
@@ -362,6 +364,11 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
|
||||
//if (currentObj==NULL) currentObj=otvi->getFWObject();
|
||||
FWObject *currentObj = getSelectedObject();
|
||||
|
||||
if (popup_menu == NULL)
|
||||
{
|
||||
popup_menu = new QMenu(this);
|
||||
popup_menu->setObjectName("objectTreeContextMenu");
|
||||
} else
|
||||
popup_menu->clear();
|
||||
|
||||
if (item->childCount() > 0)
|
||||
|
||||
@@ -237,6 +237,7 @@ public slots:
|
||||
void newObject();
|
||||
|
||||
void createNewObject();
|
||||
void newFirewallSlot();
|
||||
|
||||
void copyObj();
|
||||
void cutObj();
|
||||
|
||||
@@ -91,9 +91,6 @@ using namespace libfwbuilder;
|
||||
|
||||
void ObjectManipulator::buildNewObjectMenu()
|
||||
{
|
||||
popup_menu = new QMenu(this);
|
||||
popup_menu->setObjectName("objectTreeContextMenu");
|
||||
|
||||
QMenu* newObjectPopup = new QMenu( mw );
|
||||
|
||||
newObjectPopup->setObjectName("newObjectPopup");
|
||||
@@ -266,6 +263,35 @@ void ObjectManipulator::createNewObject()
|
||||
m_project->undoStack->push(macro);
|
||||
}
|
||||
|
||||
void ObjectManipulator::newFirewallSlot()
|
||||
{
|
||||
QString descr = FWBTree().getTranslatableObjectTypeName(Firewall::TYPENAME);
|
||||
// FWCmdMacro should be used for commands grouping
|
||||
FWCmdMacro* macro = 0;
|
||||
macro = new FWCmdMacro(
|
||||
FWBTree().getTranslatableNewObjectMenuText(Firewall::TYPENAME));
|
||||
|
||||
FWObject *new_obj = newFirewall(macro);
|
||||
|
||||
if (new_obj == NULL)
|
||||
{
|
||||
delete macro;
|
||||
return;
|
||||
}
|
||||
|
||||
QCoreApplication::postEvent(
|
||||
m_project, new expandObjectInTreeEvent(
|
||||
m_project->getFileName(), new_obj->getId()));
|
||||
|
||||
FWObject *ruleset = new_obj->getFirstByType(Policy::TYPENAME);
|
||||
if (ruleset)
|
||||
QCoreApplication::postEvent(
|
||||
m_project, new openRulesetEvent(
|
||||
m_project->getFileName(), ruleset->getId()));
|
||||
|
||||
m_project->undoStack->push(macro);
|
||||
}
|
||||
|
||||
FWObject* ObjectManipulator::createObject(const QString &objType,
|
||||
const QString &objName,
|
||||
FWObject *copyFrom,
|
||||
|
||||
@@ -49,8 +49,7 @@ WorkflowIcons::WorkflowIcons(QWidget *parent) :
|
||||
void WorkflowIcons::setUpSignals(QWidget *panel)
|
||||
{
|
||||
ObjectManipulator *om = panel->findChild<ObjectManipulator*>();
|
||||
QAction *newFirewall = om->findChild<QAction*>(QString("newObject_") + libfwbuilder::Firewall::TYPENAME);
|
||||
connect(ui->newFirewall, SIGNAL(clicked()), newFirewall, SLOT(trigger()));
|
||||
connect(ui->newFirewall, SIGNAL(clicked()), om, SLOT(newFirewallSlot()));
|
||||
|
||||
// global variable mw is null when this is running
|
||||
QObject *mainWindow = dynamic_cast<ProjectPanel*>(panel)->getWindow();
|
||||
|
||||
Reference in New Issue
Block a user