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

@@ -178,6 +178,9 @@
#def_key "2" #def_key "2"
# show_browser # show_browser
# #
#def_key "2"
# change_browse_mode
#
#def_key "3" #def_key "3"
# show_search_engine # show_search_engine
# #

View File

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

View File

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

View File

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

View File

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

View File

@@ -294,7 +294,7 @@ void Help::GetKeybindings()
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
KeyDesc(aEditDirectoryName, "Edit directory name"); KeyDesc(aEditDirectoryName, "Edit directory name");
KeyDesc(aEditPlaylistName, "Edit playlist 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(aToggleBrowserSortMode, "Toggle sort mode");
KeyDesc(aJumpToPlayingSong, "Locate playing song"); KeyDesc(aJumpToPlayingSong, "Locate playing song");
KeyDesc(aJumpToParentDirectory, "Jump to parent directory"); KeyDesc(aJumpToParentDirectory, "Jump to parent directory");