outputs: replace enterPressed with toggleOutput
This commit is contained in:
@@ -2216,6 +2216,16 @@ void SetSelectedItemsPriority::run()
|
||||
myPlaylist->SetSelectedItemsPriority(prio);
|
||||
}
|
||||
|
||||
bool ToggleOutput::canBeRun()
|
||||
{
|
||||
return myScreen == myOutputs;
|
||||
}
|
||||
|
||||
void ToggleOutput::run()
|
||||
{
|
||||
myOutputs->toggleOutput();
|
||||
}
|
||||
|
||||
bool ToggleVisualizationType::canBeRun()
|
||||
{
|
||||
# ifdef ENABLE_VISUALIZER
|
||||
@@ -2667,6 +2677,7 @@ void populateActions()
|
||||
insert_action(new Actions::ToggleMediaLibrarySortMode());
|
||||
insert_action(new Actions::RefetchLyrics());
|
||||
insert_action(new Actions::SetSelectedItemsPriority());
|
||||
insert_action(new Actions::ToggleOutput());
|
||||
insert_action(new Actions::ToggleVisualizationType());
|
||||
insert_action(new Actions::SetVisualizerSampleMultiplier());
|
||||
insert_action(new Actions::ShowSongInfo());
|
||||
|
||||
@@ -56,7 +56,7 @@ enum class Type
|
||||
ToggleAddMode, ToggleMouse, ToggleBitrateVisibility,
|
||||
AddRandomItems, ToggleBrowserSortMode, ToggleLibraryTagType,
|
||||
ToggleMediaLibrarySortMode, RefetchLyrics,
|
||||
SetSelectedItemsPriority, ToggleVisualizationType, SetVisualizerSampleMultiplier,
|
||||
SetSelectedItemsPriority, ToggleOutput, ToggleVisualizationType, SetVisualizerSampleMultiplier,
|
||||
ShowSongInfo, ShowArtistInfo, ShowLyrics, Quit, NextScreen, PreviousScreen,
|
||||
ShowHelp, ShowPlaylist, ShowBrowser, ChangeBrowseMode, ShowSearchEngine,
|
||||
ResetSearchEngine, ShowMediaLibrary, ToggleMediaLibraryColumnsMode,
|
||||
@@ -1045,6 +1045,15 @@ private:
|
||||
virtual void run() OVERRIDE;
|
||||
};
|
||||
|
||||
struct ToggleOutput: BaseAction
|
||||
{
|
||||
ToggleOutput(): BaseAction(Type::ToggleOutput, "toggle_output") { }
|
||||
|
||||
private:
|
||||
virtual bool canBeRun() OVERRIDE;
|
||||
virtual void run() OVERRIDE;
|
||||
};
|
||||
|
||||
struct ToggleVisualizationType: BaseAction
|
||||
{
|
||||
ToggleVisualizationType()
|
||||
|
||||
@@ -496,7 +496,10 @@ void BindingsConfiguration::generateDefaults()
|
||||
if (notBound(k = stringToKey("insert")))
|
||||
bind(k, Actions::Type::SelectItem);
|
||||
if (notBound(k = stringToKey("enter")))
|
||||
{
|
||||
bind(k, Actions::Type::ToggleOutput);
|
||||
bind(k, Actions::Type::PressEnter);
|
||||
}
|
||||
if (notBound(k = stringToKey("space")))
|
||||
{
|
||||
bind(k, Actions::Type::AddItemToPlaylist);
|
||||
|
||||
@@ -330,7 +330,7 @@ void write_bindings(NC::Scrollpad &w)
|
||||
|
||||
# ifdef ENABLE_OUTPUTS
|
||||
key_section(w, "Outputs");
|
||||
key(w, Type::PressEnter, "Toggle output");
|
||||
key(w, Type::ToggleOutput, "Toggle output");
|
||||
# endif // ENABLE_OUTPUTS
|
||||
|
||||
# if defined(ENABLE_VISUALIZER) && defined(HAVE_FFTW3_H)
|
||||
|
||||
@@ -69,20 +69,6 @@ std::wstring Outputs::title()
|
||||
return L"Outputs";
|
||||
}
|
||||
|
||||
void Outputs::enterPressed()
|
||||
{
|
||||
if (w.current()->value().enabled())
|
||||
{
|
||||
Mpd.DisableOutput(w.choice());
|
||||
Statusbar::printf("Output \"%s\" disabled", w.current()->value().name());
|
||||
}
|
||||
else
|
||||
{
|
||||
Mpd.EnableOutput(w.choice());
|
||||
Statusbar::printf("Output \"%s\" enabled", w.current()->value().name());
|
||||
}
|
||||
}
|
||||
|
||||
void Outputs::mouseButtonPressed(MEVENT me)
|
||||
{
|
||||
if (w.empty() || !w.hasCoords(me.x, me.y) || size_t(me.y) >= w.size())
|
||||
@@ -97,7 +83,7 @@ void Outputs::mouseButtonPressed(MEVENT me)
|
||||
Screen<WindowType>::mouseButtonPressed(me);
|
||||
}
|
||||
|
||||
void Outputs::FetchList()
|
||||
void Outputs::fetchList()
|
||||
{
|
||||
w.clear();
|
||||
for (MPD::OutputIterator out = Mpd.GetOutputs(), end; out != end; ++out)
|
||||
@@ -111,5 +97,18 @@ void Outputs::FetchList()
|
||||
w.refresh();
|
||||
}
|
||||
|
||||
#endif // ENABLE_OUTPUTS
|
||||
void Outputs::toggleOutput()
|
||||
{
|
||||
if (w.current()->value().enabled())
|
||||
{
|
||||
Mpd.DisableOutput(w.choice());
|
||||
Statusbar::printf("Output \"%s\" disabled", w.current()->value().name());
|
||||
}
|
||||
else
|
||||
{
|
||||
Mpd.EnableOutput(w.choice());
|
||||
Statusbar::printf("Output \"%s\" enabled", w.current()->value().name());
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ENABLE_OUTPUTS
|
||||
|
||||
@@ -43,14 +43,15 @@ struct Outputs: Screen<NC::Menu<MPD::Output>>, Tabbable
|
||||
|
||||
virtual void update() OVERRIDE { }
|
||||
|
||||
virtual void enterPressed() OVERRIDE;
|
||||
virtual void enterPressed() OVERRIDE { }
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// private members
|
||||
void FetchList();
|
||||
void fetchList();
|
||||
void toggleOutput();
|
||||
};
|
||||
|
||||
extern Outputs *myOutputs;
|
||||
|
||||
@@ -159,7 +159,7 @@ void initialize_status()
|
||||
|
||||
myBrowser->fetchSupportedExtensions();
|
||||
# ifdef ENABLE_OUTPUTS
|
||||
myOutputs->FetchList();
|
||||
myOutputs->fetchList();
|
||||
# endif // ENABLE_OUTPUTS
|
||||
# ifdef ENABLE_VISUALIZER
|
||||
myVisualizer->ResetFD();
|
||||
@@ -760,6 +760,6 @@ void Status::Changes::mixer()
|
||||
void Status::Changes::outputs()
|
||||
{
|
||||
# ifdef ENABLE_OUTPUTS
|
||||
myOutputs->FetchList();
|
||||
myOutputs->fetchList();
|
||||
# endif // ENABLE_OUTPUTS
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user