Compare commits
11 Commits
315cf63118
...
0983ba1339
Author | SHA1 | Date |
---|---|---|
Jonas Kvinge | 0983ba1339 | |
dependabot[bot] | 0a99eca7cd | |
Jonas Kvinge | 116bbec73e | |
Jonas Kvinge | bf19540f8d | |
Jonas Kvinge | dff3ae7410 | |
Jonas Kvinge | 76614bcde0 | |
Jonas Kvinge | 2953f9eefc | |
Jonas Kvinge | 4a24605361 | |
Jonas Kvinge | decabe8d47 | |
Jonas Kvinge | 51adcf0f1e | |
Jonas Kvinge | 2a6a07fef6 |
|
@ -185,7 +185,7 @@ jobs:
|
|||
run: dnf -y upgrade
|
||||
- name: Install dependencies
|
||||
run: >
|
||||
dnf -y --skip-broken install
|
||||
dnf -y install
|
||||
@development-tools
|
||||
redhat-lsb-core
|
||||
which
|
||||
|
@ -768,7 +768,7 @@ jobs:
|
|||
|
||||
- name: Import certificate file
|
||||
if: github.repository == 'strawberrymusicplayer/strawberry' && github.event.pull_request.head.repo.fork == false
|
||||
uses: apple-actions/import-codesign-certs@v2
|
||||
uses: apple-actions/import-codesign-certs@v3
|
||||
with:
|
||||
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_ID_CERTIFICATE }}
|
||||
p12-password: ${{ secrets.APPLE_DEVELOPER_ID_CERTIFICATE_PASSWORD }}
|
||||
|
|
|
@ -4,6 +4,11 @@ if(RPM_DISTRO AND RPM_DATE)
|
|||
endif(RPM_DISTRO AND RPM_DATE)
|
||||
|
||||
if(APPLE)
|
||||
if(DEFINED ENV{MACOSX_DEPLOYMENT_TARGET})
|
||||
set(LSMinimumSystemVersion $ENV{MACOSX_DEPLOYMENT_TARGET})
|
||||
else()
|
||||
set(LSMinimumSystemVersion 11.0)
|
||||
endif()
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/macos/Info.plist.in ${CMAKE_CURRENT_SOURCE_DIR}/macos/Info.plist)
|
||||
endif(APPLE)
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.music</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>11.0</string>
|
||||
<string>@LSMinimumSystemVersion@</string>
|
||||
<key>SUFeedURL</key>
|
||||
<string>https://www.strawberrymusicplayer.org/sparkle-macos</string>
|
||||
<key>SUPublicEDKey</key>
|
||||
|
|
|
@ -198,6 +198,7 @@ set(SOURCES
|
|||
settings/settingspage.cpp
|
||||
settings/behavioursettingspage.cpp
|
||||
settings/collectionsettingspage.cpp
|
||||
settings/collectionsettingsdirectorymodel.cpp
|
||||
settings/backendsettingspage.cpp
|
||||
settings/playlistsettingspage.cpp
|
||||
settings/scrobblersettingspage.cpp
|
||||
|
@ -441,6 +442,7 @@ set(HEADERS
|
|||
settings/settingspage.h
|
||||
settings/behavioursettingspage.h
|
||||
settings/collectionsettingspage.h
|
||||
settings/collectionsettingsdirectorymodel.h
|
||||
settings/backendsettingspage.h
|
||||
settings/playlistsettingspage.h
|
||||
settings/scrobblersettingspage.h
|
||||
|
|
|
@ -108,7 +108,7 @@ void SCollection::Init() {
|
|||
watcher_->set_task_manager(app_->task_manager());
|
||||
|
||||
QObject::connect(&*backend_, &CollectionBackend::Error, this, &SCollection::Error);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDiscovered, watcher_, &CollectionWatcher::AddDirectory);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryAdded, watcher_, &CollectionWatcher::AddDirectory);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDeleted, watcher_, &CollectionWatcher::RemoveDirectory);
|
||||
QObject::connect(&*backend_, &CollectionBackend::SongsRatingChanged, this, &SCollection::SongsRatingChanged);
|
||||
QObject::connect(&*backend_, &CollectionBackend::SongsStatisticsChanged, this, &SCollection::SongsPlaycountChanged);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QDateTime>
|
||||
#include <QRegularExpression>
|
||||
|
@ -162,7 +163,7 @@ void CollectionBackend::LoadDirectories() {
|
|||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
for (const CollectionDirectory &dir : dirs) {
|
||||
emit DirectoryDiscovered(dir, SubdirsInDirectory(dir.id, db));
|
||||
emit DirectoryAdded(dir, SubdirsInDirectory(dir.id, db));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -334,38 +335,56 @@ void CollectionBackend::UpdateTotalAlbumCount() {
|
|||
|
||||
}
|
||||
|
||||
void CollectionBackend::AddDirectory(const QString &path) {
|
||||
void CollectionBackend::AddDirectoryAsync(const QString &path) {
|
||||
QMetaObject::invokeMethod(this, "AddDirectory", Qt::QueuedConnection, Q_ARG(QString, path));
|
||||
}
|
||||
|
||||
QString canonical_path = QFileInfo(path).canonicalFilePath();
|
||||
QString db_path = canonical_path;
|
||||
void CollectionBackend::AddDirectory(const QString &path) {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
{
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("SELECT ROWID FROM %1 WHERE path = :path").arg(dirs_table_));
|
||||
q.BindValue(QStringLiteral(":path"), path);
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return;
|
||||
}
|
||||
if (q.next()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("INSERT INTO %1 (path, subdirs) VALUES (:path, 1)").arg(dirs_table_));
|
||||
q.BindValue(QStringLiteral(":path"), db_path);
|
||||
q.BindValue(QStringLiteral(":path"), path);
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return;
|
||||
}
|
||||
|
||||
CollectionDirectory dir;
|
||||
dir.path = canonical_path;
|
||||
dir.path = path;
|
||||
dir.id = q.lastInsertId().toInt();
|
||||
|
||||
emit DirectoryDiscovered(dir, CollectionSubdirectoryList());
|
||||
emit DirectoryAdded(dir, CollectionSubdirectoryList());
|
||||
|
||||
}
|
||||
|
||||
void CollectionBackend::RemoveDirectoryAsync(const CollectionDirectory &dir) {
|
||||
QMetaObject::invokeMethod(this, "RemoveDirectory", Qt::QueuedConnection, Q_ARG(CollectionDirectory, dir));
|
||||
}
|
||||
|
||||
void CollectionBackend::RemoveDirectory(const CollectionDirectory &dir) {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
// Remove songs first
|
||||
DeleteSongs(FindSongsInDirectory(dir.id));
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
ScopedTransaction transaction(&db);
|
||||
|
||||
// Delete the subdirs that were in this directory
|
||||
|
@ -390,10 +409,10 @@ void CollectionBackend::RemoveDirectory(const CollectionDirectory &dir) {
|
|||
}
|
||||
}
|
||||
|
||||
emit DirectoryDeleted(dir);
|
||||
|
||||
transaction.Commit();
|
||||
|
||||
emit DirectoryDeleted(dir);
|
||||
|
||||
}
|
||||
|
||||
SongList CollectionBackend::FindSongsInDirectory(const int id) {
|
||||
|
@ -470,7 +489,7 @@ void CollectionBackend::SongPathChanged(const Song &song, const QFileInfo &new_f
|
|||
// Take a song and update its path
|
||||
Song updated_song = song;
|
||||
updated_song.set_source(source_);
|
||||
updated_song.set_url(QUrl::fromLocalFile(new_file.absoluteFilePath()));
|
||||
updated_song.set_url(QUrl::fromLocalFile(QDir::cleanPath(new_file.filePath())));
|
||||
updated_song.set_basefilename(new_file.fileName());
|
||||
updated_song.InitArtManual();
|
||||
if (updated_song.is_collection_song() && new_collection_directory_id) {
|
||||
|
|
|
@ -132,8 +132,8 @@ class CollectionBackendInterface : public QObject {
|
|||
virtual Song GetSongByUrl(const QUrl &url, const qint64 beginning = 0) = 0;
|
||||
virtual Song GetSongByUrlAndTrack(const QUrl &url, const int track) = 0;
|
||||
|
||||
virtual void AddDirectory(const QString &path) = 0;
|
||||
virtual void RemoveDirectory(const CollectionDirectory &dir) = 0;
|
||||
virtual void AddDirectoryAsync(const QString &path) = 0;
|
||||
virtual void RemoveDirectoryAsync(const CollectionDirectory &dir) = 0;
|
||||
};
|
||||
|
||||
class CollectionBackend : public CollectionBackendInterface {
|
||||
|
@ -206,8 +206,8 @@ class CollectionBackend : public CollectionBackendInterface {
|
|||
Song GetSongByUrl(const QUrl &url, qint64 beginning = 0) override;
|
||||
Song GetSongByUrlAndTrack(const QUrl &url, const int track) override;
|
||||
|
||||
void AddDirectory(const QString &path) override;
|
||||
void RemoveDirectory(const CollectionDirectory &dir) override;
|
||||
void AddDirectoryAsync(const QString &path) override;
|
||||
void RemoveDirectoryAsync(const CollectionDirectory &dir) override;
|
||||
|
||||
bool ExecCollectionQuery(CollectionQuery *query, SongList &songs);
|
||||
bool ExecCollectionQuery(CollectionQuery *query, SongMap &songs);
|
||||
|
@ -239,6 +239,8 @@ class CollectionBackend : public CollectionBackendInterface {
|
|||
void UpdateTotalSongCount();
|
||||
void UpdateTotalArtistCount();
|
||||
void UpdateTotalAlbumCount();
|
||||
void AddDirectory(const QString &path);
|
||||
void RemoveDirectory(const CollectionDirectory &dir);
|
||||
void AddOrUpdateSongs(const SongList &songs);
|
||||
void UpdateSongsBySongID(const SongMap &new_songs);
|
||||
void UpdateMTimesOnly(const SongList &songs);
|
||||
|
@ -270,7 +272,7 @@ class CollectionBackend : public CollectionBackendInterface {
|
|||
void ExpireSongs(const int directory_id, const int expire_unavailable_songs_days);
|
||||
|
||||
signals:
|
||||
void DirectoryDiscovered(const CollectionDirectory &dir, const CollectionSubdirectoryList &subdir);
|
||||
void DirectoryAdded(const CollectionDirectory &dir, const CollectionSubdirectoryList &subdir);
|
||||
void DirectoryDeleted(const CollectionDirectory &dir);
|
||||
|
||||
void SongsDiscovered(const SongList &songs);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, 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
|
||||
|
@ -44,12 +45,15 @@ CollectionDirectoryModel::CollectionDirectoryModel(SharedPtr<CollectionBackend>
|
|||
dir_icon_(IconLoader::Load(QStringLiteral("document-open-folder"))),
|
||||
backend_(backend) {
|
||||
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDiscovered, this, &CollectionDirectoryModel::DirectoryDiscovered);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDeleted, this, &CollectionDirectoryModel::DirectoryDeleted);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryAdded, this, &CollectionDirectoryModel::AddDirectory);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDeleted, this, &CollectionDirectoryModel::RemoveDirectory);
|
||||
|
||||
}
|
||||
|
||||
void CollectionDirectoryModel::DirectoryDiscovered(const CollectionDirectory &dir) {
|
||||
void CollectionDirectoryModel::AddDirectory(const CollectionDirectory &dir) {
|
||||
|
||||
directories_.insert(dir.id, dir);
|
||||
paths_.append(dir.path);
|
||||
|
||||
QStandardItem *item = new QStandardItem(dir.path);
|
||||
item->setData(dir.id, kIdRole);
|
||||
|
@ -59,7 +63,10 @@ void CollectionDirectoryModel::DirectoryDiscovered(const CollectionDirectory &di
|
|||
|
||||
}
|
||||
|
||||
void CollectionDirectoryModel::DirectoryDeleted(const CollectionDirectory &dir) {
|
||||
void CollectionDirectoryModel::RemoveDirectory(const CollectionDirectory &dir) {
|
||||
|
||||
directories_.remove(dir.id);
|
||||
paths_.removeAll(dir.path);
|
||||
|
||||
for (int i = 0; i < rowCount(); ++i) {
|
||||
if (item(i, 0)->data(kIdRole).toInt() == dir.id) {
|
||||
|
@ -71,26 +78,6 @@ void CollectionDirectoryModel::DirectoryDeleted(const CollectionDirectory &dir)
|
|||
|
||||
}
|
||||
|
||||
void CollectionDirectoryModel::AddDirectory(const QString &path) {
|
||||
|
||||
if (!backend_) return;
|
||||
|
||||
backend_->AddDirectory(path);
|
||||
|
||||
}
|
||||
|
||||
void CollectionDirectoryModel::RemoveDirectory(const QModelIndex &idx) {
|
||||
|
||||
if (!backend_ || !idx.isValid()) return;
|
||||
|
||||
CollectionDirectory dir;
|
||||
dir.path = idx.data().toString();
|
||||
dir.id = idx.data(kIdRole).toInt();
|
||||
|
||||
backend_->RemoveDirectory(dir);
|
||||
|
||||
}
|
||||
|
||||
QVariant CollectionDirectoryModel::data(const QModelIndex &idx, int role) const {
|
||||
|
||||
switch (role) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, 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
|
||||
|
@ -26,15 +27,17 @@
|
|||
#include <QObject>
|
||||
#include <QStandardItemModel>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QIcon>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "collectiondirectory.h"
|
||||
|
||||
class QModelIndex;
|
||||
|
||||
struct CollectionDirectory;
|
||||
class CollectionBackend;
|
||||
class MusicStorage;
|
||||
|
||||
|
@ -44,22 +47,24 @@ class CollectionDirectoryModel : public QStandardItemModel {
|
|||
public:
|
||||
explicit CollectionDirectoryModel(SharedPtr<CollectionBackend> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
// To be called by GUIs
|
||||
void AddDirectory(const QString &path);
|
||||
void RemoveDirectory(const QModelIndex &idx);
|
||||
|
||||
QVariant data(const QModelIndex &idx, int role) const override;
|
||||
|
||||
SharedPtr<CollectionBackend> backend() const { return backend_; }
|
||||
|
||||
QMap<int, CollectionDirectory> directories() const { return directories_; }
|
||||
QStringList paths() const { return paths_; }
|
||||
|
||||
private slots:
|
||||
// To be called by the backend
|
||||
void DirectoryDiscovered(const CollectionDirectory &directories);
|
||||
void DirectoryDeleted(const CollectionDirectory &directories);
|
||||
void AddDirectory(const CollectionDirectory &directory);
|
||||
void RemoveDirectory(const CollectionDirectory &directory);
|
||||
|
||||
private:
|
||||
static const int kIdRole = Qt::UserRole + 1;
|
||||
|
||||
QIcon dir_icon_;
|
||||
SharedPtr<CollectionBackend> backend_;
|
||||
QMap<int, CollectionDirectory> directories_;
|
||||
QStringList paths_;
|
||||
QList<SharedPtr<MusicStorage>> storage_;
|
||||
};
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <QIODevice>
|
||||
#include <QDataStream>
|
||||
#include <QBuffer>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QByteArray>
|
||||
|
@ -364,7 +365,7 @@ bool CommandlineOptions::Parse() {
|
|||
const QString value = DecodeName(argv_[i]);
|
||||
QFileInfo fileinfo(value);
|
||||
if (fileinfo.exists()) {
|
||||
urls_ << QUrl::fromLocalFile(fileinfo.canonicalFilePath());
|
||||
urls_ << QUrl::fromLocalFile(QDir::cleanPath(fileinfo.filePath()));
|
||||
}
|
||||
else {
|
||||
urls_ << QUrl::fromUserInput(value);
|
||||
|
|
|
@ -2298,18 +2298,18 @@ void MainWindow::AddFile() {
|
|||
PlaylistParser parser(app_->collection_backend());
|
||||
|
||||
// Show dialog
|
||||
QStringList file_names = QFileDialog::getOpenFileNames(this, tr("Add file"), directory, QStringLiteral("%1 (%2);;%3;;%4").arg(tr("Music"), QLatin1String(FileView::kFileFilter), parser.filters(PlaylistParser::Type::Load), tr(kAllFilesFilterSpec)));
|
||||
QStringList filenames = QFileDialog::getOpenFileNames(this, tr("Add file"), directory, QStringLiteral("%1 (%2);;%3;;%4").arg(tr("Music"), QLatin1String(FileView::kFileFilter), parser.filters(PlaylistParser::Type::Load), tr(kAllFilesFilterSpec)));
|
||||
|
||||
if (file_names.isEmpty()) return;
|
||||
if (filenames.isEmpty()) return;
|
||||
|
||||
// Save last used directory
|
||||
settings_.setValue("add_media_path", file_names[0]);
|
||||
settings_.setValue("add_media_path", filenames[0]);
|
||||
|
||||
// Convert to URLs
|
||||
QList<QUrl> urls;
|
||||
urls.reserve(file_names.count());
|
||||
for (const QString &path : file_names) {
|
||||
urls << QUrl::fromLocalFile(QFileInfo(path).canonicalFilePath());
|
||||
urls.reserve(filenames.count());
|
||||
for (const QString &path : filenames) {
|
||||
urls << QUrl::fromLocalFile(QDir::cleanPath(path));
|
||||
}
|
||||
|
||||
MimeData *mimedata = new MimeData;
|
||||
|
@ -2332,7 +2332,7 @@ void MainWindow::AddFolder() {
|
|||
|
||||
// Add media
|
||||
MimeData *mimedata = new MimeData;
|
||||
mimedata->setUrls(QList<QUrl>() << QUrl::fromLocalFile(QFileInfo(directory).canonicalFilePath()));
|
||||
mimedata->setUrls(QList<QUrl>() << QUrl::fromLocalFile(QDir::cleanPath(directory)));
|
||||
AddToPlaylist(mimedata);
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ FilesystemDevice::FilesystemDevice(const QUrl &url, DeviceLister *lister, const
|
|||
watcher_->set_backend(backend_);
|
||||
watcher_->set_task_manager(app_->task_manager());
|
||||
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDiscovered, watcher_, &CollectionWatcher::AddDirectory);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryAdded, watcher_, &CollectionWatcher::AddDirectory);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDeleted, watcher_, &CollectionWatcher::RemoveDirectory);
|
||||
QObject::connect(watcher_, &CollectionWatcher::NewOrUpdatedSongs, &*backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsMTimeUpdated, &*backend_, &CollectionBackend::UpdateMTimesOnly);
|
||||
|
|
|
@ -114,7 +114,7 @@ void Equalizer::ReloadSettings() {
|
|||
|
||||
// Selected preset
|
||||
QString selected_preset = s.value("selected_preset", QStringLiteral("Custom")).toString();
|
||||
QString selected_preset_display_name = tr(qPrintable(selected_preset));
|
||||
QString selected_preset_display_name = tr(qUtf8Printable(selected_preset));
|
||||
int selected_index = ui_->preset->findText(selected_preset_display_name);
|
||||
if (selected_index != -1) ui_->preset->setCurrentIndex(selected_index);
|
||||
|
||||
|
@ -160,7 +160,7 @@ void Equalizer::LoadDefaultPresets() {
|
|||
|
||||
void Equalizer::AddPreset(const QString &name, const Params ¶ms) {
|
||||
|
||||
QString name_displayed = tr(qPrintable(name));
|
||||
QString name_displayed = tr(qUtf8Printable(name));
|
||||
presets_[name] = params;
|
||||
|
||||
if (ui_->preset->findText(name_displayed) == -1) {
|
||||
|
@ -201,14 +201,14 @@ void Equalizer::SavePreset() {
|
|||
QString name = SaveCurrentPreset();
|
||||
if (!name.isEmpty()) {
|
||||
last_preset_ = name;
|
||||
ui_->preset->setCurrentIndex(ui_->preset->findText(tr(qPrintable(name))));
|
||||
ui_->preset->setCurrentIndex(ui_->preset->findText(tr(qUtf8Printable(name))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString Equalizer::SaveCurrentPreset() {
|
||||
|
||||
QString name = QInputDialog::getText(this, tr("Save preset"), tr("Name"), QLineEdit::Normal, tr(qPrintable(last_preset_)));
|
||||
QString name = QInputDialog::getText(this, tr("Save preset"), tr("Name"), QLineEdit::Normal, tr(qUtf8Printable(last_preset_)));
|
||||
if (name.isEmpty()) {
|
||||
return QString();
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ void MoodbarLoader::RequestFinished(MoodbarPipeline *request, const QUrl &url) {
|
|||
disk_cache_metadata.setSaveToDisk(true);
|
||||
disk_cache_metadata.setUrl(CacheUrlEntry(filename));
|
||||
// Qt 6 now ignores any entry without headers, so add a fake header.
|
||||
disk_cache_metadata.setRawHeaders(QNetworkCacheMetaData::RawHeaderList() << qMakePair(QByteArray(), QByteArray()));
|
||||
disk_cache_metadata.setRawHeaders(QNetworkCacheMetaData::RawHeaderList() << qMakePair(QByteArray("moodbar"), QByteArray("moodbar")));
|
||||
|
||||
QIODevice *device_cache_file = cache_->prepare(disk_cache_metadata);
|
||||
if (device_cache_file) {
|
||||
|
|
|
@ -63,23 +63,10 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
|
|||
}
|
||||
}
|
||||
|
||||
// Strawberry always wants / separators internally.
|
||||
// Using QDir::fromNativeSeparators() only works on the same platform the playlist was created on/for, using replace() lets playlists work on any platform.
|
||||
filename = filename.replace(QLatin1Char('\\'), QLatin1Char('/'));
|
||||
|
||||
// Make the path absolute
|
||||
if (!QDir::isAbsolutePath(filename)) {
|
||||
filename = dir.absoluteFilePath(filename);
|
||||
}
|
||||
|
||||
// Use the canonical path
|
||||
if (QFile::exists(filename)) {
|
||||
filename = QFileInfo(filename).canonicalFilePath();
|
||||
}
|
||||
|
||||
filename = QDir::cleanPath(filename);
|
||||
const QUrl url = QUrl::fromLocalFile(filename);
|
||||
|
||||
// Search in the collection
|
||||
// Search the collection
|
||||
if (collection_backend_ && collection_search) {
|
||||
Song collection_song;
|
||||
if (track > 0) {
|
||||
|
@ -88,6 +75,19 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
|
|||
if (!collection_song.is_valid()) {
|
||||
collection_song = collection_backend_->GetSongByUrl(url, beginning);
|
||||
}
|
||||
// Try absolute path
|
||||
if (!collection_song.is_valid() && !QDir::isAbsolutePath(filename)) {
|
||||
QString absolute_filename = dir.absoluteFilePath(filename);
|
||||
if (absolute_filename != filename) {
|
||||
const QUrl absolute_url = QUrl::fromLocalFile(absolute_filename);
|
||||
if (track > 0) {
|
||||
collection_song = collection_backend_->GetSongByUrlAndTrack(absolute_url, track);
|
||||
}
|
||||
if (!collection_song.is_valid()) {
|
||||
collection_song = collection_backend_->GetSongByUrl(absolute_url, beginning);
|
||||
}
|
||||
}
|
||||
}
|
||||
// If it was found in the collection then use it, otherwise load metadata from disk.
|
||||
if (collection_song.is_valid()) {
|
||||
*song = collection_song;
|
||||
|
|
|
@ -63,7 +63,6 @@ class ParserBase : public QObject {
|
|||
|
||||
protected:
|
||||
// Loads a song. If filename_or_url is a URL (with a scheme other than "file") then it is set on the song and the song marked as a stream.
|
||||
// If it is a filename or a file:// URL then it is made absolute and canonical and set as a file:// url on the song.
|
||||
// Also sets the song's metadata by searching in the Collection, or loading from the file as a fallback.
|
||||
// This function should always be used when loading a playlist.
|
||||
Song LoadSong(const QString &filename_or_url, const qint64 beginning, const int track, const QDir &dir, const bool collection_search) const;
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, 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 "config.h"
|
||||
|
||||
#include <QStandardItemModel>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "core/iconloader.h"
|
||||
#include "collectionsettingsdirectorymodel.h"
|
||||
|
||||
CollectionSettingsDirectoryModel::CollectionSettingsDirectoryModel(QObject *parent)
|
||||
: QStandardItemModel(parent),
|
||||
dir_icon_(IconLoader::Load(QStringLiteral("document-open-folder"))) {}
|
||||
|
||||
void CollectionSettingsDirectoryModel::AddDirectory(const QString &path) {
|
||||
|
||||
QStandardItem *item = new QStandardItem(path);
|
||||
item->setIcon(dir_icon_);
|
||||
appendRow(item);
|
||||
|
||||
paths_ << path;
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsDirectoryModel::AddDirectories(const QStringList &paths) {
|
||||
|
||||
for (const QString &path : paths) {
|
||||
AddDirectory(path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsDirectoryModel::RemoveDirectory(const QModelIndex &idx) {
|
||||
|
||||
if (!idx.isValid()) return;
|
||||
|
||||
const QString path = data(idx).toString();
|
||||
|
||||
removeRow(idx.row());
|
||||
|
||||
if (paths_.contains(path)) {
|
||||
paths_.removeAll(path);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef COLLECTIONSETTINGSDIRECTORYMODEL_H
|
||||
#define COLLECTIONSETTINGSDIRECTORYMODEL_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QStandardItemModel>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QIcon>
|
||||
|
||||
class CollectionSettingsDirectoryModel : public QStandardItemModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CollectionSettingsDirectoryModel(QObject *parent = nullptr);
|
||||
|
||||
void AddDirectory(const QString &path);
|
||||
void AddDirectories(const QStringList &paths);
|
||||
void RemoveDirectory(const QModelIndex &idx);
|
||||
|
||||
QStringList paths() const { return paths_; }
|
||||
|
||||
private:
|
||||
QIcon dir_icon_;
|
||||
QStringList paths_;
|
||||
};
|
||||
|
||||
#endif // COLLECTIONSETTINGSDIRECTORYMODEL_H
|
|
@ -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-2024, 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
|
||||
|
@ -28,6 +28,7 @@
|
|||
#include <QItemSelectionModel>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QCheckBox>
|
||||
#include <QLineEdit>
|
||||
|
@ -47,9 +48,12 @@
|
|||
#include "utilities/strutils.h"
|
||||
#include "utilities/timeutils.h"
|
||||
#include "collection/collection.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "collection/collectiondirectory.h"
|
||||
#include "collection/collectiondirectorymodel.h"
|
||||
#include "collectionsettingspage.h"
|
||||
#include "collectionsettingsdirectorymodel.h"
|
||||
#include "playlist/playlistdelegates.h"
|
||||
#include "settings/settingsdialog.h"
|
||||
#include "settings/settingspage.h"
|
||||
|
@ -67,6 +71,9 @@ const int CollectionSettingsPage::kSettingsDiskCacheSizeDefault = 360;
|
|||
CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui_CollectionSettingsPage),
|
||||
collection_backend_(dialog->app()->collection_backend()),
|
||||
collectionsettings_directory_model_(new CollectionSettingsDirectoryModel(this)),
|
||||
collection_directory_model_(dialog->collection_directory_model()),
|
||||
initialized_model_(false) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
|
@ -74,7 +81,7 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog, QWidget *
|
|||
|
||||
// Icons
|
||||
setWindowIcon(IconLoader::Load(QStringLiteral("library-music"), true, 0, 32));
|
||||
ui_->add->setIcon(IconLoader::Load(QStringLiteral("document-open-folder")));
|
||||
ui_->add_directory->setIcon(IconLoader::Load(QStringLiteral("document-open-folder")));
|
||||
|
||||
ui_->combobox_cache_size->addItem(QStringLiteral("KB"), static_cast<int>(CacheSizeUnit::KB));
|
||||
ui_->combobox_cache_size->addItem(QStringLiteral("MB"), static_cast<int>(CacheSizeUnit::MB));
|
||||
|
@ -83,8 +90,8 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog, QWidget *
|
|||
ui_->combobox_disk_cache_size->addItem(QStringLiteral("MB"), static_cast<int>(CacheSizeUnit::MB));
|
||||
ui_->combobox_disk_cache_size->addItem(QStringLiteral("GB"), static_cast<int>(CacheSizeUnit::GB));
|
||||
|
||||
QObject::connect(ui_->add, &QPushButton::clicked, this, &CollectionSettingsPage::Add);
|
||||
QObject::connect(ui_->remove, &QPushButton::clicked, this, &CollectionSettingsPage::Remove);
|
||||
QObject::connect(ui_->add_directory, &QPushButton::clicked, this, &CollectionSettingsPage::AddDirectory);
|
||||
QObject::connect(ui_->remove_directory, &QPushButton::clicked, this, &CollectionSettingsPage::RemoveDirectory);
|
||||
|
||||
#ifdef HAVE_SONGFINGERPRINTING
|
||||
QObject::connect(ui_->song_tracking, &QCheckBox::toggled, this, &CollectionSettingsPage::SongTrackingToggled);
|
||||
|
@ -111,56 +118,6 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog, QWidget *
|
|||
|
||||
CollectionSettingsPage::~CollectionSettingsPage() { delete ui_; }
|
||||
|
||||
void CollectionSettingsPage::Add() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
QString path(s.value("last_path", QStandardPaths::writableLocation(QStandardPaths::MusicLocation)).toString());
|
||||
path = QFileDialog::getExistingDirectory(this, tr("Add directory..."), path);
|
||||
|
||||
if (!path.isEmpty()) {
|
||||
dialog()->collection_directory_model()->AddDirectory(path);
|
||||
}
|
||||
|
||||
s.setValue("last_path", path);
|
||||
|
||||
set_changed();
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::Remove() {
|
||||
|
||||
dialog()->collection_directory_model()->RemoveDirectory(ui_->list->currentIndex());
|
||||
set_changed();
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::CurrentRowChanged(const QModelIndex &idx) {
|
||||
ui_->remove->setEnabled(idx.isValid());
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::SongTrackingToggled() {
|
||||
|
||||
ui_->mark_songs_unavailable->setEnabled(!ui_->song_tracking->isChecked());
|
||||
if (ui_->song_tracking->isChecked()) {
|
||||
ui_->mark_songs_unavailable->setChecked(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::DiskCacheEnable(const int state) {
|
||||
|
||||
bool checked = state == Qt::Checked;
|
||||
ui_->label_disk_cache_size->setEnabled(checked);
|
||||
ui_->spinbox_disk_cache_size->setEnabled(checked);
|
||||
ui_->combobox_disk_cache_size->setEnabled(checked);
|
||||
ui_->label_disk_cache_in_use->setEnabled(checked);
|
||||
ui_->disk_cache_in_use->setEnabled(checked);
|
||||
ui_->button_clear_disk_cache->setEnabled(checked);
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::Load() {
|
||||
|
||||
if (!initialized_model_) {
|
||||
|
@ -168,12 +125,17 @@ void CollectionSettingsPage::Load() {
|
|||
QObject::disconnect(ui_->list->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &CollectionSettingsPage::CurrentRowChanged);
|
||||
}
|
||||
|
||||
ui_->list->setModel(dialog()->collection_directory_model());
|
||||
ui_->list->setModel(collectionsettings_directory_model_);
|
||||
initialized_model_ = true;
|
||||
|
||||
QObject::connect(ui_->list->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &CollectionSettingsPage::CurrentRowChanged);
|
||||
}
|
||||
|
||||
ui_->list->model()->removeRows(0, ui_->list->model()->rowCount());
|
||||
for (const QString &path : collection_directory_model_->paths()) {
|
||||
collectionsettings_directory_model_->AddDirectory(path);
|
||||
}
|
||||
|
||||
Settings s;
|
||||
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
@ -261,6 +223,69 @@ void CollectionSettingsPage::Save() {
|
|||
|
||||
s.endGroup();
|
||||
|
||||
for (const CollectionDirectory &dir : collection_directory_model_->directories()) {
|
||||
if (!collectionsettings_directory_model_->paths().contains(dir.path)) {
|
||||
collection_backend_->RemoveDirectoryAsync(dir);
|
||||
}
|
||||
}
|
||||
|
||||
for (const QString &path : collectionsettings_directory_model_->paths()) {
|
||||
if (!collection_directory_model_->paths().contains(path)) {
|
||||
collection_backend_->AddDirectoryAsync(path);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::AddDirectory() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
QString path = s.value("last_path", QStandardPaths::writableLocation(QStandardPaths::MusicLocation)).toString();
|
||||
path = QDir::cleanPath(QFileDialog::getExistingDirectory(this, tr("Add directory..."), path));
|
||||
|
||||
if (!path.isEmpty()) {
|
||||
collectionsettings_directory_model_->AddDirectory(path);
|
||||
}
|
||||
|
||||
s.setValue("last_path", path);
|
||||
|
||||
set_changed();
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::RemoveDirectory() {
|
||||
|
||||
collectionsettings_directory_model_->RemoveDirectory(ui_->list->currentIndex());
|
||||
|
||||
set_changed();
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::CurrentRowChanged(const QModelIndex &idx) {
|
||||
ui_->remove_directory->setEnabled(idx.isValid());
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::SongTrackingToggled() {
|
||||
|
||||
ui_->mark_songs_unavailable->setEnabled(!ui_->song_tracking->isChecked());
|
||||
if (ui_->song_tracking->isChecked()) {
|
||||
ui_->mark_songs_unavailable->setChecked(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::DiskCacheEnable(const int state) {
|
||||
|
||||
bool checked = state == Qt::Checked;
|
||||
ui_->label_disk_cache_size->setEnabled(checked);
|
||||
ui_->spinbox_disk_cache_size->setEnabled(checked);
|
||||
ui_->combobox_disk_cache_size->setEnabled(checked);
|
||||
ui_->label_disk_cache_in_use->setEnabled(checked);
|
||||
ui_->disk_cache_in_use->setEnabled(checked);
|
||||
ui_->button_clear_disk_cache->setEnabled(checked);
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::ClearPixmapDiskCache() {
|
||||
|
|
|
@ -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-2024, 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
|
||||
|
@ -30,8 +30,13 @@
|
|||
|
||||
#include "settingspage.h"
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
|
||||
class QModelIndex;
|
||||
class SettingsDialog;
|
||||
class CollectionBackend;
|
||||
class CollectionDirectoryModel;
|
||||
class CollectionSettingsDirectoryModel;
|
||||
class Ui_CollectionSettingsPage;
|
||||
|
||||
class CollectionSettingsPage : public SettingsPage {
|
||||
|
@ -61,8 +66,8 @@ class CollectionSettingsPage : public SettingsPage {
|
|||
void Save() override;
|
||||
|
||||
private slots:
|
||||
void Add();
|
||||
void Remove();
|
||||
void AddDirectory();
|
||||
void RemoveDirectory();
|
||||
|
||||
void CurrentRowChanged(const QModelIndex &idx);
|
||||
void SongTrackingToggled();
|
||||
|
@ -74,6 +79,9 @@ class CollectionSettingsPage : public SettingsPage {
|
|||
|
||||
private:
|
||||
Ui_CollectionSettingsPage *ui_;
|
||||
SharedPtr<CollectionBackend> collection_backend_;
|
||||
CollectionSettingsDirectoryModel *collectionsettings_directory_model_;
|
||||
CollectionDirectoryModel *collection_directory_model_;
|
||||
bool initialized_model_;
|
||||
};
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>519</width>
|
||||
<height>920</height>
|
||||
<width>565</width>
|
||||
<height>973</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -39,7 +39,7 @@
|
|||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_collection_folder_buttons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="add">
|
||||
<widget class="QPushButton" name="add_directory">
|
||||
<property name="text">
|
||||
<string>Add new folder...</string>
|
||||
</property>
|
||||
|
@ -49,7 +49,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="remove">
|
||||
<widget class="QPushButton" name="remove_directory">
|
||||
<property name="text">
|
||||
<string>Remove folder</string>
|
||||
</property>
|
||||
|
@ -58,7 +58,7 @@
|
|||
<item>
|
||||
<spacer name="spacer_collection_buttons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
@ -167,7 +167,7 @@
|
|||
<item>
|
||||
<spacer name="spacer_expire_unavailable_songs">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
@ -288,7 +288,7 @@ If there are no matches then it will use the largest image in the directory.</st
|
|||
<item row="0" column="4">
|
||||
<spacer name="spacer_cache_size">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
@ -312,7 +312,7 @@ If there are no matches then it will use the largest image in the directory.</st
|
|||
<item>
|
||||
<spacer name="spacer_disk_cache">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
@ -371,7 +371,7 @@ If there are no matches then it will use the largest image in the directory.</st
|
|||
<item row="0" column="4">
|
||||
<spacer name="spacer_disk_cache_size">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
@ -415,7 +415,7 @@ If there are no matches then it will use the largest image in the directory.</st
|
|||
<item>
|
||||
<spacer name="spacer_disk_cache_in_use">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
@ -476,7 +476,7 @@ If there are no matches then it will use the largest image in the directory.</st
|
|||
<item>
|
||||
<spacer name="spacer_save_stats">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
@ -502,8 +502,8 @@ If there are no matches then it will use the largest image in the directory.</st
|
|||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>list</tabstop>
|
||||
<tabstop>add</tabstop>
|
||||
<tabstop>remove</tabstop>
|
||||
<tabstop>add_directory</tabstop>
|
||||
<tabstop>remove_directory</tabstop>
|
||||
<tabstop>startup_scan</tabstop>
|
||||
<tabstop>monitor</tabstop>
|
||||
<tabstop>song_tracking</tabstop>
|
||||
|
|
|
@ -160,7 +160,7 @@ void SmartPlaylistsModel::Init() {
|
|||
void SmartPlaylistsModel::ItemFromSmartPlaylist(const Settings &s, const bool notify) {
|
||||
|
||||
SmartPlaylistsItem *item = new SmartPlaylistsItem(SmartPlaylistsItem::Type_SmartPlaylist, notify ? nullptr : root_);
|
||||
item->display_text = tr(qPrintable(s.value("name").toString()));
|
||||
item->display_text = tr(qUtf8Printable(s.value("name").toString()));
|
||||
item->sort_text = item->display_text;
|
||||
item->smart_playlist_type = PlaylistGenerator::Type(s.value("type").toInt());
|
||||
item->smart_playlist_data = s.value("data").toByteArray();
|
||||
|
|
|
@ -72,7 +72,7 @@ QList<QUrl> FileViewList::UrlListFromSelection() const {
|
|||
const QModelIndexList indexes = menu_selection_.indexes();
|
||||
for (const QModelIndex &index : indexes) {
|
||||
if (index.column() == 0) {
|
||||
filenames << qobject_cast<QFileSystemModel*>(model())->fileInfo(index).canonicalFilePath();
|
||||
filenames << QDir::cleanPath(qobject_cast<QFileSystemModel*>(model())->fileInfo(index).filePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,14 +78,14 @@ TEST_F(CollectionBackendTest, EmptyDatabase) {
|
|||
|
||||
TEST_F(CollectionBackendTest, AddDirectory) {
|
||||
|
||||
QSignalSpy spy(&*backend_, &CollectionBackend::DirectoryDiscovered);
|
||||
QSignalSpy spy(&*backend_, &CollectionBackend::DirectoryAdded);
|
||||
|
||||
backend_->AddDirectory(QStringLiteral("/tmp"));
|
||||
|
||||
// Check the signal was emitted correctly
|
||||
ASSERT_EQ(1, spy.count());
|
||||
CollectionDirectory dir = spy[0][0].value<CollectionDirectory>();
|
||||
EXPECT_EQ(QFileInfo(QStringLiteral("/tmp")).canonicalFilePath(), dir.path);
|
||||
EXPECT_EQ(QStringLiteral("/tmp"), dir.path);
|
||||
EXPECT_EQ(1, dir.id);
|
||||
EXPECT_EQ(0, spy[0][1].value<CollectionSubdirectoryList>().size());
|
||||
|
||||
|
|
Loading…
Reference in New Issue