MCPcopy Create free account
hub / github.com/MultiMC/Launcher / showInstanceContextMenu

Method showInstanceContextMenu

launcher/ui/MainWindow.cpp:885–947  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

883}
884
885void MainWindow::showInstanceContextMenu(const QPoint &pos)
886{
887 QList<QAction *> actions;
888
889 QAction *actionSep = new QAction("", this);
890 actionSep->setSeparator(true);
891
892 bool onInstance = view->indexAt(pos).isValid();
893 if (onInstance)
894 {
895 actions = ui->instanceToolBar->actions();
896
897 // replace the change icon widget with an actual action
898 actions.replace(0, ui->actionChangeInstIcon);
899
900 // replace the rename widget with an actual action
901 actions.replace(1, ui->actionRenameInstance);
902
903 // add header
904 actions.prepend(actionSep);
905 QAction *actionVoid = new QAction(m_selectedInstance->name(), this);
906 actionVoid->setEnabled(false);
907 actions.prepend(actionVoid);
908 }
909 else
910 {
911 auto group = view->groupNameAt(pos);
912
913 QAction *actionVoid = new QAction(BuildConfig.LAUNCHER_NAME, this);
914 actionVoid->setEnabled(false);
915
916 QAction *actionCreateInstance = new QAction(tr("Create instance"), this);
917 actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip());
918 if(!group.isNull())
919 {
920 QVariantMap data;
921 data["group"] = group;
922 actionCreateInstance->setData(data);
923 }
924
925 connect(actionCreateInstance, SIGNAL(triggered(bool)), SLOT(on_actionAddInstance_triggered()));
926
927 actions.prepend(actionSep);
928 actions.prepend(actionVoid);
929 actions.append(actionCreateInstance);
930 if(!group.isNull())
931 {
932 QAction *actionDeleteGroup = new QAction(tr("Delete group '%1'").arg(group), this);
933 QVariantMap data;
934 data["group"] = group;
935 actionDeleteGroup->setData(data);
936 connect(actionDeleteGroup, SIGNAL(triggered(bool)), SLOT(deleteGroup()));
937 actions.append(actionDeleteGroup);
938 }
939 }
940 QMenu myMenu;
941 myMenu.addActions(actions);
942 /*

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected