actions: split ShowBrowser into showBrowser and ChangeBrowseMode

This commit is contained in:
Andrzej Rybczak
2012-09-15 23:13:47 +02:00
parent 14587cb4ec
commit 3d2e5adae8
6 changed files with 48 additions and 28 deletions

View File

@@ -2032,6 +2032,16 @@ void ToggleBitrateVisibility::Run()
Statusbar::msg("Bitrate visibility %s", Config.display_bitrate ? "enabled" : "disabled");
}
bool ChangeBrowseMode::canBeRun() const
{
return myScreen == myBrowser;
}
void ChangeBrowseMode::Run()
{
myBrowser->ChangeBrowseMode();
}
void AddRandomItems::Run()
{
using Global::wFooter;
@@ -2334,8 +2344,9 @@ bool ShowPlaylist::canBeRun() const
{
return myScreen != myPlaylist
# ifdef HAVE_TAGLIB_H
&& myScreen != myTinyTagEditor;
&& myScreen != myTinyTagEditor
# endif // HAVE_TAGLIB_H
;
}
void ShowPlaylist::Run()
@@ -2343,12 +2354,14 @@ void ShowPlaylist::Run()
myPlaylist->switchTo();
}
#ifdef HAVE_TAGLIB_H
bool ShowBrowser::canBeRun() const
{
return myScreen != myTinyTagEditor;
return myScreen != myBrowser
# ifdef HAVE_TAGLIB_H
&& myScreen != myTinyTagEditor
# endif // HAVE_TAGLIB_H
;
}
#endif // HAVE_TAGLIB_H
void ShowBrowser::Run()
{
@@ -2383,8 +2396,9 @@ bool ShowPlaylistEditor::canBeRun() const
{
return myScreen != myPlaylistEditor
# ifdef HAVE_TAGLIB_H
&& myScreen != myTinyTagEditor;
&& myScreen != myTinyTagEditor
# endif // HAVE_TAGLIB_H
;
}
void ShowPlaylistEditor::Run()
@@ -2578,6 +2592,7 @@ void populateActions()
insertAction(new ToggleAddMode());
insertAction(new ToggleMouse());
insertAction(new ToggleBitrateVisibility());
insertAction(new ChangeBrowseMode());
insertAction(new AddRandomItems());
insertAction(new ToggleBrowserSortMode());
insertAction(new ToggleLibraryTagType());

View File

@@ -46,7 +46,7 @@ enum ActionType
aToggleMouse, aToggleBitrateVisibility, aAddRandomItems, aToggleBrowserSortMode, aToggleLibraryTagType,
aRefetchLyrics, aRefetchArtistInfo, aSetSelectedItemsPriority, aFilterPlaylistOnPriorities,
aShowSongInfo, aShowArtistInfo,
aShowLyrics, aQuit, aNextScreen, aPreviousScreen, aShowHelp, aShowPlaylist, aShowBrowser,
aShowLyrics, aQuit, aNextScreen, aPreviousScreen, aShowHelp, aShowPlaylist, aShowBrowser, aChangeBrowseMode,
aShowSearchEngine, aShowMediaLibrary, aShowPlaylistEditor, aShowTagEditor, aShowOutputs,
aShowVisualizer, aShowClock, aShowServerInfo
};
@@ -997,9 +997,16 @@ struct ShowBrowser : public Action
ShowBrowser() : Action(aShowBrowser, "show_browser") { }
protected:
# ifdef HAVE_TAGLIB_H
virtual bool canBeRun() const;
# endif // HAVE_TAGLIB_H
virtual void Run();
};
struct ChangeBrowseMode : public Action
{
ChangeBrowseMode() : Action(aChangeBrowseMode, "change_browse_mode") { }
protected:
virtual bool canBeRun() const;
virtual void Run();
};

View File

@@ -309,7 +309,10 @@ void BindingsConfiguration::generateDefaults()
if (notBound(k = stringToKey("1")))
bind(k, aShowPlaylist);
if (notBound(k = stringToKey("2")))
{
bind(k, aShowBrowser);
bind(k, aChangeBrowseMode);
}
if (notBound(k = stringToKey("3")))
bind(k, aShowSearchEngine);
if (notBound(k = stringToKey("4")))

View File

@@ -88,26 +88,18 @@ void Browser::resize()
void Browser::switchTo()
{
if (myScreen == this)
{
# ifndef WIN32
ChangeBrowseMode();
# endif // !WIN32
}
SwitchTo::execute(this);
// local browser doesn't support sorting by mtime
if (isLocal() && Config.browser_sort_mode == smMTime)
Config.browser_sort_mode = smName;
if (w.empty())
GetDirectory(itsBrowsedDir);
else
{
SwitchTo::execute(this);
if (isLocal() && Config.browser_sort_mode == smMTime) // local browser doesn't support sorting by mtime
Config.browser_sort_mode = smName;
if (w.empty())
GetDirectory(itsBrowsedDir);
else
markSongsInPlaylist(getProxySongList());
drawHeader();
}
markSongsInPlaylist(getProxySongList());
drawHeader();
}
std::wstring Browser::title()

View File

@@ -294,7 +294,7 @@ void Help::GetKeybindings()
# endif // HAVE_TAGLIB_H
KeyDesc(aEditDirectoryName, "Edit directory name");
KeyDesc(aEditPlaylistName, "Edit playlist name");
KeyDesc(aShowBrowser, "Browse MPD database/local filesystem");
KeyDesc(aChangeBrowseMode, "Browse MPD database/local filesystem");
KeyDesc(aToggleBrowserSortMode, "Toggle sort mode");
KeyDesc(aJumpToPlayingSong, "Locate playing song");
KeyDesc(aJumpToParentDirectory, "Jump to parent directory");