| 129 | } |
| 130 | |
| 131 | void KDevelop::RuntimeController::addRuntimes(KDevelop::IRuntime * runtime) |
| 132 | { |
| 133 | if (!runtime->parent()) |
| 134 | runtime->setParent(this); |
| 135 | |
| 136 | if (m_core->setupFlags() != Core::NoUi) { |
| 137 | auto* runtimeAction = new QAction(runtime->name(), m_runtimesMenu.data()); |
| 138 | m_group->addAction(runtimeAction); |
| 139 | runtimeAction->setCheckable(true); |
| 140 | connect(runtimeAction, &QAction::triggered, runtime, [this, runtime]() { |
| 141 | setCurrentRuntime(runtime); |
| 142 | }); |
| 143 | connect(this, &RuntimeController::currentRuntimeChanged, runtimeAction, [runtimeAction, runtime](IRuntime* currentRuntime) { |
| 144 | runtimeAction->setChecked(runtime == currentRuntime); |
| 145 | }); |
| 146 | |
| 147 | connect(runtime, &QObject::destroyed, this, [this, runtimeAction](QObject* obj) { |
| 148 | Q_ASSERT(m_currentRuntime != obj); |
| 149 | m_runtimes.removeAll(qobject_cast<KDevelop::IRuntime *>(obj)); |
| 150 | delete runtimeAction; |
| 151 | }); |
| 152 | m_runtimesMenu->addAction(runtimeAction); |
| 153 | } else { |
| 154 | connect(runtime, &QObject::destroyed, this, [this](QObject* obj) { |
| 155 | Q_ASSERT(m_currentRuntime != obj); |
| 156 | m_runtimes.removeAll(qobject_cast<KDevelop::IRuntime *>(obj)); |
| 157 | }); |
| 158 | } |
| 159 | |
| 160 | m_runtimes << runtime; |
| 161 | } |
| 162 | |
| 163 | #include "runtimecontroller.moc" |
| 164 | #include "moc_runtimecontroller.cpp" |
no test coverage detected