This commit is contained in:
Thomas Jentzsch 2021-12-11 23:34:43 +01:00
parent 147db10732
commit b4aacb3084
5 changed files with 63 additions and 46 deletions

View File

@ -2267,8 +2267,23 @@
</tr> </tr>
<tr> <tr>
<td>Go to parent directory (also in other file dialogs)</td> <td>Go to parent directory (also in other file dialogs)</td>
<td>Backspace</td> <td>Backspace, Alt + Up arrow</td>
<td>Backspace</td> <td>Backspace, Alt + Up arrow</td>
</tr>
<tr>
<td>Go to home directory</td>
<td>Alt + Home</td>
<td>Alt + Home</td>
</tr>
<tr>
<td>Go to previous directory in history</td>
<td>Alt + Left arrow</td>
<td>Alt + Left arrow</td>
</tr>
<tr>
<td>Go to next directory in history</td>
<td>Alt + Right arrow</td>
<td>Alt + Right arrow</td>
</tr> </tr>
<tr> <tr>
<td>Remove from 'Recently Played' or 'Most Popular' folder</td> <td>Remove from 'Recently Played' or 'Most Popular' folder</td>

View File

@ -58,14 +58,9 @@ void FileListWidget::setDirectory(const FilesystemNode& node,
_history.clear(); _history.clear();
while(tmp.hasParent()) while(tmp.hasParent())
{ {
if(name.back() == FilesystemNode::PATH_SEPARATOR) _history.push_back(HistoryType(tmp, fixPath(name)));
name.pop_back();
_history.push_back(HistoryType(tmp, name));
name = tmp.getName(); name = tmp.getName();
if(name.back() == FilesystemNode::PATH_SEPARATOR)
name.pop_back();
tmp = tmp.getParent(); tmp = tmp.getParent();
} }
// History is in reverse order; we need to fix that // History is in reverse order; we need to fix that
@ -191,14 +186,19 @@ void FileListWidget::selectParent()
string name = _node.getName(); string name = _node.getName();
FilesystemNode parent(_node.getParent()); FilesystemNode parent(_node.getParent());
if(name.back() == FilesystemNode::PATH_SEPARATOR)
name.pop_back();
_currentHistory->selected = selected().getName(); _currentHistory->selected = selected().getName();
addHistory(parent); addHistory(parent);
setLocation(parent, name); setLocation(parent, fixPath(name));
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileListWidget::selectHomeDir()
{
while(hasPrevHistory())
selectPrevHistory();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileListWidget::selectPrevHistory() void FileListWidget::selectPrevHistory()
{ {
@ -233,6 +233,17 @@ bool FileListWidget::hasNextHistory()
return _currentHistory != std::prev(_history.end(), 1); return _currentHistory != std::prev(_history.end(), 1);
} }
string& FileListWidget::fixPath(string& path)
{
if(path.back() == FilesystemNode::PATH_SEPARATOR)
{
path.pop_back();
if(path.length() == 2 && path.back() == ':')
path.pop_back();
}
return path;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileListWidget::addHistory(const FilesystemNode& node) void FileListWidget::addHistory(const FilesystemNode& node)
{ {
@ -241,11 +252,9 @@ void FileListWidget::addHistory(const FilesystemNode& node)
_history.pop_back(); _history.pop_back();
string select = selected().getName(); string select = selected().getName();
if(select.back() == FilesystemNode::PATH_SEPARATOR) _currentHistory->selected = fixPath(select);
select.pop_back();
_currentHistory->selected = select;
_history.push_back(HistoryType(node, select)); _history.push_back(HistoryType(node, ".."));
_currentHistory = std::prev(_history.end(), 1); _currentHistory = std::prev(_history.end(), 1);
//_historyIndex++; //_historyIndex++;
} }

View File

@ -45,7 +45,10 @@ class FileListWidget : public StringListWidget
public: public:
enum { enum {
ItemChanged = 'FLic', // Entry in the list is changed (single-click, etc) ItemChanged = 'FLic', // Entry in the list is changed (single-click, etc)
ItemActivated = 'FLac' // Entry in the list is activated (double-click, etc) ItemActivated = 'FLac', // Entry in the list is activated (double-click, etc)
kHomeDirCmd = 'homc', // go to Home directory
kPrevDirCmd = 'prvc', // go back in history to previous directory
kNextDirCmd = 'nxtc' // go back in history to next directory
}; };
using IconTypeFilter = std::function<bool(const FilesystemNode& node)>; using IconTypeFilter = std::function<bool(const FilesystemNode& node)>;
@ -83,9 +86,11 @@ class FileListWidget : public StringListWidget
virtual void selectDirectory(); virtual void selectDirectory();
/** Select parent directory (if applicable) */ /** Select parent directory (if applicable) */
void selectParent(); void selectParent();
/** Select to home directory */
void selectHomeDir();
/** Select previous directory in history (if applicable) */ /** Select previous directory in history (if applicable) */
void selectPrevHistory(); void selectPrevHistory();
/** Select next directory in history */ /** Select next directory in history (if applicable) */
void selectNextHistory(); void selectNextHistory();
/** Check if the there is a previous directory in history */ /** Check if the there is a previous directory in history */
bool hasPrevHistory(); bool hasPrevHistory();
@ -147,6 +152,7 @@ class FileListWidget : public StringListWidget
virtual const Icon* getIcon(int i) const; virtual const Icon* getIcon(int i) const;
int iconWidth() const; int iconWidth() const;
virtual bool fullPathToolTip() const { return false; } virtual bool fullPathToolTip() const { return false; }
string& fixPath(string& path);
void addHistory(const FilesystemNode& node); void addHistory(const FilesystemNode& node);
protected: protected:

View File

@ -228,25 +228,25 @@ void LauncherDialog::addPathWidgets(int& ypos, WidgetArray& wid)
const GUI::Icon& upIcon = smallIcon ? GUI::icon_up_small : GUI::icon_up_large; const GUI::Icon& upIcon = smallIcon ? GUI::icon_up_small : GUI::icon_up_large;
myHomeButton = new ButtonWidget(this, _font, xpos, ypos, myHomeButton = new ButtonWidget(this, _font, xpos, ypos,
iconWidth + iconGap - 1, lineHeight + 2, homeIcon, kHomeDirCmd); iconWidth + iconGap - 1, lineHeight + 2, homeIcon, FileListWidget::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() + BTN_GAP; xpos = myHomeButton->getRight() + BTN_GAP;
myPrevButton = new ButtonWidget(this, _font, xpos, ypos, myPrevButton = new ButtonWidget(this, _font, xpos, ypos,
iconWidth + iconGap - 1, lineHeight + 2, prevIcon, kPrevDirCmd); iconWidth + iconGap - 1, lineHeight + 2, prevIcon, FileListWidget::kPrevDirCmd);
myPrevButton->setToolTip("Go back in directory history."); myPrevButton->setToolTip("Go back in directory history.");
wid.push_back(myPrevButton); wid.push_back(myPrevButton);
xpos = myPrevButton->getRight() + BTN_GAP; xpos = myPrevButton->getRight() + BTN_GAP;
myNextButton = new ButtonWidget(this, _font, xpos, ypos, myNextButton = new ButtonWidget(this, _font, xpos, ypos,
iconWidth + iconGap - 1, lineHeight + 2, nextIcon, kNextDirCmd); iconWidth + iconGap - 1, lineHeight + 2, nextIcon, FileListWidget::kNextDirCmd);
myNextButton->setToolTip("Go forward in directory history."); myNextButton->setToolTip("Go forward in directory history.");
wid.push_back(myNextButton); wid.push_back(myNextButton);
xpos = myNextButton->getRight() + BTN_GAP; xpos = myNextButton->getRight() + BTN_GAP;
myUpButton = new ButtonWidget(this, _font, xpos, ypos, myUpButton = new ButtonWidget(this, _font, xpos, ypos,
iconWidth + iconGap - 1, lineHeight + 2, upIcon, kParentDirCmd); iconWidth + iconGap - 1, lineHeight + 2, upIcon, ListWidget::kParentDirCmd);
myUpButton->setToolTip("Go Up"); myUpButton->setToolTip("Go Up");
wid.push_back(myUpButton); wid.push_back(myUpButton);
xpos = myUpButton->getRight() + BTN_GAP; xpos = myUpButton->getRight() + BTN_GAP;
@ -358,7 +358,7 @@ void LauncherDialog::addButtonWidgets(int& ypos, WidgetArray& wid)
xpos += (buttonWidth + 0) / 4 + BUTTON_GAP; xpos += (buttonWidth + 0) / 4 + BUTTON_GAP;
myGoUpButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 1) / 4, buttonHeight, myGoUpButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 1) / 4, buttonHeight,
"Go Up", kParentDirCmd); "Go Up", ListWidget::kParentDirCmd);
wid.push_back(myGoUpButton); wid.push_back(myGoUpButton);
xpos += (buttonWidth + 1) / 4 + BUTTON_GAP; xpos += (buttonWidth + 1) / 4 + BUTTON_GAP;
@ -382,7 +382,7 @@ void LauncherDialog::addButtonWidgets(int& ypos, WidgetArray& wid)
xpos += (buttonWidth + 1) / 4 + BUTTON_GAP; xpos += (buttonWidth + 1) / 4 + BUTTON_GAP;
myGoUpButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 2) / 4, buttonHeight, myGoUpButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 2) / 4, buttonHeight,
"Go Up", kParentDirCmd); "Go Up", ListWidget::kParentDirCmd);
wid.push_back(myGoUpButton); wid.push_back(myGoUpButton);
xpos += (buttonWidth + 2) / 4 + BUTTON_GAP; xpos += (buttonWidth + 2) / 4 + BUTTON_GAP;
@ -774,7 +774,7 @@ void LauncherDialog::handleContextMenu()
else if(cmd == "subdirs") else if(cmd == "subdirs")
sendCommand(kSubDirsCmd, 0, 0); sendCommand(kSubDirsCmd, 0, 0);
else if(cmd == "homedir") else if(cmd == "homedir")
sendCommand(kHomeDirCmd, 0, 0); sendCommand(FileListWidget::kHomeDirCmd, 0, 0);
else if(cmd == "highscores") else if(cmd == "highscores")
openHighScores(); openHighScores();
else if(cmd == "reload") else if(cmd == "reload")
@ -818,19 +818,19 @@ void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated)
switch(key) switch(key)
{ {
case KBDK_HOME: case KBDK_HOME:
sendCommand(kHomeDirCmd, 0, 0); sendCommand(FileListWidget::kHomeDirCmd, 0, 0);
break; break;
case KBDK_LEFT: case KBDK_LEFT:
sendCommand(kPrevDirCmd, 0, 0); sendCommand(FileListWidget::kPrevDirCmd, 0, 0);
break; break;
case KBDK_RIGHT: case KBDK_RIGHT:
sendCommand(kNextDirCmd, 0, 0); sendCommand(FileListWidget::kNextDirCmd, 0, 0);
break; break;
case KBDK_UP: case KBDK_UP:
sendCommand(kParentDirCmd, 0, 0); sendCommand(ListWidget::kParentDirCmd, 0, 0);
break; break;
case KBDK_DOWN: case KBDK_DOWN:
@ -1007,23 +1007,22 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
toggleSubDirs(); toggleSubDirs();
break; break;
case kHomeDirCmd: case FileListWidget::kHomeDirCmd:
gotoHomeDir(); myList->selectHomeDir();
break; break;
case kPrevDirCmd: case FileListWidget::kPrevDirCmd:
myList->selectPrevHistory(); myList->selectPrevHistory();
break; break;
case kNextDirCmd: case FileListWidget::kNextDirCmd:
myList->selectNextHistory(); myList->selectNextHistory();
break; break;
case kParentDirCmd: case ListWidget::kParentDirCmd:
myList->selectParent(); myList->selectParent();
break; break;
case kLoadROMCmd: case kLoadROMCmd:
if(myList->isDirectory(myList->selected())) if(myList->isDirectory(myList->selected()))
{ {
@ -1314,13 +1313,6 @@ void LauncherDialog::openWhatsNew()
myDialog->open(); myDialog->open();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::gotoHomeDir()
{
while(myList->hasPrevHistory())
myList->selectPrevHistory();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::toggleShowAll(bool toggle) void LauncherDialog::toggleShowAll(bool toggle)
{ {

View File

@ -174,7 +174,6 @@ class LauncherDialog : public Dialog, CommandSender
void showOnlyROMs(bool state); void showOnlyROMs(bool state);
void toggleShowAll(bool toggle = true); void toggleShowAll(bool toggle = true);
void toggleSubDirs(bool toggle = true); void toggleSubDirs(bool toggle = true);
void gotoHomeDir();
void handleContextMenu(); void handleContextMenu();
void handleQuit(); void handleQuit();
void toggleExtensions(); void toggleExtensions();
@ -234,12 +233,8 @@ class LauncherDialog : public Dialog, CommandSender
enum { enum {
kAllfilesCmd = 'lalf', // show all files (or ROMs only) kAllfilesCmd = 'lalf', // show all files (or ROMs only)
kSubDirsCmd = 'lred', kSubDirsCmd = 'lred',
kParentDirCmd = 'PARD',
kOptionsCmd = 'OPTI', kOptionsCmd = 'OPTI',
kQuitCmd = 'QUIT', kQuitCmd = 'QUIT',
kHomeDirCmd = 'homc', // go to Home directory
kPrevDirCmd = 'prvc', // go back in history to previous directory
kNextDirCmd = 'nxtc', // go back in history to next directory
kReloadCmd = 'relc', kReloadCmd = 'relc',
kRmAllFav = 'rmaf', kRmAllFav = 'rmaf',
kRmAllPop = 'rmap', kRmAllPop = 'rmap',