actions: new action: set_volume
This commit is contained in:
@@ -1204,6 +1204,22 @@ void SetCrossfade::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetVolume::run()
|
||||||
|
{
|
||||||
|
using Global::wFooter;
|
||||||
|
|
||||||
|
Statusbar::lock();
|
||||||
|
Statusbar::put() << "Set volume to: ";
|
||||||
|
std::string strvolume = wFooter->getString(3);
|
||||||
|
Statusbar::unlock();
|
||||||
|
int volume = boost::lexical_cast<int>(strvolume);
|
||||||
|
if (volume >= 0 && volume <= 100)
|
||||||
|
{
|
||||||
|
if (Mpd.SetVolume(volume))
|
||||||
|
Statusbar::msg("Volume set to %d%%", volume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool EditSong::canBeRun() const
|
bool EditSong::canBeRun() const
|
||||||
{
|
{
|
||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
@@ -2490,6 +2506,7 @@ void populateActions()
|
|||||||
insert_action(new Actions::ToggleConsume());
|
insert_action(new Actions::ToggleConsume());
|
||||||
insert_action(new Actions::ToggleCrossfade());
|
insert_action(new Actions::ToggleCrossfade());
|
||||||
insert_action(new Actions::SetCrossfade());
|
insert_action(new Actions::SetCrossfade());
|
||||||
|
insert_action(new Actions::SetVolume());
|
||||||
insert_action(new Actions::EditSong());
|
insert_action(new Actions::EditSong());
|
||||||
insert_action(new Actions::EditLibraryTag());
|
insert_action(new Actions::EditLibraryTag());
|
||||||
insert_action(new Actions::EditLibraryAlbum());
|
insert_action(new Actions::EditLibraryAlbum());
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ enum class Type
|
|||||||
ToggleLyricsFetcher, ToggleFetchingLyricsInBackground, TogglePlayingSongCentering,
|
ToggleLyricsFetcher, ToggleFetchingLyricsInBackground, TogglePlayingSongCentering,
|
||||||
UpdateDatabase, JumpToPlayingSong, ToggleRepeat, Shuffle, ToggleRandom,
|
UpdateDatabase, JumpToPlayingSong, ToggleRepeat, Shuffle, ToggleRandom,
|
||||||
StartSearching, SaveTagChanges, ToggleSingle, ToggleConsume, ToggleCrossfade,
|
StartSearching, SaveTagChanges, ToggleSingle, ToggleConsume, ToggleCrossfade,
|
||||||
SetCrossfade, EditSong, EditLibraryTag, EditLibraryAlbum, EditDirectoryName,
|
SetCrossfade, SetVolume, EditSong, EditLibraryTag, EditLibraryAlbum, EditDirectoryName,
|
||||||
EditPlaylistName, EditLyrics, JumpToBrowser, JumpToMediaLibrary,
|
EditPlaylistName, EditLyrics, JumpToBrowser, JumpToMediaLibrary,
|
||||||
JumpToPlaylistEditor, ToggleScreenLock, JumpToTagEditor, JumpToPositionInSong,
|
JumpToPlaylistEditor, ToggleScreenLock, JumpToTagEditor, JumpToPositionInSong,
|
||||||
ReverseSelection, RemoveSelection, SelectAlbum, AddSelectedItems,
|
ReverseSelection, RemoveSelection, SelectAlbum, AddSelectedItems,
|
||||||
@@ -593,6 +593,14 @@ protected:
|
|||||||
virtual void run();
|
virtual void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SetVolume : public BaseAction
|
||||||
|
{
|
||||||
|
SetVolume() : BaseAction(Type::SetVolume, "set_volume") { }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void run();
|
||||||
|
};
|
||||||
|
|
||||||
struct EditSong : public BaseAction
|
struct EditSong : public BaseAction
|
||||||
{
|
{
|
||||||
EditSong() : BaseAction(Type::EditSong, "edit_song") { }
|
EditSong() : BaseAction(Type::EditSong, "edit_song") { }
|
||||||
|
|||||||
@@ -799,14 +799,16 @@ void Connection::SetConsume(bool mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::SetVolume(unsigned vol)
|
bool Connection::SetVolume(unsigned vol)
|
||||||
{
|
{
|
||||||
if (!itsConnection || vol > 100)
|
if (!itsConnection || vol > 100)
|
||||||
return;
|
return false;
|
||||||
assert(!isCommandsListEnabled);
|
assert(!isCommandsListEnabled);
|
||||||
GoBusy();
|
GoBusy();
|
||||||
if (mpd_run_set_volume(itsConnection, vol) && !supportsIdle)
|
bool success = mpd_run_set_volume(itsConnection, vol);
|
||||||
|
if (success && !supportsIdle)
|
||||||
UpdateStatus();
|
UpdateStatus();
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Connection::GetReplayGainMode()
|
std::string Connection::GetReplayGainMode()
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public:
|
|||||||
void SetSingle(bool);
|
void SetSingle(bool);
|
||||||
void SetConsume(bool);
|
void SetConsume(bool);
|
||||||
void SetCrossfade(unsigned);
|
void SetCrossfade(unsigned);
|
||||||
void SetVolume(unsigned);
|
bool SetVolume(unsigned);
|
||||||
|
|
||||||
std::string GetReplayGainMode();
|
std::string GetReplayGainMode();
|
||||||
void SetReplayGainMode(ReplayGainMode);
|
void SetReplayGainMode(ReplayGainMode);
|
||||||
|
|||||||
Reference in New Issue
Block a user