mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 13:02:35 +00:00
Switch between library types without restarting the app via
MasterLibrary pimpl-style implementation.
This commit is contained in:
parent
3ae8aed29a
commit
beef38501a
@ -121,6 +121,8 @@ void MasterLibrary::LoadDefaultLibrary() {
|
|||||||
this->wrappedLibrary->QueryCompleted.connect(this, &MasterLibrary::OnQueryCompleted);
|
this->wrappedLibrary->QueryCompleted.connect(this, &MasterLibrary::OnQueryCompleted);
|
||||||
this->wrappedLibrary->ConnectionStateChanged.connect(this, &MasterLibrary::OnConectionStateChanged);
|
this->wrappedLibrary->ConnectionStateChanged.connect(this, &MasterLibrary::OnConectionStateChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->LibraryChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,8 @@ namespace musik { namespace core { namespace library {
|
|||||||
|
|
||||||
class MasterLibrary: public ILibrary, public sigslot::has_slots<> {
|
class MasterLibrary: public ILibrary, public sigslot::has_slots<> {
|
||||||
public:
|
public:
|
||||||
|
sigslot::signal0<> LibraryChanged;
|
||||||
|
|
||||||
MasterLibrary();
|
MasterLibrary();
|
||||||
virtual ~MasterLibrary();
|
virtual ~MasterLibrary();
|
||||||
|
|
||||||
|
@ -111,6 +111,7 @@ MainLayout::MainLayout(
|
|||||||
this->prefs = Preferences::ForComponent("settings");
|
this->prefs = Preferences::ForComponent("settings");
|
||||||
|
|
||||||
library->ConnectionStateChanged.connect(this, &MainLayout::OnLibraryConnectionStateChanged);
|
library->ConnectionStateChanged.connect(this, &MainLayout::OnLibraryConnectionStateChanged);
|
||||||
|
library->LibraryChanged.connect(this, &MainLayout::OnLibraryChanged);
|
||||||
library->Indexer()->Started.connect(this, &MainLayout::OnIndexerStarted);
|
library->Indexer()->Started.connect(this, &MainLayout::OnIndexerStarted);
|
||||||
library->Indexer()->Finished.connect(this, &MainLayout::OnIndexerFinished);
|
library->Indexer()->Finished.connect(this, &MainLayout::OnIndexerFinished);
|
||||||
library->Indexer()->Progress.connect(this, &MainLayout::OnIndexerProgress);
|
library->Indexer()->Progress.connect(this, &MainLayout::OnIndexerProgress);
|
||||||
@ -302,6 +303,12 @@ void MainLayout::OnLibraryConnectionStateChanged(ILibrary::ConnectionState state
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainLayout::OnLibraryChanged() {
|
||||||
|
this->playback.Stop();
|
||||||
|
this->libraryLayout.reset(new LibraryLayout(playback, library));
|
||||||
|
this->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
void MainLayout::OnIndexerStarted() {
|
void MainLayout::OnIndexerStarted() {
|
||||||
this->Post(message::IndexerStarted);
|
this->Post(message::IndexerStarted);
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ namespace musik {
|
|||||||
void OnIndexerFinished(int count);
|
void OnIndexerFinished(int count);
|
||||||
void OnTrackChanged(size_t index, musik::core::TrackPtr track);
|
void OnTrackChanged(size_t index, musik::core::TrackPtr track);
|
||||||
void OnLibraryConnectionStateChanged(musik::core::ILibrary::ConnectionState state);
|
void OnLibraryConnectionStateChanged(musik::core::ILibrary::ConnectionState state);
|
||||||
|
void OnLibraryChanged();
|
||||||
|
|
||||||
bool IsLibraryConnected();
|
bool IsLibraryConnected();
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ static void setTransportType(TransportType type) {
|
|||||||
|
|
||||||
SettingsLayout::SettingsLayout(
|
SettingsLayout::SettingsLayout(
|
||||||
cursespp::App& app,
|
cursespp::App& app,
|
||||||
musik::core::ILibraryPtr library,
|
MasterLibraryPtr library,
|
||||||
musik::core::audio::PlaybackService& playback)
|
musik::core::audio::PlaybackService& playback)
|
||||||
: LayoutBase()
|
: LayoutBase()
|
||||||
, app(app)
|
, app(app)
|
||||||
@ -215,7 +215,10 @@ void SettingsLayout::OnCheckboxChanged(cursespp::Checkbox* cb, bool checked) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SettingsLayout::OnLibraryTypeDropdownActivated(cursespp::TextLabel* label) {
|
void SettingsLayout::OnLibraryTypeDropdownActivated(cursespp::TextLabel* label) {
|
||||||
SettingsOverlays::ShowLibraryTypeOverlay([this]() { this->LoadPreferences(); });
|
SettingsOverlays::ShowLibraryTypeOverlay([this]() {
|
||||||
|
this->LoadPreferences();
|
||||||
|
this->library->LoadDefaultLibrary();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsLayout::OnLocaleDropdownActivate(cursespp::TextLabel* label) {
|
void SettingsLayout::OnLocaleDropdownActivate(cursespp::TextLabel* label) {
|
||||||
|
@ -48,13 +48,12 @@
|
|||||||
|
|
||||||
#include <core/audio/PlaybackService.h>
|
#include <core/audio/PlaybackService.h>
|
||||||
#include <core/audio/MasterTransport.h>
|
#include <core/audio/MasterTransport.h>
|
||||||
|
#include <core/library/MasterLibrary.h>
|
||||||
|
#include <core/support/Preferences.h>
|
||||||
|
|
||||||
#include <app/window/TrackListView.h>
|
#include <app/window/TrackListView.h>
|
||||||
#include <app/model/DirectoryAdapter.h>
|
#include <app/model/DirectoryAdapter.h>
|
||||||
|
|
||||||
#include <core/library/ILibrary.h>
|
|
||||||
#include <core/support/Preferences.h>
|
|
||||||
|
|
||||||
#include <sigslot/sigslot.h>
|
#include <sigslot/sigslot.h>
|
||||||
|
|
||||||
#include "LocalLibrarySettingsLayout.h"
|
#include "LocalLibrarySettingsLayout.h"
|
||||||
@ -66,9 +65,11 @@ namespace musik { namespace cube {
|
|||||||
public sigslot::has_slots<>
|
public sigslot::has_slots<>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using MasterLibraryPtr = std::shared_ptr<musik::core::library::MasterLibrary>;
|
||||||
|
|
||||||
SettingsLayout(
|
SettingsLayout(
|
||||||
cursespp::App& app,
|
cursespp::App& app,
|
||||||
musik::core::ILibraryPtr library,
|
MasterLibraryPtr library,
|
||||||
musik::core::audio::PlaybackService& playback);
|
musik::core::audio::PlaybackService& playback);
|
||||||
|
|
||||||
virtual ~SettingsLayout();
|
virtual ~SettingsLayout();
|
||||||
@ -106,7 +107,7 @@ namespace musik { namespace cube {
|
|||||||
void OnAdvancedSettingsActivate(cursespp::TextLabel* label);
|
void OnAdvancedSettingsActivate(cursespp::TextLabel* label);
|
||||||
|
|
||||||
cursespp::App& app;
|
cursespp::App& app;
|
||||||
musik::core::ILibraryPtr library;
|
MasterLibraryPtr library;
|
||||||
musik::core::IIndexer* indexer;
|
musik::core::IIndexer* indexer;
|
||||||
musik::core::audio::PlaybackService& playback;
|
musik::core::audio::PlaybackService& playback;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user