Added ILibrary::IsConfigured()

This commit is contained in:
casey langen 2020-10-05 23:00:14 -07:00
parent c15033c77d
commit 4cfe49a061
6 changed files with 14 additions and 3 deletions

View File

@ -67,6 +67,7 @@ namespace musik { namespace core {
virtual const std::string& Name() = 0;
virtual void SetMessageQueue(musik::core::runtime::IMessageQueue& queue) = 0;
virtual musik::core::runtime::IMessageQueue& GetMessageQueue() = 0;
virtual bool IsConfigured() = 0;
virtual void Close() = 0;
};

View File

@ -134,6 +134,12 @@ void LocalLibrary::Close() {
}
}
bool LocalLibrary::IsConfigured() {
std::vector<std::string> paths;
Indexer()->GetPaths(paths);
return paths.size() > 0;
}
std::string LocalLibrary::GetLibraryDirectory() {
std::string directory(musik::core::GetDataDirectory());

View File

@ -76,6 +76,7 @@ namespace musik { namespace core { namespace library {
virtual const std::string& Name() override;
virtual void SetMessageQueue(musik::core::runtime::IMessageQueue& queue) override;
virtual musik::core::runtime::IMessageQueue& GetMessageQueue() override { return *messageQueue; }
virtual bool IsConfigured() override;
virtual void Close() override;
/* IMessageTarget */

View File

@ -130,6 +130,10 @@ void RemoteLibrary::Close() {
}
}
bool RemoteLibrary::IsConfigured() {
return LibraryFactory::Instance().Default()->IsConfigured(); /* CAL TODO FIXME */
}
int RemoteLibrary::Enqueue(QueryPtr query, unsigned int options, Callback callback) {
if (QueryRegistry::IsLocalOnlyQuery(query->Name())) {
auto defaultLocalLibrary = LibraryFactory::Instance().Default();

View File

@ -71,6 +71,7 @@ namespace musik { namespace core { namespace library {
virtual const std::string& Name() override;
virtual void SetMessageQueue(musik::core::runtime::IMessageQueue& queue) override;
virtual musik::core::runtime::IMessageQueue& GetMessageQueue() override { return *messageQueue; }
virtual bool IsConfigured() override;
virtual void Close() override;
/* IMessageTarget */

View File

@ -112,9 +112,7 @@ MainLayout::MainLayout(
/* take user to settings if they don't have a valid configuration. otherwise,
switch to the library view immediately */
std::vector<std::string> paths;
library->Indexer()->GetPaths(paths);
this->SetLayout(paths.size() > 0 ? libraryLayout : settingsLayout);
this->SetLayout(library->IsConfigured() ? libraryLayout : settingsLayout);
this->SetAutoHideCommandBar(this->prefs->GetBool(prefs::keys::AutoHideCommandBar, false));
this->RunUpdateCheck();