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

View File

@@ -428,6 +428,7 @@ class CMovieBrowser : public CMenuTarget
void onSetGUIWindowNext(void); void onSetGUIWindowNext(void);
void onSetGUIWindowPrev(void); void onSetGUIWindowPrev(void);
bool onDelete(bool cursor_only = false); 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 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); bool onSortMovieInfoHandleList(std::vector<MI_MOVIE_INFO*>& pv_handle_list, MB_INFO_ITEM sort_type, MB_DIRECTION direction);