actions: guarantee that action will not be executed without checks

This commit is contained in:
Andrzej Rybczak
2012-09-05 21:45:19 +02:00
parent 837a7c14cf
commit 39c5087d18
5 changed files with 239 additions and 38 deletions

View File

@@ -1905,20 +1905,6 @@ void ApplyFilter::Run()
ListsChangeFinisher(); ListsChangeFinisher();
} }
void DisableFilter::Run()
{
using Global::wFooter;
ApplyFilter *applyFilter = dynamic_cast<ApplyFilter *>(Get(aApplyFilter));
if (applyFilter && applyFilter->canBeRun())
{
// delete current filter
wFooter->pushChar(KEY_CTRL_U);
wFooter->pushChar(KEY_ENTER);
applyFilter->Execute();
}
}
bool Find::canBeRun() const bool Find::canBeRun() const
{ {
return myScreen == myHelp return myScreen == myHelp
@@ -2563,7 +2549,6 @@ void populateActions()
insertAction(new SortPlaylist()); insertAction(new SortPlaylist());
insertAction(new ReversePlaylist()); insertAction(new ReversePlaylist());
insertAction(new ApplyFilter()); insertAction(new ApplyFilter());
insertAction(new DisableFilter());
insertAction(new Find()); insertAction(new Find());
insertAction(new FindItemForward()); insertAction(new FindItemForward());
insertAction(new FindItemBackward()); insertAction(new FindItemBackward());

View File

@@ -41,7 +41,7 @@ enum ActionType
aJumpToMediaLibrary, aJumpToPlaylistEditor, aToggleScreenLock, aJumpToTagEditor, aJumpToMediaLibrary, aJumpToPlaylistEditor, aToggleScreenLock, aJumpToTagEditor,
aJumpToPositionInSong, aReverseSelection, aDeselectItems, aSelectAlbum, aAddSelectedItems, aJumpToPositionInSong, aReverseSelection, aDeselectItems, aSelectAlbum, aAddSelectedItems,
aCropMainPlaylist, aCropPlaylist, aClearMainPlaylist, aClearPlaylist, aSortPlaylist, aReversePlaylist, aCropMainPlaylist, aCropPlaylist, aClearMainPlaylist, aClearPlaylist, aSortPlaylist, aReversePlaylist,
aApplyFilter, aDisableFilter, aFind, aFindItemForward, aFindItemBackward, aNextFoundItem, aApplyFilter, aFind, aFindItemForward, aFindItemBackward, aNextFoundItem,
aPreviousFoundItem, aToggleFindMode, aToggleReplayGainMode, aToggleSpaceMode, aToggleAddMode, aPreviousFoundItem, aToggleFindMode, aToggleReplayGainMode, aToggleSpaceMode, aToggleAddMode,
aToggleMouse, aToggleBitrateVisibility, aAddRandomItems, aToggleBrowserSortMode, aToggleLibraryTagType, aToggleMouse, aToggleBitrateVisibility, aAddRandomItems, aToggleBrowserSortMode, aToggleLibraryTagType,
aRefetchLyrics, aRefetchArtistInfo, aSetSelectedItemsPriority, aShowSongInfo, aShowArtistInfo, aRefetchLyrics, aRefetchArtistInfo, aSetSelectedItemsPriority, aShowSongInfo, aShowArtistInfo,
@@ -92,27 +92,31 @@ struct Action
static size_t FooterHeight; static size_t FooterHeight;
static size_t FooterStartY; static size_t FooterStartY;
protected: protected:
virtual void Run() = 0; virtual void Run() = 0;
static void Seek(); static void Seek();
static void FindItem(const FindDirection); static void FindItem(const FindDirection);
static void ListsChangeFinisher(); static void ListsChangeFinisher();
private: private:
ActionType itsType; ActionType itsType;
const char *itsName; const char *itsName;
}; };
struct Dummy : public Action struct Dummy : public Action
{ {
Dummy() : Action(aDummy, "dummy") { } Dummy() : Action(aDummy, "dummy") { }
protected:
virtual void Run() { } virtual void Run() { }
}; };
struct MouseEvent : public Action struct MouseEvent : public Action
{ {
MouseEvent() : Action(aMouseEvent, "mouse_event") { } MouseEvent() : Action(aMouseEvent, "mouse_event") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
@@ -124,18 +128,24 @@ struct MouseEvent : public Action
struct ScrollUp : public Action struct ScrollUp : public Action
{ {
ScrollUp() : Action(aScrollUp, "scroll_up") { } ScrollUp() : Action(aScrollUp, "scroll_up") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ScrollDown : public Action struct ScrollDown : public Action
{ {
ScrollDown() : Action(aScrollDown, "scroll_down") { } ScrollDown() : Action(aScrollDown, "scroll_down") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ScrollUpArtist : public Action struct ScrollUpArtist : public Action
{ {
ScrollUpArtist() : Action(aScrollUpArtist, "scroll_up_artist") { } ScrollUpArtist() : Action(aScrollUpArtist, "scroll_up_artist") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -143,6 +153,8 @@ struct ScrollUpArtist : public Action
struct ScrollUpAlbum : public Action struct ScrollUpAlbum : public Action
{ {
ScrollUpAlbum() : Action(aScrollUpAlbum, "scroll_up_album") { } ScrollUpAlbum() : Action(aScrollUpAlbum, "scroll_up_album") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -150,6 +162,8 @@ struct ScrollUpAlbum : public Action
struct ScrollDownArtist : public Action struct ScrollDownArtist : public Action
{ {
ScrollDownArtist() : Action(aScrollDownArtist, "scroll_down_artist") { } ScrollDownArtist() : Action(aScrollDownArtist, "scroll_down_artist") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -157,6 +171,8 @@ struct ScrollDownArtist : public Action
struct ScrollDownAlbum : public Action struct ScrollDownAlbum : public Action
{ {
ScrollDownAlbum() : Action(aScrollDownAlbum, "scroll_down_album") { } ScrollDownAlbum() : Action(aScrollDownAlbum, "scroll_down_album") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -164,36 +180,48 @@ struct ScrollDownAlbum : public Action
struct PageUp : public Action struct PageUp : public Action
{ {
PageUp() : Action(aPageUp, "page_up") { } PageUp() : Action(aPageUp, "page_up") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct PageDown : public Action struct PageDown : public Action
{ {
PageDown() : Action(aPageDown, "page_down") { } PageDown() : Action(aPageDown, "page_down") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct MoveHome : public Action struct MoveHome : public Action
{ {
MoveHome() : Action(aMoveHome, "move_home") { } MoveHome() : Action(aMoveHome, "move_home") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct MoveEnd : public Action struct MoveEnd : public Action
{ {
MoveEnd() : Action(aMoveEnd, "move_end") { } MoveEnd() : Action(aMoveEnd, "move_end") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ToggleInterface : public Action struct ToggleInterface : public Action
{ {
ToggleInterface() : Action(aToggleInterface, "toggle_inferface") { } ToggleInterface() : Action(aToggleInterface, "toggle_inferface") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct JumpToParentDir : public Action struct JumpToParentDir : public Action
{ {
JumpToParentDir() : Action(aJumpToParentDir, "jump_to_parent_dir") { } JumpToParentDir() : Action(aJumpToParentDir, "jump_to_parent_dir") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -201,18 +229,24 @@ struct JumpToParentDir : public Action
struct PressEnter : public Action struct PressEnter : public Action
{ {
PressEnter() : Action(aPressEnter, "press_enter") { } PressEnter() : Action(aPressEnter, "press_enter") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct PressSpace : public Action struct PressSpace : public Action
{ {
PressSpace() : Action(aPressSpace, "press_space") { } PressSpace() : Action(aPressSpace, "press_space") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct PreviousColumn : public Action struct PreviousColumn : public Action
{ {
PreviousColumn() : Action(aPreviousColumn, "previous_column") { } PreviousColumn() : Action(aPreviousColumn, "previous_column") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -220,6 +254,8 @@ struct PreviousColumn : public Action
struct NextColumn : public Action struct NextColumn : public Action
{ {
NextColumn() : Action(aNextColumn, "next_column") { } NextColumn() : Action(aNextColumn, "next_column") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -227,6 +263,8 @@ struct NextColumn : public Action
struct MasterScreen : public Action struct MasterScreen : public Action
{ {
MasterScreen() : Action(aMasterScreen, "master_screen") { } MasterScreen() : Action(aMasterScreen, "master_screen") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -234,6 +272,8 @@ struct MasterScreen : public Action
struct SlaveScreen : public Action struct SlaveScreen : public Action
{ {
SlaveScreen() : Action(aSlaveScreen, "slave_screen") { } SlaveScreen() : Action(aSlaveScreen, "slave_screen") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -241,60 +281,80 @@ struct SlaveScreen : public Action
struct VolumeUp : public Action struct VolumeUp : public Action
{ {
VolumeUp() : Action(aVolumeUp, "volume_up") { } VolumeUp() : Action(aVolumeUp, "volume_up") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct VolumeDown : public Action struct VolumeDown : public Action
{ {
VolumeDown() : Action(aVolumeDown, "volume_down") { } VolumeDown() : Action(aVolumeDown, "volume_down") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct Delete : public Action struct Delete : public Action
{ {
Delete() : Action(aDelete, "delete") { } Delete() : Action(aDelete, "delete") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ReplaySong : public Action struct ReplaySong : public Action
{ {
ReplaySong() : Action(aReplaySong, "replay_song") { } ReplaySong() : Action(aReplaySong, "replay_song") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct PreviousSong : public Action struct PreviousSong : public Action
{ {
PreviousSong() : Action(aPreviousSong, "previous") { } PreviousSong() : Action(aPreviousSong, "previous") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct NextSong : public Action struct NextSong : public Action
{ {
NextSong() : Action(aNextSong, "next") { } NextSong() : Action(aNextSong, "next") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct Pause : public Action struct Pause : public Action
{ {
Pause() : Action(aPause, "pause") { } Pause() : Action(aPause, "pause") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct Stop : public Action struct Stop : public Action
{ {
Stop() : Action(aStop, "stop") { } Stop() : Action(aStop, "stop") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct SavePlaylist : public Action struct SavePlaylist : public Action
{ {
SavePlaylist() : Action(aSavePlaylist, "save_playlist") { } SavePlaylist() : Action(aSavePlaylist, "save_playlist") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct MoveSortOrderUp : public Action struct MoveSortOrderUp : public Action
{ {
MoveSortOrderUp() : Action(aMoveSortOrderUp, "move_sort_order_up") { } MoveSortOrderUp() : Action(aMoveSortOrderUp, "move_sort_order_up") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -302,6 +362,8 @@ struct MoveSortOrderUp : public Action
struct MoveSortOrderDown : public Action struct MoveSortOrderDown : public Action
{ {
MoveSortOrderDown() : Action(aMoveSortOrderDown, "move_sort_order_down") { } MoveSortOrderDown() : Action(aMoveSortOrderDown, "move_sort_order_down") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -309,6 +371,8 @@ struct MoveSortOrderDown : public Action
struct MoveSelectedItemsUp : public Action struct MoveSelectedItemsUp : public Action
{ {
MoveSelectedItemsUp() : Action(aMoveSelectedItemsUp, "move_selected_items_up") { } MoveSelectedItemsUp() : Action(aMoveSelectedItemsUp, "move_selected_items_up") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -316,6 +380,8 @@ struct MoveSelectedItemsUp : public Action
struct MoveSelectedItemsDown : public Action struct MoveSelectedItemsDown : public Action
{ {
MoveSelectedItemsDown() : Action(aMoveSelectedItemsDown, "move_selected_items_down") { } MoveSelectedItemsDown() : Action(aMoveSelectedItemsDown, "move_selected_items_down") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -323,6 +389,8 @@ struct MoveSelectedItemsDown : public Action
struct MoveSelectedItemsTo : public Action struct MoveSelectedItemsTo : public Action
{ {
MoveSelectedItemsTo() : Action(aMoveSelectedItemsTo, "move_selected_items_to") { } MoveSelectedItemsTo() : Action(aMoveSelectedItemsTo, "move_selected_items_to") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -330,6 +398,8 @@ struct MoveSelectedItemsTo : public Action
struct Add : public Action struct Add : public Action
{ {
Add() : Action(aAdd, "add") { } Add() : Action(aAdd, "add") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -337,6 +407,8 @@ struct Add : public Action
struct SeekForward : public Action struct SeekForward : public Action
{ {
SeekForward() : Action(aSeekForward, "seek_forward") { } SeekForward() : Action(aSeekForward, "seek_forward") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -344,6 +416,8 @@ struct SeekForward : public Action
struct SeekBackward : public Action struct SeekBackward : public Action
{ {
SeekBackward() : Action(aSeekBackward, "seek_backward") { } SeekBackward() : Action(aSeekBackward, "seek_backward") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -351,13 +425,18 @@ struct SeekBackward : public Action
struct ToggleDisplayMode : public Action struct ToggleDisplayMode : public Action
{ {
ToggleDisplayMode() : Action(aToggleDisplayMode, "toggle_display_mode") { } ToggleDisplayMode() : Action(aToggleDisplayMode, "toggle_display_mode") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
struct ToggleSeparatorsBetweenAlbums : public Action struct ToggleSeparatorsBetweenAlbums : public Action
{ {
ToggleSeparatorsBetweenAlbums() : Action(aToggleSeparatorsBetweenAlbums, "toggle_separators_between_albums") { } ToggleSeparatorsBetweenAlbums()
: Action(aToggleSeparatorsBetweenAlbums, "toggle_separators_between_albums") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -365,6 +444,8 @@ struct ToggleSeparatorsBetweenAlbums : public Action
struct ToggleLyricsFetcher : public Action struct ToggleLyricsFetcher : public Action
{ {
ToggleLyricsFetcher() : Action(aToggleLyricsFetcher, "toggle_lyrics_fetcher") { } ToggleLyricsFetcher() : Action(aToggleLyricsFetcher, "toggle_lyrics_fetcher") { }
protected:
# ifndef HAVE_CURL_CURL_H # ifndef HAVE_CURL_CURL_H
virtual bool canBeRun() const; virtual bool canBeRun() const;
# endif // NOT HAVE_CURL_CURL_H # endif // NOT HAVE_CURL_CURL_H
@@ -373,7 +454,10 @@ struct ToggleLyricsFetcher : public Action
struct ToggleFetchingLyricsInBackground : public Action struct ToggleFetchingLyricsInBackground : public Action
{ {
ToggleFetchingLyricsInBackground() : Action(aToggleFetchingLyricsInBackground, "toggle_fetching_lyrics_in_background") { } ToggleFetchingLyricsInBackground()
: Action(aToggleFetchingLyricsInBackground, "toggle_fetching_lyrics_in_background") { }
protected:
# ifndef HAVE_CURL_CURL_H # ifndef HAVE_CURL_CURL_H
virtual bool canBeRun() const; virtual bool canBeRun() const;
# endif // NOT HAVE_CURL_CURL_H # endif // NOT HAVE_CURL_CURL_H
@@ -383,18 +467,24 @@ struct ToggleFetchingLyricsInBackground : public Action
struct ToggleAutoCenter : public Action struct ToggleAutoCenter : public Action
{ {
ToggleAutoCenter() : Action(aToggleAutoCenter, "toggle_autocentering") { } ToggleAutoCenter() : Action(aToggleAutoCenter, "toggle_autocentering") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct UpdateDatabase : public Action struct UpdateDatabase : public Action
{ {
UpdateDatabase() : Action(aUpdateDatabase, "update_database") { } UpdateDatabase() : Action(aUpdateDatabase, "update_database") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct JumpToPlayingSong : public Action struct JumpToPlayingSong : public Action
{ {
JumpToPlayingSong() : Action(aJumpToPlayingSong, "jump_to_playing_song") { } JumpToPlayingSong() : Action(aJumpToPlayingSong, "jump_to_playing_song") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -402,24 +492,32 @@ struct JumpToPlayingSong : public Action
struct ToggleRepeat : public Action struct ToggleRepeat : public Action
{ {
ToggleRepeat() : Action(aToggleRepeat, "toggle_repeat") { } ToggleRepeat() : Action(aToggleRepeat, "toggle_repeat") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct Shuffle : public Action struct Shuffle : public Action
{ {
Shuffle() : Action(aShuffle, "shuffle") { } Shuffle() : Action(aShuffle, "shuffle") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ToggleRandom : public Action struct ToggleRandom : public Action
{ {
ToggleRandom() : Action(aToggleRandom, "toggle_random") { } ToggleRandom() : Action(aToggleRandom, "toggle_random") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct StartSearching : public Action struct StartSearching : public Action
{ {
StartSearching() : Action(aStartSearching, "start_searching") { } StartSearching() : Action(aStartSearching, "start_searching") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -427,6 +525,8 @@ struct StartSearching : public Action
struct SaveTagChanges : public Action struct SaveTagChanges : public Action
{ {
SaveTagChanges() : Action(aSaveTagChanges, "save_tag_changes") { } SaveTagChanges() : Action(aSaveTagChanges, "save_tag_changes") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -434,30 +534,40 @@ struct SaveTagChanges : public Action
struct ToggleSingle : public Action struct ToggleSingle : public Action
{ {
ToggleSingle() : Action(aToggleSingle, "toggle_single") { } ToggleSingle() : Action(aToggleSingle, "toggle_single") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ToggleConsume : public Action struct ToggleConsume : public Action
{ {
ToggleConsume() : Action(aToggleConsume, "toggle_consume") { } ToggleConsume() : Action(aToggleConsume, "toggle_consume") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ToggleCrossfade : public Action struct ToggleCrossfade : public Action
{ {
ToggleCrossfade() : Action(aToggleCrossfade, "toggle_crossfade") { } ToggleCrossfade() : Action(aToggleCrossfade, "toggle_crossfade") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct SetCrossfade : public Action struct SetCrossfade : public Action
{ {
SetCrossfade() : Action(aSetCrossfade, "set_crossfade") { } SetCrossfade() : Action(aSetCrossfade, "set_crossfade") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct EditSong : public Action struct EditSong : public Action
{ {
EditSong() : Action(aEditSong, "edit_song") { } EditSong() : Action(aEditSong, "edit_song") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -465,6 +575,8 @@ struct EditSong : public Action
struct EditLibraryTag : public Action struct EditLibraryTag : public Action
{ {
EditLibraryTag() : Action(aEditLibraryTag, "edit_library_tag") { } EditLibraryTag() : Action(aEditLibraryTag, "edit_library_tag") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -472,6 +584,8 @@ struct EditLibraryTag : public Action
struct EditLibraryAlbum : public Action struct EditLibraryAlbum : public Action
{ {
EditLibraryAlbum() : Action(aEditLibraryAlbum, "edit_library_album") { } EditLibraryAlbum() : Action(aEditLibraryAlbum, "edit_library_album") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -479,6 +593,8 @@ struct EditLibraryAlbum : public Action
struct EditDirectoryName : public Action struct EditDirectoryName : public Action
{ {
EditDirectoryName() : Action(aEditDirectoryName, "edit_directory_name") { } EditDirectoryName() : Action(aEditDirectoryName, "edit_directory_name") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -486,6 +602,8 @@ struct EditDirectoryName : public Action
struct EditPlaylistName : public Action struct EditPlaylistName : public Action
{ {
EditPlaylistName() : Action(aEditPlaylistName, "edit_playlist_name") { } EditPlaylistName() : Action(aEditPlaylistName, "edit_playlist_name") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -493,6 +611,8 @@ struct EditPlaylistName : public Action
struct EditLyrics : public Action struct EditLyrics : public Action
{ {
EditLyrics() : Action(aEditLyrics, "edit_lyrics") { } EditLyrics() : Action(aEditLyrics, "edit_lyrics") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -500,6 +620,8 @@ struct EditLyrics : public Action
struct JumpToBrowser : public Action struct JumpToBrowser : public Action
{ {
JumpToBrowser() : Action(aJumpToBrowser, "jump_to_browser") { } JumpToBrowser() : Action(aJumpToBrowser, "jump_to_browser") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -507,6 +629,8 @@ struct JumpToBrowser : public Action
struct JumpToMediaLibrary : public Action struct JumpToMediaLibrary : public Action
{ {
JumpToMediaLibrary() : Action(aJumpToMediaLibrary, "jump_to_media_library") { } JumpToMediaLibrary() : Action(aJumpToMediaLibrary, "jump_to_media_library") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -514,6 +638,8 @@ struct JumpToMediaLibrary : public Action
struct JumpToPlaylistEditor : public Action struct JumpToPlaylistEditor : public Action
{ {
JumpToPlaylistEditor() : Action(aJumpToPlaylistEditor, "jump_to_playlist_editor") { } JumpToPlaylistEditor() : Action(aJumpToPlaylistEditor, "jump_to_playlist_editor") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -521,12 +647,16 @@ struct JumpToPlaylistEditor : public Action
struct ToggleScreenLock : public Action struct ToggleScreenLock : public Action
{ {
ToggleScreenLock() : Action(aToggleScreenLock, "toggle_screen_lock") { } ToggleScreenLock() : Action(aToggleScreenLock, "toggle_screen_lock") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct JumpToTagEditor : public Action struct JumpToTagEditor : public Action
{ {
JumpToTagEditor() : Action(aJumpToTagEditor, "jump_to_tag_editor") { } JumpToTagEditor() : Action(aJumpToTagEditor, "jump_to_tag_editor") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -534,6 +664,8 @@ struct JumpToTagEditor : public Action
struct JumpToPositionInSong : public Action struct JumpToPositionInSong : public Action
{ {
JumpToPositionInSong() : Action(aJumpToPositionInSong, "jump_to_position_in_song") { } JumpToPositionInSong() : Action(aJumpToPositionInSong, "jump_to_position_in_song") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -541,6 +673,8 @@ struct JumpToPositionInSong : public Action
struct ReverseSelection : public Action struct ReverseSelection : public Action
{ {
ReverseSelection() : Action(aReverseSelection, "reverse_selection") { } ReverseSelection() : Action(aReverseSelection, "reverse_selection") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -548,6 +682,8 @@ struct ReverseSelection : public Action
struct DeselectItems : public Action struct DeselectItems : public Action
{ {
DeselectItems() : Action(aDeselectItems, "deselect_items") { } DeselectItems() : Action(aDeselectItems, "deselect_items") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -555,6 +691,8 @@ struct DeselectItems : public Action
struct SelectAlbum : public Action struct SelectAlbum : public Action
{ {
SelectAlbum() : Action(aSelectAlbum, "select_album") { } SelectAlbum() : Action(aSelectAlbum, "select_album") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -562,18 +700,24 @@ struct SelectAlbum : public Action
struct AddSelectedItems : public Action struct AddSelectedItems : public Action
{ {
AddSelectedItems() : Action(aAddSelectedItems, "add_selected_items") { } AddSelectedItems() : Action(aAddSelectedItems, "add_selected_items") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct CropMainPlaylist : public Action struct CropMainPlaylist : public Action
{ {
CropMainPlaylist() : Action(aCropMainPlaylist, "crop_main_playlist") { } CropMainPlaylist() : Action(aCropMainPlaylist, "crop_main_playlist") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct CropPlaylist : public Action struct CropPlaylist : public Action
{ {
CropPlaylist() : Action(aCropPlaylist, "crop_playlist") { } CropPlaylist() : Action(aCropPlaylist, "crop_playlist") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -581,12 +725,16 @@ struct CropPlaylist : public Action
struct ClearMainPlaylist : public Action struct ClearMainPlaylist : public Action
{ {
ClearMainPlaylist() : Action(aClearMainPlaylist, "clear_main_playlist") { } ClearMainPlaylist() : Action(aClearMainPlaylist, "clear_main_playlist") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ClearPlaylist : public Action struct ClearPlaylist : public Action
{ {
ClearPlaylist() : Action(aClearPlaylist, "clear_playlist") { } ClearPlaylist() : Action(aClearPlaylist, "clear_playlist") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -594,6 +742,8 @@ struct ClearPlaylist : public Action
struct SortPlaylist : public Action struct SortPlaylist : public Action
{ {
SortPlaylist() : Action(aSortPlaylist, "sort_playlist") { } SortPlaylist() : Action(aSortPlaylist, "sort_playlist") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -601,6 +751,8 @@ struct SortPlaylist : public Action
struct ReversePlaylist : public Action struct ReversePlaylist : public Action
{ {
ReversePlaylist() : Action(aReversePlaylist, "reverse_playlist") { } ReversePlaylist() : Action(aReversePlaylist, "reverse_playlist") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -608,19 +760,17 @@ struct ReversePlaylist : public Action
struct ApplyFilter : public Action struct ApplyFilter : public Action
{ {
ApplyFilter() : Action(aApplyFilter, "apply_filter") { } ApplyFilter() : Action(aApplyFilter, "apply_filter") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
struct DisableFilter : public Action
{
DisableFilter() : Action(aDisableFilter, "disable_filter") { }
virtual void Run();
};
struct Find : public Action struct Find : public Action
{ {
Find() : Action(aFind, "find") { } Find() : Action(aFind, "find") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -628,6 +778,8 @@ struct Find : public Action
struct FindItemForward : public Action struct FindItemForward : public Action
{ {
FindItemForward() : Action(aFindItemForward, "find_item_forward") { } FindItemForward() : Action(aFindItemForward, "find_item_forward") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -635,6 +787,8 @@ struct FindItemForward : public Action
struct FindItemBackward : public Action struct FindItemBackward : public Action
{ {
FindItemBackward() : Action(aFindItemBackward, "find_item_backward") { } FindItemBackward() : Action(aFindItemBackward, "find_item_backward") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -642,6 +796,8 @@ struct FindItemBackward : public Action
struct NextFoundItem : public Action struct NextFoundItem : public Action
{ {
NextFoundItem() : Action(aNextFoundItem, "next_found_item") { } NextFoundItem() : Action(aNextFoundItem, "next_found_item") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -649,6 +805,8 @@ struct NextFoundItem : public Action
struct PreviousFoundItem : public Action struct PreviousFoundItem : public Action
{ {
PreviousFoundItem() : Action(aPreviousFoundItem, "previous_found_item") { } PreviousFoundItem() : Action(aPreviousFoundItem, "previous_found_item") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -656,12 +814,16 @@ struct PreviousFoundItem : public Action
struct ToggleFindMode : public Action struct ToggleFindMode : public Action
{ {
ToggleFindMode() : Action(aToggleFindMode, "toggle_find_mode") { } ToggleFindMode() : Action(aToggleFindMode, "toggle_find_mode") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ToggleReplayGainMode : public Action struct ToggleReplayGainMode : public Action
{ {
ToggleReplayGainMode() : Action(aToggleReplayGainMode, "toggle_replay_gain_mode") { } ToggleReplayGainMode() : Action(aToggleReplayGainMode, "toggle_replay_gain_mode") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -669,36 +831,48 @@ struct ToggleReplayGainMode : public Action
struct ToggleSpaceMode : public Action struct ToggleSpaceMode : public Action
{ {
ToggleSpaceMode() : Action(aToggleSpaceMode, "toggle_space_mode") { } ToggleSpaceMode() : Action(aToggleSpaceMode, "toggle_space_mode") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ToggleAddMode : public Action struct ToggleAddMode : public Action
{ {
ToggleAddMode() : Action(aToggleAddMode, "toggle_add_mode") { } ToggleAddMode() : Action(aToggleAddMode, "toggle_add_mode") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ToggleMouse : public Action struct ToggleMouse : public Action
{ {
ToggleMouse() : Action(aToggleMouse, "toggle_mouse") { } ToggleMouse() : Action(aToggleMouse, "toggle_mouse") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ToggleBitrateVisibility : public Action struct ToggleBitrateVisibility : public Action
{ {
ToggleBitrateVisibility() : Action(aToggleBitrateVisibility, "toggle_bitrate_visibility") { } ToggleBitrateVisibility() : Action(aToggleBitrateVisibility, "toggle_bitrate_visibility") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct AddRandomItems : public Action struct AddRandomItems : public Action
{ {
AddRandomItems() : Action(aAddRandomItems, "add_random_items") { } AddRandomItems() : Action(aAddRandomItems, "add_random_items") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ToggleBrowserSortMode : public Action struct ToggleBrowserSortMode : public Action
{ {
ToggleBrowserSortMode() : Action(aToggleBrowserSortMode, "toggle_browser_sort_mode") { } ToggleBrowserSortMode() : Action(aToggleBrowserSortMode, "toggle_browser_sort_mode") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -706,6 +880,8 @@ struct ToggleBrowserSortMode : public Action
struct ToggleLibraryTagType : public Action struct ToggleLibraryTagType : public Action
{ {
ToggleLibraryTagType() : Action(aToggleLibraryTagType, "toggle_library_tag_type") { } ToggleLibraryTagType() : Action(aToggleLibraryTagType, "toggle_library_tag_type") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -713,6 +889,8 @@ struct ToggleLibraryTagType : public Action
struct RefetchLyrics : public Action struct RefetchLyrics : public Action
{ {
RefetchLyrics() : Action(aRefetchLyrics, "refetch_lyrics") { } RefetchLyrics() : Action(aRefetchLyrics, "refetch_lyrics") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -720,13 +898,18 @@ struct RefetchLyrics : public Action
struct RefetchArtistInfo : public Action struct RefetchArtistInfo : public Action
{ {
RefetchArtistInfo() : Action(aRefetchArtistInfo, "refetch_artist_info") { } RefetchArtistInfo() : Action(aRefetchArtistInfo, "refetch_artist_info") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
struct SetSelectedItemsPriority : public Action struct SetSelectedItemsPriority : public Action
{ {
SetSelectedItemsPriority() : Action(aSetSelectedItemsPriority, "set_selected_items_priority") { } SetSelectedItemsPriority()
: Action(aSetSelectedItemsPriority, "set_selected_items_priority") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -734,12 +917,16 @@ struct SetSelectedItemsPriority : public Action
struct ShowSongInfo : public Action struct ShowSongInfo : public Action
{ {
ShowSongInfo() : Action(aShowSongInfo, "show_song_info") { } ShowSongInfo() : Action(aShowSongInfo, "show_song_info") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ShowArtistInfo : public Action struct ShowArtistInfo : public Action
{ {
ShowArtistInfo() : Action(aShowArtistInfo, "show_artist_info") { } ShowArtistInfo() : Action(aShowArtistInfo, "show_artist_info") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -747,30 +934,40 @@ struct ShowArtistInfo : public Action
struct ShowLyrics : public Action struct ShowLyrics : public Action
{ {
ShowLyrics() : Action(aShowLyrics, "show_lyrics") { } ShowLyrics() : Action(aShowLyrics, "show_lyrics") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct Quit : public Action struct Quit : public Action
{ {
Quit() : Action(aQuit, "quit") { } Quit() : Action(aQuit, "quit") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct NextScreen : public Action struct NextScreen : public Action
{ {
NextScreen() : Action(aNextScreen, "next_screen") { } NextScreen() : Action(aNextScreen, "next_screen") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct PreviousScreen : public Action struct PreviousScreen : public Action
{ {
PreviousScreen() : Action(aPreviousScreen, "previous_screen") { } PreviousScreen() : Action(aPreviousScreen, "previous_screen") { }
protected:
virtual void Run(); virtual void Run();
}; };
struct ShowHelp : public Action struct ShowHelp : public Action
{ {
ShowHelp() : Action(aShowHelp, "show_help") { } ShowHelp() : Action(aShowHelp, "show_help") { }
protected:
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
virtual bool canBeRun() const; virtual bool canBeRun() const;
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
@@ -780,6 +977,8 @@ struct ShowHelp : public Action
struct ShowPlaylist : public Action struct ShowPlaylist : public Action
{ {
ShowPlaylist() : Action(aShowPlaylist, "show_playlist") { } ShowPlaylist() : Action(aShowPlaylist, "show_playlist") { }
protected:
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
virtual bool canBeRun() const; virtual bool canBeRun() const;
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
@@ -789,6 +988,8 @@ struct ShowPlaylist : public Action
struct ShowBrowser : public Action struct ShowBrowser : public Action
{ {
ShowBrowser() : Action(aShowBrowser, "show_browser") { } ShowBrowser() : Action(aShowBrowser, "show_browser") { }
protected:
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
virtual bool canBeRun() const; virtual bool canBeRun() const;
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
@@ -798,6 +999,8 @@ struct ShowBrowser : public Action
struct ShowSearchEngine : public Action struct ShowSearchEngine : public Action
{ {
ShowSearchEngine() : Action(aShowSearchEngine, "show_search_engine") { } ShowSearchEngine() : Action(aShowSearchEngine, "show_search_engine") { }
protected:
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
virtual bool canBeRun() const; virtual bool canBeRun() const;
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
@@ -807,6 +1010,8 @@ struct ShowSearchEngine : public Action
struct ShowMediaLibrary : public Action struct ShowMediaLibrary : public Action
{ {
ShowMediaLibrary() : Action(aShowMediaLibrary, "show_media_library") { } ShowMediaLibrary() : Action(aShowMediaLibrary, "show_media_library") { }
protected:
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
virtual bool canBeRun() const; virtual bool canBeRun() const;
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
@@ -816,6 +1021,8 @@ struct ShowMediaLibrary : public Action
struct ShowPlaylistEditor : public Action struct ShowPlaylistEditor : public Action
{ {
ShowPlaylistEditor() : Action(aShowPlaylistEditor, "show_playlist_editor") { } ShowPlaylistEditor() : Action(aShowPlaylistEditor, "show_playlist_editor") { }
protected:
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
virtual bool canBeRun() const; virtual bool canBeRun() const;
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
@@ -825,6 +1032,8 @@ struct ShowPlaylistEditor : public Action
struct ShowTagEditor : public Action struct ShowTagEditor : public Action
{ {
ShowTagEditor() : Action(aShowTagEditor, "show_tag_editor") { } ShowTagEditor() : Action(aShowTagEditor, "show_tag_editor") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -832,6 +1041,8 @@ struct ShowTagEditor : public Action
struct ShowOutputs : public Action struct ShowOutputs : public Action
{ {
ShowOutputs() : Action(aShowOutputs, "show_outputs") { } ShowOutputs() : Action(aShowOutputs, "show_outputs") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -839,6 +1050,8 @@ struct ShowOutputs : public Action
struct ShowVisualizer : public Action struct ShowVisualizer : public Action
{ {
ShowVisualizer() : Action(aShowVisualizer, "show_visualizer") { } ShowVisualizer() : Action(aShowVisualizer, "show_visualizer") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -846,6 +1059,8 @@ struct ShowVisualizer : public Action
struct ShowClock : public Action struct ShowClock : public Action
{ {
ShowClock() : Action(aShowClock, "show_clock") { } ShowClock() : Action(aShowClock, "show_clock") { }
protected:
virtual bool canBeRun() const; virtual bool canBeRun() const;
virtual void Run(); virtual void Run();
}; };
@@ -853,6 +1068,8 @@ struct ShowClock : public Action
struct ShowServerInfo : public Action struct ShowServerInfo : public Action
{ {
ShowServerInfo() : Action(aShowServerInfo, "show_server_info") { } ShowServerInfo() : Action(aShowServerInfo, "show_server_info") { }
protected:
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
virtual bool canBeRun() const; virtual bool canBeRun() const;
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H

View File

@@ -254,7 +254,6 @@ void Help::GetKeybindings()
KeyDesc(aUpdateDatabase, "Start music database update"); KeyDesc(aUpdateDatabase, "Start music database update");
*w << '\n'; *w << '\n';
KeyDesc(aApplyFilter, "Apply filter"); KeyDesc(aApplyFilter, "Apply filter");
KeyDesc(aDisableFilter, "Disable filter");
KeyDesc(aFindItemForward, "Find item forward"); KeyDesc(aFindItemForward, "Find item forward");
KeyDesc(aFindItemBackward, "Find item backward"); KeyDesc(aFindItemBackward, "Find item backward");
KeyDesc(aPreviousFoundItem, "Go to previous found item"); KeyDesc(aPreviousFoundItem, "Go to previous found item");

View File

@@ -382,8 +382,6 @@ void KeyConfiguration::generateBindings()
bind(k, aReversePlaylist); bind(k, aReversePlaylist);
if (notBound(k = stringToKey("ctrl_f"))) if (notBound(k = stringToKey("ctrl_f")))
bind(k, aApplyFilter); bind(k, aApplyFilter);
if (notBound(k = stringToKey("ctrl_g")))
bind(k, aDisableFilter);
if (notBound(k = stringToKey("/"))) if (notBound(k = stringToKey("/")))
{ {
bind(k, aFind); bind(k, aFind);

View File

@@ -29,6 +29,7 @@ struct PushCharacters : public Action
PushCharacters(NC::Window **w, std::vector<int> &&queue) PushCharacters(NC::Window **w, std::vector<int> &&queue)
: Action(aMacroUtility, ""), m_window(w), m_queue(queue) { } : Action(aMacroUtility, ""), m_window(w), m_queue(queue) { }
protected:
virtual void Run() { virtual void Run() {
for (auto it = m_queue.begin(); it != m_queue.end(); ++it) for (auto it = m_queue.begin(); it != m_queue.end(); ++it)
(*m_window)->pushChar(*it); (*m_window)->pushChar(*it);
@@ -44,6 +45,7 @@ struct RequireRunnable : public Action
RequireRunnable(Action *action) RequireRunnable(Action *action)
: Action(aMacroUtility, ""), m_action(action) { assert(action); } : Action(aMacroUtility, ""), m_action(action) { assert(action); }
protected:
virtual bool canBeRun() const { return m_action->canBeRun(); } virtual bool canBeRun() const { return m_action->canBeRun(); }
virtual void Run() { } virtual void Run() { }