void ProcessMonitor::contextMenu(QPoint const& pos) { QTableWidget* table(m_ui.processTable); QTableWidgetItem* item(table->itemAt(pos)); if (!item) return; Process* process(getSelectedProcess(item)); if (!process) return; if (process->status() == Process::Copying) return; QMenu *menu = new QMenu(this); QAction* kill = menu->addAction(tr("Kill Job"), this, SLOT(killProcess())); QAction* remove = menu->addAction(tr("Remove Process"), this, SLOT(removeProcess())); QAction* query = menu->addAction(tr("Query Process"), this, SLOT(queryProcess())); QAction* view = menu->addAction(tr("View Output File"), process, SLOT(viewOutput())); QAction* open = menu->addAction(tr("Visualize Results"), this, SLOT(openOutput())); QAction* copy = menu->addAction(tr("Copy Results From Server"), this, SLOT(copyResults())); kill->setEnabled(false); query->setEnabled(true); remove->setEnabled(false); view->setEnabled(false); open->setEnabled(false); copy->setEnabled(false); Process::Status status(process->status()); if (status == Process::Running || status == Process::Queued || status == Process::Suspended) { kill->setEnabled(true); } if (status != Process::NotRunning && status != Process::Killed && status != Process::Queued) { view->setEnabled(true); } if (status == Process::Killed || status == Process::Error || status == Process::Finished) { remove->setEnabled(true); copy->setEnabled(true); } if (status == Process::Unknown || status == Process::NotRunning) { remove->setEnabled(true); } if (status == Process::Finished && process->jobInfo()->localFilesExist()) { open->setEnabled(true); } menu->exec(table->mapToGlobal(pos)); delete menu; }
void Tool::onViewOutput() { auto tool = mtx::gui::MainWindow::watchJobTool(); m_model->withSelectedJobs(ui->jobs, [tool](Job &job) { tool->viewOutput(job); }); mtx::gui::MainWindow::get()->changeToTool(tool); }