41
43
static const auto APP_ID_FIELD = "app_id";
42
44
static const auto DEPARTMENT_ID_FIELD = "department_id";
43
45
static const auto EXCLUDED_APPS_FILTER_TITLE = _("Exclude Apps: ");
46
static const auto SEARCH_STORE_HINT = _("Search for '%s' in the store");
47
static const auto SEARCH_STORE_CATEGORY_TITLE = _("Get more apps from the store");
116
static const auto CATEGORY_STORE = R"(
120
"category-layout": "grid",
122
"card-background": "color:///#E95420"
127
"aspect-ratio": 0.55,
130
"overlay-color": "overlay-color"
110
134
} // anonymous namespace
113
std::string const Query::NO_RESULTS_HINT = _("No applications available. Install new applications with the Libertine Manager.");
114
std::string const Query::ALL_RESULTS_FILTERED_HINT = _("All applications hidden. Reset filters or check the Hidden Desktop Apps department.");
137
std::string const Query::NO_RESULTS_HINT = _("No applications available in this department.");
138
std::string const Query::ALL_RESULTS_FILTERED_HINT = _("All applications filtered. Reset filters or clear department.");
118
Query(usc::CannedQuery const& query,
119
usc::SearchMetadata const& metadata,
120
Libertine::Factory const& libertine_factory,
142
Query(usc::CannedQuery const& query,
143
usc::SearchMetadata const& metadata,
144
Libertine::Factory const& libertine_factory,
121
145
std::shared_ptr<HiddenApps> hidden,
122
std::shared_ptr<Blacklist> blacklist)
146
std::shared_ptr<Blacklist> blacklist,
147
std::string const& data_directory)
123
148
: usc::SearchQueryBase(query, metadata)
124
149
, libertine_factory_(libertine_factory)
125
150
, hidden_(hidden)
126
151
, blacklist_(blacklist)
152
, data_directory_(data_directory)
230
add_store_link(usc::SearchReplyProxy const& reply) const
232
const auto querystr = query().query_string();
233
auto cat_title = SEARCH_STORE_CATEGORY_TITLE;
235
if (!querystr.empty())
238
if (snprintf(tmp, sizeof(tmp), SEARCH_STORE_HINT, querystr.c_str()) > 0)
244
usc::CategoryRenderer rdr(CATEGORY_STORE);
245
auto cat = reply->register_category("hint", cat_title, "", rdr);
247
const unity::scopes::CannedQuery store_scope(STORE_SCOPE_FULL_NAME, querystr, "");
249
usc::CategorisedResult res(cat);
250
res.set_title(_("Install X Apps"));
251
res.set_art(data_directory_ + "/store.svg");
252
res.set_uri(store_scope.to_uri());
253
res["overlay-color"] = "transparent";
204
259
run(usc::SearchReplyProxy const& reply)
206
261
if (!hidden_->empty())
231
287
for (auto const& app: container->app_launchers())
289
auto app_info = parse_app_info(app.uri());
291
// ignore blacklisted apps
292
if (blacklist_->app_is_blacklisted(app_info.app_id, container->id()))
297
// ignore hidden apps unless in hidden dept
298
if ((!is_hidden_dept && hidden_->app_is_hidden(app_info.key)) ||
299
(is_hidden_dept && !hidden_->app_is_hidden(app_info.key)))
233
304
has_no_apps = false;
234
306
if (!(search_query.isEmpty() || QString::fromStdString(app.name()).contains(search_query)))
239
auto app_info = parse_app_info(app.uri());
241
if (blacklist_->app_is_blacklisted(app_info.app_id, container->id()))
246
311
if (excludes_by_filter.contains(app_info.key))
251
// ignore hidden apps in root department
252
if (query().department_id().empty() || query().department_id() == ROOT_DEPT_ID)
254
if (hidden_->app_is_hidden(app_info.key))
259
else if (!hidden_->app_is_hidden(app_info.key))
264
316
usc::CategorisedResult result(category);
265
317
result.set_title(app.name());
266
318
result.set_art(app.icon());
267
319
result.set_uri(app.uri());
268
320
result[DESCRIPTION_FIELD] = app.description();
269
321
result[APP_ID_FIELD] = app_info.key.toStdString();
270
result[DEPARTMENT_ID_FIELD] = (query().department_id().empty() || query().department_id() == ROOT_DEPT_ID) ? ROOT_DEPT_ID : HIDDEN_DEPT_ID;
322
result[DEPARTMENT_ID_FIELD] = is_hidden_dept ? HIDDEN_DEPT_ID : ROOT_DEPT_ID;
272
324
if (!reply->push(result))
283
show_hint(reply, NO_RESULTS_HINT);
337
show_hint(reply, NO_RESULTS_HINT);
339
else if (all_filtered)
341
show_hint(reply, ALL_RESULTS_FILTERED_HINT);
285
else if (all_filtered)
287
show_hint(reply, ALL_RESULTS_FILTERED_HINT);
346
add_store_link(reply);