mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 15:32:52 +02:00
opgk_manager: more optimizations for package menu
Menu shows more detailed and sorted list (available updates,
installable packages, installed packages).
Possible duplicated separator lines should be fixed.
Origin commit data
------------------
Branch: ni/coolstream
Commit: b4984112a6
Author: Thilo Graf <dbt@novatux.de>
Date: 2023-03-07 (Tue, 07 Mar 2023)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -521,15 +521,15 @@ void COPKGManager::updateMenu()
|
|||||||
menu->setFooter(COPKGManagerFooterButtons, COPKGManagerFooterButtonCount);
|
menu->setFooter(COPKGManagerFooterButtons, COPKGManagerFooterButtonCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CMenuItem*>& items = menu->getItems();
|
|
||||||
// Sorts the elements of the menu object, starting from the fifth element, because previous items are intro items.
|
// Sorts the elements of the menu object, starting from the fifth element, because previous items are intro items.
|
||||||
// The sorting is done in two steps: first, the elements are sorted based on the value of iconName_Info_right.
|
// The sorting is done in two steps: first, the elements are sorted based on the value of iconName_Info_right.
|
||||||
// The values NEUTRINO_ICON_MARKER_UPDATE_AVAILABLE, NEUTRINO_ICON_MARKER_DOWNLOAD_LATER and NEUTRINO_ICON_MARKER_DIALOG_OK
|
// The values NEUTRINO_ICON_MARKER_UPDATE_AVAILABLE, NEUTRINO_ICON_MARKER_DOWNLOAD_LATER and NEUTRINO_ICON_MARKER_DIALOG_OK
|
||||||
// are sorted from highest to lowest priority.
|
// are sorted from highest to lowest priority.
|
||||||
// If two elements have the same value for iconName_Info_right, they are sorted by their names.
|
// If two elements have the same value for iconName_Info_right, they are sorted by their names.
|
||||||
|
std::vector<CMenuItem*>& items = menu->getItems();
|
||||||
// We know position (5) of menu separator from we will start sort.
|
// We know about start position (5) of menu separator from we will start sort, resulted by count of intro items.
|
||||||
std::sort(items.begin() + 5, items.end(), [](CMenuItem* a, CMenuItem* b)
|
size_t intro_items_end = 5;
|
||||||
|
std::sort(items.begin() + intro_items_end, items.end(), [](CMenuItem* a, CMenuItem* b)
|
||||||
{
|
{
|
||||||
int aValue = 0, bValue = 0;
|
int aValue = 0, bValue = 0;
|
||||||
if (a->iconName_Info_right == NEUTRINO_ICON_MARKER_UPDATE_AVAILABLE)
|
if (a->iconName_Info_right == NEUTRINO_ICON_MARKER_UPDATE_AVAILABLE)
|
||||||
@@ -553,19 +553,39 @@ void COPKGManager::updateMenu()
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Now we have a sorted list, but we need some menu separators with text that describes what is inside the sections.
|
// Now we have a sorted list, but we need some menu separators with text that describes what is inside the sections.
|
||||||
for (size_t i = 5; i < items.size()-1; i++)
|
for (size_t i = intro_items_end; i > items.size(); i++)
|
||||||
{
|
{
|
||||||
|
if (items[i]->type_name == "CMenuSeparator")
|
||||||
|
menu->removeItem(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool found_available, found_installed = false;
|
||||||
|
for (size_t i = intro_items_end; i < items.size()-1; i++)
|
||||||
|
{
|
||||||
|
if (found_available && found_installed)
|
||||||
|
break;
|
||||||
|
|
||||||
if (items[i]->iconName_Info_right != NULL)
|
if (items[i]->iconName_Info_right != NULL)
|
||||||
if (items[i]->iconName_Info_right != items[i + 1]->iconName_Info_right)
|
if (items[i]->iconName_Info_right != items[i + 1]->iconName_Info_right)
|
||||||
{
|
{
|
||||||
if (items[i + 1]->iconName_Info_right == NEUTRINO_ICON_MARKER_DOWNLOAD_LATER)
|
if (!found_available && items[i + 1]->iconName_Info_right == NEUTRINO_ICON_MARKER_DOWNLOAD_LATER)
|
||||||
|
{
|
||||||
menu->insertItem(i + 1, new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_OPKG_SEPARATOR_PACKAGES_AVAILABLE));
|
menu->insertItem(i + 1, new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_OPKG_SEPARATOR_PACKAGES_AVAILABLE));
|
||||||
else
|
found_available = true;
|
||||||
|
}
|
||||||
|
else if (!found_installed)
|
||||||
|
{
|
||||||
menu->insertItem(i + 1, new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_OPKG_SEPARATOR_PACKAGES_INSTALLED));
|
menu->insertItem(i + 1, new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_OPKG_SEPARATOR_PACKAGES_INSTALLED));
|
||||||
|
found_installed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clean up last items. No separators are requierd at the end of menu.
|
||||||
|
if (items[items.size()-1]->type_name == "CMenuSeparator")
|
||||||
|
menu->removeItem(items.size()-1);
|
||||||
|
}
|
||||||
|
|
||||||
bool COPKGManager::removeInfoBarTxt()
|
bool COPKGManager::removeInfoBarTxt()
|
||||||
{
|
{
|
||||||
if (file_exists(INFOBAR_TXT_FILE))
|
if (file_exists(INFOBAR_TXT_FILE))
|
||||||
|
Reference in New Issue
Block a user