| 131 | } |
| 132 | |
| 133 | void NativeAppJob::start() |
| 134 | { |
| 135 | if (error() != NoError) { |
| 136 | emitResult(); |
| 137 | return; |
| 138 | } |
| 139 | |
| 140 | QVector<QPointer<NativeAppJob> > currentJobs; |
| 141 | // collect running instances of the same type |
| 142 | const auto& allCurrentJobs = ICore::self()->runController()->currentJobs(); |
| 143 | for (auto j : allCurrentJobs) { |
| 144 | NativeAppJob* njob = findNativeJob(j); |
| 145 | if (njob && njob != this && njob->m_name == m_name) |
| 146 | currentJobs << njob; |
| 147 | } |
| 148 | |
| 149 | if (!currentJobs.isEmpty()) { |
| 150 | int oldJobAction = m_killBeforeExecutingAgain; |
| 151 | if (oldJobAction == askIfRunning) { |
| 152 | QMessageBox msgBox(QMessageBox::Question, |
| 153 | i18nc("@title:window", "Job Already Running"), |
| 154 | i18n("'%1' is already being executed.", m_name), |
| 155 | startAnother | killAllInstances | QMessageBox::Cancel /* aka askIfRunning */); |
| 156 | msgBox.button(killAllInstances)->setText(i18nc("@action:button", "Kill All Instances")); |
| 157 | msgBox.button(startAnother)->setText(i18nc("@action:button", "Start Another")); |
| 158 | msgBox.setDefaultButton(QMessageBox::Cancel); |
| 159 | |
| 160 | QCheckBox* remember = new QCheckBox(i18nc("@option:check", "Remember choice")); |
| 161 | msgBox.setCheckBox(remember); |
| 162 | |
| 163 | oldJobAction = msgBox.exec(); |
| 164 | if (remember->isChecked() && oldJobAction != QMessageBox::Cancel) { |
| 165 | Q_EMIT killBeforeExecutingAgainChanged(oldJobAction); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | switch (oldJobAction) { |
| 170 | case startAnother: |
| 171 | break; |
| 172 | case killAllInstances: |
| 173 | for (auto & job : currentJobs) { |
| 174 | if (job) |
| 175 | job->kill(); |
| 176 | } |
| 177 | break; |
| 178 | default: // cancel starting a new job |
| 179 | kill(); |
| 180 | return; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | OutputExecuteJob::start(); |
| 185 | } |
| 186 | |
| 187 | #include "moc_nativeappjob.cpp" |
nothing calls this directly
no test coverage detected