MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / showInstanceContextMenu

Method showInstanceContextMenu

launcher/ui/MainWindow.cpp:1148–1215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1146}
1147
1148void MainWindow::showInstanceContextMenu(const QPoint &pos)
1149{
1150 QList<QAction *> actions;
1151
1152 QAction *actionSep = new QAction("", this);
1153 actionSep->setSeparator(true);
1154
1155 bool onInstance = view->indexAt(pos).isValid();
1156 if (onInstance)
1157 {
1158 actions = ui->instanceToolBar->actions();
1159
1160 // replace the change icon widget with an actual action
1161 actions.replace(0, ui->actionChangeInstIcon);
1162
1163 // replace the rename widget with an actual action
1164 actions.replace(1, ui->actionRenameInstance);
1165
1166 // add header
1167 actions.prepend(actionSep);
1168 QAction *actionVoid = new QAction(m_selectedInstance->name(), this);
1169 actionVoid->setEnabled(false);
1170 actions.prepend(actionVoid);
1171 }
1172 else
1173 {
1174 auto group = view->groupNameAt(pos);
1175
1176 QAction *actionVoid = new QAction(BuildConfig.LAUNCHER_NAME, this);
1177 actionVoid->setEnabled(false);
1178
1179 QAction *actionCreateInstance = new QAction(tr("Create instance"), this);
1180 actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip());
1181 if(!group.isNull())
1182 {
1183 QVariantMap data;
1184 data["group"] = group;
1185 actionCreateInstance->setData(data);
1186 }
1187
1188 connect(actionCreateInstance, SIGNAL(triggered(bool)), SLOT(on_actionAddInstance_triggered()));
1189
1190 actions.prepend(actionSep);
1191 actions.prepend(actionVoid);
1192 actions.append(actionCreateInstance);
1193 if(!group.isNull())
1194 {
1195 QAction *actionDeleteGroup = new QAction(tr("Delete group '%1'").arg(group), this);
1196 QVariantMap data;
1197 data["group"] = group;
1198 actionDeleteGroup->setData(data);
1199 connect(actionDeleteGroup, SIGNAL(triggered(bool)), SLOT(deleteGroup()));
1200 actions.append(actionDeleteGroup);
1201 }
1202
1203 QAction *actionUndoTrashInstance = new QAction("Undo last trash instance", this);
1204 connect(actionUndoTrashInstance, SIGNAL(triggered(bool)), SLOT(undoTrashInstance()));
1205 actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething());

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected