diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index af125a2a8..584c118b7 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -1438,13 +1438,9 @@ moviebrowser.yt_error Fehler beim laden des Youtube Feed moviebrowser.yt_history Frühere Suchen moviebrowser.yt_max_history Max. Anzahl früherer Suchen moviebrowser.yt_max_results Max. Anzahl der zu holenden Feeds -moviebrowser.yt_most_discussed Am meisten diskutiert -moviebrowser.yt_most_popular Beliebteste Videos -moviebrowser.yt_most_resent Unbeliebteste Videos -moviebrowser.yt_most_responded Feeds mit den meisten Reaktionen -moviebrowser.yt_most_shared Am häufigsten wiedergegebe Videos +moviebrowser.yt_most_popular Beliebteste Videos heute +moviebrowser.yt_most_popular_all_time Beliebteste Videos moviebrowser.yt_next_results Nächste Ergebnisse -moviebrowser.yt_on_the_web Trendvideos moviebrowser.yt_orderby Sortierung nach moviebrowser.yt_orderby.published Veröffentlichungszeitpunkt moviebrowser.yt_orderby.rating Bewertung @@ -1456,8 +1452,6 @@ moviebrowser.yt_recently_featured Vor kurzem empfohlen moviebrowser.yt_region Region moviebrowser.yt_related Passende Videos moviebrowser.yt_search Suche nach Stichwort -moviebrowser.yt_top_favorites Top Favoriten -moviebrowser.yt_top_rated Am besten bewertet movieplayer.bookmark Bookmarks movieplayer.bookmarkname Bookmark Name movieplayer.bookmarkname_hint1 Geben Sie den Namen für das neue Lesezeichen ein diff --git a/data/locale/english.locale b/data/locale/english.locale index f835b0e32..569fd7169 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -1438,13 +1438,9 @@ moviebrowser.yt_error Failed to load youtube feed moviebrowser.yt_history Search history moviebrowser.yt_max_history Max search history size moviebrowser.yt_max_results Max results to fetch -moviebrowser.yt_most_discussed Most discussed -moviebrowser.yt_most_popular Most popular -moviebrowser.yt_most_resent Most resent -moviebrowser.yt_most_responded Most responded -moviebrowser.yt_most_shared Most shared +moviebrowser.yt_most_popular Most popular today +moviebrowser.yt_most_popular_all_time Most popular moviebrowser.yt_next_results Next results -moviebrowser.yt_on_the_web Trending videos moviebrowser.yt_orderby Order by moviebrowser.yt_orderby.published publishing date moviebrowser.yt_orderby.rating rating @@ -1456,8 +1452,6 @@ moviebrowser.yt_recently_featured Recently featured moviebrowser.yt_region Region moviebrowser.yt_related Related videos moviebrowser.yt_search Search keyword -moviebrowser.yt_top_favorites Top favorites -moviebrowser.yt_top_rated Top rated movieplayer.bookmark Bookmarks movieplayer.bookmarkname Bookmarkname movieplayer.bookmarkname_hint1 Enter a name for your new bookmark diff --git a/data/satellites.xml b/data/satellites.xml index 9462dee81..6496837e3 100644 --- a/data/satellites.xml +++ b/data/satellites.xml @@ -2530,6 +2530,7 @@ + diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 8bb3fb151..3d779b6ed 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -52,20 +52,18 @@ #include #include -#include - #include #include +#include #include #include #include #include -#include -static const int FSHIFT = 16; /* nr of bits of precision */ -#define FIXED_1 (1<> FSHIFT) -#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100) +static const int FSHIFT = 16; /* nr of bits of precision */ +#define FIXED_1 (1<> FSHIFT) +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100) CDBoxInfoWidget::CDBoxInfoWidget() { @@ -77,9 +75,14 @@ CDBoxInfoWidget::CDBoxInfoWidget() height = 0; x = 0; y = 0; - stat_total = 0; -} + fontWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth(); + sizeWidth = 6 * g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getMaxDigitWidth() + + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(std::string(" MiB") + g_Locale->getText(LOCALE_UNIT_DECIMAL), true); ;//9999.99 MiB + percWidth = 3 * g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getMaxDigitWidth() + + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("%", true); //100% + nameWidth = fontWidth * 10; +} int CDBoxInfoWidget::exec(CMenuTarget* parent, const std::string &) { @@ -90,7 +93,6 @@ int CDBoxInfoWidget::exec(CMenuTarget* parent, const std::string &) COSDFader fader(g_settings.menu_Content_alpha); fader.StartFadeIn(); - sizeWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("1023,99 MiB"); paint(); frameBuffer->blit(); @@ -206,52 +208,56 @@ static std::string bytes2string(uint64_t bytes, bool binary) void CDBoxInfoWidget::paint() { - const int headSize = 5; - const char *head[headSize] = {"Filesystem", "Size", "Used", "Available", "Use"}; - int fontWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth(); - int percWidth = fontWidth * 4 ;//100% - int nameWidth = fontWidth * 10;//WWWwwwwwww mountpoint, will auto-extend + const int head_info_lines = 3; + const char *head_info[head_info_lines] = {"Uptime", "Load average", "Current load"}; + height = hheight; height += mheight/2; // space - height += mheight; // time - height += mheight; // uptime - height += mheight; // load + int cpuload_y0 = height; + int head_info_ypos = height; + height += mheight*head_info_lines; // head info lines + int cpuload_y1 = height; height += mheight/2; // space - int frontend_count = CFEManager::getInstance()->getFrontendCount(); - if (frontend_count) - height += mheight * frontend_count + mheight/2; - int icon_w = 0, icon_h = 0; frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icon_w, &icon_h); - unsigned long m[2][3] = { { 0, 0, 0 }, { 0, 0, 0 } }; // size, used, available -#define DBINFO_TOTAL 0 -#define DBINFO_USED 1 -#define DBINFO_FREE 2 -#define DBINFO_RAM 0 -#define DBINFO_SWAP 1 - const char *n[2] = { "RAM", "Swap" }; +#define MEMINFO_TOTAL 0 +#define MEMINFO_USED 1 +#define MEMINFO_FREE 2 +#define MEMINFO_COLUMNS 3 + +#define MEMINFO_RAM 0 +#define MEMINFO_SWAP 1 +#define MEMINFO_ROWS 2 + unsigned long long memstat[MEMINFO_ROWS][MEMINFO_COLUMNS] = { { 0, 0, 0 }, { 0, 0, 0 } }; // total, used, free + const char *memtype[MEMINFO_ROWS] = { "RAM", "Swap" }; FILE *procmeminfo = fopen("/proc/meminfo", "r"); if (procmeminfo) { char buf[80], a[80]; - unsigned long v; - while (fgets(buf, sizeof(buf), procmeminfo)) - if (2 == sscanf(buf, "%[^:]: %lu", a, &v)) { + long long unsigned v; + while (fgets(buf, sizeof(buf), procmeminfo)) { + char unit[10]; + *unit = 0; + if ((3 == sscanf(buf, "%[^:]: %llu %s", a, &v, unit)) + || (2 == sscanf(buf, "%[^:]: %llu", a, &v))) { + if (*unit == 'k') + v <<= 10; if (!strcasecmp(a, "MemTotal")) - m[DBINFO_RAM][DBINFO_TOTAL] += v; + memstat[MEMINFO_RAM][MEMINFO_TOTAL] += v; else if (!strcasecmp(a, "MemFree")) - m[DBINFO_RAM][DBINFO_FREE] += v; + memstat[MEMINFO_RAM][MEMINFO_FREE] += v; else if (!strcasecmp(a, "Inactive")) - m[DBINFO_RAM][DBINFO_FREE] += v; + memstat[MEMINFO_RAM][MEMINFO_FREE] += v; else if (!strcasecmp(a, "SwapTotal")) - m[DBINFO_SWAP][DBINFO_TOTAL] = v; + memstat[MEMINFO_SWAP][MEMINFO_TOTAL] = v; else if (!strcasecmp(a, "SwapFree")) - m[DBINFO_SWAP][DBINFO_FREE] += v; + memstat[MEMINFO_SWAP][MEMINFO_FREE] += v; } + } fclose(procmeminfo); } - bool have_swap = m[DBINFO_SWAP][DBINFO_TOTAL]; + bool have_swap = memstat[MEMINFO_SWAP][MEMINFO_TOTAL]; height += mheight; // header height += mheight; // ram height += have_swap * mheight; // swap @@ -272,10 +278,9 @@ void CDBoxInfoWidget::paint() std::string line; while (getline(in, line)) { - if ((line.at(0) != '/') && (line.find("rootfs") != 0)) - continue; + size_t firstslash = line.find_first_of('/'); size_t firstspace = line.find_first_of(' '); - if (firstspace != string::npos) { + if ( (firstspace != string::npos && firstslash != string::npos && firstslash < firstspace) || (line.find("rootfs") == 0) ) { firstspace++; size_t nextspace = line.find_first_of(' ', firstspace); if (nextspace == string::npos || line.find("nodev", nextspace + 1) != string::npos) @@ -288,7 +293,8 @@ void CDBoxInfoWidget::paint() bool is_rec = (st.st_dev == rec_st.st_dev); mounts[mountpoint] = is_rec; int icon_space = is_rec ? 10 + icon_w : 0; - nameWidth = std::max(nameWidth, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(mountpoint, true) + icon_space + 10); + const char *mnt = mountpoint.c_str(); + nameWidth = std::max(nameWidth, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(basename((char *)mnt), true) + icon_space + 10); } } in.close(); @@ -314,18 +320,8 @@ void CDBoxInfoWidget::paint() // fprintf(stderr, "CDBoxInfoWidget::CDBoxInfoWidget() x = %d, y = %d, width = %d height = %d\n", x, y, width, height); int ypos=y; - frameBuffer->paintBoxRel(x, ypos, width, hheight, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP); - frameBuffer->paintBoxRel(x, ypos+ hheight, width, height- hheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); - //paint menu head - string iconfile = NEUTRINO_ICON_SHELL; - int HeadiconOffset = 0; - if(!(iconfile.empty())){ - int w, h; - frameBuffer->getIconSize(iconfile.c_str(), &w, &h); - HeadiconOffset = w+6; - } - int fw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getWidth(); + //paint head std::string title(g_Locale->getText(LOCALE_EXTRA_DBOXINFO)); #if 0 std::map cpuinfo; @@ -354,71 +350,104 @@ void CDBoxInfoWidget::paint() title += g_info.hw_caps->boxvendor; title += " "; title += g_info.hw_caps->boxname; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+(fw/3)+HeadiconOffset,y+hheight+1, - width-((fw/3)+HeadiconOffset), title, COL_MENUHEAD_TEXT, 0, true); // UTF-8 - frameBuffer->paintIcon(iconfile, x + fw/4, y, hheight); + + CComponentsHeader header(x, ypos, width, hheight, title, NEUTRINO_ICON_SHELL); + header.paint(CC_SAVE_SCREEN_NO); + + //paint body + frameBuffer->paintBoxRel(x, ypos+ hheight, width, height- hheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); ypos += hheight + mheight/2; - long current_load = -1; - in.open("/proc/stat"); - if (in.is_open()) { - std::string line; - while (getline(in, line)) { - unsigned long _stat_user, _stat_nice, _stat_system, _stat_idle; - if (4 == sscanf(line.c_str(), "cpu %lu %lu %lu %lu", &_stat_user, &_stat_nice, &_stat_system, &_stat_idle)) { - if (stat_total) { - unsigned long div = _stat_user + _stat_nice + _stat_system + _stat_idle - stat_total; - if (div > 0) - current_load = (long)(1000 - 1000 * (_stat_idle - stat_idle) / div); - } - stat_idle = _stat_idle; - stat_total = _stat_user + _stat_nice + _stat_system + _stat_idle; - break; - } - } - in.close(); + int head_info_rw = 0; + for (int line = 0; line < head_info_lines; line++) { + head_info_rw = std::max(head_info_rw, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_info[line], true)); } - char ubuf[80]; - - time_t now = time(NULL); - strftime(ubuf, sizeof(ubuf), "Time: %F %H:%M:%S%z", localtime(&now)); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, ubuf, COL_MENUCONTENT_TEXT); - ypos += mheight; + int dw = offsetw - 3*10 - head_info_rw; + int buf_size=256; + char ubuf[buf_size]; + char sbuf[buf_size]; + memset(sbuf, 0, 256); struct sysinfo info; sysinfo(&info); - now -= info.uptime; - strftime(ubuf, sizeof(ubuf), "Boot: %F %H:%M:%S%z", localtime(&now)); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, ubuf, COL_MENUCONTENT_TEXT); + + //get uptime +#if 0 + struct tm *current_time; + time_t current_secs; + time(¤t_secs); + current_time = localtime(¤t_secs); + + snprintf( ubuf,buf_size, "%02d:%02d%s up ", + current_time->tm_hour%12 ? current_time->tm_hour%12 : 12, + current_time->tm_min, current_time->tm_hour > 11 ? "pm" : "am"); + strcat(sbuf, ubuf); +#endif + + int updays, uphours, upminutes; + + updays = (int) info.uptime / (60*60*24); + upminutes = (int) info.uptime / 60; + uphours = (upminutes / 60) % 24; + upminutes %= 60; + + if (updays) { + snprintf(ubuf,buf_size, "%d day%s, ", updays, (updays != 1) ? "s" : ""); + strcat(sbuf, ubuf); + } + if (uphours) { + snprintf(ubuf,buf_size,"%d hour%s, ", uphours, (uphours != 1) ? "s" : ""); + strcat(sbuf, ubuf); + } + snprintf(ubuf,buf_size,"%d minute%s", upminutes, (upminutes != 1) ? "s" : ""); + strcat(sbuf, ubuf); + + //paint uptime + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 2*10 + head_info_rw, ypos+ mheight, dw, sbuf, COL_MENUCONTENT_TEXT); ypos += mheight; - if (current_load > -1) { - snprintf(ubuf, sizeof(ubuf), "Load: %ld%s%ld%%", current_load/10, g_Locale->getText(LOCALE_UNIT_DECIMAL), current_load%10); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, ubuf, COL_MENUCONTENT_TEXT); + //get load avg + snprintf(ubuf,buf_size, "%ld.%02ld, %ld.%02ld, %ld.%02ld", + LOAD_INT(info.loads[0]), LOAD_FRAC(info.loads[0]), + LOAD_INT(info.loads[1]), LOAD_FRAC(info.loads[1]), + LOAD_INT(info.loads[2]), LOAD_FRAC(info.loads[2])); + + //paint load avg + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 2*10 + head_info_rw, ypos+ mheight, dw, ubuf, COL_MENUCONTENT_TEXT); + ypos += mheight; + + //get current load + cSysLoad *sysload = cSysLoad::getInstance(); + int data_last = sysload->data_last; + + //paint current load + if (data_last > -1) { + snprintf(ubuf, sizeof(ubuf), "%d%s%d%%", data_last/10, g_Locale->getText(LOCALE_UNIT_DECIMAL), data_last%10); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 2*10 + head_info_rw, ypos+ mheight, dw, ubuf, COL_MENUCONTENT_TEXT); } ypos += mheight; + int pbw = width - offsetw - 10; + if (pbw > 8) /* smaller progressbar is not useful ;) */ + { + unsigned int h = cpuload_y1 - cpuload_y0; + cpuload_y0 += y; + cpuload_y1 += y; + frameBuffer->paintBoxRel(x + offsetw, cpuload_y0, pbw, h, COL_MENUCONTENT_PLUS_2); + + int off = std::max(0, (int)sysload->data_avail - pbw); + for (unsigned int i = 0; i < sysload->data_avail - off; i++) { + if (sysload->data[i + off] > -1) + frameBuffer->paintVLine(x+offsetw + i, cpuload_y1 - sysload->data[i + off] * h / 1000, cpuload_y1, COL_MENUCONTENT_PLUS_7); + } + } + ypos += mheight/2; - if (frontend_count) { - for (int i = 0; i < frontend_count; i++) { - CFrontend *fe = CFEManager::getInstance()->getFE(i); - if (fe) { - std::string s("Frontend "); - s += to_string(i) + ": " + fe->getInfo()->name; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, s, COL_MENUCONTENT_TEXT); - ypos += mheight; - } - } - ypos += mheight/2; - } - int headOffset=0; int mpOffset=0; - const int headSize_mem = 5; - const char *head_mem[headSize_mem] = {"Memory", "Size", "Used", "Available", "Use"}; int offsets[] = { 10, nameWidth + 10, @@ -428,64 +457,57 @@ void CDBoxInfoWidget::paint() }; int widths[] = { 0, sizeWidth, sizeWidth, sizeWidth, percWidth }; - // paint mount head - for (int j = 0; j < headSize_mem; j++) { - headOffset = offsets[j]; - int align = 0; - if (j > 0) - align = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_mem[j], true)); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + align, ypos+ mheight, width - 10, head_mem[j], COL_MENUCONTENTINACTIVE_TEXT); - } + const int headSize = 5; + int maxWidth[headSize]; + memset(maxWidth, 0, headSize * sizeof(int)); + int ypos_mem_head = ypos; ypos += mheight; - for (int k = 0; k < 1 + have_swap; k++) { + for (int row = 0; row < 1 + have_swap; row++) { std::string tmp; - m[k][DBINFO_USED] = m[k][DBINFO_TOTAL] - m[k][DBINFO_FREE]; - for (int j = 0; j < headSize_mem; j++) { - switch (j) { + memstat[row][MEMINFO_USED] = memstat[row][MEMINFO_TOTAL] - memstat[row][MEMINFO_FREE]; + for (int column = 0; column < headSize; column++) { + switch (column) { case 0: - tmp = n[k]; + tmp = memtype[row]; break; case 1: - tmp = bytes2string(1024 * m[k][DBINFO_TOTAL]); + tmp = bytes2string(memstat[row][MEMINFO_TOTAL]); break; case 2: - tmp = bytes2string(1024 * m[k][DBINFO_USED]); + tmp = bytes2string(memstat[row][MEMINFO_USED]); break; case 3: - tmp = bytes2string(1024 * m[k][DBINFO_FREE]); + tmp = bytes2string(memstat[row][MEMINFO_FREE]); break; case 4: - tmp = to_string(m[k][DBINFO_TOTAL] ? (m[k][DBINFO_USED] * 100) / m[k][DBINFO_TOTAL] : 0) + "%"; + tmp = to_string(memstat[row][MEMINFO_TOTAL] ? (memstat[row][MEMINFO_USED] * 100) / memstat[row][MEMINFO_TOTAL] : 0) + "%"; break; } - mpOffset = offsets[j]; - int align = 0; - if (j > 0) - align = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true)); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + align, ypos+ mheight, width - 10, tmp, COL_MENUCONTENT_TEXT); + mpOffset = offsets[column]; + int space = 0; + int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true); + if (column > 0) { + space = widths[column] - rw; + } + maxWidth[column] = std::max(maxWidth[column], rw)+6; + if ((mpOffset + space + maxWidth[column]) > width) + maxWidth[column] = width - (mpOffset + space); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + space, ypos+ mheight, maxWidth[column], tmp, COL_MENUCONTENT_TEXT); } - int pbw = width - offsetw - 10; if (pbw > 8) /* smaller progressbar is not useful ;) */ { CProgressBar pb(x+offsetw, ypos+3, pbw, mheight-10); pb.setBlink(); pb.setInvert(); - pb.setValues(m[k][0] ? (m[k][1] * 100) / m[k][0] : 0, 100); + pb.setValues(memstat[row][MEMINFO_TOTAL] ? (memstat[row][MEMINFO_USED] * 100) / memstat[row][MEMINFO_TOTAL] : 0, 100); pb.paint(false); } ypos += mheight; } ypos += mheight/2; - - // paint mount head - for (int j = 0; j < headSize; j++) { - headOffset = offsets[j]; - int align = 0; - if (j > 0) - align = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head[j], true)); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + align, ypos+ mheight, width - 10, head[j], COL_MENUCONTENTINACTIVE_TEXT); - } + + int ypos_mnt_head = ypos; ypos += mheight; for (std::map::iterator it = mounts.begin(); it != mounts.end(); ++it) { @@ -500,19 +522,24 @@ void CDBoxInfoWidget::paint() bytes_free = s.f_bfree * s.f_bsize; bytes_used = bytes_total - bytes_free; percent_used = (bytes_used * 200 + bytes_total) / 2 / bytes_total; + int width_i = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("i", true); //paint mountpoints - for (int j = 0; j < headSize; j++) { + for (int column = 0; column < headSize; column++) { std::string tmp; - mpOffset = offsets[j]; - int _w = width; - switch (j) { + const char *mnt; + mpOffset = offsets[column]; + int _w = maxWidth[column]; + switch (column) { case 0: tmp = (*it).first; if (tmp == "/") tmp = "rootfs"; + mnt = tmp.c_str(); + tmp = basename((char *)mnt); _w = nameWidth - mpOffset; if ((*it).second) _w -= icon_w; + _w += width_i/2; break; case 1: tmp = bytes2string(bytes_total, false); @@ -527,15 +554,18 @@ void CDBoxInfoWidget::paint() tmp = to_string(percent_used) + "%"; break; } - int align = 0; - if (j > 0) - align = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true)); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + align, ypos+ mheight, _w - 10, tmp, COL_MENUCONTENT_TEXT); + int space = 0; + if (column > 0) { + int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true); + maxWidth[column] = std::max(maxWidth[column], rw); + space = widths[column] - rw; + } + if ((mpOffset + space + _w) > width) + _w = width - (mpOffset + space); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + space, ypos+ mheight, _w, tmp, COL_MENUCONTENT_TEXT); if ((*it).second && icon_w>0 && icon_h>0) - frameBuffer->paintIcon(NEUTRINO_ICON_REC, x + nameWidth - icon_w, ypos + (mheight/2 - icon_h/2)); + frameBuffer->paintIcon(NEUTRINO_ICON_REC, x + nameWidth - icon_w + width_i/2, ypos + (mheight/2 - icon_h/2)); } - int pbw = width - offsetw - 10; -//fprintf(stderr, "width: %d offsetw: %d pbw: %d\n", width, offsetw, pbw); if (pbw > 8) /* smaller progressbar is not useful ;) */ { CProgressBar pb(x+offsetw, ypos+3, pbw, mheight-10); @@ -550,4 +580,39 @@ void CDBoxInfoWidget::paint() if (ypos > y + height - mheight) /* the screen is not high enough */ break; /* todo: scrolling? */ } + // paint info heads + head_info_ypos += y; + for (int line = 0; line < head_info_lines; line++) { + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 10, head_info_ypos + mheight*(line+1), head_info_rw, head_info[line], COL_MENUCONTENTINACTIVE_TEXT); + } + // paint mem head + const char *head_mem[headSize] = {"Memory", "Size", "Used", "Available", "Use"}; + for (int column = 0; column < headSize; column++) { + headOffset = offsets[column]; + int space = 0; + int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_mem[column], true); + int _w = rw; + if (column > 0) { + if (rw > maxWidth[column]) + space = widths[column] - rw; + else + space = widths[column] - maxWidth[column] + (maxWidth[column] - rw)/2; + } + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + space, ypos_mem_head + mheight, _w, head_mem[column], COL_MENUCONTENTINACTIVE_TEXT); + } + // paint mount head + const char *head_mnt[headSize] = {"Filesystem", "Size", "Used", "Available", "Use"}; + for (int column = 0; column < headSize; column++) { + headOffset = offsets[column]; + int space = 0; + int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_mnt[column], true); + int _w = rw; + if (column > 0) { + if (rw > maxWidth[column]) + space = widths[column] - rw; + else + space = widths[column] - maxWidth[column] + (maxWidth[column] - rw)/2; + } + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + space, ypos_mnt_head + mheight, _w, head_mnt[column], COL_MENUCONTENTINACTIVE_TEXT); + } } diff --git a/src/gui/dboxinfo.h b/src/gui/dboxinfo.h index d52b688c6..80d039306 100644 --- a/src/gui/dboxinfo.h +++ b/src/gui/dboxinfo.h @@ -47,8 +47,10 @@ class CDBoxInfoWidget : public CMenuTarget int width; int height; int hheight,mheight; // head/menu font height - unsigned long stat_total, stat_idle; + int fontWidth; int sizeWidth; // width of mem / disk sizes + int percWidth; + int nameWidth; void paint(); diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index cb04aca6d..b12f229b6 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -120,19 +121,10 @@ void EpgPlus::Header::init() void EpgPlus::Header::paint(const char * Name) { - std::string head = g_Locale->getText (LOCALE_EPGPLUS_HEAD); - if(Name) { - head += " "; - head += Name; - } - this->frameBuffer->paintBoxRel (this->x, this->y, this->width, this->font->getHeight()+4, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP); - this->font->RenderString (this->x + 10, this->y + this->font->getHeight() + 2, - this->width - 20, head, COL_MENUHEAD_TEXT, 0, true); - //this->width - 20, g_Locale->getText (LOCALE_EPGPLUS_HEAD) , COL_MENUHEAD_TEXT, 0, true); - int icol_w, icol_h; - frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_HELP, &icol_w, &icol_h); - this->frameBuffer->paintIcon (NEUTRINO_ICON_BUTTON_HELP, this->x + this->width - icol_w - RADIUS_LARGE - 10, this->y+ ((this->font->getHeight()-icol_h)/2), icol_h); + std::string head = Name ? Name : g_Locale->getText (LOCALE_EPGPLUS_HEAD); + CComponentsHeader header(this->x, this->y, this->width, this->font->getHeight()+4, head, NULL /*no header icon*/); + header.paint(CC_SAVE_SCREEN_NO); } int EpgPlus::Header::getUsedHeight() @@ -503,7 +495,8 @@ struct button_label buttonLabels[] = { {NEUTRINO_ICON_BUTTON_RED, LOCALE_EPGPLUS_ACTIONS}, {NEUTRINO_ICON_BUTTON_GREEN, LOCALE_EPGPLUS_PREV_BOUQUET /*LOCALE_EPGPLUS_PAGE_UP*/}, {NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_EPGPLUS_NEXT_BOUQUET /*LOCALE_EPGPLUS_PAGE_DOWN*/}, - {NEUTRINO_ICON_BUTTON_BLUE, LOCALE_EPGPLUS_OPTIONS} + {NEUTRINO_ICON_BUTTON_BLUE, LOCALE_EPGPLUS_OPTIONS}, + {NEUTRINO_ICON_BUTTON_INFO_SMALL, LOCALE_EPGMENU_EVENTINFO} }; void EpgPlus::Footer::paintButtons (button_label * pbuttonLabels, int numberOfButtons) diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index 059d5143b..36ed59b3e 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -935,11 +935,10 @@ bool CFileBrowser::exec(const char * const dirname) _msg << " " << g_Locale->getText(LOCALE_FILEBROWSER_DODELETE2); if (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, _msg.str(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) { - recursiveDelete(filelist[selected].Name.c_str()); - if(".ts" ==(filelist[selected].getFileName().substr(filelist[selected].getFileName().length()-3,filelist[selected].getFileName().length())))//if bla.ts - { - recursiveDelete((filelist[selected].Name.substr(0,filelist[selected].Name.length()-7)+".xml").c_str());//remove bla.xml von bla.ts - } + std::string n = filelist[selected].Name; + recursiveDelete(n.c_str()); + if(n.length() > 3 && ".ts" == n.substr(n.length() - 3)) + recursiveDelete((n.substr(0, n.length() - 2) + "xml").c_str()); ChangeDir(Path); } diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index dddd65a92..d522a5fd2 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -3612,6 +3612,7 @@ void CMovieBrowser::loadYTitles(int mode, std::string search, std::string id) movieInfo.file.Name = ylist[i].title; movieInfo.file.Url = ylist[i].GetUrl(m_settings.ytquality, false); + movieInfo.file.Time = toEpoch(movieInfo.ytdate); m_vMovieInfo.push_back(movieInfo); } m_currentBrowserSelection = 0; @@ -3624,15 +3625,8 @@ void CMovieBrowser::loadYTitles(int mode, std::string search, std::string id) const CMenuOptionChooser::keyval YT_FEED_OPTIONS[] = { - { cYTFeedParser::TOP_RATED, LOCALE_MOVIEBROWSER_YT_TOP_RATED }, - { cYTFeedParser::TOP_FAVORITES, LOCALE_MOVIEBROWSER_YT_TOP_FAVORITES }, - { cYTFeedParser::MOST_SHARED, LOCALE_MOVIEBROWSER_YT_MOST_SHARED }, - { cYTFeedParser::MOST_POPULAR, LOCALE_MOVIEBROWSER_YT_MOST_POPULAR }, - { cYTFeedParser::MOST_RESENT, LOCALE_MOVIEBROWSER_YT_MOST_RESENT }, - { cYTFeedParser::MOST_DISCUSSED, LOCALE_MOVIEBROWSER_YT_MOST_DISCUSSED }, - { cYTFeedParser::MOST_RESPONDED, LOCALE_MOVIEBROWSER_YT_MOST_RESPONDED }, - { cYTFeedParser::RECENTLY_FEATURED, LOCALE_MOVIEBROWSER_YT_RECENTLY_FEATURED }, - { cYTFeedParser::ON_THE_WEB, LOCALE_MOVIEBROWSER_YT_ON_THE_WEB }, + { cYTFeedParser::MOST_POPULAR_ALL_TIME, LOCALE_MOVIEBROWSER_YT_MOST_POPULAR_ALL_TIME }, + { cYTFeedParser::MOST_POPULAR, LOCALE_MOVIEBROWSER_YT_MOST_POPULAR } }; #define YT_FEED_OPTION_COUNT (sizeof(YT_FEED_OPTIONS)/sizeof(CMenuOptionChooser::keyval)) @@ -3642,7 +3636,7 @@ const CMenuOptionChooser::keyval YT_ORDERBY_OPTIONS[] = { cYTFeedParser::ORDERBY_PUBLISHED, LOCALE_MOVIEBROWSER_YT_ORDERBY_PUBLISHED }, { cYTFeedParser::ORDERBY_RELEVANCE, LOCALE_MOVIEBROWSER_YT_ORDERBY_RELEVANCE }, { cYTFeedParser::ORDERBY_VIEWCOUNT, LOCALE_MOVIEBROWSER_YT_ORDERBY_VIEWCOUNT }, - { cYTFeedParser::ORDERBY_RATING, LOCALE_MOVIEBROWSER_YT_ORDERBY_RATING }, + { cYTFeedParser::ORDERBY_RATING, LOCALE_MOVIEBROWSER_YT_ORDERBY_RATING } }; #define YT_ORDERBY_OPTION_COUNT (sizeof(YT_ORDERBY_OPTIONS)/sizeof(CMenuOptionChooser::keyval)) diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index 32c698e98..4cb28a441 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -218,7 +218,7 @@ const CMenuOptionChooser::keyval NFS_TYPE_OPTIONS[NFS_TYPE_OPTION_COUNT] = int CNFSMountGui::menuEntry(int nr) { - int type, automount; + int type; char cmd[9]; char cmd2[9]; @@ -246,7 +246,7 @@ int CNFSMountGui::menuEntry(int nr) CIPInput ipInput(LOCALE_NFS_IP, g_settings.network_nfs[nr].ip, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); CStringInputSMS dirInput(LOCALE_NFS_DIR, &g_settings.network_nfs[nr].dir, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE,"abcdefghijklmnopqrstuvwxyz0123456789-_.,:|!?/ "); - CMenuOptionChooser *automountInput= new CMenuOptionChooser(LOCALE_NFS_AUTOMOUNT, &automount, MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true); + CMenuOptionChooser *automountInput= new CMenuOptionChooser(LOCALE_NFS_AUTOMOUNT, &g_settings.network_nfs[nr].automount, MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true); CStringInputSMS options1Input(LOCALE_NFS_MOUNT_OPTIONS, &g_settings.network_nfs[nr].mount_options1, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-_=.,:|!?/ "); CMenuForwarder *options1_fwd = new CMenuForwarder(LOCALE_NFS_MOUNT_OPTIONS, true, g_settings.network_nfs[nr].mount_options1, &options1Input); diff --git a/src/gui/sleeptimer.cpp b/src/gui/sleeptimer.cpp index 52c531357..371132537 100644 --- a/src/gui/sleeptimer.cpp +++ b/src/gui/sleeptimer.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -53,7 +54,7 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) } is_running = true; - int shutdown_min = 0; + shutdown_min = 0; char value[16]; CStringInput *inbox; bool permanent = (actionKey == "permanent"); @@ -109,15 +110,31 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) printf("sleeptimer min: %d\n", shutdown_min); if (shutdown_min == 0) // if set to zero remove existing sleeptimer { - if(g_Timerd->getSleeptimerID() > 0) { - g_Timerd->removeTimerEvent(g_Timerd->getSleeptimerID()); - } + int timer_id = g_Timerd->getSleeptimerID(); + if (timer_id > 0) + g_Timerd->removeTimerEvent(timer_id); } else // set the sleeptimer to actual time + shutdown mins and announce 1 min before - g_Timerd->setSleeptimer(time(NULL) + ((shutdown_min -1) * 60),time(NULL) + shutdown_min * 60,0); + { + time_t now = time(NULL); + g_Timerd->setSleeptimer(now + (shutdown_min - 1) * 60, now + shutdown_min * 60, 0); + } } is_running = false; return res; } + +const char * CSleepTimerWidget::getTargetValue() +{ + shutdown_min = g_Timerd->getSleepTimerRemaining(); + if (shutdown_min > 0) + { + shutdown_min_string = to_string(shutdown_min); + shutdown_min_string += " "; + shutdown_min_string += g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE); + return shutdown_min_string.c_str(); + } + return NULL; +} diff --git a/src/gui/sleeptimer.h b/src/gui/sleeptimer.h index dd02a34a8..f52f9bebc 100644 --- a/src/gui/sleeptimer.h +++ b/src/gui/sleeptimer.h @@ -29,9 +29,12 @@ class CSleepTimerWidget: public CMenuTarget { private: static bool is_running; + int shutdown_min; + std::string shutdown_min_string; public: int exec(CMenuTarget* parent, const std::string & actionKey); + const char * getTargetValue(); }; diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index 4717557e7..3fc03b6e9 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -52,7 +52,6 @@ #include #include -#include #include #include @@ -68,7 +67,6 @@ extern cVideo * videoDecoder; extern CPictureViewer * g_PicViewer; -extern CInfoClock *InfoClock; const struct button_label RescanButton = {NEUTRINO_ICON_BUTTON_BLUE , LOCALE_UPNPBROWSER_RESCAN}; const struct button_label BrowseButtons[4] = @@ -456,7 +454,6 @@ void CUpnpBrowserGui::selectDevice() return; CAudioMute::getInstance()->enableMuteIcon(false); - InfoClock->enableInfoClock(false); while (loop) { @@ -546,7 +543,6 @@ printf("msg: %x\n", (int) msg); } } CAudioMute::getInstance()->enableMuteIcon(true); - InfoClock->enableInfoClock(true); } void CUpnpBrowserGui::playnext(void) diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index 8940eb557..e8ebcffb9 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -85,15 +85,6 @@ CUserMenu::~CUserMenu() } -#if 0 -#define MAINMENU_RECORDING_OPTION_COUNT 2 -const CMenuOptionChooser::keyval MAINMENU_RECORDING_OPTIONS[MAINMENU_RECORDING_OPTION_COUNT] = -{ - { 0, LOCALE_MAINMENU_RECORDING_START }, - { 1, LOCALE_MAINMENU_RECORDING_STOP } -}; -#endif - // USERMENU bool CUserMenu::showUserMenu(int button) { @@ -377,40 +368,33 @@ bool CUserMenu::showUserMenu(int button) menu->addItem(menu_item, false); } break; - -#if 0 // FIXME not supported yet - case SNeutrinoSettings::ITEM_MOVIEPLAYER_TS: - menu_items++; - menu_prev = SNeutrinoSettings::ITEM_MOVIEPLAYER_TS; - keyhelper.get(&key,&icon,CRCInput::RC_green); - menu_item = new CMenuForwarder(LOCALE_MOVIEPLAYER_TSPLAYBACK, true, NULL, moviePlayerGui, "tsplayback", key, icon); - menu->addItem(menu_item, false); - break; - - case SNeutrinoSettings::ITEM_VTXT: - for (unsigned int count = 0; count < (unsigned int) g_PluginList->getNumberOfPlugins(); count++) + case SNeutrinoSettings::ITEM_YOUTUBE: { - std::string tmp = g_PluginList->getName(count); - if (g_PluginList->getType(count)== CPlugins::P_TYPE_TOOL && !g_PluginList->isHidden(count) && tmp.find("Teletext") != std::string::npos) - { - sprintf(id, "%d", count); - menu_items++; - menu_prev = SNeutrinoSettings::ITEM_VTXT; - - //keyhelper.get(&key,&icon,CRCInput::RC_blue); - keyhelper.get(&key,&icon); - menu_item = new CMenuForwarderNonLocalized(g_PluginList->getName(count), true, NULL, StreamFeaturesChanger, id, key, icon); - menu->addItem(menu_item, 0); - } + menu_items++; + menu_prev = SNeutrinoSettings::ITEM_YOUTUBE; + keyhelper.get(&key,&icon); + menu_item = new CMenuForwarder(LOCALE_MOVIEPLAYER_YTPLAYBACK, true, NULL, &CMoviePlayerGui::getInstance(), "ytplayback", key, icon); + menu_item->setHint(NEUTRINO_ICON_HINT_YTPLAY, LOCALE_MENU_HINT_YTPLAY); + menu->addItem(menu_item, 0); + } + break; + case SNeutrinoSettings::ITEM_FILEPLAY: + { + menu_items++; + menu_prev = SNeutrinoSettings::ITEM_FILEPLAY; + keyhelper.get(&key,&icon); + menu_item = new CMenuForwarder(LOCALE_MOVIEPLAYER_FILEPLAYBACK, true, NULL, &CMoviePlayerGui::getInstance(), "fileplayback", key, icon); + menu_item->setHint(NEUTRINO_ICON_HINT_FILEPLAY, LOCALE_MENU_HINT_FILEPLAY); + menu->addItem(menu_item, 0); } break; -#endif default: printf("[neutrino] WARNING! menu wrong item!!\n"); break; } } +#if 0 // Allow some tailoring for privat image bakers ;) if (button == SNeutrinoSettings::BUTTON_RED) { } @@ -419,17 +403,8 @@ bool CUserMenu::showUserMenu(int button) else if ( button == SNeutrinoSettings::BUTTON_YELLOW) { } else if ( button == SNeutrinoSettings::BUTTON_BLUE) { -#ifdef _EXPERIMENTAL_SETTINGS_ - //Experimental Settings - if (menu_prev != -1) - menu->addItem(GenericMenuSeparatorLine); - menu_items ++; - menu_key++; - // FYI: there is a memory leak with 'new CExperimentalSettingsMenuHandler() - menu_item = new CMenuForwarder(LOCALE_EXPERIMENTALSETTINGS, true, NULL, new CExperimentalSettingsMenuHandler(), "-1", CRCInput::convertDigitToKey(menu_key)); - menu->addItem(menu_item, false); -#endif } +#endif // show menu if there are more than 2 items only // otherwise, we start the item directly (must be the last one) @@ -441,9 +416,6 @@ bool CUserMenu::showUserMenu(int button) user_menu[button].selected = menu->getSelected(); - // restore mute symbol - //AudioMute(current_muted, true); - // clear the heap if (tmpFavorites) delete tmpFavorites; if (tmpAudioSelectMenuHandler) delete tmpAudioSelectMenuHandler; @@ -468,19 +440,6 @@ bool CUserMenu::showUserMenu(int button) **************************************************************************************/ bool CUserMenu::changeNotify(const neutrino_locale_t OptionName, void * Data) { -#if 0 - bool res = !CRecordManager::getInstance()->RecordingStatus() ? false:true; - - if ((ARE_LOCALES_EQUAL(OptionName, LOCALE_MAINMENU_RECORDING_START)) || (ARE_LOCALES_EQUAL(OptionName, LOCALE_MAINMENU_RECORDING))) - { - CNeutrinoApp::getInstance()->exec(NULL, "handle_record"); - - if (CRecordManager::getInstance()->RecordingStatus()) - res = false; - else - res = true; - } else -#endif if (ARE_LOCALES_EQUAL(OptionName, LOCALE_MAINMENU_PAUSESECTIONSD)) { g_Sectionsd->setPauseScanning((*((int *)Data)) == 0); } diff --git a/src/gui/user_menue_setup.cpp b/src/gui/user_menue_setup.cpp index 5b07acb5f..1872aa542 100644 --- a/src/gui/user_menue_setup.cpp +++ b/src/gui/user_menue_setup.cpp @@ -34,7 +34,6 @@ #include #endif - #include "user_menue_setup.h" #include @@ -88,7 +87,9 @@ const CMenuOptionChooser::keyval USERMENU_ITEM_OPTIONS[USERMENU_ITEM_OPTION_COUN { SNeutrinoSettings::ITEM_CLOCK, LOCALE_CLOCK_SWITCH_ON }, { SNeutrinoSettings::ITEM_GAMES, LOCALE_MAINMENU_GAMES }, { SNeutrinoSettings::ITEM_SCRIPTS, LOCALE_MAINMENU_SCRIPTS }, - { SNeutrinoSettings::ITEM_RECORD, LOCALE_TIMERLIST_TYPE_RECORD } + { SNeutrinoSettings::ITEM_RECORD, LOCALE_TIMERLIST_TYPE_RECORD }, + { SNeutrinoSettings::ITEM_YOUTUBE, LOCALE_MOVIEPLAYER_YTPLAYBACK }, + { SNeutrinoSettings::ITEM_FILEPLAY, LOCALE_MOVIEPLAYER_FILEPLAYBACK } }; int CUserMenuSetup::exec(CMenuTarget* parent, const std::string &) @@ -131,7 +132,7 @@ int CUserMenuSetup::showSetup() snprintf(text,max_char,"%d.",item+1); text[max_char-1]=0;// terminate for sure int count = (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) ? USERMENU_ITEM_OPTION_COUNT : USERMENU_ITEM_OPTION_COUNT - 1; - ums->addItem(new CMenuOptionChooser(text, &g_settings.usermenu[button][item], USERMENU_ITEM_OPTIONS, count,true, NULL, CRCInput::RC_nokey, "", true )); + ums->addItem(new CMenuOptionChooser(text, &g_settings.usermenu[button][item], USERMENU_ITEM_OPTIONS, count,true, NULL, CRCInput::RC_nokey, "", true, true)); } int res = ums->exec(NULL, ""); diff --git a/src/gui/user_menue_setup.h b/src/gui/user_menue_setup.h index 5c04d9986..2cc2b5190 100644 --- a/src/gui/user_menue_setup.h +++ b/src/gui/user_menue_setup.h @@ -58,7 +58,7 @@ const struct usermenu_props_t usermenu[USERMENU_ITEMS_COUNT] = }; - class CUserMenuSetup : public CMenuTarget +class CUserMenuSetup : public CMenuTarget { private: int width; diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index b152d7113..b45e0096f 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1284,7 +1284,7 @@ int CMenuOptionNumberChooser::getWidth(void) return width + 10; /* min 10 pixels between option name and value. enough? */ } -CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown) +CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); optionNameString = g_Locale->getText(OptionName); @@ -1295,7 +1295,8 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * observ = Observ; directKey = DirectKey; iconName = IconName; - pulldown = Pulldown; + pulldown = Pulldown; + optionsSort = OptionsSort; for (unsigned int i = 0; i < number_of_options; i++) { struct keyval_ext opt; @@ -1306,7 +1307,7 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * } } -CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown) +CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); optionNameString = OptionName; @@ -1317,7 +1318,8 @@ CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const Optio observ = Observ; directKey = DirectKey; iconName = IconName; - pulldown = Pulldown; + pulldown = Pulldown; + optionsSort = OptionsSort; for (unsigned int i = 0; i < number_of_options; i++) { struct keyval_ext opt; @@ -1330,7 +1332,7 @@ CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const Optio CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval_ext * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown) + const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); optionNameString = g_Locale->getText(OptionName); @@ -1341,14 +1343,15 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * observ = Observ; directKey = DirectKey; iconName = IconName; - pulldown = Pulldown; + pulldown = Pulldown; + optionsSort = OptionsSort; for (unsigned int i = 0; i < number_of_options; i++) options.push_back(Options[i]); } CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval_ext * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown) + const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); optionNameString = OptionName; @@ -1359,7 +1362,8 @@ CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const Optio observ = Observ; directKey = DirectKey; iconName = IconName; - pulldown = Pulldown; + pulldown = Pulldown; + optionsSort = OptionsSort; for (unsigned int i = 0; i < number_of_options; i++) options.push_back(Options[i]); } @@ -1367,6 +1371,7 @@ CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const Optio CMenuOptionChooser::~CMenuOptionChooser() { options.clear(); + clearChooserOptions(); } void CMenuOptionChooser::setOptionValue(const int newvalue) @@ -1379,12 +1384,43 @@ int CMenuOptionChooser::getOptionValue(void) const return *optionValue; } +void CMenuOptionChooser::clearChooserOptions() +{ + for (std::vector::iterator it = option_chooser_options_v.begin(); it != option_chooser_options_v.end(); ++it) + delete *it; + + option_chooser_options_v.clear(); +} int CMenuOptionChooser::exec(CMenuTarget*) { bool wantsRepaint = false; int ret = menu_return::RETURN_NONE; + if (optionsSort) { + optionsSort = false; + clearChooserOptions(); + unsigned int i1; + for (i1 = 0; i1 < number_of_options; i1++) + { + CMenuOptionChooserOptions* co = new CMenuOptionChooserOptions(); + co->key = options[i1].key; + co->valname = (options[i1].valname != 0) ? options[i1].valname : g_Locale->getText(options[i1].value); + option_chooser_options_v.push_back(co); + } + + sort(option_chooser_options_v.begin(), option_chooser_options_v.end(), CMenuOptionChooserCompareItem()); + + options.clear(); + for (std::vector::iterator it = option_chooser_options_v.begin(); it != option_chooser_options_v.end(); ++it) { + struct keyval_ext opt; + opt.key = (*it)->key; + opt.value = NONEXISTANT_LOCALE; + opt.valname = (*it)->valname.c_str(); + options.push_back(opt); + } + } + if((msg == CRCInput::RC_ok) && pulldown) { int select = -1; char cnt[5]; @@ -1515,7 +1551,7 @@ CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t Optio active = Active; optionValue = OptionValue; observ = Observ; - + optionValueString = NULL; directKey = DirectKey; iconName = IconName; pulldown = Pulldown; @@ -1545,7 +1581,6 @@ CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t Optio optionValue = (char *) OptionValue->c_str(); optionValueString = OptionValue; observ = Observ; - optionValueString = NULL; directKey = DirectKey; iconName = IconName; @@ -1804,11 +1839,11 @@ const char * CMenuForwarder::getOption(void) { if (option) return option; - else - if (option_string) - return option_string->c_str(); - else - return NULL; + if (option_string) + return option_string->c_str(); + if (jumpTarget) + return jumpTarget->getTargetValue(); + return NULL; } const char * CMenuForwarder::getName(void) diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 886f501bd..d5b067093 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -79,6 +79,7 @@ class CMenuTarget virtual void hide(){} virtual int exec(CMenuTarget* parent, const std::string & actionKey) = 0; virtual fb_pixel_t getColor(void) { return 0; } + virtual const char * getTargetValue() { return NULL; } }; class CMenuItem @@ -312,6 +313,26 @@ private: void setNumberFormat(std::string (*fun)(int)) { numberFormatFunction = fun; } }; +class CMenuOptionChooserOptions +{ + public: + int key; + std::string valname; +}; + +struct CMenuOptionChooserCompareItem: public std::binary_function +{ + static bool cmpToLower(const char a, const char b) + { + return tolower(a) < tolower(b); + }; + + bool operator() (const CMenuOptionChooserOptions * const c1, CMenuOptionChooserOptions * const c2) + { + return std::lexicographical_compare(c1->valname.begin(), c1->valname.end(), c2->valname.begin(), c2->valname.end(), cmpToLower); + }; +}; + class CMenuOptionChooser : public CAbstractMenuOptionChooser { public: @@ -330,28 +351,32 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser private: std::vector options; - unsigned number_of_options; - CChangeObserver * observ; - std::string optionNameString; - bool pulldown; + std::vector option_chooser_options_v; + unsigned number_of_options; + CChangeObserver * observ; + std::string optionNameString; + bool pulldown; + bool optionsSort; + + void clearChooserOptions(); public: CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", - bool Pulldown = false); + bool Pulldown = false, bool OptionsSort = false); CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval_ext * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", - bool Pulldown = false); + bool Pulldown = false, bool OptionsSort = false); CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", - bool Pulldown = false); + bool Pulldown = false, bool OptionsSort = false); CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval_ext * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", - bool Pulldown = false); + bool Pulldown = false, bool OptionsSort = false); ~CMenuOptionChooser(); void setOptionValue(const int newvalue); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index d1eaeed6e..8b8763011 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -110,6 +110,7 @@ #include #include #include +#include #include @@ -809,10 +810,10 @@ int CNeutrinoApp::loadSetup(const char * fname) //------------------------------------------- // this is as the current neutrino usermen const char* usermenu_default[SNeutrinoSettings::BUTTON_MAX]={ - "2,3,4,13", // RED - "6", // GREEN - "7", // YELLOW - "12,11,20,21,19,14,15" // BLUE + "2,3,4,13", // RED + "6", // GREEN + "7", // YELLOW + "12,11,20,21,19,14,15" // BLUE }; char txt1[81]; std::string txt2; @@ -2085,6 +2086,8 @@ fprintf(stderr, "[neutrino start] %d -> %5ld ms\n", __LINE__, time_monotonic_ms g_audioMute->AudioMute(current_muted, true); SHTDCNT::getInstance()->init(); + cSysLoad::getInstance(); + TIMER_STOP("################################## after all ##################################"); RealRun(personalize.getWidget(0)/**main**/); diff --git a/src/system/Makefile.am b/src/system/Makefile.am index 2a180dc17..97e523b9e 100644 --- a/src/system/Makefile.am +++ b/src/system/Makefile.am @@ -32,6 +32,7 @@ libneutrino_system_a_SOURCES = \ helpers.cpp \ ping.c \ settings.cpp \ + sysload.cpp \ ytparser.cpp \ setting_helpers.cpp # safe_system.c diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index a0e9e003c..700bb1a4a 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -345,6 +345,18 @@ std::string trim(std::string &str, const std::string &trimChars /*= " \n\r\t"*/) return result.erase(0, result.find_first_not_of(trimChars)); } +time_t toEpoch(std::string &date) +{ + struct tm t; + memset(&t, 0, sizeof(t)); + char *p = strptime(date.c_str(), "%Y-%m-%d", &t); + if(p) + return mktime(&t); + + return 0; + +} + CFileHelpers::CFileHelpers() { FileBufSize = 0xFFFF; diff --git a/src/system/helpers.h b/src/system/helpers.h index 2fbac55cd..e1f870772 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -47,6 +47,7 @@ std::string getFileName(std::string &file); std::string getFileExt(std::string &file); std::string getNowTimeStr(const char* format); std::string trim(std::string &str, const std::string &trimChars = " \n\r\t"); +time_t toEpoch(std::string &date); class CFileHelpers { diff --git a/src/system/locals.h b/src/system/locals.h index 770775708..e0bf849a1 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -1465,13 +1465,9 @@ typedef enum LOCALE_MOVIEBROWSER_YT_HISTORY, LOCALE_MOVIEBROWSER_YT_MAX_HISTORY, LOCALE_MOVIEBROWSER_YT_MAX_RESULTS, - LOCALE_MOVIEBROWSER_YT_MOST_DISCUSSED, LOCALE_MOVIEBROWSER_YT_MOST_POPULAR, - LOCALE_MOVIEBROWSER_YT_MOST_RESENT, - LOCALE_MOVIEBROWSER_YT_MOST_RESPONDED, - LOCALE_MOVIEBROWSER_YT_MOST_SHARED, + LOCALE_MOVIEBROWSER_YT_MOST_POPULAR_ALL_TIME, LOCALE_MOVIEBROWSER_YT_NEXT_RESULTS, - LOCALE_MOVIEBROWSER_YT_ON_THE_WEB, LOCALE_MOVIEBROWSER_YT_ORDERBY, LOCALE_MOVIEBROWSER_YT_ORDERBY_PUBLISHED, LOCALE_MOVIEBROWSER_YT_ORDERBY_RATING, @@ -1483,8 +1479,6 @@ typedef enum LOCALE_MOVIEBROWSER_YT_REGION, LOCALE_MOVIEBROWSER_YT_RELATED, LOCALE_MOVIEBROWSER_YT_SEARCH, - LOCALE_MOVIEBROWSER_YT_TOP_FAVORITES, - LOCALE_MOVIEBROWSER_YT_TOP_RATED, LOCALE_MOVIEPLAYER_BOOKMARK, LOCALE_MOVIEPLAYER_BOOKMARKNAME, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT1, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 0af0d3eea..5391c24bf 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -1465,13 +1465,9 @@ const char * locale_real_names[] = "moviebrowser.yt_history", "moviebrowser.yt_max_history", "moviebrowser.yt_max_results", - "moviebrowser.yt_most_discussed", "moviebrowser.yt_most_popular", - "moviebrowser.yt_most_resent", - "moviebrowser.yt_most_responded", - "moviebrowser.yt_most_shared", + "moviebrowser.yt_most_popular_all_time", "moviebrowser.yt_next_results", - "moviebrowser.yt_on_the_web", "moviebrowser.yt_orderby", "moviebrowser.yt_orderby.published", "moviebrowser.yt_orderby.rating", @@ -1483,8 +1479,6 @@ const char * locale_real_names[] = "moviebrowser.yt_region", "moviebrowser.yt_related", "moviebrowser.yt_search", - "moviebrowser.yt_top_favorites", - "moviebrowser.yt_top_rated", "movieplayer.bookmark", "movieplayer.bookmarkname", "movieplayer.bookmarkname_hint1", diff --git a/src/system/settings.h b/src/system/settings.h index 35009ff04..baef4b2a1 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -659,9 +659,8 @@ struct SNeutrinoSettings ITEM_CLOCK = 19, ITEM_GAMES = 20, ITEM_SCRIPTS = 21, -#if 0 - ITEM_MOVIEPLAYER_TS, -#endif + ITEM_YOUTUBE = 22, + ITEM_FILEPLAY = 23, ITEM_MAX // MUST be always the last in the list } USER_ITEM; std::string usermenu_text[BUTTON_MAX]; diff --git a/src/system/sysload.cpp b/src/system/sysload.cpp new file mode 100644 index 000000000..5338adcc9 --- /dev/null +++ b/src/system/sysload.cpp @@ -0,0 +1,115 @@ +/* + Neutrino-HD + + License: GPL + + (C) 2013 martii + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __USE_FILE_OFFSET64 +#define __USE_FILE_OFFSET64 1 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static cSysLoad *instance = NULL; + +cSysLoad *cSysLoad::getInstance(void) +{ + if (!instance) + instance = new cSysLoad; + return instance; +} + +void *cSysLoad::Run(void *arg) +{ + set_threadname("sysload"); + + class cSysLoad *caller = (class cSysLoad *)arg; + unsigned long stat_idle = 0, stat_total = 0; + + while (caller->running) { + std::ifstream in("/proc/stat"); + if (in.is_open()) { + std::string line; + while (getline(in, line)) { + unsigned long _stat_user, _stat_nice, _stat_system, _stat_idle; + if (4 == sscanf(line.c_str(), "cpu %lu %lu %lu %lu", &_stat_user, &_stat_nice, &_stat_system, &_stat_idle)) { + if (stat_total) { + unsigned long div = _stat_user + _stat_nice + _stat_system + _stat_idle - stat_total; + caller->data_last = (int)(1000 - 1000 * (_stat_idle - stat_idle) / div); + if (caller->data_avail < caller->data_size) { + caller->data[caller->data_avail++] = caller->data_last; + } else { + memmove(caller->data, caller->data + 1, (caller->data_size - 1) * sizeof(int)); + caller->data[caller->data_size - 1] = caller->data_last; + } + } + stat_idle = _stat_idle; + stat_total = _stat_user + _stat_nice + _stat_system + _stat_idle; + break; + } + } + in.close(); + } + + timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += caller->period; + sem_timedwait(&caller->sem, &ts); + } + pthread_exit(NULL); +} + +cSysLoad::cSysLoad(void) +{ + data_last = -1; + data_avail = 0; + period = 5; + data_size = 1800/period; + data = new int[data_size]; + for (unsigned int i = 0; i < data_size; i++) + data[i] = -1; + running = true; + sem_init(&sem, 0, 0); + if (pthread_create(&thr, NULL, Run, this)) + running = false; +} + +cSysLoad::~cSysLoad(void) +{ + if (running) { + running = false; + sem_post(&sem); + pthread_join(thr, NULL); + } + sem_destroy(&sem); + delete[] data; +} diff --git a/src/system/sysload.h b/src/system/sysload.h new file mode 100644 index 000000000..7cfa9535b --- /dev/null +++ b/src/system/sysload.h @@ -0,0 +1,51 @@ +/* + Neutrino-HD + + License: GPL + + (C) 2013 martii + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __SYSTEM_SYSLOAD__H_ +#define __SYSTEM_SYSLOAD__H_ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +class cSysLoad +{ + private: + pthread_t thr; + cSysLoad(); + static void* Run(void *); + public: + int *data; + size_t data_avail; + size_t data_size; + unsigned int period; + bool running; + sem_t sem; + ~cSysLoad(void); + static cSysLoad *getInstance(void); + int data_last; +}; +#endif diff --git a/src/system/ytparser.cpp b/src/system/ytparser.cpp index 5837f51fb..fe5b6870b 100644 --- a/src/system/ytparser.cpp +++ b/src/system/ytparser.cpp @@ -476,36 +476,15 @@ bool cYTFeedParser::ParseFeed(yt_feed_mode_t mode, std::string search, std::stri { std::string url = "http://gdata.youtube.com/feeds/api/standardfeeds/"; bool append_res = true; + std::string trailer; if (mode < FEED_LAST) { switch(mode) { - case TOP_RATED: - curfeed = "top_rated"; - break; - case TOP_FAVORITES: - curfeed = "top_favorites"; - break; - case MOST_SHARED: - curfeed = "most_shared"; - break; case MOST_POPULAR: default: + trailer = "&time=today"; + case MOST_POPULAR_ALL_TIME: curfeed = "most_popular"; break; - case MOST_RESENT: - curfeed = "most_recent"; - break; - case MOST_DISCUSSED: - curfeed = "most_discussed"; - break; - case MOST_RESPONDED: - curfeed = "most_responded"; - break; - case RECENTLY_FEATURED: - curfeed = "recently_featured"; - break; - case ON_THE_WEB: - curfeed = "on_the_web"; - break; } if (!region.empty()) { url += region; @@ -552,6 +531,8 @@ bool cYTFeedParser::ParseFeed(yt_feed_mode_t mode, std::string search, std::stri url+= res; } + url += trailer; + return ParseFeed(url); } diff --git a/src/system/ytparser.h b/src/system/ytparser.h index 5e4d6f12d..fd6d26084 100644 --- a/src/system/ytparser.h +++ b/src/system/ytparser.h @@ -113,15 +113,8 @@ class cYTFeedParser public: enum yt_feed_mode_t { - TOP_RATED, - TOP_FAVORITES, - MOST_SHARED, MOST_POPULAR, - MOST_RESENT, - MOST_DISCUSSED, - MOST_RESPONDED, - RECENTLY_FEATURED, - ON_THE_WEB, + MOST_POPULAR_ALL_TIME, FEED_LAST, NEXT, PREV,