Some checks failed
Build / Build openSUSE (leap:15.6) (push) Has been cancelled
Build / Build openSUSE (leap:16.0) (push) Has been cancelled
Build / Build openSUSE (tumbleweed) (push) Has been cancelled
Build / Build Fedora (42) (push) Has been cancelled
Build / Build Fedora (43) (push) Has been cancelled
Build / Build Fedora (44) (push) Has been cancelled
Build / Build OpenMandriva (cooker) (push) Has been cancelled
Build / Build Mageia (9) (push) Has been cancelled
Build / Build Debian (bookworm) (push) Has been cancelled
Build / Build Debian (forky) (push) Has been cancelled
Build / Build Debian (trixie) (push) Has been cancelled
Build / Build Ubuntu (noble) (push) Has been cancelled
Build / Build Ubuntu (questing) (push) Has been cancelled
Build / Build Ubuntu (resolute) (push) Has been cancelled
Build / Upload Ubuntu PPA (noble) (push) Has been cancelled
Build / Upload Ubuntu PPA (questing) (push) Has been cancelled
Build / Upload Ubuntu PPA (resolute) (push) Has been cancelled
Build / Build FreeBSD (push) Has been cancelled
Build / Build OpenBSD (push) Has been cancelled
Build / Build macOS Public (release, macos-15) (push) Has been cancelled
Build / Build macOS Public (release, macos-15-intel) (push) Has been cancelled
Build / Build macOS Private (release, macos-arm64) (push) Has been cancelled
Build / Build Windows MinGW (i686, debug) (push) Has been cancelled
Build / Build Windows MinGW (i686, release) (push) Has been cancelled
Build / Build Windows MinGW (x86_64, debug) (push) Has been cancelled
Build / Build Windows MinGW (x86_64, release) (push) Has been cancelled
Build / Build Windows MSVC (arm64, debug, arm64 debug, windows-11-arm) (push) Has been cancelled
Build / Build Windows MSVC (arm64, release, arm64 release, windows-11-arm) (push) Has been cancelled
Build / Build Windows MSVC (x86, debug, x86 debug, windows-2022) (push) Has been cancelled
Build / Build Windows MSVC (x86, release, x86 release, windows-2022) (push) Has been cancelled
Build / Build Windows MSVC (x86_64, debug, x86_64 debug, windows-2022) (push) Has been cancelled
Build / Build Windows MSVC (x86_64, release, x86_64 release, windows-2022) (push) Has been cancelled
Build / Upload (push) Has been cancelled
Build / Attach to release (push) Has been cancelled
This commit removes sponsorship-related UI elements and functionality from the application, including the donation links and associated logic in the main window and radio services. Additionally, the .gitignore file is updated to exclude various macOS-specific files and directories, ensuring a cleaner build environment while retaining necessary build tooling scripts.
162 lines
4.8 KiB
C++
162 lines
4.8 KiB
C++
/*
|
|
* Strawberry Music Player
|
|
* Copyright 2021, Jonas Kvinge <jonas@jkvinge.net>
|
|
*
|
|
* Strawberry is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Strawberry is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
#include <utility>
|
|
|
|
#include <QWidget>
|
|
#include <QMimeData>
|
|
#include <QDesktopServices>
|
|
#include <QMenu>
|
|
#include <QAction>
|
|
#include <QShowEvent>
|
|
#include <QContextMenuEvent>
|
|
|
|
#include "core/mimedata.h"
|
|
#include "core/iconloader.h"
|
|
#include "radiomodel.h"
|
|
#include "radioview.h"
|
|
#include "radioservice.h"
|
|
#include "radiomimedata.h"
|
|
#include "collection/collectionitemdelegate.h"
|
|
|
|
using namespace Qt::Literals::StringLiterals;
|
|
|
|
RadioView::RadioView(QWidget *parent)
|
|
: AutoExpandingTreeView(parent),
|
|
menu_(nullptr),
|
|
action_playlist_append_(nullptr),
|
|
action_playlist_replace_(nullptr),
|
|
action_playlist_new_(nullptr),
|
|
action_homepage_(nullptr),
|
|
initialized_(false) {
|
|
|
|
setItemDelegate(new CollectionItemDelegate(this));
|
|
SetExpandOnReset(false);
|
|
setAttribute(Qt::WA_MacShowFocusRect, false);
|
|
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
}
|
|
|
|
RadioView::~RadioView() { delete menu_; }
|
|
|
|
void RadioView::showEvent(QShowEvent *e) {
|
|
|
|
Q_UNUSED(e)
|
|
|
|
if (!initialized_) {
|
|
Q_EMIT GetChannels();
|
|
initialized_ = true;
|
|
}
|
|
|
|
}
|
|
|
|
void RadioView::contextMenuEvent(QContextMenuEvent *e) {
|
|
|
|
if (!menu_) {
|
|
menu_ = new QMenu;
|
|
|
|
action_playlist_append_ = new QAction(IconLoader::Load(u"media-playback-start"_s), tr("Append to current playlist"), this);
|
|
QObject::connect(action_playlist_append_, &QAction::triggered, this, &RadioView::AddToPlaylist);
|
|
menu_->addAction(action_playlist_append_);
|
|
|
|
action_playlist_replace_ = new QAction(IconLoader::Load(u"media-playback-start"_s), tr("Replace current playlist"), this);
|
|
QObject::connect(action_playlist_replace_, &QAction::triggered, this, &RadioView::ReplacePlaylist);
|
|
menu_->addAction(action_playlist_replace_);
|
|
|
|
action_playlist_new_ = new QAction(IconLoader::Load(u"document-new"_s), tr("Open in new playlist"), this);
|
|
QObject::connect(action_playlist_new_, &QAction::triggered, this, &RadioView::OpenInNewPlaylist);
|
|
menu_->addAction(action_playlist_new_);
|
|
|
|
action_homepage_ = new QAction(IconLoader::Load(u"download"_s), tr("Open homepage"), this);
|
|
QObject::connect(action_homepage_, &QAction::triggered, this, &RadioView::Homepage);
|
|
menu_->addAction(action_homepage_);
|
|
|
|
menu_->addAction(IconLoader::Load(u"view-refresh"_s), tr("Refresh channels"), this, &RadioView::GetChannels);
|
|
}
|
|
|
|
const bool channels_selected = !selectedIndexes().isEmpty();
|
|
|
|
action_playlist_append_->setVisible(channels_selected);
|
|
action_playlist_replace_->setVisible(channels_selected);
|
|
action_playlist_new_->setVisible(channels_selected);
|
|
action_homepage_->setVisible(channels_selected);
|
|
|
|
menu_->popup(e->globalPos());
|
|
|
|
}
|
|
|
|
void RadioView::AddToPlaylist() {
|
|
|
|
const QModelIndexList selected_indexes = selectedIndexes();
|
|
if (selected_indexes.isEmpty()) return;
|
|
|
|
Q_EMIT AddToPlaylistSignal(model()->mimeData(selected_indexes));
|
|
|
|
}
|
|
|
|
void RadioView::ReplacePlaylist() {
|
|
|
|
const QModelIndexList selected_indexes = selectedIndexes();
|
|
if (selected_indexes.isEmpty()) return;
|
|
|
|
QMimeData *qmimedata = model()->mimeData(selected_indexes);
|
|
if (MimeData *mimedata = qobject_cast<MimeData*>(qmimedata)) {
|
|
mimedata->clear_first_ = true;
|
|
}
|
|
|
|
Q_EMIT AddToPlaylistSignal(qmimedata);
|
|
|
|
}
|
|
|
|
void RadioView::OpenInNewPlaylist() {
|
|
|
|
const QModelIndexList selected_indexes = selectedIndexes();
|
|
if (selected_indexes.isEmpty()) return;
|
|
|
|
QMimeData *qmimedata = model()->mimeData(selected_indexes);
|
|
if (RadioMimeData *mimedata = qobject_cast<RadioMimeData*>(qmimedata)) {
|
|
mimedata->open_in_new_playlist_ = true;
|
|
if (!mimedata->songs.isEmpty()) {
|
|
mimedata->name_for_new_playlist_ = mimedata->songs.first().title();
|
|
}
|
|
}
|
|
|
|
Q_EMIT AddToPlaylistSignal(qmimedata);
|
|
|
|
}
|
|
|
|
void RadioView::Homepage() {
|
|
|
|
const QModelIndexList selected_indexes = selectedIndexes();
|
|
if (selected_indexes.isEmpty()) return;
|
|
|
|
QList<QUrl> urls;
|
|
for (const QModelIndex &idx : selected_indexes) {
|
|
QUrl url = idx.data(RadioModel::Role_Homepage).toUrl();
|
|
if (!urls.contains(url)) {
|
|
urls << url; // clazy:exclude=reserve-candidates
|
|
}
|
|
}
|
|
|
|
for (const QUrl &url : std::as_const(urls)) {
|
|
QDesktopServices::openUrl(url);
|
|
}
|
|
|
|
}
|