Skip to content

Commit

Permalink
Shortened context menus
Browse files Browse the repository at this point in the history
  • Loading branch information
Skaleee committed Sep 7, 2024
1 parent cd54a23 commit ed1bf20
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace hal {
class ModuleContextMenu
{
public:
static void addSubmenu(QMenu* contextMenu, const QSet<u32>& modules = QSet<u32>(), const QSet<u32>& gates = QSet<u32>(), const QSet<u32>& nets = QSet<u32>());
static void addModuleSubmenu(QMenu* contextMenu, u32 id);
static void addGateSubmenu(QMenu* contextMenu, u32 id);
static void addNetSubmenu(QMenu* contextMenu, u32 id);
Expand Down
7 changes: 0 additions & 7 deletions plugins/gui/include/gui/netlist_relay/netlist_relay.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@ namespace hal
*/
void changeModuleColorDialog(const u32 id);

/**
* Adds the currently selected gates to a specific module.
*
* @param id - The id of the module that should be appended
*/
void addSelectionToModule(const u32 id);

/**
* Adds an empty child module to the specified module by asking the user for a new name in a dialogue.
*
Expand Down
92 changes: 41 additions & 51 deletions plugins/gui/src/graph_widget/graph_graphics_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,17 +603,6 @@ namespace hal
}
}

if(isGate || isModule)
{
action = context_menu.addAction("Fold parent module");
QObject::connect(action, &QAction::triggered, this, &GraphGraphicsView::handleFoldParentSingle);
}
if(isModule)
{
action = context_menu.addAction("Unfold module");
QObject::connect(action, &QAction::triggered, this, &GraphGraphicsView::handleUnfoldSingleAction);
}

if (isGate || isModule)
{
QMenu* preSucMenu = context_menu.addMenu("Successor/Predecessor …");
Expand Down Expand Up @@ -655,45 +644,57 @@ namespace hal
}
}

if (isGate || isModule)
if (!gContentManager->getGraphTabWidget()->isSelectMode())
{
action = context_menu.addAction("Fold all parent modules");
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleFoldParentAll);
if(gSelectionRelay->numberSelectedItems() <= 1) action->setEnabled(false);
action = context_menu.addAction("Cancel pick-item mode");
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleCancelPickMode);
}

action = context_menu.addAction("Isolate all in new view");
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleIsolationViewAction);
if(gSelectionRelay->numberSelectedItems() <= 1) action->setEnabled(false);
if(isModule)
ModuleContextMenu::addModuleSubmenu(&context_menu, mItem->id());
else if(isGate)
ModuleContextMenu::addGateSubmenu(&context_menu, mItem->id());
else if(isNet)
ModuleContextMenu::addNetSubmenu(&context_menu, mItem->id());

// Appended to single selected item menu
if(isGate || isModule)
{
action = context_menu.addAction(" Fold parent module");
QObject::connect(action, &QAction::triggered, this, &GraphGraphicsView::handleFoldParentSingle);
}
if(isModule)
{
action = context_menu.addAction(" Unfold module");
QObject::connect(action, &QAction::triggered, this, &GraphGraphicsView::handleUnfoldSingleAction);
}

if (gSelectionRelay->numberSelectedItems() > 1)
{
ModuleContextMenu::addMultipleElementsSubmenu(&context_menu, gSelectionRelay->selectedModules(), gSelectionRelay->selectedGates(), gSelectionRelay->selectedNets());

action = context_menu.addAction("Unfold all selected modules");
// Appended to multiple selected items menu
action = context_menu.addAction(" Fold all parent modules");
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleFoldParentAll);
action = context_menu.addAction(" Isolate all in new view");
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleIsolationViewAction);
action = context_menu.addAction(" Unfold all selected modules");
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleUnfoldAllAction);
if(gSelectionRelay->numberSelectedModules() <= 1) action->setEnabled(false);

action = context_menu.addAction("Remove item from view");
action = context_menu.addAction(" Remove items from view");
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleRemoveFromView);
// Gate* g = isGate ? gNetlist->get_gate_by_id(mItem->id()) : nullptr;
Module* m = isModule ? gNetlist->get_module_by_id(mItem->id()) : nullptr;

action = context_menu.addAction("Add comment");
action = context_menu.addAction(" Add comment");
QVariant data;
data.setValue(Node(mItem->id(), isGate ? Node::NodeType::Gate : Node::NodeType::Module));
action->setData(data);
QObject::connect(action, &QAction::triggered, this, &GraphGraphicsView::handleAddCommentAction);
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleAddCommentAction);

// only allow move actions on anything that is not the top module
if (!gContentManager->getGraphTabWidget()->isSelectMode())
{
action = context_menu.addAction("Cancel pick-item mode");
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleCancelPickMode);
}
else
Module* m = isModule ? gNetlist->get_module_by_id(mItem->id()) : nullptr;
if (!(isModule && m == gNetlist->get_top_module()))
{
if (!(isModule && m == gNetlist->get_top_module()))
{
action = context_menu.addAction("Move to module …");
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleModuleDialog);
}
action = context_menu.addAction(" Move to module …");
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleModuleDialog);
}
}
}
Expand All @@ -702,33 +703,24 @@ namespace hal
context_menu.addAction("This view:")->setEnabled(false);

action = context_menu.addAction(" Add module to view");
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleAddModuleToView);

int selectable_modules_count = 0;
QSet<u32> not_selectable_modules = getNotSelectableModules();

for (Module* m : gNetlist->get_modules())
{
if (!not_selectable_modules.contains(m->get_id()))
{
selectable_modules_count++;
}
}

if (selectable_modules_count == 0) {
if (selectable_modules_count == 0)
action->setDisabled(true);
}

QObject::connect(action, &QAction::triggered, this, &GraphGraphicsView::handleAddModuleToView);

action = context_menu.addAction(" Add gate to view");

connect(action, &QAction::triggered, this, &GraphGraphicsView::handleAddGateToView);
if (getSelectableGates().empty())
action->setDisabled(true);

QObject::connect(action, &QAction::triggered, this, &GraphGraphicsView::handleAddGateToView);
}


// if (!item || isNet)
// {
// QAction* antialiasing_action = context_menu.addAction("Antialiasing");
Expand All @@ -742,8 +734,6 @@ namespace hal
// connect(action, &QAction::triggered, this, SLOT);
// }

ModuleContextMenu::addSubmenu(&context_menu, gSelectionRelay->selectedModules(), gSelectionRelay->selectedGates(), gSelectionRelay->selectedNets());

GuiPluginManager::addPluginSubmenus(&context_menu, gNetlist,
gSelectionRelay->selectedModulesVector(),
gSelectionRelay->selectedGatesVector(),
Expand Down
Loading

0 comments on commit ed1bf20

Please sign in to comment.