internet: Add common InternetService::ConfigRequired() method.
This will allow some common handling of unconfigured services.
This commit is contained in:
parent
7cb5f5c804
commit
a5e84bbe98
@ -83,7 +83,7 @@ QStandardItem* CloudFileService::CreateRootItem() {
|
||||
void CloudFileService::LazyPopulate(QStandardItem* item) {
|
||||
switch (item->data(InternetModel::Role_Type).toInt()) {
|
||||
case InternetModel::Type_Service:
|
||||
if (!has_credentials()) {
|
||||
if (ConfigRequired()) {
|
||||
ShowConfig();
|
||||
} else {
|
||||
Connect();
|
||||
|
@ -49,6 +49,7 @@ class CloudFileService : public InternetService {
|
||||
virtual bool has_credentials() const = 0;
|
||||
bool is_indexing() const { return indexing_task_id_ != -1; }
|
||||
|
||||
bool ConfigRequired() override { return !has_credentials(); }
|
||||
signals:
|
||||
void AllIndexingTasksFinished();
|
||||
|
||||
|
@ -88,6 +88,8 @@ class InternetService : public QObject {
|
||||
|
||||
virtual QString Icon() { return QString(); }
|
||||
|
||||
virtual bool ConfigRequired() { return false; }
|
||||
|
||||
signals:
|
||||
void StreamError(const QString& message);
|
||||
void StreamMetadataFound(const QUrl& original_url, const Song& song);
|
||||
|
@ -126,7 +126,7 @@ void DigitallyImportedServiceBase::RefreshStreamsFinished(QNetworkReply* reply,
|
||||
void DigitallyImportedServiceBase::PopulateStreams() {
|
||||
if (root_->hasChildren()) root_->removeRows(0, root_->rowCount());
|
||||
|
||||
if (!is_premium_account()) {
|
||||
if (ConfigRequired()) {
|
||||
ShowConfig();
|
||||
return;
|
||||
}
|
||||
|
@ -64,6 +64,8 @@ class DigitallyImportedServiceBase : public InternetService {
|
||||
void SongFromChannel(const DigitallyImportedClient::Channel& channel,
|
||||
Song* song) const;
|
||||
|
||||
bool ConfigRequired() override { return !is_premium_account(); }
|
||||
|
||||
public slots:
|
||||
void ShowConfig() override;
|
||||
|
||||
|
@ -92,6 +92,8 @@ class SpotifyService : public InternetService {
|
||||
LoginState login_state() const { return login_state_; }
|
||||
bool IsLoggedIn() const { return login_state_ == LoginState_LoggedIn; }
|
||||
|
||||
bool ConfigRequired() override { return !IsLoggedIn(); }
|
||||
|
||||
static void SongFromProtobuf(const cpb::spotify::Track& track, Song* song);
|
||||
|
||||
signals:
|
||||
|
@ -168,7 +168,7 @@ void SubsonicService::LazyPopulate(QStandardItem* item) {
|
||||
switch (item->data(InternetModel::Role_Type).toInt()) {
|
||||
case InternetModel::Type_Service:
|
||||
library_model_->Init();
|
||||
if (login_state() != LoginState_Loggedin) {
|
||||
if (ConfigRequired()) {
|
||||
ShowConfig();
|
||||
} else if (total_song_count_ == 0 && !load_database_task_id_) {
|
||||
ReloadDatabase();
|
||||
|
@ -103,6 +103,10 @@ class SubsonicService : public InternetService {
|
||||
|
||||
LoginState login_state() const { return login_state_; }
|
||||
|
||||
bool ConfigRequired() override {
|
||||
return login_state() != LoginState_Loggedin;
|
||||
}
|
||||
|
||||
// Subsonic API methods
|
||||
void Ping();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user