void RadioWidget::on_StationsView__customContextMenuRequested (const QPoint& point) { const auto& idx = Ui_.StationsView_->indexAt (point); if (!idx.isValid ()) return; const auto type = idx.data (Media::RadioItemRole::ItemType).toInt (); const auto parentType = idx.parent ().data (Media::RadioItemRole::ItemType).toInt (); QMenu menu; menu.addAction (tr ("Refresh"), this, SLOT (handleRefresh ())); if (type == Media::RadioType::CustomAddableStreams) { menu.addAction (tr ("Add an URL..."), this, SLOT (handleAddUrl ())); const auto& url = Player_->GetSourceObject ()->GetCurrentSource ().ToUrl (); if (url.isValid () && !url.isLocalFile ()) menu.addAction (tr ("Add current stream..."), this, SLOT (handleAddCurrentUrl ())); } else if (parentType == Media::RadioType::CustomAddableStreams) { menu.addAction (tr ("Remove this URL"), this, SLOT (handleRemoveUrl ())); } menu.exec (Ui_.StationsView_->viewport ()->mapToGlobal (point)); }
void RadioWidget::on_StationsView__customContextMenuRequested (const QPoint& point) { const auto& idx = Ui_.StationsView_->indexAt (point); if (!idx.isValid ()) return; const auto type = idx.data (Media::RadioItemRole::ItemType).toInt (); const auto parentType = idx.parent ().data (Media::RadioItemRole::ItemType).toInt (); const auto iconsMgr = Core::Instance ().GetProxy ()->GetIconThemeManager (); QMenu menu; menu.addAction (iconsMgr->GetIcon ("view-refresh"), tr ("Refresh"), this, SLOT (handleRefresh ())); switch (type) { case Media::RadioType::CustomAddableStreams: { menu.addAction (iconsMgr->GetIcon ("list-add"), tr ("Add an URL..."), this, SLOT (handleAddUrl ())); const auto& url = Player_->GetSourceObject ()->GetCurrentSource ().ToUrl (); if (url.isValid () && !url.isLocalFile ()) menu.addAction (tr ("Add current stream..."), this, SLOT (handleAddCurrentUrl ())); break; } case Media::RadioType::TracksList: case Media::RadioType::TracksRoot: case Media::RadioType::SingleTrack: { menu.addAction (iconsMgr->GetIcon ("download"), tr ("Download tracks..."), this, SLOT (handleDownloadTracks ())); break; } default: break; } if (parentType == Media::RadioType::CustomAddableStreams) { menu.addAction (iconsMgr->GetIcon ("list-remove"), tr ("Remove this URL"), this, SLOT (handleRemoveUrl ())); } menu.exec (Ui_.StationsView_->viewport ()->mapToGlobal (point)); }