actions: split ShowSearchEngine into ShowSearchEngine and ResetSearchEngine

This commit is contained in:
Andrzej Rybczak
2012-09-15 23:20:18 +02:00
parent 3d2e5adae8
commit b4ab065b2d
7 changed files with 51 additions and 29 deletions

View File

@@ -184,6 +184,9 @@
#def_key "3" #def_key "3"
# show_search_engine # show_search_engine
# #
#def_key "3"
# reset_search_engine
#
#def_key "4" #def_key "4"
# show_media_library # show_media_library
# #

View File

@@ -2032,16 +2032,6 @@ 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;
@@ -2368,18 +2358,40 @@ void ShowBrowser::Run()
myBrowser->switchTo(); myBrowser->switchTo();
} }
#ifdef HAVE_TAGLIB_H bool ChangeBrowseMode::canBeRun() const
{
return myScreen == myBrowser;
}
void ChangeBrowseMode::Run()
{
myBrowser->ChangeBrowseMode();
}
bool ShowSearchEngine::canBeRun() const bool ShowSearchEngine::canBeRun() const
{ {
return myScreen != myTinyTagEditor; return myScreen != mySearcher
# ifdef HAVE_TAGLIB_H
&& myScreen != myTinyTagEditor
# endif // HAVE_TAGLIB_H
;
} }
#endif // HAVE_TAGLIB_H
void ShowSearchEngine::Run() void ShowSearchEngine::Run()
{ {
mySearcher->switchTo(); mySearcher->switchTo();
} }
bool ResetSearchEngine::canBeRun() const
{
return myScreen == mySearcher;
}
void ResetSearchEngine::Run()
{
mySearcher->reset();
}
#ifdef HAVE_TAGLIB_H #ifdef HAVE_TAGLIB_H
bool ShowMediaLibrary::canBeRun() const bool ShowMediaLibrary::canBeRun() const
{ {
@@ -2592,7 +2604,6 @@ 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());
@@ -2609,7 +2620,9 @@ void populateActions()
insertAction(new ShowHelp()); insertAction(new ShowHelp());
insertAction(new ShowPlaylist()); insertAction(new ShowPlaylist());
insertAction(new ShowBrowser()); insertAction(new ShowBrowser());
insertAction(new ChangeBrowseMode());
insertAction(new ShowSearchEngine()); insertAction(new ShowSearchEngine());
insertAction(new ResetSearchEngine());
insertAction(new ShowMediaLibrary()); insertAction(new ShowMediaLibrary());
insertAction(new ShowPlaylistEditor()); insertAction(new ShowPlaylistEditor());
insertAction(new ShowTagEditor()); insertAction(new ShowTagEditor());

View File

@@ -47,7 +47,7 @@ enum ActionType
aRefetchLyrics, aRefetchArtistInfo, aSetSelectedItemsPriority, aFilterPlaylistOnPriorities, aRefetchLyrics, aRefetchArtistInfo, aSetSelectedItemsPriority, aFilterPlaylistOnPriorities,
aShowSongInfo, aShowArtistInfo, aShowSongInfo, aShowArtistInfo,
aShowLyrics, aQuit, aNextScreen, aPreviousScreen, aShowHelp, aShowPlaylist, aShowBrowser, aChangeBrowseMode, aShowLyrics, aQuit, aNextScreen, aPreviousScreen, aShowHelp, aShowPlaylist, aShowBrowser, aChangeBrowseMode,
aShowSearchEngine, aShowMediaLibrary, aShowPlaylistEditor, aShowTagEditor, aShowOutputs, aShowSearchEngine, aResetSearchEngine, aShowMediaLibrary, aShowPlaylistEditor, aShowTagEditor, aShowOutputs,
aShowVisualizer, aShowClock, aShowServerInfo aShowVisualizer, aShowClock, aShowServerInfo
}; };
@@ -1015,9 +1015,16 @@ struct ShowSearchEngine : public Action
ShowSearchEngine() : Action(aShowSearchEngine, "show_search_engine") { } ShowSearchEngine() : Action(aShowSearchEngine, "show_search_engine") { }
protected: protected:
# ifdef HAVE_TAGLIB_H
virtual bool canBeRun() const; virtual bool canBeRun() const;
# endif // HAVE_TAGLIB_H virtual void Run();
};
struct ResetSearchEngine : public Action
{
ResetSearchEngine() : Action(aResetSearchEngine, "reset_search_engine") { }
protected:
virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };

View File

@@ -314,7 +314,10 @@ void BindingsConfiguration::generateDefaults()
bind(k, aChangeBrowseMode); bind(k, aChangeBrowseMode);
} }
if (notBound(k = stringToKey("3"))) if (notBound(k = stringToKey("3")))
{
bind(k, aShowSearchEngine); bind(k, aShowSearchEngine);
bind(k, aResetSearchEngine);
}
if (notBound(k = stringToKey("4"))) if (notBound(k = stringToKey("4")))
bind(k, aShowMediaLibrary); bind(k, aShowMediaLibrary);
if (notBound(k = stringToKey("5"))) if (notBound(k = stringToKey("5")))

View File

@@ -308,7 +308,7 @@ void Help::GetKeybindings()
KeyDesc(aEditSong, "Edit song"); KeyDesc(aEditSong, "Edit song");
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
KeyDesc(aStartSearching, "Start searching"); KeyDesc(aStartSearching, "Start searching");
KeyDesc(aShowSearchEngine, "Reset search constraints and clear results"); KeyDesc(aResetSearchEngine, "Reset search constraints and clear results");
KeysSection("Media library"); KeysSection("Media library");
if (!Config.media_library_disable_two_column_mode) if (!Config.media_library_disable_two_column_mode)

View File

@@ -126,16 +126,11 @@ void SearchEngine::resize()
void SearchEngine::switchTo() void SearchEngine::switchTo()
{ {
if (Global::myScreen != this) SwitchTo::execute(this);
{ if (w.empty())
SwitchTo::execute(this); Prepare();
if (w.empty()) markSongsInPlaylist(getProxySongList());
Prepare(); drawHeader();
markSongsInPlaylist(getProxySongList());
drawHeader();
}
else
reset();
} }
std::wstring SearchEngine::title() std::wstring SearchEngine::title()

View File

@@ -110,6 +110,8 @@ struct SearchEngine: Screen<NC::Menu<SEItem>>, Filterable, HasSongs, Searchable,
virtual MPD::SongList getSelectedSongs() OVERRIDE; virtual MPD::SongList getSelectedSongs() OVERRIDE;
// private members // private members
void reset();
static size_t StaticOptions; static size_t StaticOptions;
static size_t SearchButton; static size_t SearchButton;
static size_t ResetButton; static size_t ResetButton;
@@ -120,7 +122,6 @@ protected:
private: private:
void Prepare(); void Prepare();
void Search(); void Search();
void reset();
const char **SearchMode; const char **SearchMode;