From 4382f45236108c711af2ecbcb3dabb46bfdc9e1e Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Sun, 29 Dec 2013 22:24:34 +0100 Subject: [PATCH 01/36] - epgplus: use CComponents to paint header; move header-icon to footer --- src/gui/epgplus.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index 3ee640c51..326c67981 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -119,19 +120,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() @@ -502,7 +494,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) From ce189253332bb575bf99ba1a864e76c39da8677a Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Mon, 30 Dec 2013 01:34:07 +0100 Subject: [PATCH 02/36] gui/dboxinfo: move cpu load calculation to dedicated thread ... ... that keeps history; show load graph --- src/gui/dboxinfo.cpp | 54 ++++++++++--------- src/gui/dboxinfo.h | 1 - src/neutrino.cpp | 3 ++ src/system/Makefile.am | 1 + src/system/sysload.cpp | 115 +++++++++++++++++++++++++++++++++++++++++ src/system/sysload.h | 51 ++++++++++++++++++ 6 files changed, 196 insertions(+), 29 deletions(-) create mode 100644 src/system/sysload.cpp create mode 100644 src/system/sysload.h diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 82e3246fe..abdc7d88d 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -54,6 +54,7 @@ #include #include +#include #include #include #include @@ -75,7 +76,6 @@ CDBoxInfoWidget::CDBoxInfoWidget() height = 0; x = 0; y = 0; - stat_total = 0; } @@ -211,14 +211,18 @@ void CDBoxInfoWidget::paint() int nameWidth = fontWidth * 17;//WWWwwwwwww height = hheight; height += mheight/2; // space + int cpuload_y0 = height; height += mheight; // time height += mheight; // uptime height += mheight; // load + int cpuload_y1 = height; height += mheight/2; // space int frontend_count = CFEManager::getInstance()->getFrontendCount(); - if (frontend_count) - height += mheight * frontend_count + mheight/2; + if (frontend_count) { + height += mheight * frontend_count; + height += mheight/2; + } int icon_w = 0, icon_h = 0; frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icon_w, &icon_h); @@ -352,28 +356,10 @@ void CDBoxInfoWidget::paint() 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(); - } + cSysLoad *sysload = cSysLoad::getInstance(); + int data_last = sysload->data_last; 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); @@ -386,12 +372,27 @@ void CDBoxInfoWidget::paint() g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, ubuf, 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); + if (data_last > -1) { + snprintf(ubuf, sizeof(ubuf), "Load: %d%s%d%%", data_last/10, g_Locale->getText(LOCALE_UNIT_DECIMAL), data_last%10); g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, 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) { @@ -457,7 +458,6 @@ void CDBoxInfoWidget::paint() center = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true))/2; g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + center, ypos+ mheight, width - 10, 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); @@ -526,8 +526,6 @@ void CDBoxInfoWidget::paint() if ((*it).second && icon_w>0 && icon_h>0) frameBuffer->paintIcon(NEUTRINO_ICON_REC, x + nameWidth - icon_w, 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); diff --git a/src/gui/dboxinfo.h b/src/gui/dboxinfo.h index 4a8cc52ee..5587ba7d0 100644 --- a/src/gui/dboxinfo.h +++ b/src/gui/dboxinfo.h @@ -47,7 +47,6 @@ class CDBoxInfoWidget : public CMenuTarget int width; int height; int hheight,mheight; // head/menu font height - unsigned long stat_total, stat_idle; void paint(); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 56ab88e34..7548983b2 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -106,6 +106,7 @@ #include #include #include +#include #include @@ -1978,6 +1979,8 @@ TIMER_START(); hintBox->hide(); delete hintBox; + cSysLoad::getInstance(); + TIMER_STOP("################################## after all ##################################"); RealRun(personalize.getWidget(0)/**main**/); diff --git a/src/system/Makefile.am b/src/system/Makefile.am index 11bad7cd8..bee2e4350 100644 --- a/src/system/Makefile.am +++ b/src/system/Makefile.am @@ -42,5 +42,6 @@ libneutrino_system_a_SOURCES = \ helpers.cpp \ ping.c \ settings.cpp \ + sysload.cpp \ ytparser.cpp \ setting_helpers.cpp 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 From 7fbe179a1f00de18da6558758646b86e4aea2d9b Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Mon, 30 Dec 2013 01:51:08 +0100 Subject: [PATCH 03/36] Revert "gui/dboxinfo: move cpu load calculation to dedicated thread ..." This reverts commit ce189253332bb575bf99ba1a864e76c39da8677a. --- src/gui/dboxinfo.cpp | 54 +++++++++---------- src/gui/dboxinfo.h | 1 + src/neutrino.cpp | 3 -- src/system/Makefile.am | 1 - src/system/sysload.cpp | 115 ----------------------------------------- src/system/sysload.h | 51 ------------------ 6 files changed, 29 insertions(+), 196 deletions(-) delete mode 100644 src/system/sysload.cpp delete mode 100644 src/system/sysload.h diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index abdc7d88d..82e3246fe 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -54,7 +54,6 @@ #include #include -#include #include #include #include @@ -76,6 +75,7 @@ CDBoxInfoWidget::CDBoxInfoWidget() height = 0; x = 0; y = 0; + stat_total = 0; } @@ -211,18 +211,14 @@ void CDBoxInfoWidget::paint() int nameWidth = fontWidth * 17;//WWWwwwwwww height = hheight; height += mheight/2; // space - int cpuload_y0 = height; height += mheight; // time height += mheight; // uptime height += mheight; // load - int cpuload_y1 = height; height += mheight/2; // space int frontend_count = CFEManager::getInstance()->getFrontendCount(); - if (frontend_count) { - height += mheight * frontend_count; - height += mheight/2; - } + 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); @@ -356,10 +352,28 @@ void CDBoxInfoWidget::paint() ypos += hheight + mheight/2; - cSysLoad *sysload = cSysLoad::getInstance(); - int data_last = sysload->data_last; + 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(); + } 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); @@ -372,27 +386,12 @@ void CDBoxInfoWidget::paint() g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, ubuf, COL_MENUCONTENT_TEXT); ypos += mheight; - if (data_last > -1) { - snprintf(ubuf, sizeof(ubuf), "Load: %d%s%d%%", data_last/10, g_Locale->getText(LOCALE_UNIT_DECIMAL), data_last%10); + 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); } 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) { @@ -458,6 +457,7 @@ void CDBoxInfoWidget::paint() center = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true))/2; g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + center, ypos+ mheight, width - 10, 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); @@ -526,6 +526,8 @@ void CDBoxInfoWidget::paint() if ((*it).second && icon_w>0 && icon_h>0) frameBuffer->paintIcon(NEUTRINO_ICON_REC, x + nameWidth - icon_w, 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); diff --git a/src/gui/dboxinfo.h b/src/gui/dboxinfo.h index 5587ba7d0..4a8cc52ee 100644 --- a/src/gui/dboxinfo.h +++ b/src/gui/dboxinfo.h @@ -47,6 +47,7 @@ class CDBoxInfoWidget : public CMenuTarget int width; int height; int hheight,mheight; // head/menu font height + unsigned long stat_total, stat_idle; void paint(); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 7548983b2..56ab88e34 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -106,7 +106,6 @@ #include #include #include -#include #include @@ -1979,8 +1978,6 @@ TIMER_START(); hintBox->hide(); delete hintBox; - cSysLoad::getInstance(); - TIMER_STOP("################################## after all ##################################"); RealRun(personalize.getWidget(0)/**main**/); diff --git a/src/system/Makefile.am b/src/system/Makefile.am index bee2e4350..11bad7cd8 100644 --- a/src/system/Makefile.am +++ b/src/system/Makefile.am @@ -42,6 +42,5 @@ libneutrino_system_a_SOURCES = \ helpers.cpp \ ping.c \ settings.cpp \ - sysload.cpp \ ytparser.cpp \ setting_helpers.cpp diff --git a/src/system/sysload.cpp b/src/system/sysload.cpp deleted file mode 100644 index 5338adcc9..000000000 --- a/src/system/sysload.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - 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 deleted file mode 100644 index 7cfa9535b..000000000 --- a/src/system/sysload.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - 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 From 6fff156164fe126a4bd4132ba0a09b7c6184c592 Mon Sep 17 00:00:00 2001 From: martii Date: Mon, 30 Dec 2013 01:34:07 +0100 Subject: [PATCH 04/36] gui/dboxinfo: move cpu load calculation to dedicated thread ... ... that keeps history; show load graph --- src/gui/dboxinfo.cpp | 54 ++++++++++--------- src/gui/dboxinfo.h | 1 - src/neutrino.cpp | 3 ++ src/system/Makefile.am | 1 + src/system/sysload.cpp | 115 +++++++++++++++++++++++++++++++++++++++++ src/system/sysload.h | 51 ++++++++++++++++++ 6 files changed, 196 insertions(+), 29 deletions(-) create mode 100644 src/system/sysload.cpp create mode 100644 src/system/sysload.h diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 82e3246fe..abdc7d88d 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -54,6 +54,7 @@ #include #include +#include #include #include #include @@ -75,7 +76,6 @@ CDBoxInfoWidget::CDBoxInfoWidget() height = 0; x = 0; y = 0; - stat_total = 0; } @@ -211,14 +211,18 @@ void CDBoxInfoWidget::paint() int nameWidth = fontWidth * 17;//WWWwwwwwww height = hheight; height += mheight/2; // space + int cpuload_y0 = height; height += mheight; // time height += mheight; // uptime height += mheight; // load + int cpuload_y1 = height; height += mheight/2; // space int frontend_count = CFEManager::getInstance()->getFrontendCount(); - if (frontend_count) - height += mheight * frontend_count + mheight/2; + if (frontend_count) { + height += mheight * frontend_count; + height += mheight/2; + } int icon_w = 0, icon_h = 0; frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icon_w, &icon_h); @@ -352,28 +356,10 @@ void CDBoxInfoWidget::paint() 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(); - } + cSysLoad *sysload = cSysLoad::getInstance(); + int data_last = sysload->data_last; 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); @@ -386,12 +372,27 @@ void CDBoxInfoWidget::paint() g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, ubuf, 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); + if (data_last > -1) { + snprintf(ubuf, sizeof(ubuf), "Load: %d%s%d%%", data_last/10, g_Locale->getText(LOCALE_UNIT_DECIMAL), data_last%10); g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, 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) { @@ -457,7 +458,6 @@ void CDBoxInfoWidget::paint() center = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true))/2; g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + center, ypos+ mheight, width - 10, 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); @@ -526,8 +526,6 @@ void CDBoxInfoWidget::paint() if ((*it).second && icon_w>0 && icon_h>0) frameBuffer->paintIcon(NEUTRINO_ICON_REC, x + nameWidth - icon_w, 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); diff --git a/src/gui/dboxinfo.h b/src/gui/dboxinfo.h index 4a8cc52ee..5587ba7d0 100644 --- a/src/gui/dboxinfo.h +++ b/src/gui/dboxinfo.h @@ -47,7 +47,6 @@ class CDBoxInfoWidget : public CMenuTarget int width; int height; int hheight,mheight; // head/menu font height - unsigned long stat_total, stat_idle; void paint(); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 56ab88e34..7548983b2 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -106,6 +106,7 @@ #include #include #include +#include #include @@ -1978,6 +1979,8 @@ TIMER_START(); hintBox->hide(); delete hintBox; + cSysLoad::getInstance(); + TIMER_STOP("################################## after all ##################################"); RealRun(personalize.getWidget(0)/**main**/); diff --git a/src/system/Makefile.am b/src/system/Makefile.am index 11bad7cd8..bee2e4350 100644 --- a/src/system/Makefile.am +++ b/src/system/Makefile.am @@ -42,5 +42,6 @@ libneutrino_system_a_SOURCES = \ helpers.cpp \ ping.c \ settings.cpp \ + sysload.cpp \ ytparser.cpp \ setting_helpers.cpp 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 From ce0d12281331f3d17c833e3408b2338d89cf347c Mon Sep 17 00:00:00 2001 From: martii Date: Sun, 29 Dec 2013 12:44:22 +0100 Subject: [PATCH 05/36] gui/upnpbrowser: leave infoclock alone --- src/gui/upnpbrowser.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index d9bd7947b..6ab2b3990 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -51,7 +51,6 @@ #include #include -#include #include #include @@ -67,7 +66,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] = @@ -454,9 +452,6 @@ void CUpnpBrowserGui::selectDevice() if (!discoverDevices()) return; - CAudioMute::getInstance()->enableMuteIcon(false); - InfoClock->enableInfoClock(false); - while (loop) { if (refresh) @@ -545,7 +540,6 @@ printf("msg: %x\n", (int) msg); } } CAudioMute::getInstance()->enableMuteIcon(true); - InfoClock->enableInfoClock(true); } void CUpnpBrowserGui::playnext(void) From b179ee51436c409e65c0cb3d9c8dd25f5b5ad1eb Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Mon, 30 Dec 2013 19:02:36 +0100 Subject: [PATCH 06/36] CUpnpBrowserGui::selectDevice(): disable MuteIcon, supplement to ce0d12281331f3d17c833e3408b2338d89cf347c --- src/gui/upnpbrowser.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index 6ab2b3990..c240b85cb 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -452,6 +452,8 @@ void CUpnpBrowserGui::selectDevice() if (!discoverDevices()) return; + CAudioMute::getInstance()->enableMuteIcon(false); + while (loop) { if (refresh) From 74e454fc809724c5980a640a0faf34877b5f1a32 Mon Sep 17 00:00:00 2001 From: martii Date: Mon, 30 Dec 2013 21:06:11 +0100 Subject: [PATCH 07/36] gui/dboxinfo: rename some poorly named variables --- src/gui/dboxinfo.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index abdc7d88d..4ab750806 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -227,13 +227,13 @@ void CDBoxInfoWidget::paint() int icon_w = 0, icon_h = 0; frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icon_w, &icon_h); - int m[2][3] = { { 0, 0, 0 }, { 0, 0, 0 } }; // size, used, available #define DBINFO_TOTAL 0 #define DBINFO_USED 1 #define DBINFO_FREE 2 + int memstat[2][3] = { { 0, 0, 0 }, { 0, 0, 0 } }; // total, used, free #define DBINFO_RAM 0 #define DBINFO_SWAP 1 - const char *n[2] = { "RAM", "Swap" }; + const char *memtype[2] = { "RAM", "Swap" }; FILE *procmeminfo = fopen("/proc/meminfo", "r"); if (procmeminfo) { char buf[80], a[80]; @@ -241,19 +241,19 @@ void CDBoxInfoWidget::paint() while (fgets(buf, sizeof(buf), procmeminfo)) if (2 == sscanf(buf, "%[^:]: %d", a, &v)) { if (!strcasecmp(a, "MemTotal")) - m[DBINFO_RAM][DBINFO_TOTAL] += v; + memstat[DBINFO_RAM][DBINFO_TOTAL] += v; else if (!strcasecmp(a, "MemFree")) - m[DBINFO_RAM][DBINFO_FREE] += v; + memstat[DBINFO_RAM][DBINFO_FREE] += v; else if (!strcasecmp(a, "Inactive")) - m[DBINFO_RAM][DBINFO_FREE] += v; + memstat[DBINFO_RAM][DBINFO_FREE] += v; else if (!strcasecmp(a, "SwapTotal")) - m[DBINFO_SWAP][DBINFO_TOTAL] = v; + memstat[DBINFO_SWAP][DBINFO_TOTAL] = v; else if (!strcasecmp(a, "SwapFree")) - m[DBINFO_SWAP][DBINFO_FREE] += v; + memstat[DBINFO_SWAP][DBINFO_FREE] += v; } fclose(procmeminfo); } - bool have_swap = m[DBINFO_SWAP][DBINFO_TOTAL]; + bool have_swap = memstat[DBINFO_SWAP][DBINFO_TOTAL]; height += mheight; // header height += mheight; // ram height += have_swap * mheight; // swap @@ -433,23 +433,23 @@ void CDBoxInfoWidget::paint() for (int k = 0; k < 1 + have_swap; k++) { std::string tmp; - m[k][DBINFO_USED] = m[k][DBINFO_TOTAL] - m[k][DBINFO_FREE]; + memstat[k][DBINFO_USED] = memstat[k][DBINFO_TOTAL] - memstat[k][DBINFO_FREE]; for (int j = 0; j < headSize_mem; j++) { switch (j) { case 0: - tmp = n[k]; + tmp = memtype[k]; break; case 1: - tmp = bytes2string(1024 * m[k][DBINFO_TOTAL]); + tmp = bytes2string(1024 * memstat[k][DBINFO_TOTAL]); break; case 2: - tmp = bytes2string(1024 * m[k][DBINFO_USED]); + tmp = bytes2string(1024 * memstat[k][DBINFO_USED]); break; case 3: - tmp = bytes2string(1024 * m[k][DBINFO_FREE]); + tmp = bytes2string(1024 * memstat[k][DBINFO_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[k][DBINFO_TOTAL] ? (memstat[k][DBINFO_USED] * 100) / memstat[k][DBINFO_TOTAL] : 0) + "%"; break; } mpOffset = offsets[j]; @@ -463,7 +463,7 @@ void CDBoxInfoWidget::paint() 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[k][0] ? (memstat[k][1] * 100) / memstat[k][0] : 0, 100); pb.paint(false); } ypos += mheight; From 6c117ff03e1c340fdf09e136ac0dd659ac9a42bc Mon Sep 17 00:00:00 2001 From: martii Date: Mon, 30 Dec 2013 18:37:23 +0100 Subject: [PATCH 08/36] gui/dboxinfo: cleanup --- src/gui/dboxinfo.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 4ab750806..231ff5375 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -59,12 +59,6 @@ #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) CDBoxInfoWidget::CDBoxInfoWidget() { @@ -78,7 +72,6 @@ CDBoxInfoWidget::CDBoxInfoWidget() y = 0; } - int CDBoxInfoWidget::exec(CMenuTarget* parent, const std::string &) { if (parent) From 673a6dc424cebce5a47549ce273ec3f032ce872f Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Mon, 30 Dec 2013 21:32:10 +0100 Subject: [PATCH 09/36] - dboxinfo: use CComponents to paint header --- src/gui/dboxinfo.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 231ff5375..f79c5cbb9 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -309,18 +309,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)); std::map cpuinfo; in.open("/proc/cpuinfo"); @@ -343,9 +333,12 @@ void CDBoxInfoWidget::paint() title += ": "; title + cpuinfo["machine"]; } - 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; From 3bb33bb9ef9acfbf6f43950ea143d81153571d12 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Mon, 30 Dec 2013 21:44:48 +0100 Subject: [PATCH 10/36] - dboxinfo: move init of mount-head to mount-section --- src/gui/dboxinfo.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index f79c5cbb9..3e3152e30 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -196,8 +196,6 @@ 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 sizeWidth = fontWidth * 11;//9999.99 MiB int percWidth = fontWidth * 4 ;//100% @@ -407,7 +405,7 @@ void CDBoxInfoWidget::paint() }; int widths[] = { 0, sizeWidth, sizeWidth, sizeWidth, percWidth }; - // paint mount head + // paint mem head for (int j = 0; j < headSize_mem; j++) { headOffset = offsets[j]; int center = 0; @@ -456,13 +454,15 @@ void CDBoxInfoWidget::paint() } ypos += mheight/2; + const int headSize_mnt = 5; + const char *head_mnt[headSize_mnt] = {"Filesystem", "Size", "Used", "Available", "Use"}; // paint mount head - for (int j = 0; j < headSize; j++) { + for (int j = 0; j < headSize_mnt; j++) { headOffset = offsets[j]; int center = 0; if (j > 0) - center = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head[j], true))/2; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + center, ypos+ mheight, width - 10, head[j], COL_MENUCONTENTINACTIVE_TEXT); + center = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_mnt[j], true))/2; + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + center, ypos+ mheight, width - 10, head_mnt[j], COL_MENUCONTENTINACTIVE_TEXT); } ypos += mheight; @@ -479,7 +479,7 @@ void CDBoxInfoWidget::paint() bytes_used = bytes_total - bytes_free; percent_used = (bytes_used * 200 + bytes_total) / 2 / bytes_total; //paint mountpoints - for (int j = 0; j < headSize; j++) { + for (int j = 0; j < headSize_mnt; j++) { std::string tmp; mpOffset = offsets[j]; int _w = width; From 0a195c7c4855761b5cc84598e84fe5663fab2e10 Mon Sep 17 00:00:00 2001 From: Christian Schuett Date: Mon, 30 Dec 2013 22:41:26 +0100 Subject: [PATCH 11/36] Neutrino sleeptimer: speed up timer deletion --- src/gui/sleeptimer.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/sleeptimer.cpp b/src/gui/sleeptimer.cpp index b34caddde..8779552cd 100644 --- a/src/gui/sleeptimer.cpp +++ b/src/gui/sleeptimer.cpp @@ -108,12 +108,15 @@ 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; From 7d041133076280eba01e136065cedd8bc9d43868 Mon Sep 17 00:00:00 2001 From: Christian Schuett Date: Mon, 30 Dec 2013 23:25:26 +0100 Subject: [PATCH 12/36] Neutrino menu forwarder: add possibility to show value from jump target based on idea by martii in Neutrino-MP Git --- src/gui/widget/menue.cpp | 10 +++++----- src/gui/widget/menue.h | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 8c0300681..f3af34176 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1789,11 +1789,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..28e5d0bb4 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 From 9f10fc9821e1492a5f5187f8c8a17727f3700ffa Mon Sep 17 00:00:00 2001 From: Christian Schuett Date: Mon, 30 Dec 2013 23:27:04 +0100 Subject: [PATCH 13/36] Neutrino: show remaining sleep time in main menu if sleeptimer exists based on idea by martii in Neutrino-MP Git --- src/gui/sleeptimer.cpp | 16 +++++++++++++++- src/gui/sleeptimer.h | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/gui/sleeptimer.cpp b/src/gui/sleeptimer.cpp index 8779552cd..eeb5dd079 100644 --- a/src/gui/sleeptimer.cpp +++ b/src/gui/sleeptimer.cpp @@ -28,6 +28,7 @@ #include +#include #include #include @@ -52,7 +53,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"); @@ -123,3 +124,16 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) 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(); }; From 7ea08502fed6840f9ef89c3e74fa096b187a84bb Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Tue, 31 Dec 2013 07:07:32 +0100 Subject: [PATCH 14/36] CNFSMountGui: Supplement to cbc9299df8cd5fb1639f9e7db9db59ce9ce3fbf6 - Fix saving automount --- src/gui/nfs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); From 47a2cf0e54b794688f1e59788d8c9ec8ec5c4a37 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Thu, 2 Jan 2014 21:10:34 +0100 Subject: [PATCH 15/36] - usermenu: add youtube player --- src/gui/user_menue.cpp | 10 ++++++++++ src/gui/user_menue_setup.cpp | 3 ++- src/system/settings.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index 123066d18..749effe2a 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -372,6 +372,16 @@ bool CUserMenu::showUserMenu(int button) menu->addItem(menu_item, false); } break; + case SNeutrinoSettings::ITEM_YOUTUBE: + { + 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; #if 0 // FIXME not supported yet case SNeutrinoSettings::ITEM_MOVIEPLAYER_TS: diff --git a/src/gui/user_menue_setup.cpp b/src/gui/user_menue_setup.cpp index 5b07acb5f..aa1c3db92 100644 --- a/src/gui/user_menue_setup.cpp +++ b/src/gui/user_menue_setup.cpp @@ -88,7 +88,8 @@ 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 } }; int CUserMenuSetup::exec(CMenuTarget* parent, const std::string &) diff --git a/src/system/settings.h b/src/system/settings.h index 2ccdd41f6..3e515a3bd 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -654,6 +654,7 @@ struct SNeutrinoSettings ITEM_CLOCK = 19, ITEM_GAMES = 20, ITEM_SCRIPTS = 21, + ITEM_YOUTUBE = 22, #if 0 ITEM_MOVIEPLAYER_TS, #endif From 419cff8c8a080314098ce6eeec1970d0e1488812 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Thu, 2 Jan 2014 22:36:42 +0100 Subject: [PATCH 16/36] - usermenu: add file player --- src/gui/user_menue.cpp | 10 ++++++++++ src/gui/user_menue_setup.cpp | 3 ++- src/system/settings.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index 749effe2a..ed8b9124f 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -382,6 +382,16 @@ bool CUserMenu::showUserMenu(int button) 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; #if 0 // FIXME not supported yet case SNeutrinoSettings::ITEM_MOVIEPLAYER_TS: diff --git a/src/gui/user_menue_setup.cpp b/src/gui/user_menue_setup.cpp index aa1c3db92..6977a0a67 100644 --- a/src/gui/user_menue_setup.cpp +++ b/src/gui/user_menue_setup.cpp @@ -89,7 +89,8 @@ const CMenuOptionChooser::keyval USERMENU_ITEM_OPTIONS[USERMENU_ITEM_OPTION_COUN { SNeutrinoSettings::ITEM_GAMES, LOCALE_MAINMENU_GAMES }, { SNeutrinoSettings::ITEM_SCRIPTS, LOCALE_MAINMENU_SCRIPTS }, { SNeutrinoSettings::ITEM_RECORD, LOCALE_TIMERLIST_TYPE_RECORD }, - { SNeutrinoSettings::ITEM_YOUTUBE, LOCALE_MOVIEPLAYER_YTPLAYBACK } + { SNeutrinoSettings::ITEM_YOUTUBE, LOCALE_MOVIEPLAYER_YTPLAYBACK }, + { SNeutrinoSettings::ITEM_FILEPLAY, LOCALE_MOVIEPLAYER_FILEPLAYBACK } }; int CUserMenuSetup::exec(CMenuTarget* parent, const std::string &) diff --git a/src/system/settings.h b/src/system/settings.h index 3e515a3bd..debc6b064 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -655,6 +655,7 @@ struct SNeutrinoSettings ITEM_GAMES = 20, ITEM_SCRIPTS = 21, ITEM_YOUTUBE = 22, + ITEM_FILEPLAY = 23, #if 0 ITEM_MOVIEPLAYER_TS, #endif From e529bd011b08941cc9d558a076ad9b3e62f16901 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Thu, 2 Jan 2014 22:57:01 +0100 Subject: [PATCH 17/36] - usermenu: cleanup from unused code --- src/gui/user_menue.cpp | 65 ++---------------------------------- src/gui/user_menue_setup.cpp | 1 - src/gui/user_menue_setup.h | 2 +- src/neutrino.cpp | 8 ++--- src/system/settings.h | 3 -- 5 files changed, 7 insertions(+), 72 deletions(-) diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index ed8b9124f..34e8fdad3 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -82,15 +82,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) { @@ -392,40 +383,13 @@ bool CUserMenu::showUserMenu(int button) menu->addItem(menu_item, 0); } 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++) - { - 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); - } - } - 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) { } @@ -434,17 +398,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) @@ -456,9 +411,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; @@ -483,19 +435,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 6977a0a67..c14e27e48 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 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/neutrino.cpp b/src/neutrino.cpp index 7548983b2..e40ccbb37 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -755,10 +755,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; diff --git a/src/system/settings.h b/src/system/settings.h index debc6b064..7250f64a8 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -656,9 +656,6 @@ struct SNeutrinoSettings ITEM_SCRIPTS = 21, ITEM_YOUTUBE = 22, ITEM_FILEPLAY = 23, -#if 0 - ITEM_MOVIEPLAYER_TS, -#endif ITEM_MAX // MUST be always the last in the list } USER_ITEM; std::string usermenu_text[BUTTON_MAX]; From 98c7d0724648488b039cf203dabe301233ebc816 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Fri, 3 Jan 2014 12:33:16 +0100 Subject: [PATCH 18/36] CMenuOptionStringChooser:: optionValueString mismatch, supplement to cbc9299df8cd5fb1639f9e7db9db59ce9ce3fbf6 --- src/gui/widget/menue.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index f3af34176..d84f69c13 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1500,7 +1500,7 @@ CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t Optio active = Active; optionValue = OptionValue; observ = Observ; - + optionValueString = NULL; directKey = DirectKey; iconName = IconName; pulldown = Pulldown; @@ -1530,7 +1530,6 @@ CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t Optio optionValue = (char *) OptionValue->c_str(); optionValueString = OptionValue; observ = Observ; - optionValueString = NULL; directKey = DirectKey; iconName = IconName; From bb7f90681f10ccc6b40f7d290e7b8b3f29d85cad Mon Sep 17 00:00:00 2001 From: martii Date: Fri, 3 Jan 2014 08:42:47 +0100 Subject: [PATCH 19/36] gui/dboxinfo: rework table alignment --- src/gui/dboxinfo.cpp | 150 ++++++++++++++++++++++++++----------------- 1 file changed, 90 insertions(+), 60 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 3e3152e30..1f5ab8027 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -218,33 +218,42 @@ void CDBoxInfoWidget::paint() int icon_w = 0, icon_h = 0; frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icon_w, &icon_h); -#define DBINFO_TOTAL 0 -#define DBINFO_USED 1 -#define DBINFO_FREE 2 - int memstat[2][3] = { { 0, 0, 0 }, { 0, 0, 0 } }; // total, used, free -#define DBINFO_RAM 0 -#define DBINFO_SWAP 1 - const char *memtype[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]; - int v; - while (fgets(buf, sizeof(buf), procmeminfo)) - if (2 == sscanf(buf, "%[^:]: %d", 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")) - memstat[DBINFO_RAM][DBINFO_TOTAL] += v; + memstat[MEMINFO_RAM][MEMINFO_TOTAL] += v; else if (!strcasecmp(a, "MemFree")) - memstat[DBINFO_RAM][DBINFO_FREE] += v; + memstat[MEMINFO_RAM][MEMINFO_FREE] += v; else if (!strcasecmp(a, "Inactive")) - memstat[DBINFO_RAM][DBINFO_FREE] += v; + memstat[MEMINFO_RAM][MEMINFO_FREE] += v; else if (!strcasecmp(a, "SwapTotal")) - memstat[DBINFO_SWAP][DBINFO_TOTAL] = v; + memstat[MEMINFO_SWAP][MEMINFO_TOTAL] = v; else if (!strcasecmp(a, "SwapFree")) - memstat[DBINFO_SWAP][DBINFO_FREE] += v; + memstat[MEMINFO_SWAP][MEMINFO_FREE] += v; } + } fclose(procmeminfo); } - bool have_swap = memstat[DBINFO_SWAP][DBINFO_TOTAL]; + bool have_swap = memstat[MEMINFO_SWAP][MEMINFO_TOTAL]; height += mheight; // header height += mheight; // ram height += have_swap * mheight; // swap @@ -394,8 +403,6 @@ void CDBoxInfoWidget::paint() 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, @@ -405,65 +412,56 @@ void CDBoxInfoWidget::paint() }; int widths[] = { 0, sizeWidth, sizeWidth, sizeWidth, percWidth }; - // paint mem head - for (int j = 0; j < headSize_mem; j++) { - headOffset = offsets[j]; - int center = 0; - if (j > 0) - center = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_mem[j], true))/2; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + center, 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; - memstat[k][DBINFO_USED] = memstat[k][DBINFO_TOTAL] - memstat[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 = memtype[k]; + tmp = memtype[row]; break; case 1: - tmp = bytes2string(1024 * memstat[k][DBINFO_TOTAL]); + tmp = bytes2string(memstat[row][MEMINFO_TOTAL]); break; case 2: - tmp = bytes2string(1024 * memstat[k][DBINFO_USED]); + tmp = bytes2string(memstat[row][MEMINFO_USED]); break; case 3: - tmp = bytes2string(1024 * memstat[k][DBINFO_FREE]); + tmp = bytes2string(memstat[row][MEMINFO_FREE]); break; case 4: - tmp = to_string(memstat[k][DBINFO_TOTAL] ? (memstat[k][DBINFO_USED] * 100) / memstat[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 center = 0; - if (j > 0) - center = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true))/2; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + center, ypos+ mheight, width - 10, tmp, COL_MENUCONTENT_TEXT); + mpOffset = offsets[column]; + 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; + } + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + space, ypos+ mheight, width - 10, tmp, COL_MENUCONTENT_TEXT); } if (pbw > 8) /* smaller progressbar is not useful ;) */ { CProgressBar pb(x+offsetw, ypos+3, pbw, mheight-10); pb.setBlink(); pb.setInvert(); - pb.setValues(memstat[k][0] ? (memstat[k][1] * 100) / memstat[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; - - const int headSize_mnt = 5; - const char *head_mnt[headSize_mnt] = {"Filesystem", "Size", "Used", "Available", "Use"}; - // paint mount head - for (int j = 0; j < headSize_mnt; j++) { - headOffset = offsets[j]; - int center = 0; - if (j > 0) - center = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_mnt[j], true))/2; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + center, ypos+ mheight, width - 10, head_mnt[j], COL_MENUCONTENTINACTIVE_TEXT); - } + + int ypos_mnt_head = ypos; ypos += mheight; for (std::map::iterator it = mounts.begin(); it != mounts.end(); ++it) { @@ -479,11 +477,11 @@ void CDBoxInfoWidget::paint() bytes_used = bytes_total - bytes_free; percent_used = (bytes_used * 200 + bytes_total) / 2 / bytes_total; //paint mountpoints - for (int j = 0; j < headSize_mnt; j++) { + for (int column = 0; column < headSize; column++) { std::string tmp; - mpOffset = offsets[j]; + mpOffset = offsets[column]; int _w = width; - switch (j) { + switch (column) { case 0: tmp = (*it).first; if (tmp == "/") @@ -491,6 +489,7 @@ void CDBoxInfoWidget::paint() _w = nameWidth - mpOffset; if ((*it).second) _w -= icon_w + 10; + _w += fontWidth; break; case 1: tmp = bytes2string(bytes_total, false); @@ -505,12 +504,15 @@ void CDBoxInfoWidget::paint() tmp = to_string(percent_used) + "%"; break; } - int center = 0; - if (j > 0) - center = (widths[j] - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true))/2; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + center, 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; + } + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + space, ypos+ mheight, _w - 10, 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 + fontWidth, ypos + (mheight/2 - icon_h/2)); } if (pbw > 8) /* smaller progressbar is not useful ;) */ { @@ -526,4 +528,32 @@ void CDBoxInfoWidget::paint() if (ypos > y + height - mheight) /* the screen is not high enough */ break; /* todo: scrolling? */ } + // 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; + if (column > 0) { + int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_mem[column], true); + 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, width - 10, 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; + if (column > 0) { + int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_mnt[column], true); + 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, width - 10, head_mnt[column], COL_MENUCONTENTINACTIVE_TEXT); + } } From b95f7298e96af445a8b5b1f25df0b537f61629b1 Mon Sep 17 00:00:00 2001 From: martii Date: Tue, 31 Dec 2013 13:58:31 +0100 Subject: [PATCH 20/36] gui/dboxinfo: fix widths --- src/gui/dboxinfo.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 1f5ab8027..fafa46423 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -447,7 +447,7 @@ void CDBoxInfoWidget::paint() maxWidth[column] = std::max(maxWidth[column], rw); space = widths[column] - rw; } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + space, ypos+ mheight, width - 10, tmp, COL_MENUCONTENT_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + space, ypos+ mheight, width, tmp, COL_MENUCONTENT_TEXT); } if (pbw > 8) /* smaller progressbar is not useful ;) */ { @@ -510,7 +510,7 @@ void CDBoxInfoWidget::paint() maxWidth[column] = std::max(maxWidth[column], rw); space = widths[column] - rw; } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + space, ypos+ mheight, _w - 10, tmp, COL_MENUCONTENT_TEXT); + 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 + fontWidth, ypos + (mheight/2 - icon_h/2)); } @@ -540,7 +540,7 @@ void CDBoxInfoWidget::paint() else space = widths[column] - maxWidth[column] + (maxWidth[column] - rw)/2; } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + space, ypos_mem_head + mheight, width - 10, head_mem[column], COL_MENUCONTENTINACTIVE_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + space, ypos_mem_head + mheight, width, head_mem[column], COL_MENUCONTENTINACTIVE_TEXT); } // paint mount head const char *head_mnt[headSize] = {"Filesystem", "Size", "Used", "Available", "Use"}; @@ -554,6 +554,6 @@ void CDBoxInfoWidget::paint() else space = widths[column] - maxWidth[column] + (maxWidth[column] - rw)/2; } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + space, ypos_mnt_head + mheight, width - 10, head_mnt[column], COL_MENUCONTENTINACTIVE_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + space, ypos_mnt_head + mheight, width, head_mnt[column], COL_MENUCONTENTINACTIVE_TEXT); } } From 9285f9cdbd80d6e157ab905ac8d83301b43aa3db Mon Sep 17 00:00:00 2001 From: martii Date: Fri, 3 Jan 2014 08:50:34 +0100 Subject: [PATCH 21/36] gui/dboxinfo: slightly re-arrange window --- src/gui/dboxinfo.cpp | 46 +++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index fafa46423..65b9252c2 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -210,10 +210,9 @@ void CDBoxInfoWidget::paint() height += mheight/2; // space int frontend_count = CFEManager::getInstance()->getFrontendCount(); - if (frontend_count) { - height += mheight * frontend_count; - height += mheight/2; - } + if (frontend_count > 2) + height += mheight * (frontend_count - 2); + height += mheight/2; int icon_w = 0, icon_h = 0; frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icon_w, &icon_h); @@ -355,22 +354,28 @@ void CDBoxInfoWidget::paint() 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; + char ubuf_boot[80]; 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); + strftime(ubuf_boot, sizeof(ubuf_boot), "Boot: %FT%H:%M:%S%z", localtime(&now)); + + int time_width = std::max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(ubuf), g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(ubuf_boot)); + + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + offsetw - time_width - 10, ypos+ mheight, time_width, ubuf, COL_MENUCONTENT_TEXT); + ypos += mheight; + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + offsetw - time_width - 10, ypos+ mheight, time_width, ubuf_boot, COL_MENUCONTENT_TEXT); ypos += mheight; if (data_last > -1) { snprintf(ubuf, sizeof(ubuf), "Load: %d%s%d%%", data_last/10, g_Locale->getText(LOCALE_UNIT_DECIMAL), data_last%10); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, ubuf, COL_MENUCONTENT_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + offsetw - time_width - 10, ypos+ mheight, time_width, ubuf, COL_MENUCONTENT_TEXT); } ypos += mheight; + int ypos_mem = ypos; + int pbw = width - offsetw - 10; if (pbw > 8) /* smaller progressbar is not useful ;) */ { @@ -386,21 +391,22 @@ void CDBoxInfoWidget::paint() } } - ypos += mheight/2; + ypos = y + hheight + 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; - } + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 10, ypos + mheight, width - 10, "Frontends", COL_MENUCONTENTINACTIVE_TEXT); + ypos += mheight; + for (int i = 0; i < frontend_count; i++) { + CFrontend *fe = CFEManager::getInstance()->getFE(i); + if (fe) { + std::string 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; } + ypos = std::max(ypos, ypos_mem); + ypos += mheight/2; + int headOffset=0; int mpOffset=0; int offsets[] = { From 06a95008fd15a501a6118c70923b27ddc259e399 Mon Sep 17 00:00:00 2001 From: martii Date: Thu, 2 Jan 2014 14:30:49 +0100 Subject: [PATCH 22/36] gui/dboxinfo: unbreak height calculation --- src/gui/dboxinfo.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 65b9252c2..8d38fdff5 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -212,7 +212,6 @@ void CDBoxInfoWidget::paint() int frontend_count = CFEManager::getInstance()->getFrontendCount(); if (frontend_count > 2) height += mheight * (frontend_count - 2); - height += mheight/2; int icon_w = 0, icon_h = 0; frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icon_w, &icon_h); From 5e9af14eb5aa7aa0e8b87b034aa7762bb10eaa0e Mon Sep 17 00:00:00 2001 From: martii Date: Thu, 2 Jan 2014 19:59:49 +0100 Subject: [PATCH 23/36] gui/dboxinfo: adjust spacing --- src/gui/dboxinfo.cpp | 16 ++++++++++------ src/gui/dboxinfo.h | 4 ++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 8d38fdff5..3eae5bdd2 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -70,6 +70,13 @@ CDBoxInfoWidget::CDBoxInfoWidget() height = 0; x = 0; y = 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 * 17; } int CDBoxInfoWidget::exec(CMenuTarget* parent, const std::string &) @@ -196,10 +203,6 @@ static std::string bytes2string(uint64_t bytes, bool binary) void CDBoxInfoWidget::paint() { - int fontWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth(); - int sizeWidth = fontWidth * 11;//9999.99 MiB - int percWidth = fontWidth * 4 ;//100% - int nameWidth = fontWidth * 17;//WWWwwwwwww height = hheight; height += mheight/2; // space int cpuload_y0 = height; @@ -481,6 +484,7 @@ 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 column = 0; column < headSize; column++) { std::string tmp; @@ -494,7 +498,7 @@ void CDBoxInfoWidget::paint() _w = nameWidth - mpOffset; if ((*it).second) _w -= icon_w + 10; - _w += fontWidth; + _w += width_i/2; break; case 1: tmp = bytes2string(bytes_total, false); @@ -517,7 +521,7 @@ void CDBoxInfoWidget::paint() } 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 + fontWidth, ypos + (mheight/2 - icon_h/2)); + frameBuffer->paintIcon(NEUTRINO_ICON_REC, x + nameWidth - icon_w + width_i/2, ypos + (mheight/2 - icon_h/2)); } if (pbw > 8) /* smaller progressbar is not useful ;) */ { diff --git a/src/gui/dboxinfo.h b/src/gui/dboxinfo.h index 5587ba7d0..68b839b54 100644 --- a/src/gui/dboxinfo.h +++ b/src/gui/dboxinfo.h @@ -47,6 +47,10 @@ class CDBoxInfoWidget : public CMenuTarget int width; int height; int hheight,mheight; // head/menu font height + int fontWidth; + int sizeWidth; + int percWidth; + int nameWidth; void paint(); From f2f2e208d66ff798d40564fc9dd593b24ad31bf6 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Sat, 4 Jan 2014 08:50:15 +0100 Subject: [PATCH 24/36] - dboxinfo: don't show frontends --- src/gui/dboxinfo.cpp | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 3eae5bdd2..2d1a623d3 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -50,8 +50,6 @@ #include #include -#include - #include #include #include @@ -212,10 +210,6 @@ void CDBoxInfoWidget::paint() int cpuload_y1 = height; height += mheight/2; // space - int frontend_count = CFEManager::getInstance()->getFrontendCount(); - if (frontend_count > 2) - height += mheight * (frontend_count - 2); - int icon_w = 0, icon_h = 0; frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icon_w, &icon_h); @@ -361,23 +355,19 @@ void CDBoxInfoWidget::paint() struct sysinfo info; sysinfo(&info); now -= info.uptime; - strftime(ubuf_boot, sizeof(ubuf_boot), "Boot: %FT%H:%M:%S%z", localtime(&now)); + strftime(ubuf_boot, sizeof(ubuf_boot), "Boot: %F %H:%M:%S%z", localtime(&now)); - int time_width = std::max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(ubuf), g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(ubuf_boot)); - - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + offsetw - time_width - 10, ypos+ mheight, time_width, ubuf, COL_MENUCONTENT_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 10, ypos+ mheight, offsetw -10, ubuf, COL_MENUCONTENT_TEXT); ypos += mheight; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + offsetw - time_width - 10, ypos+ mheight, time_width, ubuf_boot, COL_MENUCONTENT_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 10, ypos+ mheight, offsetw -10, ubuf_boot, COL_MENUCONTENT_TEXT); ypos += mheight; if (data_last > -1) { snprintf(ubuf, sizeof(ubuf), "Load: %d%s%d%%", data_last/10, g_Locale->getText(LOCALE_UNIT_DECIMAL), data_last%10); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + offsetw - time_width - 10, ypos+ mheight, time_width, ubuf, COL_MENUCONTENT_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 10, ypos+ mheight, offsetw -10, ubuf, COL_MENUCONTENT_TEXT); } ypos += mheight; - int ypos_mem = ypos; - int pbw = width - offsetw - 10; if (pbw > 8) /* smaller progressbar is not useful ;) */ { @@ -393,20 +383,6 @@ void CDBoxInfoWidget::paint() } } - ypos = y + hheight + mheight/2; - - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 10, ypos + mheight, width - 10, "Frontends", COL_MENUCONTENTINACTIVE_TEXT); - ypos += mheight; - for (int i = 0; i < frontend_count; i++) { - CFrontend *fe = CFEManager::getInstance()->getFE(i); - if (fe) { - std::string 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 = std::max(ypos, ypos_mem); ypos += mheight/2; int headOffset=0; From 19bcfa5329e6fbaaa239302152daab0a595f732c Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Sat, 4 Jan 2014 08:57:43 +0100 Subject: [PATCH 25/36] - dboxinfo: show uptime more human readable; show load average --- src/gui/dboxinfo.cpp | 100 +++++++++++++++++++++++++++++++++---------- 1 file changed, 78 insertions(+), 22 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 2d1a623d3..d8259329b 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -58,6 +58,11 @@ #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) + CDBoxInfoWidget::CDBoxInfoWidget() { frameBuffer = CFrameBuffer::getInstance(); @@ -74,7 +79,7 @@ CDBoxInfoWidget::CDBoxInfoWidget() + 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 * 17; + nameWidth = fontWidth * 10; } int CDBoxInfoWidget::exec(CMenuTarget* parent, const std::string &) @@ -201,12 +206,14 @@ static std::string bytes2string(uint64_t bytes, bool binary) void CDBoxInfoWidget::paint() { + const int head_info_lines = 3; + const char *head_info[head_info_lines] = {"Uptime", "Load average", "Current load"}; + height = hheight; height += mheight/2; // space int cpuload_y0 = height; - height += mheight; // time - height += mheight; // uptime - height += mheight; // load + int head_info_ypos = height; + height += mheight*head_info_lines; // head info lines int cpuload_y1 = height; height += mheight/2; // space @@ -285,7 +292,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(); @@ -344,27 +352,67 @@ void CDBoxInfoWidget::paint() ypos += hheight + mheight/2; + 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)); + } + + int dw = offsetw - 3*10 - head_info_rw; + int buf_size=256; + char ubuf[buf_size]; + char sbuf[buf_size]; + memset(sbuf, 0, 256); + + int updays, uphours, upminutes; + struct sysinfo info; + struct tm *current_time; + time_t current_secs; + time(¤t_secs); + current_time = localtime(¤t_secs); + + sysinfo(&info); + + //get uptime + 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); + updays = (int) info.uptime / (60*60*24); + if (updays) { + snprintf(ubuf,buf_size, "%d day%s, ", updays, (updays != 1) ? "s" : ""); + strcat(sbuf, ubuf); + } + upminutes = (int) info.uptime / 60; + uphours = (upminutes / 60) % 24; + upminutes %= 60; + if (uphours) + snprintf(ubuf,buf_size,"%2d:%02d", uphours, upminutes); + else + snprintf(ubuf,buf_size,"%d min", upminutes); + 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; + + //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; - char ubuf[80]; - time_t now = time(NULL); - strftime(ubuf, sizeof(ubuf), "Time: %F %H:%M:%S%z", localtime(&now)); - - char ubuf_boot[80]; - struct sysinfo info; - sysinfo(&info); - now -= info.uptime; - strftime(ubuf_boot, sizeof(ubuf_boot), "Boot: %F %H:%M:%S%z", localtime(&now)); - - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 10, ypos+ mheight, offsetw -10, ubuf, COL_MENUCONTENT_TEXT); - ypos += mheight; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 10, ypos+ mheight, offsetw -10, ubuf_boot, COL_MENUCONTENT_TEXT); - ypos += mheight; - + //paint current load if (data_last > -1) { - snprintf(ubuf, sizeof(ubuf), "Load: %d%s%d%%", data_last/10, g_Locale->getText(LOCALE_UNIT_DECIMAL), data_last%10); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 10, ypos+ mheight, offsetw -10, ubuf, COL_MENUCONTENT_TEXT); + 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; @@ -464,6 +512,7 @@ void CDBoxInfoWidget::paint() //paint mountpoints for (int column = 0; column < headSize; column++) { std::string tmp; + const char *mnt; mpOffset = offsets[column]; int _w = width; switch (column) { @@ -471,6 +520,8 @@ void CDBoxInfoWidget::paint() tmp = (*it).first; if (tmp == "/") tmp = "rootfs"; + mnt = tmp.c_str(); + tmp = basename((char *)mnt); _w = nameWidth - mpOffset; if ((*it).second) _w -= icon_w + 10; @@ -513,6 +564,11 @@ 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++) { From fb5aa513d661c79a836a1dc2a6e15439c5efa8b7 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Sat, 4 Jan 2014 12:01:46 +0100 Subject: [PATCH 26/36] - dboxinfo: prevent rendering outside window --- src/gui/dboxinfo.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index d8259329b..f630b9084 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -474,12 +474,14 @@ void CDBoxInfoWidget::paint() } mpOffset = offsets[column]; int space = 0; + int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true); 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; } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + space, ypos+ mheight, width, tmp, COL_MENUCONTENT_TEXT); + 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); } if (pbw > 8) /* smaller progressbar is not useful ;) */ { @@ -514,7 +516,7 @@ void CDBoxInfoWidget::paint() std::string tmp; const char *mnt; mpOffset = offsets[column]; - int _w = width; + int _w = maxWidth[column]; switch (column) { case 0: tmp = (*it).first; @@ -546,6 +548,8 @@ void CDBoxInfoWidget::paint() 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 + width_i/2, ypos + (mheight/2 - icon_h/2)); @@ -574,27 +578,29 @@ void CDBoxInfoWidget::paint() 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) { - int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_mem[column], true); 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, width, head_mem[column], COL_MENUCONTENTINACTIVE_TEXT); + 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) { - int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_mnt[column], true); 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, width, head_mnt[column], COL_MENUCONTENTINACTIVE_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + space, ypos_mnt_head + mheight, _w, head_mnt[column], COL_MENUCONTENTINACTIVE_TEXT); } } From 535f5dfc67e7b8c387d54a7776e5f480041636c1 Mon Sep 17 00:00:00 2001 From: martii Date: Sat, 4 Jan 2014 12:13:05 +0100 Subject: [PATCH 27/36] gui/dboxinfo: show remote volumes, too --- src/gui/dboxinfo.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index f630b9084..4f0c01630 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -276,10 +276,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) From 621a712e8132b0f2c249333af1b198fb9239edee Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Sat, 4 Jan 2014 12:18:29 +0100 Subject: [PATCH 28/36] - dboxinfo: show uptime even more human readable --- src/gui/dboxinfo.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 4f0c01630..fdb1a7a87 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -362,32 +362,38 @@ void CDBoxInfoWidget::paint() char sbuf[buf_size]; memset(sbuf, 0, 256); - int updays, uphours, upminutes; struct sysinfo info; + sysinfo(&info); + + //get uptime +#if 0 struct tm *current_time; time_t current_secs; time(¤t_secs); current_time = localtime(¤t_secs); - sysinfo(&info); - - //get uptime 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); } - upminutes = (int) info.uptime / 60; - uphours = (upminutes / 60) % 24; - upminutes %= 60; - if (uphours) - snprintf(ubuf,buf_size,"%2d:%02d", uphours, upminutes); - else - snprintf(ubuf,buf_size,"%d min", upminutes); + 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 From 8832b803bdde56377446f71c032e611e46805ee5 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Sat, 4 Jan 2014 01:18:15 +0100 Subject: [PATCH 29/36] CMenuOptionChooser: Add alphanumeric sort option - default is false - Activate by OptionsSort = true --- src/gui/widget/menue.cpp | 50 +++++++++++++++++++++++++++++++++------- src/gui/widget/menue.h | 34 +++++++++++++++++++++++---- 2 files changed, 71 insertions(+), 13 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index d84f69c13..94545daec 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1269,7 +1269,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); @@ -1280,7 +1280,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; @@ -1291,7 +1292,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; @@ -1302,7 +1303,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; @@ -1315,7 +1317,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); @@ -1326,14 +1328,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; @@ -1344,7 +1347,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]); } @@ -1352,6 +1356,7 @@ CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const Optio CMenuOptionChooser::~CMenuOptionChooser() { options.clear(); + clearChooserOptions(); } void CMenuOptionChooser::setOptionValue(const int newvalue) @@ -1364,12 +1369,41 @@ 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) { + 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()); + + i1 = 0; + for (std::vector::iterator it = option_chooser_options_v.begin(); it != option_chooser_options_v.end() && i1 < number_of_options; ++it) { + options[i1].key = (*it)->key; + options[i1].value = NONEXISTANT_LOCALE; + options[i1].valname = (*it)->valname.c_str(); + i1++; + } + } + if((msg == CRCInput::RC_ok) && pulldown) { int select = -1; char cnt[5]; diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 28e5d0bb4..d2a39fb86 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -313,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: @@ -331,28 +351,32 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser private: std::vector options; + std::vector option_chooser_options_v; unsigned number_of_options; CChangeObserver * observ; std::string optionNameString; - bool pulldown; + 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); From 3318812fbc8da73115f0b8236ecdec5d22301bf3 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Sat, 4 Jan 2014 01:20:30 +0100 Subject: [PATCH 30/36] CUserMenuSetup: Activate alphanumeric sort option --- src/gui/user_menue_setup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/user_menue_setup.cpp b/src/gui/user_menue_setup.cpp index c14e27e48..1872aa542 100644 --- a/src/gui/user_menue_setup.cpp +++ b/src/gui/user_menue_setup.cpp @@ -132,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, ""); From f953cd07b32effb38b405674c049616c04f457d3 Mon Sep 17 00:00:00 2001 From: martii Date: Sat, 4 Jan 2014 13:20:57 +0100 Subject: [PATCH 31/36] gui/filebrowser: don't segv when removing files with small names --- src/gui/filebrowser.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index ac519dc5e..2967377c4 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -934,11 +934,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); } From 9af1cdb3187d140c6f710135f1a3fb0b7f9b789b Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Sat, 4 Jan 2014 15:20:56 +0100 Subject: [PATCH 32/36] CMenuOptionChooser: Fix multiple menu items, when using sort option --- src/gui/widget/menue.cpp | 14 ++++++++------ src/gui/widget/menue.h | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 94545daec..d622db8c3 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1383,6 +1383,7 @@ int CMenuOptionChooser::exec(CMenuTarget*) int ret = menu_return::RETURN_NONE; if (optionsSort) { + optionsSort = false; clearChooserOptions(); unsigned int i1; for (i1 = 0; i1 < number_of_options; i1++) @@ -1395,12 +1396,13 @@ int CMenuOptionChooser::exec(CMenuTarget*) sort(option_chooser_options_v.begin(), option_chooser_options_v.end(), CMenuOptionChooserCompareItem()); - i1 = 0; - for (std::vector::iterator it = option_chooser_options_v.begin(); it != option_chooser_options_v.end() && i1 < number_of_options; ++it) { - options[i1].key = (*it)->key; - options[i1].value = NONEXISTANT_LOCALE; - options[i1].valname = (*it)->valname.c_str(); - i1++; + 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); } } diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index d2a39fb86..d5b067093 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -352,9 +352,9 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser private: std::vector options; std::vector option_chooser_options_v; - unsigned number_of_options; - CChangeObserver * observ; - std::string optionNameString; + unsigned number_of_options; + CChangeObserver * observ; + std::string optionNameString; bool pulldown; bool optionsSort; From eda90ac834fa2dd00b485e5e6e7e8c0ab094c0fe Mon Sep 17 00:00:00 2001 From: martii Date: Sat, 23 Nov 2013 21:42:00 +0100 Subject: [PATCH 33/36] gui/moviebrowser, system/ytparser: Google dropped most YouTube feeds. Limit code to what's left. --- data/locale/deutsch.locale | 10 ++-------- data/locale/english.locale | 10 ++-------- src/gui/moviebrowser.cpp | 13 +++---------- src/system/locals.h | 8 +------- src/system/locals_intern.h | 8 +------- src/system/ytparser.cpp | 29 +++++------------------------ src/system/ytparser.h | 9 +-------- 7 files changed, 15 insertions(+), 72 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 6d8b3d256..14501d999 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 7fdfef066..b4a44d5f8 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/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 95ea6c168..1905b8904 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -3623,15 +3623,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)) @@ -3641,7 +3634,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/system/locals.h b/src/system/locals.h index 700f83a79..1f9308dc3 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 5fad67d8f..d662757fa 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/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, From 3bdb1af87e1180c4c21a873fc3e57d24c39c930b Mon Sep 17 00:00:00 2001 From: martii Date: Fri, 3 Jan 2014 20:17:33 +0100 Subject: [PATCH 34/36] gui/moviebrowser: fix yt sort-by-date --- src/gui/moviebrowser.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 1905b8904..3690e6d52 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -3574,6 +3574,17 @@ void CMovieBrowser::autoFindSerie(void) } } } +static time_t toEpoch(std::string &date) +{ + struct tm t; + memset(&t, 0, sizeof(t)); + if (3 == sscanf(date.c_str(), "%d-%d-%d", &t.tm_year, &t.tm_mon, &t.tm_mday)) { + t.tm_year -= 1900; + t.tm_mon += 1; + return mktime(&t); + } + return 0; +} void CMovieBrowser::loadYTitles(int mode, std::string search, std::string id) { @@ -3611,6 +3622,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; From 52741fb1e42a0ffdfd312bfd8b7b9dd18ee2952f Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Sat, 4 Jan 2014 20:48:13 +0100 Subject: [PATCH 35/36] move toEpoch to helpers.cpp, use strptime --- src/gui/moviebrowser.cpp | 11 ----------- src/system/helpers.cpp | 12 ++++++++++++ src/system/helpers.h | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 3690e6d52..891daca53 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -3574,17 +3574,6 @@ void CMovieBrowser::autoFindSerie(void) } } } -static time_t toEpoch(std::string &date) -{ - struct tm t; - memset(&t, 0, sizeof(t)); - if (3 == sscanf(date.c_str(), "%d-%d-%d", &t.tm_year, &t.tm_mon, &t.tm_mday)) { - t.tm_year -= 1900; - t.tm_mon += 1; - return mktime(&t); - } - return 0; -} void CMovieBrowser::loadYTitles(int mode, std::string search, std::string id) { diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 2aa1be84b..5dea11f92 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -344,6 +344,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 { From c79c3e7cd74a45179a4f9bccfc9b963a5d6f5131 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Sun, 5 Jan 2014 10:24:59 +0100 Subject: [PATCH 36/36] Update satellites.xml (THX Houdini) --- data/satellites.xml | 1 + 1 file changed, 1 insertion(+) 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 @@ +