MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / PluginListContextMenu

Method PluginListContextMenu

src/pluginlistcontextmenu.cpp:11–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9using namespace MOBase;
10
11PluginListContextMenu::PluginListContextMenu(const QModelIndex& index,
12 OrganizerCore& core, PluginListView* view)
13 : QMenu(view), m_core(core),
14 m_index(index.model() == view->model() ? view->indexViewToModel(index) : index),
15 m_view(view)
16{
17 if (view->selectionModel()->hasSelection()) {
18 m_selected = view->indexViewToModel(view->selectionModel()->selectedRows());
19 } else if (index.isValid()) {
20 m_selected = {index};
21 }
22
23 if (!m_selected.isEmpty()) {
24 addAction(tr("Enable selected"), [=]() {
25 m_core.pluginList()->setEnabled(m_selected, true);
26 });
27 addAction(tr("Disable selected"), [=]() {
28 m_core.pluginList()->setEnabled(m_selected, false);
29 });
30
31 addSeparator();
32 }
33
34 addAction(tr("Enable all"), [=]() {
35 if (QMessageBox::question(m_view->topLevelWidget(), tr("Confirm"),
36 tr("Really enable all plugins?"),
37 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
38 m_core.pluginList()->setEnabledAll(true);
39 }
40 });
41 addAction(tr("Disable all"), [=]() {
42 if (QMessageBox::question(m_view->topLevelWidget(), tr("Confirm"),
43 tr("Really disable all plugins?"),
44 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
45 m_core.pluginList()->setEnabledAll(false);
46 }
47 });
48
49 if (!m_selected.isEmpty()) {
50 addSeparator();
51 addMenu(createSendToContextMenu());
52
53 addSeparator();
54
55 bool hasLocked = false;
56 bool hasUnlocked = false;
57 for (auto& idx : m_selected) {
58 if (m_core.pluginList()->isEnabled(idx.row())) {
59 if (m_core.pluginList()->isESPLocked(idx.row())) {
60 hasLocked = true;
61 } else {
62 hasUnlocked = true;
63 }
64 }
65 }
66
67 if (hasLocked) {
68 addAction(tr("Unlock load order"), [=]() {

Callers

nothing calls this directly

Calls 15

modelMethod · 0.80
setEnabledAllMethod · 0.80
isESPLockedMethod · 0.80
indexViewToModelMethod · 0.45
isValidMethod · 0.45
isEmptyMethod · 0.45
setEnabledMethod · 0.45
pluginListMethod · 0.45
isEnabledMethod · 0.45
originMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected