moviebrowser: Fix text display in message box when deleting a movie

Origin commit data
------------------
Branch: ni/coolstream
Commit: 4fd7808afd
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2016-08-12 (Fri, 12 Aug 2016)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
Michael Liebmann
2016-08-12 19:19:32 +02:00
parent c3a7bcfd5b
commit c7be05d5db
2 changed files with 41 additions and 40 deletions

View File

@@ -2223,61 +2223,61 @@ bool CMovieBrowser::onButtonPressMovieInfoList(neutrino_msg_t msg)
return (result);
}
bool CMovieBrowser::onDeleteFile(MI_MOVIE_INFO *movieinfo, bool skipAsk)
std::string CMovieBrowser::formatDeleteMsg(MI_MOVIE_INFO *movieinfo, Font *msgFont, const int boxWidth)
{
//TRACE("[onDeleteFile] ");
bool result = false;
#if 0
int test= movieinfo->file.Name.find(".ts", movieinfo->file.Name.length()-3);
if (test == -1) {
// not a TS file, return!!!!!
TRACE("show_ts_info: not a TS file ");
return;
}
#endif
size_t msgMax = 50;
int msgWidth = boxWidth - 20;
std::string msg = g_Locale->getText(LOCALE_FILEBROWSER_DODELETE1);
msg += "\n ";
msg += "\n";
if (!movieinfo->epgTitle.empty()) {
if ((movieinfo->epgTitle.length() + movieinfo->epgInfo1.length()) <= msgMax) {
msg += movieinfo->epgTitle;
int titleW = msgFont->getRenderWidth(movieinfo->epgTitle);
int infoW = 0;
int zW = 0;
if (!movieinfo->epgInfo1.empty()) {
infoW = msgFont->getRenderWidth(movieinfo->epgInfo1);
zW = msgFont->getRenderWidth(" ()");
}
if ((titleW+infoW+zW) <= msgWidth) {
/* one line */
msg += trim(movieinfo->epgTitle);
if (!movieinfo->epgInfo1.empty()) {
msg += " (";
msg += movieinfo->epgInfo1;
msg += trim(movieinfo->epgInfo1);
msg += ")";
}
}
else {
if (movieinfo->epgTitle.length() > msgMax) {
msg += movieinfo->epgTitle.substr(0, msgMax);
msg += "...";
}
else {
msg += movieinfo->epgTitle;
if (!movieinfo->epgInfo1.empty()) {
msg += "\n (";
if (movieinfo->epgInfo1.length() > msgMax) {
msg = movieinfo->epgInfo1.substr(0, msgMax);
msg += "...";
}
else
msg += movieinfo->epgInfo1;
/* two lines */
msg += cutString(movieinfo->epgTitle, msgFont, msgWidth);
if (!movieinfo->epgInfo1.empty()) {
msg += "\n(";
msg += cutString(movieinfo->epgInfo1, msgFont, msgWidth);
msg += ")";
}
}
}
}
else {
if (movieinfo->file.Name.length() > msgMax) {
msg += movieinfo->file.Name.substr(0, msgMax);
msg += "...";
}
else
msg += movieinfo->file.Name;
}
else
msg += cutString(movieinfo->file.Name, msgFont, msgWidth);
msg += "\n";
msg += g_Locale->getText(LOCALE_FILEBROWSER_DODELETE2);
if ((skipAsk || !movieinfo->delAsk) || (ShowMsg(LOCALE_FILEBROWSER_DELETE, msg, CMessageBox::mbrYes, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes))
return msg;
}
bool CMovieBrowser::onDeleteFile(MI_MOVIE_INFO *movieinfo, bool skipAsk)
{
//TRACE("[onDeleteFile] ");
bool result = false;
/* default font for ShowMsg */
Font *msgFont = g_Font[SNeutrinoSettings::FONT_TYPE_MENU];
/* default width for ShowMsg */
int msgBoxWidth = 450;
std::string msg = formatDeleteMsg(movieinfo, msgFont, msgBoxWidth);
if ((skipAsk || !movieinfo->delAsk) || (ShowMsg(LOCALE_FILEBROWSER_DELETE, msg, CMessageBox::mbrYes, CMessageBox::mbYes|CMessageBox::mbNo, NULL, msgBoxWidth)==CMessageBox::mbrYes))
{
CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MOVIEBROWSER_DELETE_INFO));
hintBox->paint();

View File

@@ -428,6 +428,7 @@ class CMovieBrowser : public CMenuTarget
void onSetGUIWindowNext(void);
void onSetGUIWindowPrev(void);
bool onDelete(bool cursor_only = false);
std::string formatDeleteMsg(MI_MOVIE_INFO *movieinfo, Font *msgFont, const int boxWidth = 450);
bool onDeleteFile(MI_MOVIE_INFO *movieinfo, bool skipAsk = false); // P4
bool onSortMovieInfoHandleList(std::vector<MI_MOVIE_INFO*>& pv_handle_list, MB_INFO_ITEM sort_type, MB_DIRECTION direction);