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>
<td>Go to parent directory (also in other file dialogs)</td>
<td>Backspace</td>
<td>Backspace</td>
<td>Backspace, Alt + Up arrow</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>
<td>Remove from 'Recently Played' or 'Most Popular' folder</td>

View File

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

View File

@ -45,7 +45,10 @@ class FileListWidget : public StringListWidget
public:
enum {
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)>;
@ -83,9 +86,11 @@ class FileListWidget : public StringListWidget
virtual void selectDirectory();
/** Select parent directory (if applicable) */
void selectParent();
/** Select to home directory */
void selectHomeDir();
/** Select previous directory in history (if applicable) */
void selectPrevHistory();
/** Select next directory in history */
/** Select next directory in history (if applicable) */
void selectNextHistory();
/** Check if the there is a previous directory in history */
bool hasPrevHistory();
@ -147,6 +152,7 @@ class FileListWidget : public StringListWidget
virtual const Icon* getIcon(int i) const;
int iconWidth() const;
virtual bool fullPathToolTip() const { return false; }
string& fixPath(string& path);
void addHistory(const FilesystemNode& node);
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;
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.");
wid.push_back(myHomeButton);
xpos = myHomeButton->getRight() + BTN_GAP;
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.");
wid.push_back(myPrevButton);
xpos = myPrevButton->getRight() + BTN_GAP;
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.");
wid.push_back(myNextButton);
xpos = myNextButton->getRight() + BTN_GAP;
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");
wid.push_back(myUpButton);
xpos = myUpButton->getRight() + BTN_GAP;
@ -358,7 +358,7 @@ void LauncherDialog::addButtonWidgets(int& ypos, WidgetArray& wid)
xpos += (buttonWidth + 0) / 4 + BUTTON_GAP;
myGoUpButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 1) / 4, buttonHeight,
"Go Up", kParentDirCmd);
"Go Up", ListWidget::kParentDirCmd);
wid.push_back(myGoUpButton);
xpos += (buttonWidth + 1) / 4 + BUTTON_GAP;
@ -382,7 +382,7 @@ void LauncherDialog::addButtonWidgets(int& ypos, WidgetArray& wid)
xpos += (buttonWidth + 1) / 4 + BUTTON_GAP;
myGoUpButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 2) / 4, buttonHeight,
"Go Up", kParentDirCmd);
"Go Up", ListWidget::kParentDirCmd);
wid.push_back(myGoUpButton);
xpos += (buttonWidth + 2) / 4 + BUTTON_GAP;
@ -774,7 +774,7 @@ void LauncherDialog::handleContextMenu()
else if(cmd == "subdirs")
sendCommand(kSubDirsCmd, 0, 0);
else if(cmd == "homedir")
sendCommand(kHomeDirCmd, 0, 0);
sendCommand(FileListWidget::kHomeDirCmd, 0, 0);
else if(cmd == "highscores")
openHighScores();
else if(cmd == "reload")
@ -818,19 +818,19 @@ void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated)
switch(key)
{
case KBDK_HOME:
sendCommand(kHomeDirCmd, 0, 0);
sendCommand(FileListWidget::kHomeDirCmd, 0, 0);
break;
case KBDK_LEFT:
sendCommand(kPrevDirCmd, 0, 0);
sendCommand(FileListWidget::kPrevDirCmd, 0, 0);
break;
case KBDK_RIGHT:
sendCommand(kNextDirCmd, 0, 0);
sendCommand(FileListWidget::kNextDirCmd, 0, 0);
break;
case KBDK_UP:
sendCommand(kParentDirCmd, 0, 0);
sendCommand(ListWidget::kParentDirCmd, 0, 0);
break;
case KBDK_DOWN:
@ -1007,23 +1007,22 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
toggleSubDirs();
break;
case kHomeDirCmd:
gotoHomeDir();
case FileListWidget::kHomeDirCmd:
myList->selectHomeDir();
break;
case kPrevDirCmd:
case FileListWidget::kPrevDirCmd:
myList->selectPrevHistory();
break;
case kNextDirCmd:
case FileListWidget::kNextDirCmd:
myList->selectNextHistory();
break;
case kParentDirCmd:
case ListWidget::kParentDirCmd:
myList->selectParent();
break;
case kLoadROMCmd:
if(myList->isDirectory(myList->selected()))
{
@ -1314,13 +1313,6 @@ void LauncherDialog::openWhatsNew()
myDialog->open();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::gotoHomeDir()
{
while(myList->hasPrevHistory())
myList->selectPrevHistory();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::toggleShowAll(bool toggle)
{

View File

@ -174,7 +174,6 @@ class LauncherDialog : public Dialog, CommandSender
void showOnlyROMs(bool state);
void toggleShowAll(bool toggle = true);
void toggleSubDirs(bool toggle = true);
void gotoHomeDir();
void handleContextMenu();
void handleQuit();
void toggleExtensions();
@ -234,12 +233,8 @@ class LauncherDialog : public Dialog, CommandSender
enum {
kAllfilesCmd = 'lalf', // show all files (or ROMs only)
kSubDirsCmd = 'lred',
kParentDirCmd = 'PARD',
kOptionsCmd = 'OPTI',
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',
kRmAllFav = 'rmaf',
kRmAllPop = 'rmap',