| 527 | } |
| 528 | |
| 529 | void MainWindow::showInstanceContextMenu(const QPoint& pos) |
| 530 | { |
| 531 | QList<QAction*> actions; |
| 532 | |
| 533 | QAction* actionSep = new QAction("", this); |
| 534 | actionSep->setSeparator(true); |
| 535 | |
| 536 | bool onInstance = view->indexAt(pos).isValid(); |
| 537 | if (onInstance) { |
| 538 | // reuse the file menu actions |
| 539 | actions = ui->fileMenu->actions(); |
| 540 | |
| 541 | // remove the add instance action, launcher settings action and close action |
| 542 | actions.removeFirst(); |
| 543 | actions.removeLast(); |
| 544 | actions.removeLast(); |
| 545 | |
| 546 | actions.prepend(ui->actionChangeInstIcon); |
| 547 | actions.prepend(ui->actionRenameInstance); |
| 548 | |
| 549 | // add header |
| 550 | actions.prepend(actionSep); |
| 551 | QAction* actionVoid = new QAction(m_selectedInstance->name(), this); |
| 552 | actionVoid->setEnabled(false); |
| 553 | actions.prepend(actionVoid); |
| 554 | } else { |
| 555 | auto group = view->groupNameAt(pos); |
| 556 | |
| 557 | QAction* actionVoid = new QAction(group.isNull() ? BuildConfig.LAUNCHER_DISPLAYNAME : group, this); |
| 558 | actionVoid->setEnabled(false); |
| 559 | |
| 560 | QAction* actionCreateInstance = new QAction(tr("&Create instance"), this); |
| 561 | actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip()); |
| 562 | if (!group.isNull()) { |
| 563 | QVariantMap instance_action_data; |
| 564 | instance_action_data["group"] = group; |
| 565 | actionCreateInstance->setData(instance_action_data); |
| 566 | } |
| 567 | |
| 568 | connect(actionCreateInstance, &QAction::triggered, this, &MainWindow::on_actionAddInstance_triggered); |
| 569 | |
| 570 | actions.prepend(actionSep); |
| 571 | actions.prepend(actionVoid); |
| 572 | actions.append(actionCreateInstance); |
| 573 | if (!group.isNull()) { |
| 574 | QAction* actionDeleteGroup = new QAction(tr("&Delete group"), this); |
| 575 | connect(actionDeleteGroup, &QAction::triggered, this, [this, group] { deleteGroup(group); }); |
| 576 | actions.append(actionDeleteGroup); |
| 577 | |
| 578 | QAction* actionRenameGroup = new QAction(tr("&Rename group"), this); |
| 579 | connect(actionRenameGroup, &QAction::triggered, this, [this, group] { renameGroup(group); }); |
| 580 | actions.append(actionRenameGroup); |
| 581 | } |
| 582 | } |
| 583 | QMenu myMenu; |
| 584 | myMenu.addActions(actions); |
| 585 | /* |
| 586 | if (onInstance) |
nothing calls this directly
no test coverage detected