Make CloudFileServices show logged in state and settings dialog properly in
global search.
This commit is contained in:
parent
25544cb672
commit
2134e13b53
@ -164,6 +164,7 @@ set(SOURCES
|
||||
globalsearch/suggestionwidget.cpp
|
||||
globalsearch/urlsearchprovider.cpp
|
||||
|
||||
internet/cloudfilesearchprovider.cpp
|
||||
internet/cloudfileservice.cpp
|
||||
internet/digitallyimportedclient.cpp
|
||||
internet/digitallyimportedservicebase.cpp
|
||||
|
@ -184,6 +184,8 @@ bool CompareProvider(const QStringList& provider_order, SearchProvider* left,
|
||||
}
|
||||
|
||||
void GlobalSearchView::ReloadSettings() {
|
||||
const bool old_show_suggestions = show_suggestions_;
|
||||
|
||||
QSettings s;
|
||||
|
||||
// Library settings
|
||||
@ -246,6 +248,10 @@ void GlobalSearchView::ReloadSettings() {
|
||||
if (!show_suggestions_) {
|
||||
update_suggestions_timer_->stop();
|
||||
}
|
||||
|
||||
if (!old_show_suggestions && show_suggestions_) {
|
||||
UpdateSuggestions();
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalSearchView::UpdateSuggestions() {
|
||||
|
@ -37,6 +37,14 @@ void SearchProvider::Init(const QString& name, const QString& id,
|
||||
hints_ = hints;
|
||||
}
|
||||
|
||||
void SearchProvider::SetHint(Hint hint, bool set) {
|
||||
if (set) {
|
||||
hints_ |= hint;
|
||||
} else {
|
||||
hints_ &= ~hint;
|
||||
}
|
||||
}
|
||||
|
||||
QStringList SearchProvider::TokenizeQuery(const QString& query) {
|
||||
QStringList tokens(query.split(QRegExp("\\s+")));
|
||||
|
||||
|
@ -164,6 +164,7 @@ signals:
|
||||
// Subclasses must call this from their constructors.
|
||||
void Init(const QString& name, const QString& id, const QIcon& icon,
|
||||
Hints hints = NoHints);
|
||||
void SetHint(Hint hint, bool set = true);
|
||||
|
||||
struct PendingState {
|
||||
PendingState() : orig_id_(-1) {}
|
||||
|
48
src/internet/cloudfilesearchprovider.cpp
Normal file
48
src/internet/cloudfilesearchprovider.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
/* This file is part of Clementine.
|
||||
Copyright 2014, David Sansome <me@davidsansome.com>
|
||||
|
||||
Clementine 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.
|
||||
|
||||
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "internet/cloudfilesearchprovider.h"
|
||||
#include "internet/cloudfileservice.h"
|
||||
#include "internet/internetmodel.h"
|
||||
|
||||
CloudFileSearchProvider::CloudFileSearchProvider(
|
||||
LibraryBackendInterface* backend,
|
||||
const QString& id,
|
||||
const QIcon& icon,
|
||||
CloudFileService* service)
|
||||
: LibrarySearchProvider(backend,
|
||||
service->name(),
|
||||
id,
|
||||
icon,
|
||||
true,
|
||||
service->model()->app(),
|
||||
service),
|
||||
service_(service) {
|
||||
SetHint(CanShowConfig);
|
||||
}
|
||||
|
||||
bool CloudFileSearchProvider::IsLoggedIn() {
|
||||
return service_->has_credentials();
|
||||
}
|
||||
|
||||
void CloudFileSearchProvider::ShowConfig() {
|
||||
service_->ShowSettingsDialog();
|
||||
}
|
||||
|
||||
InternetService* CloudFileSearchProvider::internet_service() {
|
||||
return service_;
|
||||
}
|
40
src/internet/cloudfilesearchprovider.h
Normal file
40
src/internet/cloudfilesearchprovider.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* This file is part of Clementine.
|
||||
Copyright 2014, David Sansome <me@davidsansome.com>
|
||||
|
||||
Clementine 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.
|
||||
|
||||
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CLOUDFILESEARCHPROVIDER_H
|
||||
#define CLOUDFILESEARCHPROVIDER_H
|
||||
|
||||
#include "globalsearch/librarysearchprovider.h"
|
||||
|
||||
class CloudFileService;
|
||||
|
||||
class CloudFileSearchProvider : public LibrarySearchProvider {
|
||||
public:
|
||||
CloudFileSearchProvider(LibraryBackendInterface* backend,
|
||||
const QString& id,
|
||||
const QIcon& icon,
|
||||
CloudFileService* service);
|
||||
|
||||
virtual bool IsLoggedIn();
|
||||
virtual void ShowConfig();
|
||||
virtual InternetService* internet_service();
|
||||
|
||||
private:
|
||||
CloudFileService* service_;
|
||||
};
|
||||
|
||||
#endif // CLOUDFILESEARCHPROVIDER_H
|
@ -10,7 +10,7 @@
|
||||
#include "core/player.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "globalsearch/globalsearch.h"
|
||||
#include "globalsearch/librarysearchprovider.h"
|
||||
#include "internet/cloudfilesearchprovider.h"
|
||||
#include "internet/internetmodel.h"
|
||||
#include "library/librarybackend.h"
|
||||
#include "library/librarymodel.h"
|
||||
@ -48,8 +48,8 @@ CloudFileService::CloudFileService(Application* app, InternetModel* parent,
|
||||
library_sort_model_->setSortLocaleAware(true);
|
||||
library_sort_model_->sort(0);
|
||||
|
||||
app->global_search()->AddProvider(new LibrarySearchProvider(
|
||||
library_backend_, service_name, service_id, icon_, true, app_, this));
|
||||
app->global_search()->AddProvider(new CloudFileSearchProvider(
|
||||
library_backend_, service_id, icon_, this));
|
||||
}
|
||||
|
||||
QStandardItem* CloudFileService::CreateRootItem() {
|
||||
|
@ -29,13 +29,16 @@ class CloudFileService : public InternetService {
|
||||
virtual void LazyPopulate(QStandardItem* item);
|
||||
virtual void ShowContextMenu(const QPoint& point);
|
||||
|
||||
virtual bool has_credentials() const = 0;
|
||||
bool is_indexing() const { return indexing_task_id_ != -1; }
|
||||
|
||||
signals:
|
||||
void AllIndexingTasksFinished();
|
||||
|
||||
public slots:
|
||||
void ShowSettingsDialog();
|
||||
|
||||
protected:
|
||||
virtual bool has_credentials() const = 0;
|
||||
virtual void Connect() = 0;
|
||||
virtual bool ShouldIndexFile(const QUrl& url, const QString& mime_type) const;
|
||||
virtual void MaybeAddFileToDatabase(const Song& metadata,
|
||||
@ -48,7 +51,6 @@ class CloudFileService : public InternetService {
|
||||
protected slots:
|
||||
void ShowCoverManager();
|
||||
void AddToPlaylist(QMimeData* mime);
|
||||
void ShowSettingsDialog();
|
||||
void ReadTagsFinished(TagReaderClient::ReplyType* reply,
|
||||
const Song& metadata);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user