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

Method showInstanceContextMenu

launcher/ui/MainWindow.cpp:903–965  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

901}
902
903void MainWindow::showInstanceContextMenu(const QPoint &pos)
904{
905 QList<QAction *> actions;
906
907 QAction *actionSep = new QAction("", this);
908 actionSep->setSeparator(true);
909
910 bool onInstance = view->indexAt(pos).isValid();
911 if (onInstance)
912 {
913 actions = ui->instanceToolBar->actions();
914
915 // replace the change icon widget with an actual action
916 actions.replace(0, ui->actionChangeInstIcon);
917
918 // replace the rename widget with an actual action
919 actions.replace(1, ui->actionRenameInstance);
920
921 // add header
922 actions.prepend(actionSep);
923 QAction *actionVoid = new QAction(m_selectedInstance->name(), this);
924 actionVoid->setEnabled(false);
925 actions.prepend(actionVoid);
926 }
927 else
928 {
929 auto group = view->groupNameAt(pos);
930
931 QAction *actionVoid = new QAction(BuildConfig.LAUNCHER_NAME, this);
932 actionVoid->setEnabled(false);
933
934 QAction *actionCreateInstance = new QAction(tr("Create instance"), this);
935 actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip());
936 if(!group.isNull())
937 {
938 QVariantMap data;
939 data["group"] = group;
940 actionCreateInstance->setData(data);
941 }
942
943 connect(actionCreateInstance, SIGNAL(triggered(bool)), SLOT(on_actionAddInstance_triggered()));
944
945 actions.prepend(actionSep);
946 actions.prepend(actionVoid);
947 actions.append(actionCreateInstance);
948 if(!group.isNull())
949 {
950 QAction *actionDeleteGroup = new QAction(tr("Delete group '%1'").arg(group), this);
951 QVariantMap data;
952 data["group"] = group;
953 actionDeleteGroup->setData(data);
954 connect(actionDeleteGroup, SIGNAL(triggered(bool)), SLOT(deleteGroup()));
955 actions.append(actionDeleteGroup);
956 }
957 }
958 QMenu myMenu;
959 myMenu.addActions(actions);
960 /*

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