+
Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

feat: added option categories column to catalog #522

Merged
merged 3 commits into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ and `Removed`.

## [Unreleased]

## Added

- Optional 'Categories' column for Catalog.

## [0.7.0] - 2021-01-26

### Added
Expand Down
5 changes: 3 additions & 2 deletions locale/cs_CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Dostupná aktualizace",
"weakaura-update-queued": "Aktualizace zařazena",
"settings-general": "Obecné",
"catalog-results": "Výsledky: {number}"
}
"catalog-results": "Výsledky: {number}",
"categories": ""
}
5 changes: 3 additions & 2 deletions locale/da_DK.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Opdatering tilgængelig",
"weakaura-update-queued": "Opdatering klargjort",
"settings-general": "Generelt",
"catalog-results": "Resultater: {number}"
}
"catalog-results": "Resultater: {number}",
"categories": ""
}
5 changes: 3 additions & 2 deletions locale/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Update verfügbar",
"weakaura-update-queued": "Update in Warteschlange",
"settings-general": "Allgemein",
"catalog-results": "Ergebnisse: {number}"
}
"catalog-results": "Ergebnisse: {number}",
"categories": ""
}
5 changes: 3 additions & 2 deletions locale/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Update Available",
"weakaura-update-queued": "Update Queued",
"settings-general": "General",
"catalog-results": "Results: {number}"
}
"catalog-results": "Results: {number}",
"categories": "Categories"
}
5 changes: 3 additions & 2 deletions locale/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Actualización disponible",
"weakaura-update-queued": "Actualización en cola",
"settings-general": "Ajustes globales",
"catalog-results": "Resultados: {number}"
}
"catalog-results": "Resultados: {number}",
"categories": ""
}
5 changes: 3 additions & 2 deletions locale/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Mise à jour disponible",
"weakaura-update-queued": "Mise à jour en attente",
"settings-general": "Paramètres généraux",
"catalog-results": "Résultats: {number}"
}
"catalog-results": "Résultats: {number}",
"categories": ""
}
5 changes: 3 additions & 2 deletions locale/hu_HU.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Frissítés elérhető",
"weakaura-update-queued": "Frissítés sorbaállítva",
"settings-general": "Általános",
"catalog-results": "Találatok: {number}"
}
"catalog-results": "Találatok: {number}",
"categories": ""
}
5 changes: 3 additions & 2 deletions locale/nb_NO.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Oppdatering Tilgjengelig",
"weakaura-update-queued": "Oppdatering Køet",
"settings-general": "Generelt",
"catalog-results": "Resultater: {number}"
}
"catalog-results": "Resultater: {number}",
"categories": ""
}
5 changes: 3 additions & 2 deletions locale/pt_PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Atualização disponível",
"weakaura-update-queued": "Atualização em fila",
"settings-general": "Configuração geral",
"catalog-results": "Resultados: {number}"
}
"catalog-results": "Resultados: {number}",
"categories": ""
}
5 changes: 3 additions & 2 deletions locale/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Доступны обновления",
"weakaura-update-queued": "Обновления поставлены в очередь",
"settings-general": "Общие",
"catalog-results": "Результат: {number}"
}
"catalog-results": "Результат: {number}",
"categories": ""
}
5 changes: 3 additions & 2 deletions locale/se_SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Uppdateringar tillgängliga",
"weakaura-update-queued": "Uppdateringar köade",
"settings-general": "Allmänna inställningar",
"catalog-results": "Resultat: {number}"
}
"catalog-results": "Resultat: {number}",
"categories": ""
}
5 changes: 3 additions & 2 deletions locale/sk_SK.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Dostupná aktualizácia",
"weakaura-update-queued": "Aktualizácia zaradená",
"settings-general": "Všeobecné",
"catalog-results": "Výsledky: {number}"
}
"catalog-results": "Výsledky: {number}",
"categories": ""
}
5 changes: 3 additions & 2 deletions locale/tr_TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"weakaura-update-available": "Güncelleme Mevcut",
"weakaura-update-queued": "Güncelleme Sırada",
"settings-general": "Genel",
"catalog-results": "{number} sonuç"
}
"catalog-results": "{number} sonuç",
"categories": ""
}
23 changes: 23 additions & 0 deletions src/gui/element/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,29 @@ pub fn data_row_container<'a, 'b>(
row_containers.push((idx, num_downloads_container));
}

if let Some((idx, width)) = column_config
.iter()
.enumerate()
.filter_map(|(idx, (key, width, hidden))| {
if *key == CatalogColumnKey::Categories && !hidden {
Some((idx, width))
} else {
None
}
})
.next()
{
let categories = Text::new(&addon_data.categories.join(", ")).size(DEFAULT_FONT_SIZE);
let categories_container = Container::new(categories)
.height(default_height)
.width(*width)
.center_y()
.padding(5)
.style(style::HoverableForegroundContainer(color_palette));

row_containers.push((idx, categories_container));
}

let left_spacer = Space::new(Length::Units(DEFAULT_PADDING), Length::Units(0));
let right_spacer = Space::new(Length::Units(DEFAULT_PADDING + 5), Length::Units(0));

Expand Down
17 changes: 17 additions & 0 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,7 @@ pub enum CatalogColumnKey {
GameVersion,
DateReleased,
Install,
Categories,
}

impl CatalogColumnKey {
Expand All @@ -1439,6 +1440,7 @@ impl CatalogColumnKey {
NumDownloads => localized_string("num-downloads"),
GameVersion => localized_string("game-version"),
DateReleased => localized_string("latest-release"),
Categories => localized_string("categories"),
CatalogColumnKey::Install => localized_string("status"),
}
}
Expand All @@ -1453,6 +1455,7 @@ impl CatalogColumnKey {
NumDownloads => "num_downloads",
GameVersion => "game_version",
DateReleased => "date_released",
Categories => "categories",
CatalogColumnKey::Install => "install",
};

Expand All @@ -1470,6 +1473,7 @@ impl From<&str> for CatalogColumnKey {
"install" => CatalogColumnKey::Install,
"game_version" => CatalogColumnKey::GameVersion,
"date_released" => CatalogColumnKey::DateReleased,
"categories" => CatalogColumnKey::Categories,
_ => panic!(format!("Unknown CatalogColumnKey for {}", s)),
}
}
Expand Down Expand Up @@ -1547,6 +1551,13 @@ impl Default for CatalogHeaderState {
hidden: false,
order: 6,
},
CatalogColumnState {
key: CatalogColumnKey::Categories,
btn_state: Default::default(),
width: Length::Units(85),
hidden: true,
order: 7,
},
],
}
}
Expand Down Expand Up @@ -1629,6 +1640,12 @@ impl Default for CatalogColumnSettings {
up_btn_state: Default::default(),
down_btn_state: Default::default(),
},
CatalogColumnSettingState {
key: CatalogColumnKey::Categories,
order: 7,
up_btn_state: Default::default(),
down_btn_state: Default::default(),
},
],
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/gui/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2360,6 +2360,23 @@ fn sort_catalog_addons(
let gv_b = b.addon.game_versions.iter().find(|gc| &gc.flavor == flavor);
gv_a.cmp(&gv_b).reverse()
}),
(CatalogColumnKey::Categories, SortDirection::Desc) => {
addons.sort_by(|a, b| {
a.addon
.categories
.join(", ")
.cmp(&b.addon.categories.join(", "))
.reverse()
});
}
(CatalogColumnKey::Categories, SortDirection::Asc) => {
addons.sort_by(|a, b| {
a.addon
.categories
.join(", ")
.cmp(&b.addon.categories.join(", "))
});
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/localization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,6 @@ mod test {
channel_beta: String,
channel_alpha: String,
catalog_results: String,
categories: String,
}
}
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载