Network remote:
- Send status. - Since QIcon can not be converted in a background thread, create a QImage from it in the SearchProvider itself.
This commit is contained in:
parent
3f536d2571
commit
3c332782fd
|
@ -56,6 +56,7 @@ enum MsgType {
|
||||||
DOWNLOAD_TOTAL_SIZE = 53;
|
DOWNLOAD_TOTAL_SIZE = 53;
|
||||||
GLOBAL_SEARCH_RESULT = 54;
|
GLOBAL_SEARCH_RESULT = 54;
|
||||||
TRANSCODING_FILES = 55;
|
TRANSCODING_FILES = 55;
|
||||||
|
GLOBAL_SEARCH_STATUS = 56;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid Engine states
|
// Valid Engine states
|
||||||
|
@ -306,6 +307,17 @@ message ResponseTranscoderStatus {
|
||||||
optional int32 total = 2;
|
optional int32 total = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum GlobalSearchStatus {
|
||||||
|
GlobalSearchStarted = 1;
|
||||||
|
GlobalSearchFinished = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ResponseGlobalSearchStatus {
|
||||||
|
optional int32 id = 1;
|
||||||
|
optional string query = 2;
|
||||||
|
optional GlobalSearchStatus status = 3;
|
||||||
|
}
|
||||||
|
|
||||||
// The message itself
|
// The message itself
|
||||||
message Message {
|
message Message {
|
||||||
optional int32 version = 1 [default=20];
|
optional int32 version = 1 [default=20];
|
||||||
|
@ -343,4 +355,5 @@ message Message {
|
||||||
optional ResponseDownloadTotalSize response_download_total_size = 36;
|
optional ResponseDownloadTotalSize response_download_total_size = 36;
|
||||||
optional ResponseGlobalSearch response_global_search = 38;
|
optional ResponseGlobalSearch response_global_search = 38;
|
||||||
optional ResponseTranscoderStatus response_transcoder_status = 39;
|
optional ResponseTranscoderStatus response_transcoder_status = 39;
|
||||||
|
optional ResponseGlobalSearchStatus response_global_search_status = 40;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ void SearchProvider::Init(const QString& name, const QString& id,
|
||||||
id_ = id;
|
id_ = id;
|
||||||
icon_ = icon;
|
icon_ = icon;
|
||||||
hints_ = hints;
|
hints_ = hints;
|
||||||
|
icon_as_image_ = QImage(icon.pixmap(48, 48).toImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchProvider::SetHint(Hint hint, bool set) {
|
void SearchProvider::SetHint(Hint hint, bool set) {
|
||||||
|
|
|
@ -104,6 +104,7 @@ class SearchProvider : public QObject {
|
||||||
const QString& name() const { return name_; }
|
const QString& name() const { return name_; }
|
||||||
const QString& id() const { return id_; }
|
const QString& id() const { return id_; }
|
||||||
const QIcon& icon() const { return icon_; }
|
const QIcon& icon() const { return icon_; }
|
||||||
|
const QImage& icon_as_image() const { return icon_as_image_; }
|
||||||
|
|
||||||
Hints hints() const { return hints_; }
|
Hints hints() const { return hints_; }
|
||||||
bool wants_delayed_queries() const { return hints() & WantsDelayedQueries; }
|
bool wants_delayed_queries() const { return hints() & WantsDelayedQueries; }
|
||||||
|
@ -190,6 +191,7 @@ signals:
|
||||||
QString id_;
|
QString id_;
|
||||||
QIcon icon_;
|
QIcon icon_;
|
||||||
Hints hints_;
|
Hints hints_;
|
||||||
|
QImage icon_as_image_;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(SearchProvider::Result)
|
Q_DECLARE_METATYPE(SearchProvider::Result)
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
#include "core/timeconstants.h"
|
#include "core/timeconstants.h"
|
||||||
#include "core/utilities.h"
|
#include "core/utilities.h"
|
||||||
|
#include "globalsearch/librarysearchprovider.h"
|
||||||
#include "library/librarybackend.h"
|
#include "library/librarybackend.h"
|
||||||
|
#include "ui/iconloader.h"
|
||||||
|
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
|
@ -70,13 +72,17 @@ void OutgoingDataCreator::SetClients(QList<RemoteClient*>* clients) {
|
||||||
CheckEnabledProviders();
|
CheckEnabledProviders();
|
||||||
|
|
||||||
// Setup global search
|
// Setup global search
|
||||||
|
app_->global_search()->ReloadSettings();
|
||||||
|
|
||||||
connect(app_->global_search(),
|
connect(app_->global_search(),
|
||||||
SIGNAL(ResultsAvailable(int, SearchProvider::ResultList)),
|
SIGNAL(ResultsAvailable(int, SearchProvider::ResultList)),
|
||||||
SLOT(ResultsAvailable(int, SearchProvider::ResultList)),
|
SLOT(ResultsAvailable(int, SearchProvider::ResultList)),
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(app_->global_search(), SIGNAL(SearchFinished(int)),
|
connect(app_->global_search(),
|
||||||
SLOT(SearchFinished(int)));
|
SIGNAL(SearchFinished(int)),
|
||||||
|
SLOT(SearchFinished(int)),
|
||||||
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutgoingDataCreator::CheckEnabledProviders() {
|
void OutgoingDataCreator::CheckEnabledProviders() {
|
||||||
|
@ -661,6 +667,19 @@ void OutgoingDataCreator::DoGlobalSearch(const QString& query,
|
||||||
|
|
||||||
GlobalSearchRequest request(id, query, client);
|
GlobalSearchRequest request(id, query, client);
|
||||||
global_search_result_map_.insert(id, request);
|
global_search_result_map_.insert(id, request);
|
||||||
|
|
||||||
|
// Send status message
|
||||||
|
pb::remote::Message msg;
|
||||||
|
pb::remote::ResponseGlobalSearchStatus* status = msg.mutable_response_global_search_status();
|
||||||
|
|
||||||
|
msg.set_type(pb::remote::GLOBAL_SEARCH_STATUS);
|
||||||
|
status->set_id(id);
|
||||||
|
status->set_query(DataCommaSizeFromQString(query));
|
||||||
|
status->set_status(pb::remote::GlobalSearchStarted);
|
||||||
|
|
||||||
|
client->SendData(&msg);
|
||||||
|
|
||||||
|
qLog(Debug) << "DoGlobalSearch" << id << query;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutgoingDataCreator::ResultsAvailable(
|
void OutgoingDataCreator::ResultsAvailable(
|
||||||
|
@ -682,11 +701,12 @@ void OutgoingDataCreator::ResultsAvailable(
|
||||||
DataCommaSizeFromQString(results.first().provider_->name()));
|
DataCommaSizeFromQString(results.first().provider_->name()));
|
||||||
|
|
||||||
// Append the icon
|
// Append the icon
|
||||||
QImage icon_image(results.first().provider_->icon().pixmap(48, 48).toImage());
|
QImage icon_image(results.first().provider_->icon_as_image());
|
||||||
QByteArray byte_array;
|
QByteArray byte_array;
|
||||||
QBuffer buf(&byte_array);
|
QBuffer buf(&byte_array);
|
||||||
|
buf.open(QIODevice::WriteOnly);
|
||||||
icon_image.save(&buf, "PNG");
|
icon_image.save(&buf, "PNG");
|
||||||
response->set_search_provider_icon(byte_array.data(), byte_array.size());
|
response->set_search_provider_icon(byte_array.constData(), byte_array.size());
|
||||||
|
|
||||||
for (const SearchProvider::Result& result : results) {
|
for (const SearchProvider::Result& result : results) {
|
||||||
pb::remote::SongMetadata* pb_song = response->add_song_metadata();
|
pb::remote::SongMetadata* pb_song = response->add_song_metadata();
|
||||||
|
@ -694,8 +714,25 @@ void OutgoingDataCreator::ResultsAvailable(
|
||||||
}
|
}
|
||||||
|
|
||||||
client->SendData(&msg);
|
client->SendData(&msg);
|
||||||
|
|
||||||
|
qLog(Debug) << "ResultsAvailable" << id << results.first().provider_->name() << results.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutgoingDataCreator::SearchFinished(int id) {
|
void OutgoingDataCreator::SearchFinished(int id) {
|
||||||
global_search_result_map_.remove(id);
|
if (!global_search_result_map_.contains(id)) return;
|
||||||
|
|
||||||
|
GlobalSearchRequest req = global_search_result_map_.take(id);
|
||||||
|
|
||||||
|
// Send status message
|
||||||
|
pb::remote::Message msg;
|
||||||
|
pb::remote::ResponseGlobalSearchStatus* status = msg.mutable_response_global_search_status();
|
||||||
|
|
||||||
|
msg.set_type(pb::remote::GLOBAL_SEARCH_STATUS);
|
||||||
|
status->set_id(req.id_);
|
||||||
|
status->set_query(DataCommaSizeFromQString(req.query_));
|
||||||
|
status->set_status(pb::remote::GlobalSearchFinished);
|
||||||
|
|
||||||
|
req.client_->SendData(&msg);
|
||||||
|
|
||||||
|
qLog(Debug) << "SearchFinished" << req.id_ << req.query_;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue