Compare commits
37 Commits
dca6baa6b4
...
0d3889b59d
Author | SHA1 | Date |
---|---|---|
Poldi | 0d3889b59d | |
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 | |
Jonas Kvinge | 315cf63118 | |
Poldi | 992a16769a | |
Poldi | 6c8be50fbb | |
Poldi | 84ac6f7915 | |
Poldi | 4785e5fe2e | |
Poldi | c00a3433eb | |
Poldi | 809027f26d | |
Poldi | 711316c5db | |
Poldi | 7cebff9a03 | |
Poldi | 59e6714edc | |
Poldi | 2315da7858 | |
Poldi | fe7e4635a6 | |
Poldi | d4fb61d644 | |
Poldi | 09847eeffd | |
Poldi | 5376ed6a34 | |
Poldi | 33a34010db | |
Poldi | 1e313f529a | |
Poldi | fcb11f0405 | |
Poldi | b38d20a3a7 | |
Poldi | 8a087afdc6 | |
Poldi | d4f6ff208e | |
Poldi | 2ea822d33c | |
Poldi | d8c2f1afe4 | |
Poldi | 4cb917dc2a | |
Poldi | 181623406e |
|
@ -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 }}
|
||||
|
@ -985,7 +985,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [ 'i686', 'x86_64' ]
|
||||
arch: [ 'x86_64' ]
|
||||
buildtype: [ 'debug', 'release' ]
|
||||
container:
|
||||
image: jonaski/strawberry-mxe-${{matrix.arch}}-${{matrix.buildtype}}
|
||||
|
@ -1156,8 +1156,8 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [ 'x86', 'x86_64' ]
|
||||
buildtype: [ 'debug', 'release' ]
|
||||
arch: [ 'x86_64' ]
|
||||
buildtype: [ 'release' ]
|
||||
steps:
|
||||
|
||||
- name: Set prefix path
|
||||
|
|
|
@ -525,6 +525,7 @@ add_subdirectory(dist)
|
|||
add_subdirectory(ext/libstrawberry-common)
|
||||
add_subdirectory(ext/libstrawberry-tagreader)
|
||||
add_subdirectory(ext/strawberry-tagreader)
|
||||
add_subdirectory(src/networkremote)
|
||||
if(HAVE_MOODBAR)
|
||||
add_subdirectory(ext/gstmoodbar)
|
||||
endif()
|
||||
|
|
|
@ -501,5 +501,6 @@
|
|||
<file>icons/22x22/somafm.png</file>
|
||||
<file>icons/22x22/radioparadise.png</file>
|
||||
<file>icons/22x22/musicbrainz.png</file>
|
||||
<file>icons/32x32/network-remote.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
|
@ -0,0 +1,64 @@
|
|||
Source: strawberry
|
||||
Section: sound
|
||||
Priority: optional
|
||||
Maintainer: Jonas Kvinge <jonas@jkvinge.net>
|
||||
Build-Depends: debhelper (>= 11),
|
||||
git,
|
||||
make,
|
||||
cmake,
|
||||
gcc,
|
||||
g++,
|
||||
protobuf-compiler,
|
||||
libglib2.0-dev,
|
||||
libdbus-1-dev,
|
||||
libprotobuf-dev,
|
||||
libboost-dev,
|
||||
libsqlite3-dev,
|
||||
libasound2-dev,
|
||||
libpulse-dev,
|
||||
libtag1-dev,
|
||||
libicu-dev,
|
||||
qt6-base-dev,qt6-base-dev-tools,qt6-tools-dev,qt6-tools-dev-tools,qt6-l10n-tools,
|
||||
libgstreamer1.0-dev,
|
||||
libgstreamer-plugins-base1.0-dev,
|
||||
libcdio-dev,
|
||||
libgpod-dev,
|
||||
libmtp-dev,
|
||||
libchromaprint-dev,
|
||||
libfftw3-dev,
|
||||
libebur128-dev
|
||||
Standards-Version: 4.6.1
|
||||
|
||||
Package: strawberry
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libqt6sql6-sqlite,qt6-qpa-plugins,
|
||||
gstreamer1.0-plugins-base,
|
||||
gstreamer1.0-plugins-good,
|
||||
gstreamer1.0-alsa,
|
||||
gstreamer1.0-pulseaudio
|
||||
Homepage: http://www.strawberrymusicplayer.org/
|
||||
Description: music player and music collection organizer
|
||||
Strawberry is a music player aimed at music collectors and audiophiles.
|
||||
.
|
||||
Features:
|
||||
- Play and organize music
|
||||
- Supports WAV, FLAC, WavPack, Ogg Vorbis, Speex, MPC, TrueAudio, AIFF, MP4, MP3 and ASF
|
||||
- Audio CD playback
|
||||
- Native desktop notifications
|
||||
- Playlist management and playlists in multiple formats
|
||||
- Smart and dynamic playlists
|
||||
- Advanced audio output and device configuration for bit-perfect playback on Linux
|
||||
- Edit tags on audio files
|
||||
- Automatically retrieve tags from MusicBrainz
|
||||
- Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal, Qobuz and Spotify
|
||||
- Song lyrics from Genius, Musixmatch, ChartLyrics, lyrics.ovh, lololyrics.com, songlyrics.com, azlyrics.com, elyrics.net and lyricsmode.com
|
||||
- Audio analyzer
|
||||
- Audio equalizer
|
||||
- Transfer music to mass-storage USB players, MTP compatible devices and iPod Nano/Classic
|
||||
- Scrobbler with support for Last.fm, Libre.fm and ListenBrainz
|
||||
- Streaming support for Subsonic-compatible servers
|
||||
- Unofficial streaming support for Tidal and Qobuz
|
||||
.
|
||||
It is a fork of Clementine. The name is inspired by the band Strawbs.
|
|
@ -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
|
||||
|
@ -207,6 +208,7 @@ set(SOURCES
|
|||
settings/appearancesettingspage.cpp
|
||||
settings/contextsettingspage.cpp
|
||||
settings/notificationssettingspage.cpp
|
||||
settings/networkremotesettingspage.cpp
|
||||
|
||||
dialogs/about.cpp
|
||||
dialogs/console.cpp
|
||||
|
@ -293,6 +295,13 @@ set(SOURCES
|
|||
organize/organizedialog.cpp
|
||||
organize/organizeerrordialog.cpp
|
||||
|
||||
networkremote/networkremote.cpp
|
||||
networkremote/tcpserver.cpp
|
||||
networkremote/remotesettings.cpp
|
||||
networkremote/client.cpp
|
||||
networkremote/clientmanager.cpp
|
||||
networkremote/incomingmsg.cpp
|
||||
networkremote/outgoingmsg.cpp
|
||||
)
|
||||
|
||||
set(HEADERS
|
||||
|
@ -441,6 +450,7 @@ set(HEADERS
|
|||
settings/settingspage.h
|
||||
settings/behavioursettingspage.h
|
||||
settings/collectionsettingspage.h
|
||||
settings/collectionsettingsdirectorymodel.h
|
||||
settings/backendsettingspage.h
|
||||
settings/playlistsettingspage.h
|
||||
settings/scrobblersettingspage.h
|
||||
|
@ -450,6 +460,7 @@ set(HEADERS
|
|||
settings/appearancesettingspage.h
|
||||
settings/contextsettingspage.h
|
||||
settings/notificationssettingspage.h
|
||||
settings/networkremotesettingspage.h
|
||||
|
||||
dialogs/about.h
|
||||
dialogs/errordialog.h
|
||||
|
@ -532,6 +543,13 @@ set(HEADERS
|
|||
organize/organizedialog.h
|
||||
organize/organizeerrordialog.h
|
||||
|
||||
networkremote/networkremote.h
|
||||
networkremote/tcpserver.h
|
||||
networkremote/remotesettings.h
|
||||
networkremote/client.h
|
||||
networkremote/clientmanager.h
|
||||
networkremote/incomingmsg.h
|
||||
networkremote/outgoingmsg.h
|
||||
)
|
||||
|
||||
set(UI
|
||||
|
@ -576,6 +594,7 @@ set(UI
|
|||
settings/networkproxysettingspage.ui
|
||||
settings/appearancesettingspage.ui
|
||||
settings/notificationssettingspage.ui
|
||||
settings/networkremotesettingspage.ui
|
||||
|
||||
equalizer/equalizer.ui
|
||||
equalizer/equalizerslider.ui
|
||||
|
@ -1116,6 +1135,7 @@ target_link_libraries(strawberry_lib PUBLIC
|
|||
${SINGLEAPPLICATION_LIBRARIES}
|
||||
libstrawberry-common
|
||||
libstrawberry-tagreader
|
||||
lib-networkremote
|
||||
)
|
||||
|
||||
if(HAVE_DBUS)
|
||||
|
|
|
@ -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_;
|
||||
};
|
||||
|
||||
|
|
|
@ -103,6 +103,8 @@
|
|||
#include "radios/radioservices.h"
|
||||
#include "radios/radiobackend.h"
|
||||
|
||||
#include "networkremote/networkremote.h"
|
||||
|
||||
using std::make_shared;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
@ -203,8 +205,13 @@ class ApplicationImpl {
|
|||
moodbar_loader_([app]() { return new MoodbarLoader(app); }),
|
||||
moodbar_controller_([app]() { return new MoodbarController(app); }),
|
||||
#endif
|
||||
lastfm_import_([app]() { return new LastFMImport(app->network()); })
|
||||
{}
|
||||
lastfm_import_([app]() { return new LastFMImport(app->network()); }),
|
||||
network_remote_([app]() {
|
||||
NetworkRemote *remote = new NetworkRemote(app);
|
||||
app->MoveToNewThread(remote);
|
||||
return remote;
|
||||
})
|
||||
{}
|
||||
|
||||
Lazy<TagReaderClient> tag_reader_client_;
|
||||
Lazy<Database> database_;
|
||||
|
@ -230,6 +237,7 @@ class ApplicationImpl {
|
|||
Lazy<MoodbarController> moodbar_controller_;
|
||||
#endif
|
||||
Lazy<LastFMImport> lastfm_import_;
|
||||
Lazy<NetworkRemote> network_remote_;
|
||||
|
||||
};
|
||||
|
||||
|
@ -239,6 +247,7 @@ Application::Application(QObject *parent)
|
|||
device_finders()->Init();
|
||||
collection()->Init();
|
||||
tag_reader_client();
|
||||
network_remote()->Init();
|
||||
|
||||
QObject::connect(&*database(), &Database::Error, this, &Application::ErrorAdded);
|
||||
|
||||
|
@ -288,7 +297,8 @@ void Application::Exit() {
|
|||
<< &*device_manager()
|
||||
#endif
|
||||
<< &*internet_services()
|
||||
<< &*radio_services()->radio_backend();
|
||||
<< &*radio_services()->radio_backend()
|
||||
<< &*network_remote();
|
||||
|
||||
QObject::connect(&*tag_reader_client(), &TagReaderClient::ExitFinished, this, &Application::ExitReceived);
|
||||
tag_reader_client()->ExitAsync();
|
||||
|
@ -357,7 +367,9 @@ SharedPtr<InternetServices> Application::internet_services() const { return p_->
|
|||
SharedPtr<RadioServices> Application::radio_services() const { return p_->radio_services_.ptr(); }
|
||||
SharedPtr<AudioScrobbler> Application::scrobbler() const { return p_->scrobbler_.ptr(); }
|
||||
SharedPtr<LastFMImport> Application::lastfm_import() const { return p_->lastfm_import_.ptr(); }
|
||||
SharedPtr<NetworkRemote> Application::network_remote() const { return p_->network_remote_.ptr();}
|
||||
#ifdef HAVE_MOODBAR
|
||||
SharedPtr<MoodbarController> Application::moodbar_controller() const { return p_->moodbar_controller_.ptr(); }
|
||||
SharedPtr<MoodbarLoader> Application::moodbar_loader() const { return p_->moodbar_loader_.ptr(); }
|
||||
|
||||
#endif
|
||||
|
|
|
@ -65,6 +65,8 @@ class MoodbarController;
|
|||
class MoodbarLoader;
|
||||
#endif
|
||||
|
||||
class NetworkRemote;
|
||||
|
||||
class Application : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -107,6 +109,8 @@ class Application : public QObject {
|
|||
|
||||
SharedPtr<LastFMImport> lastfm_import() const;
|
||||
|
||||
SharedPtr<NetworkRemote> network_remote() const;
|
||||
|
||||
void Exit();
|
||||
|
||||
QThread *MoveToNewThread(QObject *object);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
set(SOURCES RemoteMessages.proto)
|
||||
|
||||
link_directories(
|
||||
${GLIB_LIBRARY_DIRS}
|
||||
${PROTOBUF_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
add_library(lib-networkremote OBJECT ${PROTO_SOURCES} ${SOURCES})
|
||||
|
||||
target_include_directories(lib-networkremote SYSTEM PRIVATE
|
||||
${GLIB_INCLUDE_DIRS}
|
||||
${PROTOBUF_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_include_directories(lib-networkremote PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_BINARY_DIR}/src
|
||||
)
|
||||
|
||||
target_link_libraries(lib-networkremote PRIVATE
|
||||
${GLIB_LIBRARIES}
|
||||
${Protobuf_LIBRARIES}
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Network
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
)
|
||||
|
||||
protobuf_generate(TARGET lib-networkremote)
|
|
@ -0,0 +1,131 @@
|
|||
syntax = "proto3";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
package nw.remote;
|
||||
|
||||
enum MsgType {
|
||||
MSG_TYPE_UNSPECIFIED = 0;
|
||||
|
||||
// Client message
|
||||
MSG_TYPE_REQUEST_SONG_INFO = 1;
|
||||
MSG_TYPE_REQUEST_PLAY = 2;
|
||||
MSG_TYPE_REQUEST_NEXT = 3;
|
||||
MSG_TYPE_REQUEST_PREVIOUS = 4;
|
||||
MSG_TYPE_REQUEST_PAUSE = 5;
|
||||
MSG_TYPE_REQUEST_STOP = 6;
|
||||
MSG_TYPE_REQUEST_FINISH = 7;
|
||||
|
||||
|
||||
// Server messages
|
||||
MSG_TYPE_REPLY_SONG_INFO = 8;
|
||||
MSG_TYPE_REPLY_PLAY = 9;
|
||||
MSG_TYPE_REPLY_NEXT = 10;
|
||||
MSG_TYPE_REPLY_PREVIOUS = 11;
|
||||
MSG_TYPE_REPLY_PAUSE = 12;
|
||||
MSG_TYPE_REPLY_STOP = 13;
|
||||
MSG_TYPE_REPLY_FINISH = 14;
|
||||
MSG_TYPE_ENGINE_STATE_CHANGE = 15;
|
||||
|
||||
// Bidirectional messages
|
||||
MSG_TYPE_DISCONNECT = 16;
|
||||
}
|
||||
|
||||
enum PlayerState{
|
||||
PLAYER_STATUS_UNSPECIFIED = 0;
|
||||
PLAYER_STATUS_PLAYING = 1;
|
||||
}
|
||||
|
||||
enum EngineState {
|
||||
ENGINE_STATE_EMPTY = 0;
|
||||
ENGINE_STATE_IDELE = 1;
|
||||
ENGINE_STATE_PLAYING = 2;
|
||||
ENGINE_STATE_PAUSED = 3;
|
||||
}
|
||||
|
||||
enum ReasonDisconnect {
|
||||
REASON_DISCONNECT_SERVER_SHUTDOWN = 0;
|
||||
REASON_DISCONNECT_CLIENT_SHUTDOWN = 1;
|
||||
}
|
||||
|
||||
message RequestDisconnect {
|
||||
ReasonDisconnect reason_disconnect = 1;
|
||||
}
|
||||
|
||||
message SongMetadata{
|
||||
uint32 id = 1;
|
||||
string title = 2;
|
||||
string album = 3;
|
||||
string artist = 4;
|
||||
string albumartist = 5;
|
||||
uint32 track = 6;
|
||||
string stryear = 7;
|
||||
string genre = 8;
|
||||
uint32 playcount = 9;
|
||||
string songlength = 10;
|
||||
}
|
||||
message RequestSongMetadata {
|
||||
bool send = 1;
|
||||
}
|
||||
|
||||
message ResponseSongMetadata {
|
||||
SongMetadata song_metadata = 1;
|
||||
PlayerState player_state = 2;
|
||||
}
|
||||
|
||||
message RequestNextTrack {
|
||||
bool next = 1;
|
||||
}
|
||||
|
||||
message ResponseNextTrack {
|
||||
bool next = 1;
|
||||
}
|
||||
|
||||
message RequestPreviousTrack {
|
||||
bool previous = 1;
|
||||
}
|
||||
|
||||
message ResponsePreviousTrack {
|
||||
bool previous = 1;
|
||||
}
|
||||
|
||||
message RequestPlay {
|
||||
bool play = 1;
|
||||
}
|
||||
|
||||
message ResponsePlay {
|
||||
bool play = 1;
|
||||
}
|
||||
|
||||
message RequestPause {
|
||||
bool pause = 1;
|
||||
}
|
||||
|
||||
message ResponsePause {
|
||||
bool pause = 1;
|
||||
}
|
||||
|
||||
message RequestStop {
|
||||
bool stop = 1;
|
||||
}
|
||||
|
||||
message EngineStateChange {
|
||||
EngineState state = 1;
|
||||
}
|
||||
message Message {
|
||||
MsgType type = 1;
|
||||
RequestSongMetadata request_song_metadata = 2;
|
||||
ResponseSongMetadata response_song_metadata = 3;
|
||||
RequestNextTrack request_next_track = 4;
|
||||
RequestPreviousTrack request_previous_track = 5;
|
||||
RequestPlay request_play = 6;
|
||||
RequestPause request_pause = 7;
|
||||
RequestStop request_stop = 8;
|
||||
EngineStateChange engine_state_change = 9;
|
||||
RequestDisconnect request_disconnect = 10;
|
||||
ResponseNextTrack response_next_track = 11;
|
||||
ResponsePreviousTrack response_previous_track = 12;
|
||||
ResponsePlay response_play = 13;
|
||||
ResponsePause response_pause = 14;
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
#include "client.h"
|
||||
|
||||
Client::Client(Application *app, QObject *parent)
|
||||
: QObject{parent},
|
||||
app_(app),
|
||||
incomingMsg_(new IncomingMsg(app)),
|
||||
outgoingMsg_(new OutgoingMsg(app)),
|
||||
player_(app_->player())
|
||||
{
|
||||
}
|
||||
|
||||
Client::~Client()
|
||||
{
|
||||
incomingMsg_->deleteLater();
|
||||
outgoingMsg_->deleteLater();
|
||||
}
|
||||
|
||||
void Client::Init(QTcpSocket *socket)
|
||||
{
|
||||
socket_ = socket;
|
||||
QObject::connect(incomingMsg_,&IncomingMsg::InMsgParsed,this, &Client::ProcessIncoming);
|
||||
|
||||
incomingMsg_->Init(socket_);
|
||||
outgoingMsg_->Init(socket_, player_);
|
||||
}
|
||||
|
||||
QTcpSocket* Client::GetSocket()
|
||||
{
|
||||
return socket_;
|
||||
}
|
||||
|
||||
void Client::ProcessIncoming()
|
||||
{
|
||||
msgType_ = incomingMsg_->GetMsgType();
|
||||
switch (msgType_)
|
||||
{
|
||||
case nw::remote::MSG_TYPE_REQUEST_SONG_INFO:
|
||||
outgoingMsg_->SendCurrentTrackInfo();
|
||||
break;
|
||||
case nw::remote::MSG_TYPE_REQUEST_PLAY:
|
||||
player_->Play();
|
||||
// In case the player was paused when the client started send the song info again
|
||||
outgoingMsg_->SendCurrentTrackInfo();
|
||||
break;
|
||||
case nw::remote::MSG_TYPE_REQUEST_NEXT:
|
||||
player_->Next();
|
||||
outgoingMsg_->SendCurrentTrackInfo();
|
||||
break;
|
||||
case nw::remote::MSG_TYPE_REQUEST_PREVIOUS:
|
||||
player_->Previous();
|
||||
outgoingMsg_->SendCurrentTrackInfo();
|
||||
break;
|
||||
case nw::remote::MSG_TYPE_REQUEST_PAUSE:
|
||||
player_->Pause();
|
||||
break;
|
||||
case nw::remote::MSG_TYPE_REQUEST_STOP:
|
||||
break;
|
||||
case nw::remote::MSG_TYPE_REQUEST_FINISH:
|
||||
emit ClientIsLeaving();
|
||||
break;
|
||||
case nw::remote::MSG_TYPE_DISCONNECT:
|
||||
break;
|
||||
default:
|
||||
qInfo("Unknown mwessage type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef CLIENT_H
|
||||
#define CLIENT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTcpSocket>
|
||||
|
||||
#include "incomingmsg.h"
|
||||
#include "outgoingmsg.h"
|
||||
#include "core/player.h"
|
||||
|
||||
|
||||
class Application;
|
||||
|
||||
class Client : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Client(Application *app, QObject *parent = nullptr);
|
||||
~Client();
|
||||
void Init(QTcpSocket*);
|
||||
QTcpSocket* GetSocket();
|
||||
void ProcessIncoming();
|
||||
|
||||
signals:
|
||||
void ReceiveMsg();
|
||||
void PrepareResponse();
|
||||
void ClientIsLeaving();
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
QTcpSocket *socket_;
|
||||
IncomingMsg *incomingMsg_;
|
||||
OutgoingMsg *outgoingMsg_;
|
||||
qint32 msgType_;
|
||||
SharedPtr<Player> player_;
|
||||
};
|
||||
|
||||
#endif // CLIENT_H
|
|
@ -0,0 +1,74 @@
|
|||
#include "clientmanager.h"
|
||||
#include "core/application.h"
|
||||
#include "core/logging.h"
|
||||
|
||||
|
||||
ClientManager::ClientManager(Application *app, QObject *parent)
|
||||
: QObject{parent},
|
||||
app_(app)
|
||||
{
|
||||
clients_ = new QVector<Client*>;
|
||||
}
|
||||
|
||||
ClientManager::~ClientManager()
|
||||
{}
|
||||
|
||||
void ClientManager::AddClient(QTcpSocket *socket)
|
||||
{
|
||||
qLog(Debug) << "New Client connection +++++++++++++++";
|
||||
socket_ = socket;
|
||||
QObject::connect(socket_, &QAbstractSocket::errorOccurred, this, &ClientManager::Error);
|
||||
QObject::connect(socket_, &QAbstractSocket::stateChanged, this, &ClientManager::StateChanged);
|
||||
|
||||
client_ = new Client(app_);
|
||||
client_->Init(socket_);
|
||||
clients_->append(client_);
|
||||
QObject::connect(client_, &Client::ClientIsLeaving, this, &ClientManager::RemoveClient);
|
||||
|
||||
qLog(Debug) << "Socket State is " << socket_->state();;
|
||||
qLog(Debug) << "There are now +++++++++++++++" << clients_->count() << "clients connected";
|
||||
}
|
||||
|
||||
void ClientManager::RemoveClient()
|
||||
{
|
||||
for (Client* client : *clients_) {
|
||||
if (client->GetSocket() == socket_){
|
||||
clients_->removeAt(clients_->indexOf(client));
|
||||
client->deleteLater();
|
||||
}
|
||||
}
|
||||
socket_->close();
|
||||
|
||||
qLog(Debug) << "There are now +++++++++++++++" << clients_->count() << "clients connected";
|
||||
}
|
||||
|
||||
void ClientManager::Ready()
|
||||
{
|
||||
qLog(Debug) << "Socket Ready";
|
||||
}
|
||||
|
||||
void ClientManager::Error(QAbstractSocket::SocketError socketError)
|
||||
{
|
||||
switch (socketError) {
|
||||
case QAbstractSocket::RemoteHostClosedError:
|
||||
qLog(Debug) << "Remote Host closed";
|
||||
break;
|
||||
case QAbstractSocket::HostNotFoundError:
|
||||
qLog(Debug) << "The host was not found. Please check the host name and port settings.";
|
||||
break;
|
||||
case QAbstractSocket::ConnectionRefusedError:
|
||||
qLog(Debug) << "The connection was refused by the peer. ";
|
||||
break;
|
||||
default:
|
||||
qLog(Debug) << "The following error occurred: %1." << socket_->errorString();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientManager::StateChanged()
|
||||
{
|
||||
qLog(Debug) << socket_->state();
|
||||
qLog(Debug) << "State Changed";
|
||||
if (socket_->state() == QAbstractSocket::UnconnectedState){
|
||||
RemoveClient();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef CLIENTMANAGER_H
|
||||
#define CLIENTMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTcpSocket>
|
||||
#include <QVector>
|
||||
#include "networkremote/client.h"
|
||||
|
||||
class Application;
|
||||
|
||||
class ClientManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ClientManager(Application *app, QObject *parent = nullptr);
|
||||
~ClientManager();
|
||||
void AddClient(QTcpSocket *socket);
|
||||
void RemoveClient();
|
||||
|
||||
private slots:
|
||||
void Ready();
|
||||
void Error(QAbstractSocket::SocketError);
|
||||
void StateChanged();
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
QVector<Client*> *clients_;
|
||||
Client *client_ = nullptr;
|
||||
QTcpSocket *socket_ = nullptr;
|
||||
};
|
||||
|
||||
#endif // CLIENTMANAGER_H
|
|
@ -0,0 +1,35 @@
|
|||
#include "incomingmsg.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/player.h"
|
||||
|
||||
IncomingMsg::IncomingMsg(Application *app, QObject *parent)
|
||||
: QObject{parent},
|
||||
msg_(new nw::remote::Message),
|
||||
app_(app)
|
||||
{
|
||||
}
|
||||
|
||||
void IncomingMsg::Init(QTcpSocket *socket)
|
||||
{
|
||||
socket_ = socket;
|
||||
QObject::connect(socket_, &QIODevice::readyRead, this, &IncomingMsg::ReadyRead);
|
||||
}
|
||||
|
||||
void IncomingMsg::SetMsgType()
|
||||
{
|
||||
msgString_ = msgStream_.toStdString();
|
||||
msg_->ParseFromString(msgString_);
|
||||
emit InMsgParsed();
|
||||
}
|
||||
|
||||
qint32 IncomingMsg::GetMsgType()
|
||||
{
|
||||
return msg_->type();
|
||||
}
|
||||
|
||||
void IncomingMsg::ReadyRead()
|
||||
{
|
||||
qLog(Debug) << "Ready To Read";
|
||||
msgStream_ = socket_->readAll();
|
||||
if (msgStream_.length() > 0) SetMsgType();
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef INCOMINGMSG_H
|
||||
#define INCOMINGMSG_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTcpSocket>
|
||||
#include "networkremote/RemoteMessages.pb.h"
|
||||
#include "core/application.h"
|
||||
|
||||
class IncomingMsg : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IncomingMsg(Application *app, QObject *parent = nullptr);
|
||||
void Init(QTcpSocket*);
|
||||
void SetMsgType();
|
||||
qint32 GetMsgType();
|
||||
|
||||
private slots:
|
||||
void ReadyRead();
|
||||
|
||||
signals:
|
||||
void InMsgParsed();
|
||||
|
||||
private:
|
||||
nw::remote::Message *msg_;
|
||||
QTcpSocket *socket_;
|
||||
long bytesIn_;
|
||||
QByteArray msgStream_;
|
||||
std::string msgString_;
|
||||
Application *app_;
|
||||
qint32 msgType_;
|
||||
};
|
||||
|
||||
#endif // INCOMINGMSG_H
|
|
@ -0,0 +1,84 @@
|
|||
#include <QThread>
|
||||
|
||||
#include "networkremote/networkremote.h"
|
||||
#include "core/application.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/player.h"
|
||||
|
||||
|
||||
NetworkRemote* NetworkRemote::sInstance = nullptr;
|
||||
const char *NetworkRemote::kSettingsGroup = "Remote";
|
||||
|
||||
NetworkRemote::NetworkRemote(Application* app, QObject *parent)
|
||||
: QObject(parent),
|
||||
app_(app),
|
||||
original_thread_(nullptr)
|
||||
{
|
||||
setObjectName("Strawberry Remote");
|
||||
original_thread_ = thread();
|
||||
sInstance = this;
|
||||
server_ = new TcpServer(app_);
|
||||
}
|
||||
|
||||
NetworkRemote::~NetworkRemote()
|
||||
{
|
||||
stopTcpServer();
|
||||
}
|
||||
|
||||
void NetworkRemote::Init()
|
||||
{
|
||||
LoadSettings();
|
||||
if (use_remote_){
|
||||
startTcpServer();
|
||||
}
|
||||
else {
|
||||
stopTcpServer();
|
||||
}
|
||||
qLog(Debug) << "NetworkRemote Init() ";
|
||||
}
|
||||
|
||||
void NetworkRemote::Update()
|
||||
{
|
||||
LoadSettings();
|
||||
if (use_remote_){
|
||||
stopTcpServer();
|
||||
startTcpServer();
|
||||
}
|
||||
else {
|
||||
stopTcpServer();
|
||||
}
|
||||
qLog(Debug) << "NetworkRemote Updated ==== ";
|
||||
}
|
||||
|
||||
void NetworkRemote::LoadSettings()
|
||||
{
|
||||
s_->Load();
|
||||
use_remote_ = s_->UserRemote();
|
||||
local_only_ = s_->LocalOnly();
|
||||
remote_port_ = s_->GetPort();
|
||||
ipAddr_.setAddress(s_->GetIpAddress());
|
||||
}
|
||||
|
||||
void NetworkRemote::startTcpServer()
|
||||
{
|
||||
server_->StartServer(ipAddr_,remote_port_);
|
||||
}
|
||||
|
||||
void NetworkRemote::stopTcpServer()
|
||||
{
|
||||
if (server_->ServerUp()){
|
||||
qLog(Debug) << "TcpServer stopped ";
|
||||
server_->StopServer();
|
||||
}
|
||||
}
|
||||
|
||||
NetworkRemote* NetworkRemote::Instance() {
|
||||
if (!sInstance) {
|
||||
// Error
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
qLog(Debug) << "NetworkRemote instance is up ";
|
||||
return sInstance;
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef NETWORKREMOTE_H
|
||||
#define NETWORKREMOTE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
#include <QHostAddress>
|
||||
#include <QSettings>
|
||||
|
||||
#include "tcpserver.h"
|
||||
#include "networkremote/remotesettings.h"
|
||||
|
||||
class Application;
|
||||
class QThread;
|
||||
|
||||
class NetworkRemote : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const char* kSettingsGroup;
|
||||
explicit NetworkRemote(Application* app, QObject *parent = nullptr);
|
||||
static NetworkRemote* Instance();
|
||||
~NetworkRemote() override;
|
||||
|
||||
public slots:
|
||||
void Init();
|
||||
void Update();
|
||||
void LoadSettings();
|
||||
void startTcpServer();
|
||||
void stopTcpServer();
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
bool use_remote_;
|
||||
bool local_only_;
|
||||
int remote_port_;
|
||||
QHostAddress ipAddr_;
|
||||
TcpServer *server_;
|
||||
QThread *original_thread_;
|
||||
static NetworkRemote* sInstance;
|
||||
RemoteSettings *s_ = new RemoteSettings;
|
||||
|
||||
};
|
||||
|
||||
#endif // NETWORKREMOTE_H
|
|
@ -0,0 +1,85 @@
|
|||
#include "outgoingmsg.h"
|
||||
#include "core/player.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
|
||||
OutgoingMsg::OutgoingMsg(Application *app, QObject *parent)
|
||||
: QObject{parent},
|
||||
app_(app),
|
||||
msg_(new nw::remote::Message),
|
||||
responeSong_(new nw::remote::ResponseSongMetadata)
|
||||
{
|
||||
}
|
||||
|
||||
OutgoingMsg::~OutgoingMsg()
|
||||
{
|
||||
}
|
||||
|
||||
void OutgoingMsg::Init(QTcpSocket *socket, SharedPtr<Player> player)
|
||||
{
|
||||
socket_ = socket;
|
||||
player_ = player;
|
||||
}
|
||||
|
||||
|
||||
void OutgoingMsg::SendCurrentTrackInfo()
|
||||
{
|
||||
msg_->Clear();
|
||||
song_ = new nw::remote::SongMetadata;
|
||||
responeSong_->Clear();
|
||||
|
||||
//PlaylistItemPtr current_item() const;
|
||||
currentItem_ = app_->playlist_manager()->active()->current_item();
|
||||
|
||||
//PlaylistItemPtr prt = player_->GetCurrentItem();
|
||||
|
||||
|
||||
//if (playerState_ == EngineBase::State::Playing){
|
||||
if (currentItem_ != NULL){
|
||||
song_->mutable_title()->assign(currentItem_->Metadata().PrettyTitle().toStdString());
|
||||
song_->mutable_album()->assign(currentItem_->Metadata().album().toStdString());
|
||||
song_->mutable_artist()->assign(currentItem_->Metadata().artist().toStdString());
|
||||
song_->mutable_albumartist()->assign(currentItem_->Metadata().albumartist().toStdString());
|
||||
song_->set_track(currentItem_->Metadata().track());
|
||||
song_->mutable_stryear()->assign(currentItem_->Metadata().PrettyYear().toStdString());
|
||||
song_->mutable_genre()->assign(currentItem_->Metadata().genre().toStdString());
|
||||
song_->set_playcount(currentItem_->Metadata().playcount());
|
||||
song_->mutable_songlength()->assign(currentItem_->Metadata().PrettyLength().toStdString());
|
||||
|
||||
msg_->set_type(nw::remote::MSG_TYPE_REPLY_SONG_INFO);
|
||||
msg_->mutable_response_song_metadata()->set_player_state(nw::remote::PLAYER_STATUS_PLAYING);
|
||||
msg_->mutable_response_song_metadata()->set_allocated_song_metadata(song_);
|
||||
}
|
||||
else {
|
||||
/* NOTE: TODO
|
||||
* I couldn't figure out how to get the song data if the song wasn't playing
|
||||
*
|
||||
* */
|
||||
msg_->set_type(nw::remote::MSG_TYPE_UNSPECIFIED);
|
||||
msg_->mutable_response_song_metadata()->set_player_state(nw::remote::PLAYER_STATUS_UNSPECIFIED);
|
||||
}
|
||||
SendMsg();
|
||||
}
|
||||
|
||||
void OutgoingMsg::SendMsg()
|
||||
{
|
||||
std::string msgOut;
|
||||
|
||||
msg_->SerializeToString(&msgOut);
|
||||
|
||||
|
||||
bytesOut_ = msg_->ByteSizeLong();
|
||||
|
||||
if(socket_->isWritable())
|
||||
{
|
||||
|
||||
socket_->write(QByteArray::fromStdString(msgOut));
|
||||
qInfo() << socket_->bytesToWrite() << " bytes written to socket " << socket_->socketDescriptor();
|
||||
statusOk_ = true;
|
||||
msg_->Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
statusOk_ = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef OUTGOINGMSG_H
|
||||
#define OUTGOINGMSG_H
|
||||
|
||||
#include <QObject>
|
||||
#include "core/application.h"
|
||||
#include "playlist/playlist.h"
|
||||
#include "playlist/playlistitem.h"
|
||||
#include "qtcpsocket.h"
|
||||
#include "networkremote/RemoteMessages.pb.h"
|
||||
|
||||
class OutgoingMsg : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit OutgoingMsg(Application *app, QObject *parent = nullptr);
|
||||
~OutgoingMsg();
|
||||
void Init(QTcpSocket*, SharedPtr<Player>);
|
||||
void SendCurrentTrackInfo();
|
||||
void SendMsg();
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
PlaylistItemPtr currentItem_;
|
||||
Playlist *playlist_;
|
||||
QTcpSocket *socket_;
|
||||
qint32 msgType_;
|
||||
QByteArray msgStream_;
|
||||
nw::remote::Message *msg_;
|
||||
long bytesOut_;
|
||||
std::string msgString_;
|
||||
nw::remote::SongMetadata *song_;
|
||||
nw::remote::ResponseSongMetadata *responeSong_;
|
||||
SharedPtr<Player> player_ ;
|
||||
bool statusOk_;
|
||||
|
||||
};
|
||||
|
||||
#endif // OUTGOINGMSG_H
|
|
@ -0,0 +1,102 @@
|
|||
#include <QHostAddress>
|
||||
#include <QNetworkInterface>
|
||||
|
||||
#include "remotesettings.h"
|
||||
#include "core/logging.h"
|
||||
|
||||
const char *RemoteSettings::kSettingsGroup = "NetworkRemote";
|
||||
|
||||
RemoteSettings::RemoteSettings(QObject *parent)
|
||||
: QObject{parent}
|
||||
{}
|
||||
|
||||
RemoteSettings::~RemoteSettings()
|
||||
{}
|
||||
|
||||
void RemoteSettings::Load()
|
||||
{
|
||||
SetIpAdress();
|
||||
s_.beginGroup(RemoteSettings::kSettingsGroup);
|
||||
if (!s_.contains("useRemote")){
|
||||
qLog(Debug) << "First time run the Network Remote";
|
||||
s_.setValue("useRemote", false);
|
||||
s_.setValue("localOnly",false);
|
||||
s_.setValue("remotePort",5050);
|
||||
s_.setValue("ipAddress",ipAddr_);
|
||||
}
|
||||
else {
|
||||
use_remote_ = s_.value("useRemote").toBool();
|
||||
local_only_ = s_.value("localOnly").toBool();
|
||||
remote_port_ = s_.value("remotePort").toInt();
|
||||
s_.setValue("ipAddress",ipAddr_);
|
||||
}
|
||||
s_.endGroup();
|
||||
qInfo("QSettings Loaded ++++++++++++++++");
|
||||
}
|
||||
|
||||
void RemoteSettings::Save()
|
||||
{
|
||||
s_.beginGroup(RemoteSettings::kSettingsGroup);
|
||||
s_.setValue("useRemote",use_remote_);
|
||||
s_.setValue("localOnly",local_only_);
|
||||
s_.setValue("remotePort",remote_port_);
|
||||
s_.setValue("ipAddress",ipAddr_);
|
||||
s_.endGroup();
|
||||
s_.sync();
|
||||
qInfo("Saving QSettings ++++++++++++++++");
|
||||
}
|
||||
|
||||
bool RemoteSettings::UserRemote()
|
||||
{
|
||||
return use_remote_;
|
||||
}
|
||||
|
||||
bool RemoteSettings::LocalOnly()
|
||||
{
|
||||
return local_only_;
|
||||
}
|
||||
|
||||
QString RemoteSettings::GetIpAddress()
|
||||
{
|
||||
return ipAddr_;
|
||||
}
|
||||
|
||||
int RemoteSettings::GetPort()
|
||||
{
|
||||
return remote_port_;
|
||||
}
|
||||
|
||||
void RemoteSettings::SetUseRemote(bool useRemote)
|
||||
{
|
||||
use_remote_ = useRemote;
|
||||
Save();
|
||||
}
|
||||
|
||||
void RemoteSettings::SetLocalOnly(bool localOnly)
|
||||
{
|
||||
local_only_ = localOnly;
|
||||
Save();
|
||||
}
|
||||
|
||||
void RemoteSettings::SetIpAdress()
|
||||
{
|
||||
bool found = false;
|
||||
QList<QHostAddress> hostList = QNetworkInterface::allAddresses();
|
||||
|
||||
for (const QHostAddress &address : hostList)
|
||||
{
|
||||
if (address.protocol() == QAbstractSocket::IPv4Protocol && address.isLoopback() == false && !found){
|
||||
// NOTE: this code currently only takes the first ip address it finds
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
qInfo("Warning: The code only picks the first IPv4 address");
|
||||
found = true;
|
||||
ipAddr_ = address.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteSettings::SetPort(int port)
|
||||
{
|
||||
remote_port_ = port;
|
||||
Save();
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef REMOTESETTINGS_H
|
||||
#define REMOTESETTINGS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
|
||||
class RemoteSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const char *kSettingsGroup;
|
||||
explicit RemoteSettings(QObject *parent = nullptr);
|
||||
~RemoteSettings();
|
||||
void Load();
|
||||
void Save();
|
||||
bool UserRemote();
|
||||
bool LocalOnly();
|
||||
QString GetIpAddress();
|
||||
int GetPort();
|
||||
void SetUseRemote(bool);
|
||||
void SetLocalOnly(bool);
|
||||
void SetIpAdress ();
|
||||
void SetPort(int);
|
||||
|
||||
private:
|
||||
QSettings s_;
|
||||
bool use_remote_ = false;
|
||||
bool local_only_ = false;
|
||||
int remote_port_ = 5050;
|
||||
QString ipAddr_ = "0.0.0.0";
|
||||
};
|
||||
|
||||
#endif // REMOTESETTINGS_H
|
|
@ -0,0 +1,48 @@
|
|||
#include "tcpserver.h"
|
||||
#include "core/logging.h"
|
||||
#include "networkremote/clientmanager.h"
|
||||
#include <QNetworkProxy>
|
||||
|
||||
|
||||
TcpServer::TcpServer(Application* app, QObject *parent)
|
||||
: QObject{parent},
|
||||
app_(app)
|
||||
{
|
||||
server_ = new QTcpServer(this);
|
||||
clientMgr_ = new ClientManager(app_);
|
||||
connect(server_,&QTcpServer::newConnection, this, &TcpServer::NewTcpConnection);
|
||||
}
|
||||
|
||||
TcpServer::~TcpServer()
|
||||
{
|
||||
}
|
||||
|
||||
void TcpServer::StartServer(QHostAddress ipAddr, int port)
|
||||
{
|
||||
bool ok = false;
|
||||
server_->setProxy(QNetworkProxy::NoProxy);
|
||||
ok = server_->listen(ipAddr, port);
|
||||
if (ok){
|
||||
qLog(Debug) << "TCP Server Started on --- " << ipAddr.toString() << " and port -- " << port;
|
||||
}
|
||||
}
|
||||
|
||||
void TcpServer::NewTcpConnection()
|
||||
{
|
||||
socket_ = server_->nextPendingConnection();
|
||||
clientMgr_->AddClient(socket_);
|
||||
qLog(Debug) << "New Socket -------------------";
|
||||
}
|
||||
|
||||
void TcpServer::StopServer()
|
||||
{
|
||||
server_->close();
|
||||
qLog(Debug) << "TCP Server Stopped ----------------------";
|
||||
}
|
||||
|
||||
|
||||
bool TcpServer::ServerUp()
|
||||
{
|
||||
return server_->isListening();
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef TCPSERVER_H
|
||||
#define TCPSERVER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QHostAddress>
|
||||
#include <QNetworkInterface>
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
#include "networkremote/clientmanager.h"
|
||||
|
||||
class Application;
|
||||
|
||||
class TcpServer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
explicit TcpServer(Application* app, QObject *parent = nullptr);
|
||||
~TcpServer();
|
||||
|
||||
bool ServerUp();
|
||||
|
||||
public slots:
|
||||
void NewTcpConnection();
|
||||
void StartServer(QHostAddress ipAddr, int port);
|
||||
void StopServer();
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
QTcpServer *server_;
|
||||
QTcpSocket *socket_;
|
||||
ClientManager *clientMgr_;
|
||||
};
|
||||
|
||||
#endif // TCPSERVER_H
|
|
@ -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>
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
#include <QHostInfo>
|
||||
#include <QHostAddress>
|
||||
#include <QNetworkInterface>
|
||||
|
||||
#include "core/iconloader.h"
|
||||
#include "networkremote/networkremote.h"
|
||||
#include "settings/settingsdialog.h"
|
||||
#include "settings/networkremotesettingspage.h"
|
||||
#include "ui_networkremotesettingspage.h"
|
||||
|
||||
NetworkRemoteSettingsPage::NetworkRemoteSettingsPage(SettingsDialog *dialog, QWidget *parent) :
|
||||
SettingsPage(dialog,parent),
|
||||
ui_(new Ui_NetworkRemoteSettingsPage)
|
||||
{
|
||||
|
||||
ui_->setupUi(this);
|
||||
setWindowIcon(IconLoader::Load("network-remote", true, 0,32));
|
||||
QObject::connect(ui_->useRemoteClient,&QAbstractButton::clicked, this, &NetworkRemoteSettingsPage::RemoteButtonClicked);
|
||||
QObject::connect(ui_->localConnectionsOnly, &QAbstractButton::clicked, this, &NetworkRemoteSettingsPage::LocalConnectButtonClicked);
|
||||
QObject::connect(ui_->portSelected, &QAbstractSpinBox::editingFinished, this, &NetworkRemoteSettingsPage::PortChanged);
|
||||
}
|
||||
|
||||
NetworkRemoteSettingsPage::~NetworkRemoteSettingsPage()
|
||||
{
|
||||
delete ui_;
|
||||
}
|
||||
|
||||
void NetworkRemoteSettingsPage::Load()
|
||||
{
|
||||
ui_->portSelected->setRange(5050, 65535);
|
||||
ui_->ip_address->setText("0.0.0.0");
|
||||
s_->Load();
|
||||
|
||||
ui_->useRemoteClient->setCheckable(true);
|
||||
ui_->useRemoteClient->setChecked(s_->UserRemote());
|
||||
if (s_->UserRemote()){
|
||||
ui_->localConnectionsOnly->setCheckable(true);
|
||||
ui_->localConnectionsOnly->setChecked(s_->LocalOnly());
|
||||
ui_->portSelected->setReadOnly(false);
|
||||
ui_->portSelected->setValue(s_->GetPort());
|
||||
}
|
||||
else{
|
||||
ui_->localConnectionsOnly->setCheckable(false);
|
||||
ui_->portSelected->setReadOnly(true);
|
||||
}
|
||||
|
||||
DisplayIP();
|
||||
qInfo("SettingsPage Loaded QSettings ++++++++++++++++");
|
||||
|
||||
Init(ui_->layout_networkremotesettingspage->parentWidget());
|
||||
}
|
||||
|
||||
void NetworkRemoteSettingsPage::Save()
|
||||
{
|
||||
qInfo("Saving QSettings ++++++++++++++++");
|
||||
}
|
||||
|
||||
void NetworkRemoteSettingsPage::Refresh()
|
||||
{
|
||||
if (NetworkRemote::Instance()) {
|
||||
qInfo() << "NetworkRemote Instance is up";
|
||||
NetworkRemote::Instance()->Update();
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkRemoteSettingsPage::DisplayIP()
|
||||
{
|
||||
ui_->ip_address->setText(s_->GetIpAddress());
|
||||
}
|
||||
|
||||
void NetworkRemoteSettingsPage::RemoteButtonClicked()
|
||||
{
|
||||
s_->SetUseRemote(ui_->useRemoteClient->isChecked());
|
||||
ui_->useRemoteClient->setChecked(s_->UserRemote());
|
||||
if (ui_->useRemoteClient->isChecked()){
|
||||
ui_->localConnectionsOnly->setCheckable(true);
|
||||
ui_->portSelected->setReadOnly(false);
|
||||
}
|
||||
else{
|
||||
ui_->localConnectionsOnly->setCheckable(false);
|
||||
ui_->portSelected->setReadOnly(true);
|
||||
}
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
void NetworkRemoteSettingsPage::LocalConnectButtonClicked()
|
||||
{
|
||||
s_->SetLocalOnly(ui_->localConnectionsOnly->isChecked());
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void NetworkRemoteSettingsPage::PortChanged()
|
||||
{
|
||||
s_->SetPort(ui_->portSelected->value());
|
||||
Refresh();
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef NETWORKREMOTESETTINGSPAGE_H
|
||||
#define NETWORKREMOTESETTINGSPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
|
||||
#include "settingspage.h"
|
||||
#include "networkremote/remotesettings.h"
|
||||
|
||||
class SettingsDialog;
|
||||
class Ui_NetworkRemoteSettingsPage;
|
||||
class NetworkRemote;
|
||||
|
||||
class NetworkRemoteSettingsPage : public SettingsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NetworkRemoteSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
~NetworkRemoteSettingsPage() override;
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
void Refresh();
|
||||
|
||||
signals:
|
||||
void remoteSettingsChanged();
|
||||
|
||||
private:
|
||||
Ui_NetworkRemoteSettingsPage *ui_;
|
||||
RemoteSettings *s_ = new RemoteSettings;
|
||||
|
||||
private slots:
|
||||
void RemoteButtonClicked();
|
||||
void LocalConnectButtonClicked();
|
||||
void PortChanged();
|
||||
void DisplayIP();
|
||||
};
|
||||
|
||||
#endif // NETWORKREMOTESETTINGSPAGE_H
|
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NetworkRemoteSettingsPage</class>
|
||||
<widget class="QWidget" name="NetworkRemoteSettingsPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>496</width>
|
||||
<height>195</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Remote</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="layout_networkremotesettingspage">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useRemoteClient">
|
||||
<property name="text">
|
||||
<string>Use Remote Network Client</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="settingsBox">
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<widget class="QLabel" name="remotePortLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>101</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remote Port</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="portSelected">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>10</y>
|
||||
<width>71</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="localConnectionsOnly">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>60</y>
|
||||
<width>231</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Only allow local connections</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="ipAddressLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>110</y>
|
||||
<width>141</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Your IP Address is</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="ip_address">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>110</y>
|
||||
<width>191</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -65,6 +65,7 @@
|
|||
#include "lyricssettingspage.h"
|
||||
#include "transcodersettingspage.h"
|
||||
#include "networkproxysettingspage.h"
|
||||
#include "networkremotesettingspage.h"
|
||||
#include "appearancesettingspage.h"
|
||||
#include "contextsettingspage.h"
|
||||
#include "notificationssettingspage.h"
|
||||
|
@ -141,6 +142,7 @@ SettingsDialog::SettingsDialog(Application *app, OSDBase *osd, QMainWindow *main
|
|||
AddPage(Page::Transcoding, new TranscoderSettingsPage(this, this), general);
|
||||
#endif
|
||||
AddPage(Page::Proxy, new NetworkProxySettingsPage(this, this), general);
|
||||
AddPage(Page::Remote, new NetworkRemoteSettingsPage(this, this), general);
|
||||
|
||||
QTreeWidgetItem *iface = AddCategory(tr("User interface"));
|
||||
AddPage(Page::Appearance, new AppearanceSettingsPage(this, this), iface);
|
||||
|
|
|
@ -92,6 +92,7 @@ class SettingsDialog : public QDialog {
|
|||
Subsonic,
|
||||
Tidal,
|
||||
Qobuz,
|
||||
Remote,
|
||||
};
|
||||
|
||||
enum Role {
|
||||
|
|
|
@ -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