void TransfersContentsWidget::showContextMenu(const QPoint &point) { TransferInformation *transfer = getTransfer(m_ui->transfersView->indexAt(point)); QMenu menu(this); if (transfer) { menu.addAction(tr("Open"), this, SLOT(openTransfer())); menu.addAction(tr("Open Folder"), this, SLOT(openTransferFolder())); menu.addSeparator(); menu.addAction(((transfer->state == ErrorTransfer) ? tr("Resume") : tr("Stop")), this, SLOT(stopResumeTransfer()))->setEnabled(transfer->state == RunningTransfer || transfer->state == ErrorTransfer); menu.addAction("Redownload", this, SLOT(redownloadTransfer())); menu.addSeparator(); menu.addAction(tr("Copy Transfer Information"), this, SLOT(copyTransferInformation())); menu.addSeparator(); menu.addAction(tr("Remove"), this, SLOT(removeTransfer())); } const QList<TransferInformation*> transfers = TransfersManager::getTransfers(); int finishedTransfers = 0; for (int i = 0; i < transfers.count(); ++i) { if (transfers.at(i)->state == FinishedTransfer) { ++finishedTransfers; } } menu.addAction(tr("Clear Finished Transfers"), this, SLOT(clearFinishedTransfers()))->setEnabled(finishedTransfers > 0); menu.exec(m_ui->transfersView->mapToGlobal(point)); }
void TransfersContentsWidget::showContextMenu(const QPoint &point) { Transfer *transfer = getTransfer(m_ui->transfersViewWidget->indexAt(point)); QMenu menu(this); if (transfer) { menu.addAction(tr("Open"), this, SLOT(openTransfer())); const QList<ApplicationInformation> applications = Utils::getApplicationsForMimeType(transfer->getMimeType()); if (applications.count() > 1) { QMenu *applicationsMenu = menu.addMenu(tr("Open With")); for (int i = 0; i < applications.count(); ++i) { applicationsMenu->addAction(applications.at(i).icon, ((applications.at(i).name.isEmpty()) ? tr("Unknown") : applications.at(i).name))->setData(applications.at(i).command); if (i == 0) { applicationsMenu->addSeparator(); } } connect(applicationsMenu, SIGNAL(triggered(QAction*)), this, SLOT(openTransfer(QAction*))); } menu.addAction(tr("Open Folder"), this, SLOT(openTransferFolder())); menu.addSeparator(); menu.addAction(((transfer->getState() == Transfer::ErrorState) ? tr("Resume") : tr("Stop")), this, SLOT(stopResumeTransfer()))->setEnabled(transfer->getState() == Transfer::RunningState || transfer->getState() == Transfer::ErrorState); menu.addAction(tr("Redownload"), this, SLOT(redownloadTransfer())); menu.addSeparator(); menu.addAction(tr("Copy Transfer Information"), this, SLOT(copyTransferInformation())); menu.addSeparator(); menu.addAction(tr("Remove"), this, SLOT(removeTransfer())); }