lyrics: move code that saves lyrics to separate function
This commit is contained in:
@@ -229,15 +229,11 @@ void *Lyrics::Get(void *screen_void_ptr)
|
|||||||
|
|
||||||
if (result.first == true)
|
if (result.first == true)
|
||||||
{
|
{
|
||||||
screen->w->Clear();
|
screen->Save(result.second);
|
||||||
*screen->w << utf_to_locale_cpy(result.second);
|
|
||||||
|
|
||||||
std::ofstream output(screen->itsFilenamePath.c_str());
|
utf_to_locale(result.second);
|
||||||
if (output.is_open())
|
screen->w->Clear();
|
||||||
{
|
*screen->w << result.second;
|
||||||
output << result.second;
|
|
||||||
output.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*screen->w << "\nLyrics weren't found.";
|
*screen->w << "\nLyrics weren't found.";
|
||||||
@@ -273,6 +269,16 @@ void Lyrics::Edit()
|
|||||||
system(("nohup " + Config.external_editor + " \"" + itsFilenamePath + "\" > /dev/null 2>&1 &").c_str());
|
system(("nohup " + Config.external_editor + " \"" + itsFilenamePath + "\" > /dev/null 2>&1 &").c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Lyrics::Save(const std::string &lyrics)
|
||||||
|
{
|
||||||
|
std::ofstream output(itsFilenamePath.c_str());
|
||||||
|
if (output.is_open())
|
||||||
|
{
|
||||||
|
output << lyrics;
|
||||||
|
output.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Lyrics::FetchAgain()
|
void Lyrics::FetchAgain()
|
||||||
{
|
{
|
||||||
std::string path = Folder + "/" + locale_to_utf_cpy(itsSong.GetArtist()) + " - " + locale_to_utf_cpy(itsSong.GetTitle()) + ".txt";
|
std::string path = Folder + "/" + locale_to_utf_cpy(itsSong.GetArtist()) + " - " + locale_to_utf_cpy(itsSong.GetTitle()) + ".txt";
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class Lyrics : public Screen<Scrollpad>
|
|||||||
virtual List *GetList() { return 0; }
|
virtual List *GetList() { return 0; }
|
||||||
|
|
||||||
void Edit();
|
void Edit();
|
||||||
|
void Save(const std::string &lyrics);
|
||||||
void FetchAgain();
|
void FetchAgain();
|
||||||
|
|
||||||
static bool Reload;
|
static bool Reload;
|
||||||
|
|||||||
Reference in New Issue
Block a user