added "remove all" options for favorites

This commit is contained in:
Thomas Jentzsch 2021-12-03 20:57:34 +01:00
parent 59f8b8c16d
commit 0a6560b47f
6 changed files with 154 additions and 44 deletions

View File

@ -126,6 +126,12 @@ void FavoritesManager::removeUser(const string& path)
myUserSet.erase(path); myUserSet.erase(path);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FavoritesManager::removeAllUser()
{
myUserSet.clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FavoritesManager::toggleUser(const string& path) bool FavoritesManager::toggleUser(const string& path)
{ {
@ -199,6 +205,12 @@ bool FavoritesManager::removeRecent(const string& path)
return it != myRecentList.end(); return it != myRecentList.end();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FavoritesManager::removeAllRecent()
{
myRecentList.clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const FavoritesManager::RecentList& FavoritesManager::recentList() const const FavoritesManager::RecentList& FavoritesManager::recentList() const
{ {
@ -232,6 +244,12 @@ bool FavoritesManager::removePopular(const string& path)
return myPopularMap.erase(path); return myPopularMap.erase(path);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FavoritesManager::removeAllPopular()
{
myPopularMap.clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FavoritesManager::incPopular(const string& path) void FavoritesManager::incPopular(const string& path)
{ {

View File

@ -47,7 +47,8 @@ class FavoritesManager
// User favorites // User favorites
void addUser(const string& path); void addUser(const string& path);
void removeUser(const string& path); void removeUser(const string& path);
void removeAllUser();
bool toggleUser(const string& path); bool toggleUser(const string& path);
bool existsUser(const string& path) const; bool existsUser(const string& path) const;
const UserList& userList() const; const UserList& userList() const;
@ -56,10 +57,12 @@ class FavoritesManager
// Recently played // Recently played
bool removeRecent(const string& path); bool removeRecent(const string& path);
void removeAllRecent();
const RecentList& recentList() const; const RecentList& recentList() const;
// Most popular // Most popular
bool removePopular(const string& path); bool removePopular(const string& path);
void removeAllPopular();
const PopularList& popularList() const; const PopularList& popularList() const;

View File

@ -60,6 +60,8 @@
#include "MediaFactory.hxx" #include "MediaFactory.hxx"
#include "LauncherDialog.hxx" #include "LauncherDialog.hxx"
#include "MessageMenu.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
int x, int y, int w, int h) int x, int y, int w, int h)
@ -244,6 +246,11 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
xpos = HBORDER; xpos = HBORDER;
ypos += myList->getHeight() + VGAP; ypos += myList->getHeight() + VGAP;
// Path display
lwSelect = _font.getStringWidth("Path") + LBL_GAP;
myDirLabel = new StaticTextWidget(this, _font, xpos, ypos + 2, lwSelect, fontHeight, "Path");
xpos += lwSelect;
// Home button // Home button
static const uIntArray home_small = { static const uIntArray home_small = {
0b0000001000000, 0b0000001000000,
@ -260,44 +267,28 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
0b0011100011100, 0b0011100011100,
0b0011100011100, 0b0011100011100,
0b0011100011100 0b0011100011100
//0b000000010000000,
//0b000000111000000,
//0b000001101100000,
//0b000011010110000,
//0b000110111011000,
//0b001101111101100,
//0b011011111110110,
//0b110111111111011,
//0b101111111111101,
//0b001111101111100,
//0b001111000111100,
//0b001111000111100,
//0b001111000111100,
//0b001111000111100,
//0b001111000111100,
}; };
static const uIntArray home_large = { static const uIntArray home_large = {
0b0000000001000000000, 0b0000000001000000000,
0b0000000011100000000, 0b0000000011100000000,
0b0000000110110000000, 0b0000000110110000000,
0b0000001101011000000, 0b0000001101011000000,
0b0000011011101100000, 0b0000011011101100000,
0b0000110111110110000, 0b0000110111110110000,
0b0001101111111011000, 0b0001101111111011000,
0b0011011111111101100, 0b0011011111111101100,
0b0110111111111110110, 0b0110111111111110110,
0b1101111111111111011, 0b1101111111111111011,
0b1001111111111111001, 0b1001111111111111001,
0b0001111100011111000, 0b0001111100011111000,
0b0001111000001111000, 0b0001111000001111000,
0b0001111000001111000, 0b0001111000001111000,
0b0001111000001111000, 0b0001111000001111000,
0b0001111000001111000, 0b0001111000001111000,
0b0001111000001111000, 0b0001111000001111000,
0b0001111000001111000, 0b0001111000001111000,
0b0001111000001111000, 0b0001111000001111000,
0b0001111000001111000 0b0001111000001111000
}; };
const bool smallIcon = lineHeight < 26; const bool smallIcon = lineHeight < 26;
const uIntArray* icon = smallIcon ? &home_small : &home_large; const uIntArray* icon = smallIcon ? &home_small : &home_large;
@ -308,12 +299,8 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
icon->data(), iconWidth, int(icon->size()), kHomeDirCmd); icon->data(), iconWidth, int(icon->size()), kHomeDirCmd);
myHomeButton->setToolTip("Go back to Stella's ROM directory."); myHomeButton->setToolTip("Go back to Stella's ROM directory.");
wid.push_back(myHomeButton); wid.push_back(myHomeButton);
xpos = myHomeButton->getRight() + LBL_GAP; xpos = myHomeButton->getRight() + 1;// +LBL_GAP;
// Path display
lwSelect = _font.getStringWidth("Path") + LBL_GAP;
myDirLabel = new StaticTextWidget(this, _font, xpos, ypos+2, lwSelect, fontHeight, "Path");
xpos += lwSelect;
myDir = new EditTextWidget(this, _font, xpos, ypos, _w - xpos - HBORDER, lineHeight, ""); myDir = new EditTextWidget(this, _font, xpos, ypos, _w - xpos - HBORDER, lineHeight, "");
myDir->setEditable(false, true); myDir->setEditable(false, true);
myDir->clearFlags(Widget::FLAG_RETAIN_FOCUS); myDir->clearFlags(Widget::FLAG_RETAIN_FOCUS);
@ -737,6 +724,12 @@ void LauncherDialog::handleContextMenu()
myList->removeFavorite(); myList->removeFavorite();
reload(); reload();
} }
else if (cmd == "removefavorites")
removeAllFavorites();
else if (cmd == "removepopular")
removeAllPopular();
else if (cmd == "removerecent")
removeAllRecent();
else if(cmd == "override") else if(cmd == "override")
openGlobalProps(); openGlobalProps();
else if(cmd == "extensions") else if(cmd == "extensions")
@ -1043,6 +1036,21 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
handleFavoritesChanged(); handleFavoritesChanged();
break; break;
case kRmAllFav:
myList->removeAllUserFavorites();
reload();
break;
case kRmAllPop:
myList->removeAllPopular();
reload();
break;
case kRmAllRec:
myList->removeAllRecent();
reload();
break;
case kExtChangedCmd: case kExtChangedCmd:
reload(); reload();
break; break;
@ -1133,6 +1141,51 @@ void LauncherDialog::toggleSorting()
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::removeAllFavorites()
{
StringList msg;
msg.push_back("This will remove ALL ROMs from");
msg.push_back("your 'Favorites' list!");
msg.push_back("");
msg.push_back("Are you sure?");
myConfirmMsg = make_unique<GUI::MessageBox>
(this, _font, msg, _w, _h, kRmAllFav,
"Yes", "No", "Remove all Favorites", false);
myConfirmMsg->show();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::removeAllPopular()
{
StringList msg;
msg.push_back("This will remove ALL ROMs from");
msg.push_back("your 'Most Popular' list!");
msg.push_back("");
msg.push_back("Are you sure?");
myConfirmMsg = make_unique<GUI::MessageBox>
(this, _font, msg, _w, _h, kRmAllPop,
"Yes", "No", "Remove all Most Popular", false);
myConfirmMsg->show();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::removeAllRecent()
{
StringList msg;
msg.push_back("This will remove ALL ROMs from");
msg.push_back("from your 'Recently Played' list!");
msg.push_back("");
msg.push_back("Are you sure?");
myConfirmMsg = make_unique<GUI::MessageBox>
(this, _font, msg, _w, _h, kRmAllRec,
"Yes", "No", "Remove all Recently Played", false);
myConfirmMsg->show();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::openContextMenu(int x, int y) void LauncherDialog::openContextMenu(int x, int y)
{ {
@ -1200,6 +1253,12 @@ void LauncherDialog::openContextMenu(int x, int y)
: "Alternative sorting", "Ctrl+S", "sorting")); : "Alternative sorting", "Ctrl+S", "sorting"));
items.push_back(ContextItem("Reload listing", "Ctrl+R", "reload")); items.push_back(ContextItem("Reload listing", "Ctrl+R", "reload"));
} }
if (useFavorites)
{
items.push_back(ContextItem("Remove all from favorites", "", "removefavorites"));
items.push_back(ContextItem("Remove all from most popular", "", "removepopular"));
items.push_back(ContextItem("Remove all from recently played", "", "removerecent"));
}
// Format items for menu // Format items for menu
VariantList varItems; VariantList varItems;

View File

@ -53,7 +53,6 @@ class LauncherDialog : public Dialog
kRomDirChosenCmd = 'romc', // ROM dir chosen kRomDirChosenCmd = 'romc', // ROM dir chosen
kFavChangedCmd = 'favc', // Favorite tracking changed kFavChangedCmd = 'favc', // Favorite tracking changed
kExtChangedCmd = 'extc', // File extension display changed kExtChangedCmd = 'extc', // File extension display changed
kHomeDirCmd = 'homc', // goto Home directory
}; };
using FileList = std::unordered_set<string>; using FileList = std::unordered_set<string>;
@ -170,6 +169,9 @@ class LauncherDialog : public Dialog
void toggleSubDirs(); void toggleSubDirs();
void toggleExtensions(); void toggleExtensions();
void toggleSorting(); void toggleSorting();
void removeAllFavorites();
void removeAllPopular();
void removeAllRecent();
void openContextMenu(int x = -1, int y = -1); void openContextMenu(int x = -1, int y = -1);
void openGlobalProps(); void openGlobalProps();
void openSettings(); void openSettings();
@ -205,6 +207,9 @@ class LauncherDialog : public Dialog
std::unordered_map<string,string> myMD5List; std::unordered_map<string,string> myMD5List;
// Show a message about the dangers of using this function
unique_ptr<GUI::MessageBox> myConfirmMsg;
int mySelectedItem{0}; int mySelectedItem{0};
bool myShowOnlyROMs{false}; bool myShowOnlyROMs{false};
@ -219,7 +224,11 @@ class LauncherDialog : public Dialog
kSubDirsCmd = 'lred', kSubDirsCmd = 'lred',
kPrevDirCmd = 'PRVD', kPrevDirCmd = 'PRVD',
kOptionsCmd = 'OPTI', kOptionsCmd = 'OPTI',
kQuitCmd = 'QUIT' kQuitCmd = 'QUIT',
kHomeDirCmd = 'homc', // goto Home directory
kRmAllFav = 'rmaf',
kRmAllPop = 'rmap',
kRmAllRec = 'rmar'
}; };
private: private:

View File

@ -238,6 +238,24 @@ void LauncherFileListWidget::userFavor(const string& path)
_iconTypeList[pos] = getIconType(path); _iconTypeList[pos] = getIconType(path);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherFileListWidget::removeAllUserFavorites()
{
myFavorites->removeAllUser();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherFileListWidget::removeAllPopular()
{
myFavorites->removeAllPopular();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherFileListWidget::removeAllRecent()
{
myFavorites->removeAllRecent();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileListWidget::IconType LauncherFileListWidget::getIconType(const string& path) const FileListWidget::IconType LauncherFileListWidget::getIconType(const string& path) const
{ {

View File

@ -49,6 +49,9 @@ class LauncherFileListWidget : public FileListWidget
bool isUserFavorite(const string& path) const; bool isUserFavorite(const string& path) const;
void toggleUserFavorite(); void toggleUserFavorite();
void removeFavorite(); void removeFavorite();
void removeAllUserFavorites();
void removeAllPopular();
void removeAllRecent();
bool isDirectory(const FilesystemNode& node) const override; bool isDirectory(const FilesystemNode& node) const override;
bool inVirtualDir() const { return myInVirtualDir; } bool inVirtualDir() const { return myInVirtualDir; }