MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / showInstanceContextMenu

Method showInstanceContextMenu

launcher/ui/MainWindow.cpp:504–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502}
503
504void MainWindow::showInstanceContextMenu(const QPoint& pos)
505{
506 QList<QAction*> actions;
507
508 QAction* actionSep = new QAction("", this);
509 actionSep->setSeparator(true);
510
511 bool onInstance = view->indexAt(pos).isValid();
512 if (onInstance) {
513 // reuse the file menu actions
514 actions = ui->fileMenu->actions();
515
516 // remove the add instance action, launcher settings action and close action
517 actions.removeFirst();
518 actions.removeLast();
519 actions.removeLast();
520
521 actions.prepend(ui->actionChangeInstIcon);
522 actions.prepend(ui->actionRenameInstance);
523
524 // add header
525 actions.prepend(actionSep);
526 QAction* actionVoid = new QAction(m_selectedInstance->name(), this);
527 actionVoid->setEnabled(false);
528 actions.prepend(actionVoid);
529 } else {
530 auto group = view->groupNameAt(pos);
531
532 QAction* actionVoid = new QAction(group.isNull() ? BuildConfig.LAUNCHER_DISPLAYNAME : group, this);
533 actionVoid->setEnabled(false);
534
535 QAction* actionCreateInstance = new QAction(tr("&Create instance"), this);
536 actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip());
537 if (!group.isNull()) {
538 QVariantMap instance_action_data;
539 instance_action_data["group"] = group;
540 actionCreateInstance->setData(instance_action_data);
541 }
542
543 connect(actionCreateInstance, SIGNAL(triggered(bool)), SLOT(on_actionAddInstance_triggered()));
544
545 actions.prepend(actionSep);
546 actions.prepend(actionVoid);
547 actions.append(actionCreateInstance);
548 if (!group.isNull()) {
549 QAction* actionDeleteGroup = new QAction(tr("&Delete group"), this);
550 connect(actionDeleteGroup, &QAction::triggered, this, [this, group] { deleteGroup(group); });
551 actions.append(actionDeleteGroup);
552
553 QAction* actionRenameGroup = new QAction(tr("&Rename group"), this);
554 connect(actionRenameGroup, &QAction::triggered, this, [this, group] { renameGroup(group); });
555 actions.append(actionRenameGroup);
556 }
557 }
558 QMenu myMenu;
559 myMenu.addActions(actions);
560 /*
561 if (onInstance)

Callers

nothing calls this directly

Calls 9

setSeparatorMethod · 0.80
indexAtMethod · 0.80
setEnabledMethod · 0.80
groupNameAtMethod · 0.80
appendMethod · 0.80
isValidMethod · 0.45
nameMethod · 0.45
setDataMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected