Compare commits
14 Commits
copilot/fi
...
moodbar
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29b5b889ab | ||
|
|
da2f28811a | ||
|
|
0bfa736081 | ||
|
|
1392bcbbe1 | ||
|
|
11705889f1 | ||
|
|
604dd2dbde | ||
|
|
25065ba98f | ||
|
|
7b16ec62bb | ||
|
|
d8f31592b9 | ||
|
|
80bb0f476d | ||
|
|
b7222ac85c | ||
|
|
241bca0828 | ||
|
|
90d86b10a3 | ||
|
|
4130c6670f |
12
.github/workflows/build.yml
vendored
12
.github/workflows/build.yml
vendored
@@ -739,12 +739,18 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
- name: Free disk space
|
||||
run: |
|
||||
df -h
|
||||
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
|
||||
sudo apt-get clean
|
||||
df -h
|
||||
- name: Build FreeBSD
|
||||
id: build-freebsd
|
||||
uses: vmactions/freebsd-vm@v1.3.0
|
||||
uses: vmactions/freebsd-vm@v1.3.2
|
||||
with:
|
||||
usesh: true
|
||||
mem: 4096
|
||||
mem: 8192
|
||||
prepare: pkg install -y git cmake pkgconf boost-libs alsa-lib glib qt6-base qt6-tools sqlite gstreamer1 gstreamer1-plugins chromaprint libebur128 taglib libcdio libmtp gdk-pixbuf2 libgpod fftw3 icu kdsingleapplication googletest pulseaudio sparsehash rapidjson
|
||||
run: |
|
||||
set -e
|
||||
@@ -766,7 +772,7 @@ jobs:
|
||||
submodules: recursive
|
||||
- name: Build OpenBSD
|
||||
id: build-openbsd
|
||||
uses: vmactions/openbsd-vm@v1.2.5
|
||||
uses: vmactions/openbsd-vm@v1.2.9
|
||||
with:
|
||||
usesh: true
|
||||
mem: 4096
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2018-2025, 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
|
||||
@@ -189,6 +189,26 @@ void CollectionLibrary::ReloadSettings() {
|
||||
|
||||
}
|
||||
|
||||
void CollectionLibrary::CurrentSongChanged(const Song &song) {
|
||||
|
||||
current_song_url_ = song.url();
|
||||
|
||||
if (!pending_song_saves_.isEmpty()) {
|
||||
SavePendingPlaycountsAndRatings();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CollectionLibrary::Stopped() {
|
||||
|
||||
current_song_url_ = QUrl();
|
||||
|
||||
if (!pending_song_saves_.isEmpty()) {
|
||||
SavePendingPlaycountsAndRatings();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CollectionLibrary::SyncPlaycountAndRatingToFilesAsync() {
|
||||
|
||||
(void)QtConcurrent::run(&CollectionLibrary::SyncPlaycountAndRatingToFiles, this);
|
||||
@@ -212,18 +232,85 @@ void CollectionLibrary::SyncPlaycountAndRatingToFiles() {
|
||||
|
||||
}
|
||||
|
||||
void CollectionLibrary::SongsPlaycountChanged(const SongList &songs, const bool save_tags) const {
|
||||
void CollectionLibrary::SongsPlaycountChanged(const SongList &songs, const bool save_tags) {
|
||||
|
||||
if (save_tags || save_playcounts_to_files_) {
|
||||
tagreader_client_->SaveSongsPlaycountAsync(songs);
|
||||
SongList songs_to_save_now;
|
||||
for (const Song &song : songs) {
|
||||
if (song.url().isLocalFile() && song.url() == current_song_url_ &&
|
||||
(song.filetype() == Song::FileType::OggFlac || song.filetype() == Song::FileType::OggVorbis || song.filetype() == Song::FileType::OggOpus)) {
|
||||
qLog(Debug) << "Deferring playcount save for currently playing file" << song.url().toLocalFile();
|
||||
if (pending_song_saves_.contains(song.url())) {
|
||||
SharedPtr<PendingSongSave> pending_song_save = pending_song_saves_[song.url()];
|
||||
pending_song_save->save_playcount = true;
|
||||
pending_song_save->song.set_playcount(song.playcount());
|
||||
}
|
||||
else {
|
||||
SharedPtr<PendingSongSave> pending_song_save = make_shared<PendingSongSave>();
|
||||
pending_song_save->save_playcount = true;
|
||||
pending_song_save->song = song;
|
||||
pending_song_saves_.insert(song.url(), pending_song_save);
|
||||
}
|
||||
}
|
||||
else {
|
||||
songs_to_save_now << song;
|
||||
}
|
||||
}
|
||||
if (!songs_to_save_now.isEmpty()) {
|
||||
tagreader_client_->SaveSongsPlaycountAsync(songs_to_save_now);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CollectionLibrary::SongsRatingChanged(const SongList &songs, const bool save_tags) const {
|
||||
void CollectionLibrary::SongsRatingChanged(const SongList &songs, const bool save_tags) {
|
||||
|
||||
if (save_tags || save_ratings_to_files_) {
|
||||
tagreader_client_->SaveSongsRatingAsync(songs);
|
||||
SongList songs_to_save_now;
|
||||
for (const Song &song : songs) {
|
||||
if (song.url().isLocalFile() && song.url() == current_song_url_ &&
|
||||
(song.filetype() == Song::FileType::OggFlac || song.filetype() == Song::FileType::OggVorbis || song.filetype() == Song::FileType::OggOpus)) {
|
||||
qLog(Debug) << "Deferring rating save for currently playing file" << song.url().toLocalFile();
|
||||
if (pending_song_saves_.contains(song.url())) {
|
||||
SharedPtr<PendingSongSave> pending_song_save = pending_song_saves_[song.url()];
|
||||
pending_song_save->save_rating = true;
|
||||
pending_song_save->song.set_rating(song.rating());
|
||||
}
|
||||
else {
|
||||
SharedPtr<PendingSongSave> pending_song_save = make_shared<PendingSongSave>();
|
||||
pending_song_save->save_rating = true;
|
||||
pending_song_save->song = song;
|
||||
pending_song_saves_.insert(song.url(), pending_song_save);
|
||||
}
|
||||
}
|
||||
else {
|
||||
songs_to_save_now << song;
|
||||
}
|
||||
}
|
||||
if (!songs_to_save_now.isEmpty()) {
|
||||
tagreader_client_->SaveSongsRatingAsync(songs_to_save_now);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CollectionLibrary::SavePendingPlaycountsAndRatings() {
|
||||
|
||||
for (auto it = pending_song_saves_.constBegin(); it != pending_song_saves_.constEnd();) {
|
||||
const QUrl url = it.key();
|
||||
SharedPtr<PendingSongSave> pending_song_save = it.value();
|
||||
if (url == current_song_url_) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
qLog(Debug) << "Saving deferred playcount/rating for" << url.toLocalFile();
|
||||
if (pending_song_save->save_playcount) {
|
||||
tagreader_client_->SaveSongsPlaycountAsync(SongList() << pending_song_save->song);
|
||||
}
|
||||
if (pending_song_save->save_rating) {
|
||||
tagreader_client_->SaveSongsRatingAsync(SongList() << pending_song_save->song);
|
||||
}
|
||||
it = pending_song_saves_.erase(it);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2018-2025, 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
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
@@ -71,6 +72,7 @@ class CollectionLibrary : public QObject {
|
||||
|
||||
private:
|
||||
void SyncPlaycountAndRatingToFiles();
|
||||
void SavePendingPlaycountsAndRatings();
|
||||
|
||||
public Q_SLOTS:
|
||||
void ReloadSettings();
|
||||
@@ -84,16 +86,26 @@ class CollectionLibrary : public QObject {
|
||||
|
||||
void IncrementalScan();
|
||||
|
||||
void CurrentSongChanged(const Song &song);
|
||||
void Stopped();
|
||||
|
||||
private Q_SLOTS:
|
||||
void ExitReceived();
|
||||
void SongsPlaycountChanged(const SongList &songs, const bool save_tags = false) const;
|
||||
void SongsRatingChanged(const SongList &songs, const bool save_tags = false) const;
|
||||
void SongsPlaycountChanged(const SongList &songs, const bool save_tags = false);
|
||||
void SongsRatingChanged(const SongList &songs, const bool save_tags = false);
|
||||
|
||||
Q_SIGNALS:
|
||||
void Error(const QString &error);
|
||||
void ExitFinished();
|
||||
|
||||
private:
|
||||
class PendingSongSave {
|
||||
public:
|
||||
Song song;
|
||||
bool save_playcount = false;
|
||||
bool save_rating = false;
|
||||
};
|
||||
|
||||
const SharedPtr<TaskManager> task_manager_;
|
||||
const SharedPtr<TagReaderClient> tagreader_client_;
|
||||
|
||||
@@ -111,6 +123,10 @@ class CollectionLibrary : public QObject {
|
||||
|
||||
bool save_playcounts_to_files_;
|
||||
bool save_ratings_to_files_;
|
||||
|
||||
QUrl current_song_url_;
|
||||
|
||||
QMap<QUrl, SharedPtr<PendingSongSave>> pending_song_saves_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1209,49 +1209,41 @@ QString CollectionModel::ContainerKey(const GroupBy group_by, const Song &song,
|
||||
switch (group_by) {
|
||||
case GroupBy::AlbumArtist:
|
||||
key = TextOrUnknown(song.effective_albumartist());
|
||||
if (!song.effective_albumartistsort().isEmpty() && song.effective_albumartistsort() != song.effective_albumartist()) key.append(QLatin1Char('-') + TextOrUnknown(song.effective_albumartistsort()));
|
||||
has_unique_album_identifier = true;
|
||||
break;
|
||||
case GroupBy::Artist:
|
||||
key = TextOrUnknown(song.artist());
|
||||
if (!song.artistsort().isEmpty() && song.artistsort() != song.artist()) key.append(QLatin1Char('-') + TextOrUnknown(song.artistsort()));
|
||||
has_unique_album_identifier = true;
|
||||
break;
|
||||
case GroupBy::Album:
|
||||
key = TextOrUnknown(song.album());
|
||||
if (!song.albumsort().isEmpty() && song.albumsort() != song.album()) key.append(QLatin1Char('-') + TextOrUnknown(song.albumsort()));
|
||||
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
||||
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
||||
break;
|
||||
case GroupBy::AlbumDisc:
|
||||
key = TextOrUnknown(song.album());
|
||||
if (!song.albumsort().isEmpty() && song.albumsort() != song.album()) key.append(QLatin1Char('-') + TextOrUnknown(song.albumsort()));
|
||||
key.append(QLatin1Char('-') + SortTextForNumber(song.disc()));
|
||||
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
||||
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
||||
break;
|
||||
case GroupBy::YearAlbum:
|
||||
key = SortTextForYear(song.year()) + QLatin1Char('-') + TextOrUnknown(song.album());
|
||||
if (!song.albumsort().isEmpty() && song.albumsort() != song.album()) key.append(QLatin1Char('-') + TextOrUnknown(song.albumsort()));
|
||||
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
||||
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
||||
break;
|
||||
case GroupBy::YearAlbumDisc:
|
||||
key = SortTextForYear(song.year()) + QLatin1Char('-') + TextOrUnknown(song.album());
|
||||
if (!song.albumsort().isEmpty() && song.albumsort() != song.album()) key.append(QLatin1Char('-') + TextOrUnknown(song.albumsort()));
|
||||
key.append(QLatin1Char('-') + SortTextForNumber(song.disc()));
|
||||
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
||||
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
||||
break;
|
||||
case GroupBy::OriginalYearAlbum:
|
||||
key = SortTextForYear(song.effective_originalyear()) + QLatin1Char('-') + TextOrUnknown(song.album());
|
||||
if (!song.albumsort().isEmpty() && song.albumsort() != song.album()) key.append(QLatin1Char('-') + TextOrUnknown(song.albumsort()));
|
||||
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
||||
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
||||
break;
|
||||
case GroupBy::OriginalYearAlbumDisc:
|
||||
key = SortTextForYear(song.effective_originalyear()) + QLatin1Char('-') + TextOrUnknown(song.album());
|
||||
if (!song.albumsort().isEmpty() && song.albumsort() != song.album()) key.append(QLatin1Char('-') + TextOrUnknown(song.albumsort()));
|
||||
key.append(QLatin1Char('-') + SortTextForNumber(song.disc()));
|
||||
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
||||
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
||||
@@ -1270,12 +1262,10 @@ QString CollectionModel::ContainerKey(const GroupBy group_by, const Song &song,
|
||||
break;
|
||||
case GroupBy::Composer:
|
||||
key = TextOrUnknown(song.composer());
|
||||
if (!song.composersort().isEmpty() && song.composersort() != song.composer()) key.append(QLatin1Char('-') + song.composersort());
|
||||
has_unique_album_identifier = true;
|
||||
break;
|
||||
case GroupBy::Performer:
|
||||
key = TextOrUnknown(song.performer());
|
||||
if (!song.performersort().isEmpty() && song.performersort() != song.performer()) key.append(QLatin1Char('-') + song.performersort());
|
||||
has_unique_album_identifier = true;
|
||||
break;
|
||||
case GroupBy::Grouping:
|
||||
|
||||
@@ -110,21 +110,32 @@ bool FilesystemMusicStorage::CopyToStorage(const CopyJob &job, QString &error_te
|
||||
|
||||
bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob &job) {
|
||||
|
||||
QString path = job.metadata_.url().toLocalFile();
|
||||
QFileInfo fileInfo(path);
|
||||
const QString path = job.metadata_.url().toLocalFile();
|
||||
const QFileInfo fileInfo(path);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
|
||||
if (job.use_trash_ && QFile::supportsMoveToTrash()) {
|
||||
#else
|
||||
if (job.use_trash_) {
|
||||
#endif
|
||||
return QFile::moveToTrash(path);
|
||||
if (QFile::moveToTrash(path)) {
|
||||
return true;
|
||||
}
|
||||
qLog(Warning) << "Moving file to trash failed for" << path << ", falling back to direct deletion";
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
if (fileInfo.isDir()) {
|
||||
return Utilities::RemoveRecursive(path);
|
||||
success = Utilities::RemoveRecursive(path);
|
||||
}
|
||||
else {
|
||||
success = QFile::remove(path);
|
||||
}
|
||||
|
||||
return QFile::remove(path);
|
||||
if (!success) {
|
||||
qLog(Error) << "Failed to delete file" << path;
|
||||
}
|
||||
|
||||
return success;
|
||||
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
#include <QShortcut>
|
||||
#include <QMessageBox>
|
||||
#include <QErrorMessage>
|
||||
#include <QSettings>
|
||||
#include <QColor>
|
||||
#include <QFrame>
|
||||
#include <QItemSelectionModel>
|
||||
@@ -697,6 +696,9 @@ MainWindow::MainWindow(Application *app,
|
||||
QObject::connect(&*app_->task_manager(), &TaskManager::PauseCollectionWatchers, &*app_->collection(), &CollectionLibrary::PauseWatcher);
|
||||
QObject::connect(&*app_->task_manager(), &TaskManager::ResumeCollectionWatchers, &*app_->collection(), &CollectionLibrary::ResumeWatcher);
|
||||
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, &*app_->collection(), &CollectionLibrary::CurrentSongChanged);
|
||||
QObject::connect(&*app_->player(), &Player::Stopped, &*app_->collection(), &CollectionLibrary::Stopped);
|
||||
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, &*app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::LoadAlbumCover);
|
||||
QObject::connect(&*app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &MainWindow::AlbumCoverLoaded);
|
||||
QObject::connect(album_cover_choice_controller_, &AlbumCoverChoiceController::Error, this, &MainWindow::ShowErrorDialog);
|
||||
@@ -977,27 +979,28 @@ MainWindow::MainWindow(Application *app,
|
||||
|
||||
// Load settings
|
||||
qLog(Debug) << "Loading settings";
|
||||
settings_.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||
Settings settings;
|
||||
settings.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||
|
||||
// Set last used geometry to position window on the correct monitor
|
||||
// Set window state only if the window was last maximized
|
||||
if (settings_.contains("geometry")) {
|
||||
restoreGeometry(settings_.value("geometry").toByteArray());
|
||||
if (settings.contains("geometry")) {
|
||||
restoreGeometry(settings.value("geometry").toByteArray());
|
||||
}
|
||||
|
||||
if (!settings_.contains(MainWindowSettings::kSplitterState) || !ui_->splitter->restoreState(settings_.value(MainWindowSettings::kSplitterState).toByteArray())) {
|
||||
if (!settings.contains(MainWindowSettings::kSplitterState) || !ui_->splitter->restoreState(settings.value(MainWindowSettings::kSplitterState).toByteArray())) {
|
||||
ui_->splitter->setSizes(QList<int>() << 20 << (width() - 20));
|
||||
}
|
||||
|
||||
ui_->tabs->setCurrentIndex(settings_.value("current_tab", 1).toInt());
|
||||
ui_->tabs->setCurrentIndex(settings.value("current_tab", 1).toInt());
|
||||
FancyTabWidget::Mode default_mode = FancyTabWidget::Mode::LargeSidebar;
|
||||
FancyTabWidget::Mode tab_mode = static_cast<FancyTabWidget::Mode>(settings_.value("tab_mode", static_cast<int>(default_mode)).toInt());
|
||||
FancyTabWidget::Mode tab_mode = static_cast<FancyTabWidget::Mode>(settings.value("tab_mode", static_cast<int>(default_mode)).toInt());
|
||||
if (tab_mode == FancyTabWidget::Mode::None) tab_mode = default_mode;
|
||||
ui_->tabs->SetMode(tab_mode);
|
||||
|
||||
TabSwitched();
|
||||
|
||||
file_view_->SetPath(settings_.value("file_path", QDir::homePath()).toString());
|
||||
file_view_->SetPath(settings.value("file_path", QDir::homePath()).toString());
|
||||
|
||||
// Users often collapse one side of the splitter by mistake and don't know how to restore it. This must be set after the state is restored above.
|
||||
ui_->splitter->setChildrenCollapsible(false);
|
||||
@@ -1040,13 +1043,13 @@ MainWindow::MainWindow(Application *app,
|
||||
case BehaviourSettings::StartupBehaviour::Remember:
|
||||
default:{
|
||||
|
||||
was_maximized_ = settings_.value(MainWindowSettings::kMaximized, true).toBool();
|
||||
was_maximized_ = settings.value(MainWindowSettings::kMaximized, true).toBool();
|
||||
if (was_maximized_) setWindowState(windowState() | Qt::WindowMaximized);
|
||||
|
||||
was_minimized_ = settings_.value(MainWindowSettings::kMinimized, false).toBool();
|
||||
was_minimized_ = settings.value(MainWindowSettings::kMinimized, false).toBool();
|
||||
if (was_minimized_) setWindowState(windowState() | Qt::WindowMinimized);
|
||||
|
||||
if (!systemtrayicon_->IsSystemTrayAvailable() || !systemtrayicon_->isVisible() || !settings_.value(MainWindowSettings::kHidden, false).toBool()) {
|
||||
if (!systemtrayicon_->IsSystemTrayAvailable() || !systemtrayicon_->isVisible() || !settings.value(MainWindowSettings::kHidden, false).toBool()) {
|
||||
show();
|
||||
}
|
||||
break;
|
||||
@@ -1054,7 +1057,7 @@ MainWindow::MainWindow(Application *app,
|
||||
}
|
||||
#endif
|
||||
|
||||
bool show_sidebar = settings_.value(MainWindowSettings::kShowSidebar, true).toBool();
|
||||
bool show_sidebar = settings.value(MainWindowSettings::kShowSidebar, true).toBool();
|
||||
ui_->sidebar_layout->setVisible(show_sidebar);
|
||||
ui_->action_toggle_show_sidebar->setChecked(show_sidebar);
|
||||
|
||||
@@ -1225,7 +1228,9 @@ void MainWindow::ReloadSettings() {
|
||||
|
||||
osd_->ReloadSettings();
|
||||
|
||||
album_cover_choice_controller_->search_cover_auto_action()->setChecked(settings_.value(MainWindowSettings::kSearchForCoverAuto, true).toBool());
|
||||
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||
album_cover_choice_controller_->search_cover_auto_action()->setChecked(s.value(MainWindowSettings::kSearchForCoverAuto, true).toBool());
|
||||
s.endGroup();
|
||||
|
||||
#ifdef HAVE_SUBSONIC
|
||||
s.beginGroup(SubsonicSettings::kSettingsGroup);
|
||||
@@ -1342,8 +1347,11 @@ void MainWindow::SaveSettings() {
|
||||
ui_->playlist->view()->SaveSettings();
|
||||
app_->scrobbler()->WriteCache();
|
||||
|
||||
settings_.setValue(MainWindowSettings::kShowSidebar, ui_->action_toggle_show_sidebar->isChecked());
|
||||
settings_.setValue(MainWindowSettings::kSearchForCoverAuto, album_cover_choice_controller_->search_cover_auto_action()->isChecked());
|
||||
Settings s;
|
||||
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||
s.setValue(MainWindowSettings::kShowSidebar, ui_->action_toggle_show_sidebar->isChecked());
|
||||
s.setValue(MainWindowSettings::kSearchForCoverAuto, album_cover_choice_controller_->search_cover_auto_action()->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
@@ -1584,23 +1592,35 @@ void MainWindow::ToggleSidebar(const bool checked) {
|
||||
|
||||
ui_->sidebar_layout->setVisible(checked);
|
||||
TabSwitched();
|
||||
settings_.setValue(MainWindowSettings::kShowSidebar, checked);
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||
s.setValue(MainWindowSettings::kShowSidebar, checked);
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::ToggleSearchCoverAuto(const bool checked) {
|
||||
settings_.setValue(MainWindowSettings::kSearchForCoverAuto, checked);
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||
s.setValue(MainWindowSettings::kSearchForCoverAuto, checked);
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::SaveGeometry() {
|
||||
|
||||
if (!initialized_) return;
|
||||
|
||||
settings_.setValue(MainWindowSettings::kMaximized, isMaximized());
|
||||
settings_.setValue(MainWindowSettings::kMinimized, isMinimized());
|
||||
settings_.setValue(MainWindowSettings::kHidden, isHidden());
|
||||
settings_.setValue(MainWindowSettings::kGeometry, saveGeometry());
|
||||
settings_.setValue(MainWindowSettings::kSplitterState, ui_->splitter->saveState());
|
||||
Settings s;
|
||||
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||
s.setValue(MainWindowSettings::kMaximized, isMaximized());
|
||||
s.setValue(MainWindowSettings::kMinimized, isMinimized());
|
||||
s.setValue(MainWindowSettings::kHidden, isHidden());
|
||||
s.setValue(MainWindowSettings::kGeometry, saveGeometry());
|
||||
s.setValue(MainWindowSettings::kSplitterState, ui_->splitter->saveState());
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
@@ -1742,7 +1762,12 @@ void MainWindow::SetHiddenInTray(const bool hidden) {
|
||||
}
|
||||
|
||||
void MainWindow::FilePathChanged(const QString &path) {
|
||||
settings_.setValue("file_path", path);
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||
s.setValue("file_path", path);
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::Seeked(const qint64 microseconds) {
|
||||
@@ -2324,7 +2349,9 @@ void MainWindow::EditValue() {
|
||||
void MainWindow::AddFile() {
|
||||
|
||||
// Last used directory
|
||||
QString directory = settings_.value("add_media_path", QDir::currentPath()).toString();
|
||||
Settings s;
|
||||
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||
QString directory = s.value("add_media_path", QDir::currentPath()).toString();
|
||||
|
||||
PlaylistParser parser(app_->tagreader_client(), app_->collection_backend());
|
||||
|
||||
@@ -2334,7 +2361,7 @@ void MainWindow::AddFile() {
|
||||
if (filenames.isEmpty()) return;
|
||||
|
||||
// Save last used directory
|
||||
settings_.setValue("add_media_path", filenames[0]);
|
||||
s.setValue("add_media_path", filenames[0]);
|
||||
|
||||
// Convert to URLs
|
||||
QList<QUrl> urls;
|
||||
@@ -2352,14 +2379,16 @@ void MainWindow::AddFile() {
|
||||
void MainWindow::AddFolder() {
|
||||
|
||||
// Last used directory
|
||||
QString directory = settings_.value("add_folder_path", QDir::currentPath()).toString();
|
||||
Settings s;
|
||||
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||
QString directory = s.value("add_folder_path", QDir::currentPath()).toString();
|
||||
|
||||
// Show dialog
|
||||
directory = QFileDialog::getExistingDirectory(this, tr("Add folder"), directory);
|
||||
if (directory.isEmpty()) return;
|
||||
|
||||
// Save last used directory
|
||||
settings_.setValue("add_folder_path", directory);
|
||||
s.setValue("add_folder_path", directory);
|
||||
|
||||
// Add media
|
||||
MimeData *mimedata = new MimeData;
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QTimer>
|
||||
#include <QSettings>
|
||||
#include <QtEvents>
|
||||
|
||||
#include "includes/scoped_ptr.h"
|
||||
@@ -53,7 +52,6 @@
|
||||
#include "includes/lazy.h"
|
||||
#include "core/platforminterface.h"
|
||||
#include "core/song.h"
|
||||
#include "core/settings.h"
|
||||
#include "core/commandlineoptions.h"
|
||||
#include "tagreader/tagreaderclient.h"
|
||||
#include "osd/osdbase.h"
|
||||
@@ -390,7 +388,6 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
QTimer *track_position_timer_;
|
||||
QTimer *track_slider_timer_;
|
||||
Settings settings_;
|
||||
|
||||
bool keep_running_;
|
||||
bool playing_widget_;
|
||||
|
||||
@@ -805,19 +805,19 @@ bool Song::lyrics_supported() const {
|
||||
}
|
||||
|
||||
bool Song::albumartistsort_supported() const {
|
||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::MPEG;
|
||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::OggOpus || d->filetype_ == FileType::MPEG;
|
||||
}
|
||||
|
||||
bool Song::albumsort_supported() const {
|
||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::MPEG;
|
||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::OggOpus || d->filetype_ == FileType::MPEG;
|
||||
}
|
||||
|
||||
bool Song::artistsort_supported() const {
|
||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::MPEG;
|
||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::OggOpus || d->filetype_ == FileType::MPEG;
|
||||
}
|
||||
|
||||
bool Song::composersort_supported() const {
|
||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::MPEG;
|
||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::OggOpus || d->filetype_ == FileType::MPEG;
|
||||
}
|
||||
|
||||
bool Song::performersort_supported() const {
|
||||
@@ -826,7 +826,7 @@ bool Song::performersort_supported() const {
|
||||
}
|
||||
|
||||
bool Song::titlesort_supported() const {
|
||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::MPEG;
|
||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::OggOpus || d->filetype_ == FileType::MPEG;
|
||||
}
|
||||
|
||||
bool Song::save_embedded_cover_supported(const FileType filetype) {
|
||||
|
||||
@@ -98,6 +98,9 @@ SongLoader::SongLoader(const SharedPtr<UrlHandlers> url_handlers,
|
||||
|
||||
QObject::connect(timeout_timer_, &QTimer::timeout, this, &SongLoader::Timeout);
|
||||
|
||||
QObject::connect(playlist_parser_, &PlaylistParser::Error, this, &SongLoader::ParserError);
|
||||
QObject::connect(cue_parser_, &CueParser::Error, this, &SongLoader::ParserError);
|
||||
|
||||
}
|
||||
|
||||
SongLoader::~SongLoader() {
|
||||
@@ -106,6 +109,10 @@ SongLoader::~SongLoader() {
|
||||
|
||||
}
|
||||
|
||||
void SongLoader::ParserError(const QString &error) {
|
||||
errors_ << error;
|
||||
}
|
||||
|
||||
SongLoader::Result SongLoader::Load(const QUrl &url) {
|
||||
|
||||
if (url.isEmpty()) return Result::Error;
|
||||
@@ -287,6 +294,7 @@ SongLoader::Result SongLoader::LoadLocalAsync(const QString &filename) {
|
||||
}
|
||||
|
||||
if (parser) { // It's a playlist!
|
||||
QObject::connect(parser, &ParserBase::Error, this, &SongLoader::ParserError, static_cast<Qt::ConnectionType>(Qt::QueuedConnection | Qt::UniqueConnection));
|
||||
qLog(Debug) << "Parsing using" << parser->name();
|
||||
LoadPlaylist(parser, filename);
|
||||
return Result::Success;
|
||||
@@ -706,6 +714,10 @@ void SongLoader::MagicReady() {
|
||||
StopTypefindAsync(true);
|
||||
}
|
||||
|
||||
if (parser_) {
|
||||
QObject::connect(parser_, &ParserBase::Error, this, &SongLoader::ParserError, static_cast<Qt::ConnectionType>(Qt::QueuedConnection | Qt::UniqueConnection));
|
||||
}
|
||||
|
||||
state_ = State::WaitingForData;
|
||||
|
||||
if (!IsPipelinePlaying()) {
|
||||
|
||||
@@ -99,6 +99,7 @@ class SongLoader : public QObject {
|
||||
void ScheduleTimeout();
|
||||
void Timeout();
|
||||
void StopTypefind();
|
||||
void ParserError(const QString &error);
|
||||
|
||||
#ifdef HAVE_AUDIOCD
|
||||
void AudioCDTracksLoadErrorSlot(const QString &error);
|
||||
|
||||
@@ -178,7 +178,6 @@ GstEnginePipeline::GstEnginePipeline(QObject *parent)
|
||||
audiobin_(nullptr),
|
||||
audiosink_(nullptr),
|
||||
audioqueue_(nullptr),
|
||||
audioqueueconverter_(nullptr),
|
||||
volume_(nullptr),
|
||||
volume_sw_(nullptr),
|
||||
volume_fading_(nullptr),
|
||||
@@ -187,6 +186,7 @@ GstEnginePipeline::GstEnginePipeline(QObject *parent)
|
||||
equalizer_(nullptr),
|
||||
equalizer_preamp_(nullptr),
|
||||
eventprobe_(nullptr),
|
||||
bufferprobe_(nullptr),
|
||||
logged_unsupported_analyzer_format_(false),
|
||||
about_to_finish_(false),
|
||||
finish_requested_(false),
|
||||
@@ -436,7 +436,7 @@ void GstEnginePipeline::Disconnect() {
|
||||
}
|
||||
|
||||
if (buffer_probe_cb_id_.has_value()) {
|
||||
GstPad *pad = gst_element_get_static_pad(audioqueueconverter_, "src");
|
||||
GstPad *pad = gst_element_get_static_pad(bufferprobe_, "src");
|
||||
if (pad) {
|
||||
gst_pad_remove_probe(pad, buffer_probe_cb_id_.value());
|
||||
gst_object_unref(pad);
|
||||
@@ -674,8 +674,13 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
audioqueueconverter_ = CreateElement(u"audioconvert"_s, u"audioqueueconverter"_s, audiobin_, error);
|
||||
if (!audioqueueconverter_) {
|
||||
GstElement *audioqueueconverter = CreateElement(u"audioconvert"_s, u"audioqueueconverter"_s, audiobin_, error);
|
||||
if (!audioqueueconverter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GstElement *audioqueueresampler = CreateElement(u"audioresample"_s, u"audioqueueresampler"_s, audiobin_, error);
|
||||
if (!audioqueueresampler) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -684,6 +689,11 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GstElement *audiosinkresampler = CreateElement(u"audioresample"_s, u"audiosinkresampler"_s, audiobin_, error);
|
||||
if (!audiosinkresampler) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the volume element if it's enabled.
|
||||
if (volume_enabled_ && !volume_) {
|
||||
volume_sw_ = CreateElement(u"volume"_s, u"volume_sw"_s, audiobin_, error);
|
||||
@@ -761,7 +771,8 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
|
||||
}
|
||||
|
||||
eventprobe_ = audioqueueconverter_;
|
||||
eventprobe_ = audioqueueconverter;
|
||||
bufferprobe_ = audioqueueconverter;
|
||||
|
||||
// Create the replaygain elements if it's enabled.
|
||||
GstElement *rgvolume = nullptr;
|
||||
@@ -847,12 +858,17 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
|
||||
// Link all elements
|
||||
|
||||
if (!gst_element_link(audioqueue_, audioqueueconverter_)) {
|
||||
if (!gst_element_link(audioqueue_, audioqueueconverter)) {
|
||||
error = u"Failed to link audio queue to audio queue converter."_s;
|
||||
return false;
|
||||
}
|
||||
|
||||
GstElement *element_link = audioqueueconverter_; // The next element to link from.
|
||||
if (!gst_element_link(audioqueueconverter, audioqueueresampler)) {
|
||||
error = u"Failed to link audio queue converter to audio queue resampler."_s;
|
||||
return false;
|
||||
}
|
||||
|
||||
GstElement *element_link = audioqueueresampler; // The next element to link from.
|
||||
|
||||
// Link replaygain elements if enabled.
|
||||
if (rg_enabled_ && rgvolume && rglimiter && rgconverter) {
|
||||
@@ -928,6 +944,11 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!gst_element_link(audiosinkconverter, audiosinkresampler)) {
|
||||
error = "Failed to link audio sink converter to audio sink resampler."_L1;
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
GstCaps *caps = gst_caps_new_empty_simple("audio/x-raw");
|
||||
if (!caps) {
|
||||
@@ -938,16 +959,16 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
qLog(Debug) << "Setting channels to" << channels_;
|
||||
gst_caps_set_simple(caps, "channels", G_TYPE_INT, channels_, nullptr);
|
||||
}
|
||||
const bool link_filtered_result = gst_element_link_filtered(audiosinkconverter, audiosink_, caps);
|
||||
const bool link_filtered_result = gst_element_link_filtered(audiosinkresampler, audiosink_, caps);
|
||||
gst_caps_unref(caps);
|
||||
if (!link_filtered_result) {
|
||||
error = "Failed to link audio sink converter to audio sink with filter for "_L1 + output_;
|
||||
error = "Failed to link audio sink resampler to audio sink with filter for "_L1 + output_;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
{ // Add probes and handlers.
|
||||
GstPad *pad = gst_element_get_static_pad(audioqueueconverter_, "src");
|
||||
GstPad *pad = gst_element_get_static_pad(bufferprobe_, "src");
|
||||
if (pad) {
|
||||
buffer_probe_cb_id_ = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER, BufferProbeCallback, this, nullptr);
|
||||
gst_object_unref(pad);
|
||||
|
||||
@@ -355,7 +355,6 @@ class GstEnginePipeline : public QObject {
|
||||
GstElement *audiobin_;
|
||||
GstElement *audiosink_;
|
||||
GstElement *audioqueue_;
|
||||
GstElement *audioqueueconverter_;
|
||||
GstElement *volume_;
|
||||
GstElement *volume_sw_;
|
||||
GstElement *volume_fading_;
|
||||
@@ -364,6 +363,7 @@ class GstEnginePipeline : public QObject {
|
||||
GstElement *equalizer_;
|
||||
GstElement *equalizer_preamp_;
|
||||
GstElement *eventprobe_;
|
||||
GstElement *bufferprobe_;
|
||||
|
||||
std::optional<gulong> upstream_events_probe_cb_id_;
|
||||
std::optional<gulong> buffer_probe_cb_id_;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <QKeySequence>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/settings.h"
|
||||
|
||||
#include "globalshortcutsmanager.h"
|
||||
#include "globalshortcutsbackend.h"
|
||||
@@ -58,29 +59,32 @@ using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
GlobalShortcutsManager::GlobalShortcutsManager(QWidget *parent) : QWidget(parent) {
|
||||
|
||||
settings_.beginGroup(GlobalShortcutsSettings::kSettingsGroup);
|
||||
Settings s;
|
||||
s.beginGroup(GlobalShortcutsSettings::kSettingsGroup);
|
||||
|
||||
// Create actions
|
||||
AddShortcut(u"play"_s, tr("Play"), std::bind(&GlobalShortcutsManager::Play, this));
|
||||
AddShortcut(u"pause"_s, tr("Pause"), std::bind(&GlobalShortcutsManager::Pause, this));
|
||||
AddShortcut(u"play_pause"_s, tr("Play/Pause"), std::bind(&GlobalShortcutsManager::PlayPause, this), QKeySequence(Qt::Key_MediaPlay));
|
||||
AddShortcut(u"stop"_s, tr("Stop"), std::bind(&GlobalShortcutsManager::Stop, this), QKeySequence(Qt::Key_MediaStop));
|
||||
AddShortcut(u"stop_after"_s, tr("Stop playing after current track"), std::bind(&GlobalShortcutsManager::StopAfter, this));
|
||||
AddShortcut(u"next_track"_s, tr("Next track"), std::bind(&GlobalShortcutsManager::Next, this), QKeySequence(Qt::Key_MediaNext));
|
||||
AddShortcut(u"prev_track"_s, tr("Previous track"), std::bind(&GlobalShortcutsManager::Previous, this), QKeySequence(Qt::Key_MediaPrevious));
|
||||
AddShortcut(u"restart_or_prev_track"_s, tr("Restart or previous track"), std::bind(&GlobalShortcutsManager::RestartOrPrevious, this));
|
||||
AddShortcut(u"inc_volume"_s, tr("Increase volume"), std::bind(&GlobalShortcutsManager::IncVolume, this));
|
||||
AddShortcut(u"dec_volume"_s, tr("Decrease volume"), std::bind(&GlobalShortcutsManager::DecVolume, this));
|
||||
AddShortcut(u"mute"_s, tr("Mute"), std::bind(&GlobalShortcutsManager::Mute, this));
|
||||
AddShortcut(u"seek_forward"_s, tr("Seek forward"), std::bind(&GlobalShortcutsManager::SeekForward, this));
|
||||
AddShortcut(u"seek_backward"_s, tr("Seek backward"), std::bind(&GlobalShortcutsManager::SeekBackward, this));
|
||||
AddShortcut(u"show_hide"_s, tr("Show/Hide"), std::bind(&GlobalShortcutsManager::ShowHide, this));
|
||||
AddShortcut(u"show_osd"_s, tr("Show OSD"), std::bind(&GlobalShortcutsManager::ShowOSD, this));
|
||||
AddShortcut(u"toggle_pretty_osd"_s, tr("Toggle Pretty OSD"), std::bind(&GlobalShortcutsManager::TogglePrettyOSD, this)); // Toggling possible only for pretty OSD
|
||||
AddShortcut(u"shuffle_mode"_s, tr("Change shuffle mode"), std::bind(&GlobalShortcutsManager::CycleShuffleMode, this));
|
||||
AddShortcut(u"repeat_mode"_s, tr("Change repeat mode"), std::bind(&GlobalShortcutsManager::CycleRepeatMode, this));
|
||||
AddShortcut(u"toggle_scrobbling"_s, tr("Enable/disable scrobbling"), std::bind(&GlobalShortcutsManager::ToggleScrobbling, this));
|
||||
AddShortcut(u"love"_s, tr("Love"), std::bind(&GlobalShortcutsManager::Love, this));
|
||||
AddShortcut(s, u"play"_s, tr("Play"), std::bind(&GlobalShortcutsManager::Play, this));
|
||||
AddShortcut(s, u"pause"_s, tr("Pause"), std::bind(&GlobalShortcutsManager::Pause, this));
|
||||
AddShortcut(s, u"play_pause"_s, tr("Play/Pause"), std::bind(&GlobalShortcutsManager::PlayPause, this), QKeySequence(Qt::Key_MediaPlay));
|
||||
AddShortcut(s, u"stop"_s, tr("Stop"), std::bind(&GlobalShortcutsManager::Stop, this), QKeySequence(Qt::Key_MediaStop));
|
||||
AddShortcut(s, u"stop_after"_s, tr("Stop playing after current track"), std::bind(&GlobalShortcutsManager::StopAfter, this));
|
||||
AddShortcut(s, u"next_track"_s, tr("Next track"), std::bind(&GlobalShortcutsManager::Next, this), QKeySequence(Qt::Key_MediaNext));
|
||||
AddShortcut(s, u"prev_track"_s, tr("Previous track"), std::bind(&GlobalShortcutsManager::Previous, this), QKeySequence(Qt::Key_MediaPrevious));
|
||||
AddShortcut(s, u"restart_or_prev_track"_s, tr("Restart or previous track"), std::bind(&GlobalShortcutsManager::RestartOrPrevious, this));
|
||||
AddShortcut(s, u"inc_volume"_s, tr("Increase volume"), std::bind(&GlobalShortcutsManager::IncVolume, this));
|
||||
AddShortcut(s, u"dec_volume"_s, tr("Decrease volume"), std::bind(&GlobalShortcutsManager::DecVolume, this));
|
||||
AddShortcut(s, u"mute"_s, tr("Mute"), std::bind(&GlobalShortcutsManager::Mute, this));
|
||||
AddShortcut(s, u"seek_forward"_s, tr("Seek forward"), std::bind(&GlobalShortcutsManager::SeekForward, this));
|
||||
AddShortcut(s, u"seek_backward"_s, tr("Seek backward"), std::bind(&GlobalShortcutsManager::SeekBackward, this));
|
||||
AddShortcut(s, u"show_hide"_s, tr("Show/Hide"), std::bind(&GlobalShortcutsManager::ShowHide, this));
|
||||
AddShortcut(s, u"show_osd"_s, tr("Show OSD"), std::bind(&GlobalShortcutsManager::ShowOSD, this));
|
||||
AddShortcut(s, u"toggle_pretty_osd"_s, tr("Toggle Pretty OSD"), std::bind(&GlobalShortcutsManager::TogglePrettyOSD, this)); // Toggling possible only for pretty OSD
|
||||
AddShortcut(s, u"shuffle_mode"_s, tr("Change shuffle mode"), std::bind(&GlobalShortcutsManager::CycleShuffleMode, this));
|
||||
AddShortcut(s, u"repeat_mode"_s, tr("Change repeat mode"), std::bind(&GlobalShortcutsManager::CycleRepeatMode, this));
|
||||
AddShortcut(s, u"toggle_scrobbling"_s, tr("Enable/disable scrobbling"), std::bind(&GlobalShortcutsManager::ToggleScrobbling, this));
|
||||
AddShortcut(s, u"love"_s, tr("Love"), std::bind(&GlobalShortcutsManager::Love, this));
|
||||
|
||||
s.endGroup();
|
||||
|
||||
// Create backends - these do the actual shortcut registration
|
||||
|
||||
@@ -116,35 +120,39 @@ void GlobalShortcutsManager::ReloadSettings() {
|
||||
backends_enabled_ << GlobalShortcutsBackend::Type::Win;
|
||||
#endif
|
||||
|
||||
{
|
||||
Settings s;
|
||||
s.beginGroup(GlobalShortcutsSettings::kSettingsGroup);
|
||||
#ifdef HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
|
||||
if (settings_.value(GlobalShortcutsSettings::kUseKGlobalAccel, true).toBool()) {
|
||||
backends_enabled_ << GlobalShortcutsBackend::Type::KGlobalAccel;
|
||||
}
|
||||
if (s.value(GlobalShortcutsSettings::kUseKGlobalAccel, true).toBool()) {
|
||||
backends_enabled_ << GlobalShortcutsBackend::Type::KGlobalAccel;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_X11_GLOBALSHORTCUTS
|
||||
if (settings_.value(GlobalShortcutsSettings::kUseX11, false).toBool()) {
|
||||
backends_enabled_ << GlobalShortcutsBackend::Type::X11;
|
||||
}
|
||||
if (s.value(GlobalShortcutsSettings::kUseX11, false).toBool()) {
|
||||
backends_enabled_ << GlobalShortcutsBackend::Type::X11;
|
||||
}
|
||||
#endif
|
||||
s.endGroup();
|
||||
}
|
||||
|
||||
Unregister();
|
||||
Register();
|
||||
|
||||
}
|
||||
|
||||
void GlobalShortcutsManager::AddShortcut(const QString &id, const QString &name, std::function<void()> signal, const QKeySequence &default_key) { // clazy:exclude=function-args-by-ref
|
||||
void GlobalShortcutsManager::AddShortcut(Settings &s, const QString &id, const QString &name, std::function<void()> signal, const QKeySequence &default_key) { // clazy:exclude=function-args-by-ref
|
||||
|
||||
Shortcut shortcut = AddShortcut(id, name, default_key);
|
||||
Shortcut shortcut = AddShortcut(s, id, name, default_key);
|
||||
QObject::connect(shortcut.action, &QAction::triggered, this, signal);
|
||||
|
||||
}
|
||||
|
||||
GlobalShortcutsManager::Shortcut GlobalShortcutsManager::AddShortcut(const QString &id, const QString &name, const QKeySequence &default_key) {
|
||||
GlobalShortcutsManager::Shortcut GlobalShortcutsManager::AddShortcut(Settings &s, const QString &id, const QString &name, const QKeySequence &default_key) {
|
||||
|
||||
Shortcut shortcut;
|
||||
shortcut.action = new QAction(name, this);
|
||||
QKeySequence key_sequence = QKeySequence::fromString(settings_.value(id, default_key.toString()).toString());
|
||||
QKeySequence key_sequence = QKeySequence::fromString(s.value(id, default_key.toString()).toString());
|
||||
shortcut.action->setShortcut(key_sequence);
|
||||
shortcut.id = id;
|
||||
shortcut.default_key = default_key;
|
||||
|
||||
@@ -32,15 +32,14 @@
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QKeySequence>
|
||||
#include <QSettings>
|
||||
|
||||
#include "globalshortcutsbackend.h"
|
||||
|
||||
#include "core/settings.h"
|
||||
|
||||
class QShortcut;
|
||||
class QAction;
|
||||
|
||||
class Settings;
|
||||
|
||||
class GlobalShortcutsManager : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -99,12 +98,11 @@ class GlobalShortcutsManager : public QWidget {
|
||||
void Love();
|
||||
|
||||
private:
|
||||
void AddShortcut(const QString &id, const QString &name, std::function<void()> signal, const QKeySequence &default_key = QKeySequence(0));
|
||||
Shortcut AddShortcut(const QString &id, const QString &name, const QKeySequence &default_key);
|
||||
void AddShortcut(Settings &s, const QString &id, const QString &name, std::function<void()> signal, const QKeySequence &default_key = QKeySequence(0));
|
||||
Shortcut AddShortcut(Settings &s, const QString &id, const QString &name, const QKeySequence &default_key);
|
||||
|
||||
private:
|
||||
QList<GlobalShortcutsBackend*> backends_;
|
||||
Settings settings_;
|
||||
QList<GlobalShortcutsBackend::Type> backends_enabled_;
|
||||
QMap<QString, Shortcut> shortcuts_;
|
||||
};
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QByteArray>
|
||||
|
||||
@@ -61,6 +64,29 @@ void MoodbarBuilder::Init(const int bands, const int rate_hz) {
|
||||
|
||||
}
|
||||
|
||||
void MoodbarBuilder::AddFrame(const GValue *magnitudes, const int size) {
|
||||
|
||||
if (size > barkband_table_.length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate total magnitudes for different bark bands.
|
||||
double bands[sBarkBandCount]{};
|
||||
for (int i = 0; i < size; ++i) {
|
||||
const GValue *magnitude = gst_value_list_get_value(magnitudes, i);
|
||||
bands[barkband_table_[i]] += g_value_get_float(magnitude);
|
||||
}
|
||||
|
||||
// Now divide the bark bands into thirds and compute their total amplitudes.
|
||||
double rgb[] = { 0, 0, 0 };
|
||||
for (int i = 0; i < sBarkBandCount; ++i) {
|
||||
rgb[(i * 3) / sBarkBandCount] += bands[i] * bands[i];
|
||||
}
|
||||
|
||||
frames_.append(Rgb(sqrt(rgb[0]), sqrt(rgb[1]), sqrt(rgb[2])));
|
||||
|
||||
}
|
||||
|
||||
void MoodbarBuilder::AddFrame(const double *magnitudes, const int size) {
|
||||
|
||||
if (size > barkband_table_.length()) {
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#ifndef MOODBARBUILDER_H
|
||||
#define MOODBARBUILDER_H
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QList>
|
||||
#include <QByteArray>
|
||||
@@ -31,6 +33,7 @@ class MoodbarBuilder {
|
||||
explicit MoodbarBuilder();
|
||||
|
||||
void Init(const int bands, const int rate_hz);
|
||||
void AddFrame(const GValue *magnitudes, const int size);
|
||||
void AddFrame(const double *magnitudes, const int size);
|
||||
QByteArray Finish(const int width);
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ void MoodbarPipeline::Start() {
|
||||
|
||||
GstElement *decodebin = CreateElement("uridecodebin");
|
||||
convert_element_ = CreateElement("audioconvert");
|
||||
GstElement *spectrum = CreateElement("strawberry-fastspectrum");
|
||||
GstElement *spectrum = CreateElement("spectrum");
|
||||
GstElement *fakesink = CreateElement("fakesink");
|
||||
|
||||
if (!decodebin || !convert_element_ || !spectrum || !fakesink) {
|
||||
@@ -122,7 +122,7 @@ void MoodbarPipeline::Start() {
|
||||
return;
|
||||
}
|
||||
|
||||
builder_ = make_unique<MoodbarBuilder>();
|
||||
//builder_ = make_unique<MoodbarBuilder>();
|
||||
|
||||
// Set properties
|
||||
|
||||
@@ -130,8 +130,16 @@ void MoodbarPipeline::Start() {
|
||||
g_object_set(decodebin, "uri", gst_url.constData(), nullptr);
|
||||
g_object_set(spectrum, "bands", kBands, nullptr);
|
||||
|
||||
GstStrawberryFastSpectrum *fastspectrum = reinterpret_cast<GstStrawberryFastSpectrum*>(spectrum);
|
||||
fastspectrum->output_callback = [this](double *magnitudes, const int size) { builder_->AddFrame(magnitudes, size); };
|
||||
//GstStrawberryFastSpectrum *fastspectrum = reinterpret_cast<GstStrawberryFastSpectrum*>(spectrum);
|
||||
//fastspectrum->output_callback = [this](double *magnitudes, const int size) { builder_->AddFrame(magnitudes, size); };
|
||||
|
||||
{
|
||||
GstPad *pad = gst_element_get_static_pad(fakesink, "src");
|
||||
if (pad) {
|
||||
buffer_probe_cb_id_ = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER, BufferProbeCallback, this, nullptr);
|
||||
gst_object_unref(pad);
|
||||
}
|
||||
}
|
||||
|
||||
// Connect signals
|
||||
CHECKED_GCONNECT(decodebin, "pad-added", &NewPadCallback, this);
|
||||
@@ -212,6 +220,20 @@ GstBusSyncReply MoodbarPipeline::BusCallbackSync(GstBus *bus, GstMessage *messag
|
||||
if (!instance->running_) return GST_BUS_PASS;
|
||||
|
||||
switch (GST_MESSAGE_TYPE(message)) {
|
||||
#if 0
|
||||
case GST_MESSAGE_ELEMENT:{
|
||||
const GstStructure *structure = gst_message_get_structure(message);
|
||||
const gchar *name = gst_structure_get_name(structure);
|
||||
if (strcmp(name, "spectrum") == 0) {
|
||||
const GValue *magnitudes = gst_structure_get_value(structure, "magnitude");
|
||||
if (instance->builder_) {
|
||||
instance->builder_->AddFrame(magnitudes, kBands);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case GST_MESSAGE_EOS:
|
||||
instance->Stop(true);
|
||||
break;
|
||||
@@ -229,6 +251,24 @@ GstBusSyncReply MoodbarPipeline::BusCallbackSync(GstBus *bus, GstMessage *messag
|
||||
|
||||
}
|
||||
|
||||
GstPadProbeReturn MoodbarPipeline::BufferProbeCallback(GstPad *pad, GstPadProbeInfo *info, gpointer self) {
|
||||
|
||||
Q_UNUSED(pad)
|
||||
|
||||
MoodbarPipeline *instance = reinterpret_cast<MoodbarPipeline*>(self);
|
||||
|
||||
GstBuffer *buffer = gst_pad_probe_info_get_buffer(info);
|
||||
|
||||
GstMapInfo map;
|
||||
gst_buffer_map(buffer, &map, GST_MAP_READ);
|
||||
instance->data_.append(reinterpret_cast<const char*>(map.data), map.size);
|
||||
gst_buffer_unmap(buffer, &map);
|
||||
gst_buffer_unref(buffer);
|
||||
|
||||
return GST_PAD_PROBE_OK;
|
||||
|
||||
}
|
||||
|
||||
void MoodbarPipeline::Stop(const bool success) {
|
||||
|
||||
running_ = false;
|
||||
|
||||
@@ -63,6 +63,7 @@ class MoodbarPipeline : public QObject {
|
||||
|
||||
static void NewPadCallback(GstElement *element, GstPad *pad, gpointer self);
|
||||
static GstBusSyncReply BusCallbackSync(GstBus *bus, GstMessage *message, gpointer self);
|
||||
static GstPadProbeReturn BufferProbeCallback(GstPad *pad, GstPadProbeInfo *info, gpointer self);
|
||||
|
||||
private:
|
||||
QUrl url_;
|
||||
@@ -74,6 +75,7 @@ class MoodbarPipeline : public QObject {
|
||||
bool success_;
|
||||
bool running_;
|
||||
QByteArray data_;
|
||||
gint buffer_probe_cb_id_;
|
||||
};
|
||||
|
||||
using MoodbarPipelinePtr = QSharedPointer<MoodbarPipeline>;
|
||||
|
||||
@@ -106,8 +106,6 @@ PlaylistContainer::PlaylistContainer(QWidget *parent)
|
||||
no_matches_font.setBold(true);
|
||||
no_matches_label_->setFont(no_matches_font);
|
||||
|
||||
settings_.beginGroup(kSettingsGroup);
|
||||
|
||||
// Tab bar
|
||||
ui_->tab_bar->setExpanding(false);
|
||||
ui_->tab_bar->setMovable(true);
|
||||
@@ -257,7 +255,11 @@ void PlaylistContainer::ReloadSettings() {
|
||||
ui_->redo->setIconSize(QSize(iconsize, iconsize));
|
||||
ui_->search_field->setIconSize(iconsize);
|
||||
|
||||
bool playlist_clear = settings_.value("playlist_clear", true).toBool();
|
||||
s.beginGroup(kSettingsGroup);
|
||||
const bool playlist_clear = s.value("playlist_clear", true).toBool();
|
||||
const bool show_toolbar = s.value("show_toolbar", true).toBool();
|
||||
s.endGroup();
|
||||
|
||||
if (playlist_clear) {
|
||||
ui_->clear->show();
|
||||
}
|
||||
@@ -265,7 +267,6 @@ void PlaylistContainer::ReloadSettings() {
|
||||
ui_->clear->hide();
|
||||
}
|
||||
|
||||
bool show_toolbar = settings_.value("show_toolbar", true).toBool();
|
||||
ui_->toolbar->setVisible(show_toolbar);
|
||||
|
||||
if (!show_toolbar) ui_->search_field->clear();
|
||||
@@ -308,7 +309,12 @@ void PlaylistContainer::PlaylistAdded(const int id, const QString &name, const b
|
||||
ui_->tab_bar->InsertTab(id, index, name, favorite);
|
||||
|
||||
// Are we start up, should we select this tab?
|
||||
if (starting_up_ && settings_.value("current_playlist", 1).toInt() == id) {
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
const int current_playlist = s.value("current_playlist", 1).toInt();
|
||||
s.endGroup();
|
||||
|
||||
if (starting_up_ && current_playlist == id) {
|
||||
starting_up_ = false;
|
||||
ui_->tab_bar->set_current_id(id);
|
||||
}
|
||||
@@ -347,12 +353,14 @@ void PlaylistContainer::NewPlaylist() { manager_->New(tr("Playlist")); }
|
||||
|
||||
void PlaylistContainer::LoadPlaylist() {
|
||||
|
||||
QString filename = settings_.value("last_load_playlist").toString();
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
QString filename = s.value("last_load_playlist").toString();
|
||||
filename = QFileDialog::getOpenFileName(this, tr("Load playlist"), filename, manager_->parser()->filters(PlaylistParser::Type::Load));
|
||||
|
||||
if (filename.isNull()) return;
|
||||
|
||||
settings_.setValue("last_load_playlist", filename);
|
||||
s.setValue("last_load_playlist", filename);
|
||||
|
||||
manager_->Load(filename);
|
||||
|
||||
@@ -391,7 +399,10 @@ void PlaylistContainer::Save() {
|
||||
|
||||
if (starting_up_) return;
|
||||
|
||||
settings_.setValue("current_playlist", ui_->tab_bar->current_id());
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("current_playlist", ui_->tab_bar->current_id());
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <QWidget>
|
||||
#include <QString>
|
||||
#include <QIcon>
|
||||
#include <QSettings>
|
||||
|
||||
class QTimer;
|
||||
class QTimeLine;
|
||||
@@ -45,7 +44,6 @@ class PlaylistView;
|
||||
class Ui_PlaylistContainer;
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/settings.h"
|
||||
|
||||
class PlaylistContainer : public QWidget {
|
||||
Q_OBJECT
|
||||
@@ -118,7 +116,6 @@ class PlaylistContainer : public QWidget {
|
||||
QAction *redo_;
|
||||
Playlist *playlist_;
|
||||
|
||||
Settings settings_;
|
||||
bool starting_up_;
|
||||
|
||||
bool tab_bar_visible_;
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
#include <QLinearGradient>
|
||||
#include <QScrollBar>
|
||||
#include <QtEvents>
|
||||
#include <QSettings>
|
||||
#include <QDrag>
|
||||
|
||||
#include "includes/qt_blurimage.h"
|
||||
|
||||
@@ -80,12 +80,13 @@ void SongLoaderInserter::Load(Playlist *destination, const int row, const bool p
|
||||
songs_ << loader->songs();
|
||||
playlist_name_ = loader->playlist_name();
|
||||
}
|
||||
else {
|
||||
const QStringList errors = loader->errors();
|
||||
for (const QString &error : errors) {
|
||||
Q_EMIT Error(error);
|
||||
}
|
||||
|
||||
// Always check for errors, even on success (e.g., playlist parsed but some songs failed to load)
|
||||
const QStringList errors = loader->errors();
|
||||
for (const QString &error : errors) {
|
||||
Q_EMIT Error(error);
|
||||
}
|
||||
|
||||
delete loader;
|
||||
}
|
||||
|
||||
@@ -192,11 +193,13 @@ void SongLoaderInserter::AsyncLoad() {
|
||||
const SongLoader::Result result = loader->LoadFilenamesBlocking();
|
||||
task_manager_->SetTaskProgress(async_load_id, static_cast<quint64>(++async_progress));
|
||||
|
||||
// Always check for errors, even on success (e.g., playlist parsed but some songs failed to load)
|
||||
const QStringList errors = loader->errors();
|
||||
for (const QString &error : errors) {
|
||||
Q_EMIT Error(error);
|
||||
}
|
||||
|
||||
if (result == SongLoader::Result::Error) {
|
||||
const QStringList errors = loader->errors();
|
||||
for (const QString &error : errors) {
|
||||
Q_EMIT Error(error);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,10 +112,18 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the file exists before trying to read it
|
||||
if (!QFile::exists(filename)) {
|
||||
qLog(Error) << "File does not exist:" << filename;
|
||||
Q_EMIT Error(tr("File %1 does not exist").arg(filename));
|
||||
return;
|
||||
}
|
||||
|
||||
if (tagreader_client_) {
|
||||
const TagReaderResult result = tagreader_client_->ReadFileBlocking(filename, song);
|
||||
if (!result.success()) {
|
||||
qLog(Error) << "Could not read file" << filename << result.error_string();
|
||||
Q_EMIT Error(tr("Could not read file %1: %2").arg(filename, result.error_string()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5526,7 +5526,7 @@ Are you sure you want to continue?</source>
|
||||
<name>RadioParadiseService</name>
|
||||
<message>
|
||||
<source>Getting %1 channels</source>
|
||||
<translation>Получение %1 каналов</translation>
|
||||
<translation>Получение каналов %1</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@@ -6191,7 +6191,7 @@ Are you sure you want to continue?</source>
|
||||
<name>SomaFMService</name>
|
||||
<message>
|
||||
<source>Getting %1 channels</source>
|
||||
<translation>Получение %1 каналов</translation>
|
||||
<translation>Получение каналов %1</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
||||
@@ -1187,7 +1187,7 @@ If there are no matches then it will use the largest image in the directory.</tr
|
||||
</message>
|
||||
<message>
|
||||
<source>Queue to play next</source>
|
||||
<translation>Sıradaki Yap</translation>
|
||||
<translation>Sıradaki yap</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Search for this</source>
|
||||
@@ -3496,7 +3496,7 @@ If there are no matches then it will use the largest image in the directory.</tr
|
||||
</message>
|
||||
<message>
|
||||
<source>Queue to play next</source>
|
||||
<translation>Sıradaki Yap</translation>
|
||||
<translation>Sıradaki yap</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unskip track</source>
|
||||
@@ -4431,7 +4431,7 @@ If there are no matches then it will use the largest image in the directory.</tr
|
||||
</message>
|
||||
<message>
|
||||
<source>&Hide %1</source>
|
||||
<translation>&%1'i sakla</translation>
|
||||
<translation>&%1 ögesini sakla</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@@ -6407,7 +6407,7 @@ Devam etmek istediğinizden emin misiniz?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Queue to play next</source>
|
||||
<translation>Sıradaki Yap</translation>
|
||||
<translation>Sıradaki yap</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remove from favorites</source>
|
||||
|
||||
Reference in New Issue
Block a user