diff options
28 files changed, 1574 insertions, 16 deletions
@@ -1,6 +1,19 @@ VDR Plugin 'skinflatplus' Revision History --------------------------------------- +2014-MM-DD: Version 0.4.4 +- [add] main menu widgets + - there are several widgets that can be displayed in the main menu + - Widget dvb devices + - Widget active timer + - Widget timer conflicts + - Widget last recordings + - Widget system information + - Widget system updates + - Widget temperatures + - Widget custom command + - Please see the example scripts and README-files + 2014-10-29: Version 0.4.3 - [add] option to draw the menu background over the entire height - [add] sort icon in recordings menu @@ -145,7 +145,11 @@ install-configs: mkdir -p $(DESTDIR)$(VDRCONFDIR)/plugins/$(PLUGIN)/configs cp configs/* $(DESTDIR)$(VDRCONFDIR)/plugins/$(PLUGIN)/configs -install: install-lib install-i18n install-themes install-icons install-decors install-configs +install-widgets: + mkdir -p $(DESTDIR)$(VDRCONFDIR)/plugins/$(PLUGIN)/widgets + cp -r widgets/* $(DESTDIR)$(VDRCONFDIR)/plugins/$(PLUGIN)/widgets + +install: install-lib install-i18n install-themes install-icons install-decors install-configs install-widgets dist: $(I18Npo) clean @-rm -rf $(TMPDIR)/$(ARCHIVE) diff --git a/complexcontent.c b/complexcontent.c index d1301c77..d77a1139 100644 --- a/complexcontent.c +++ b/complexcontent.c @@ -81,7 +81,8 @@ void cComplexContent::CalculateDrawPortHeight(void) { if( (*it).GetBottom() > DrawPortHeight ) DrawPortHeight = (*it).GetBottom(); } - DrawPortHeight = ScrollTotal() * ScrollSize; + if( isScrollingActive ) + DrawPortHeight = ScrollTotal() * ScrollSize; } int cComplexContent::BottomContent(void) { @@ -97,6 +98,7 @@ int cComplexContent::BottomContent(void) { int cComplexContent::ContentHeight( bool Full ) { if( Full ) return Height(); + CalculateDrawPortHeight(); if( DrawPortHeight > Height() ) return Height(); @@ -52,8 +52,6 @@ cFlatConfig::cFlatConfig(void) { MessageColorPosition = 1; - MainMenuItemScale = 1.0; - MenuChannelView = 1; MenuTimerView = 1; MenuEventView = 1; @@ -76,6 +74,39 @@ cFlatConfig::cFlatConfig(void) { ScrollerDelay = 40; ScrollerType = 0; + // Widgets + MainMenuWidgetsEnable = 1; + MainMenuItemScale = 0.5; + + MainMenuWidgetDVBDevicesShow = true; + MainMenuWidgetDVBDevicesPosition = 1; + + MainMenuWidgetActiveTimerShow = true; + MainMenuWidgetActiveTimerPosition = 2; + MainMenuWidgetActiveTimerMaxCount = 2; + MainMenuWidgetActiveTimerHideEmpty = false; + + MainMenuWidgetLastRecShow = false; + MainMenuWidgetLastRecPosition = 3; + MainMenuWidgetLastRecMaxCount = 3; + + MainMenuWidgetTimerConflictsShow = false; + MainMenuWidgetTimerConflictsPosition = 4; + MainMenuWidgetTimerConflictsHideEmpty = false; + + MainMenuWidgetSystemInfoShow = true; + MainMenuWidgetSystemInfoPosition = 5; + + MainMenuWidgetSystemUpdatesShow = true; + MainMenuWidgetSystemUpdatesPosition = 6; + MainMenuWidgetSystemUpdatesHideIfZero = 0; + + MainMenuWidgetTemperaturesShow = true; + MainMenuWidgetTemperaturesPosition = 7; + + MainMenuWidgetCommandShow = true; + MainMenuWidgetCommandPosition = 8; + TopBarFontClockScale = 0.01; TopBarHideClockText = 0; @@ -274,6 +305,28 @@ bool cFlatConfig::SetupParse(const char *Name, const char *Value) { else if (strcmp(Name, "MenuTimerShowCount") == 0) MenuTimerShowCount = atoi(Value); else if (strcmp(Name, "MenuChannelShowCount") == 0) MenuChannelShowCount = atoi(Value); else if (strcmp(Name, "ShortRecordingCount") == 0) ShortRecordingCount = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetsEnable") == 0) MainMenuWidgetsEnable = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetDVBDevicesShow") == 0) MainMenuWidgetDVBDevicesShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetDVBDevicesPosition") == 0) MainMenuWidgetDVBDevicesPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetActiveTimerShow") == 0) MainMenuWidgetActiveTimerShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetActiveTimerPosition") == 0) MainMenuWidgetActiveTimerPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetActiveTimerMaxCount") == 0) MainMenuWidgetActiveTimerMaxCount = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetActiveTimerHideEmpty") == 0) MainMenuWidgetActiveTimerHideEmpty = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetLastRecShow") == 0) MainMenuWidgetLastRecShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetLastRecPosition") == 0) MainMenuWidgetLastRecPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetLastRecMaxCount") == 0) MainMenuWidgetLastRecMaxCount = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetTimerConflictsShow") == 0) MainMenuWidgetTimerConflictsShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetTimerConflictsPosition") == 0) MainMenuWidgetTimerConflictsPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetTimerConflictsHideEmpty") == 0)MainMenuWidgetTimerConflictsHideEmpty = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetSystemInfoShow") == 0) MainMenuWidgetSystemInfoShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetSystemInfoPosition") == 0) MainMenuWidgetSystemInfoPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetSystemUpdatesShow") == 0) MainMenuWidgetSystemUpdatesShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetSystemUpdatesPosition") == 0) MainMenuWidgetSystemUpdatesPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetSystemUpdatesHideIfZero") == 0)MainMenuWidgetSystemUpdatesHideIfZero = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetTemperaturesShow") == 0) MainMenuWidgetTemperaturesShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetTemperaturesPosition") == 0) MainMenuWidgetTemperaturesPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetCommandShow") == 0) MainMenuWidgetCommandShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetCommandPosition") == 0) MainMenuWidgetCommandPosition = atoi(Value); else return false; @@ -546,6 +599,14 @@ bool stringCompare( const std::string &left, const std::string &right ) { return false; } +bool pairCompareTimeStringDesc(const std::pair<time_t, std::string>&i, const std::pair<time_t, std::string>&j) { + return i.first < j.first; +} + +bool pairCompareIntString(const std::pair<int, std::string>&i, const std::pair<int, std::string>&j) { + return i.first > j.first; +} + void cFlatConfig::DecorDescriptions(cStringList &Decors) { cString decorPath = cString::sprintf("%s/decors", PLUGINRESOURCEPATH); std::vector<std::string> files; @@ -9,6 +9,10 @@ #define PLUGINCONFIGPATH (cPlugin::ConfigDirectory(PLUGIN_NAME_I18N)) #define PLUGINRESOURCEPATH (cPlugin::ResourceDirectory(PLUGIN_NAME_I18N)) +bool stringCompare( const std::string &left, const std::string &right ); +bool pairCompareTimeStringDesc(const std::pair<time_t, std::string>&i, const std::pair<time_t, std::string>&j); +bool pairCompareIntString(const std::pair<int, std::string>&i, const std::pair<int, std::string>&j); + class cFlatConfig { private: @@ -215,8 +219,6 @@ class cFlatConfig int TopBarMenuIconShow; int TopBarHideClockText; - double MainMenuItemScale; - int MenuChannelView; int MenuTimerView; int MenuEventView; @@ -244,6 +246,39 @@ class cFlatConfig int ScrollerDelay; int ScrollerType; + // mainmenu widgets + int MainMenuWidgetsEnable; + double MainMenuItemScale; + + int MainMenuWidgetDVBDevicesShow; + int MainMenuWidgetDVBDevicesPosition; + + int MainMenuWidgetActiveTimerShow; + int MainMenuWidgetActiveTimerPosition; + int MainMenuWidgetActiveTimerMaxCount; + int MainMenuWidgetActiveTimerHideEmpty; + + int MainMenuWidgetLastRecShow; + int MainMenuWidgetLastRecPosition; + int MainMenuWidgetLastRecMaxCount; + + int MainMenuWidgetTimerConflictsShow; + int MainMenuWidgetTimerConflictsPosition; + int MainMenuWidgetTimerConflictsHideEmpty; + + int MainMenuWidgetSystemInfoShow; + int MainMenuWidgetSystemInfoPosition; + + int MainMenuWidgetSystemUpdatesShow; + int MainMenuWidgetSystemUpdatesPosition; + int MainMenuWidgetSystemUpdatesHideIfZero; + + int MainMenuWidgetTemperaturesShow; + int MainMenuWidgetTemperaturesPosition; + + int MainMenuWidgetCommandShow; + int MainMenuWidgetCommandPosition; + // TVScraper int TVScraperChanInfoShowPoster; double TVScraperChanInfoPosterSize; diff --git a/displaymenu.c b/displaymenu.c index 591839fa..83b7174a 100644 --- a/displaymenu.c +++ b/displaymenu.c @@ -1,6 +1,9 @@ #include "displaymenu.h" #include "services/scraper2vdr.h" #include "services/epgsearch.h" +#include <utility> +#include <fstream> +#include <iostream> #ifndef VDRLOGO #define VDRLOGO "vdrlogo_default" @@ -125,6 +128,8 @@ void cFlatDisplayMenu::SetMenuCategory(eMenuCategory MenuCategory) { itemRecordingHeight = fontHeight + Config.MenuItemPadding + Config.decorBorderMenuItemSize*2; else if( Config.MenuRecordingView == 2 || Config.MenuRecordingView == 3 ) itemRecordingHeight = fontHeight + fontSmlHeight + marginItem + Config.MenuItemPadding + Config.decorBorderMenuItemSize*2; + } else if( menuCategory == mcMain ) { + DrawMainMenuWidgets(); } } @@ -215,6 +220,9 @@ void cFlatDisplayMenu::Clear(void) { MenuFullOsdIsDrawn = false; ComplexContent.Clear(); + + contentWidget.Clear(); + ShowRecording = ShowEvent = ShowText = false; } @@ -340,7 +348,7 @@ void cFlatDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool S int y = Index * itemHeight; menuItemWidth = menuWidth - Config.decorBorderMenuItemSize*2; - if( menuCategory == mcMain ) + if( menuCategory == mcMain && Config.MainMenuWidgetsEnable ) menuItemWidth *= Config.MainMenuItemScale; int AvailableTextWidth = menuItemWidth - scrollBarWidth; @@ -3868,6 +3876,772 @@ const char* cFlatDisplayMenu::GetGenreIcon(uchar genre) { return ""; } +void cFlatDisplayMenu::DrawMainMenuWidgets(void) { + int wLeft = osdWidth * Config.MainMenuItemScale + marginItem + Config.decorBorderMenuContentSize; + int wTop = topBarHeight + marginItem + Config.decorBorderTopBarSize*2 + Config.decorBorderMenuContentSize; + int wWidth = osdWidth - wLeft - Config.decorBorderMenuContentSize; + int wHeight = menuPixmap->ViewPort().Height() - marginItem*2; + int ContentTop = 0; + + contentWidget.Clear(); + contentWidget.SetOsd(osd); + contentWidget.SetPosition(cRect(wLeft, wTop, wWidth, wHeight)); + contentWidget.SetBGColor(Theme.Color(clrMenuRecBg)); + contentWidget.SetScrollingActive(false); + + std::vector<std::pair<int, std::string> > widgets; + + if( Config.MainMenuWidgetDVBDevicesShow ) + widgets.push_back(std::make_pair(Config.MainMenuWidgetDVBDevicesPosition, "dvb_devices")); + if( Config.MainMenuWidgetActiveTimerShow ) + widgets.push_back(std::make_pair(Config.MainMenuWidgetActiveTimerPosition, "active_timer")); + if( Config.MainMenuWidgetLastRecShow ) + widgets.push_back(std::make_pair(Config.MainMenuWidgetDVBDevicesPosition, "last_recordings")); + if( Config.MainMenuWidgetSystemInfoShow ) + widgets.push_back(std::make_pair(Config.MainMenuWidgetSystemInfoPosition, "system_information")); + if( Config.MainMenuWidgetSystemUpdatesShow ) + widgets.push_back(std::make_pair(Config.MainMenuWidgetSystemUpdatesPosition, "system_updates")); + if( Config.MainMenuWidgetTemperaturesShow ) + widgets.push_back(std::make_pair(Config.MainMenuWidgetTemperaturesPosition, "temperatures")); + if( Config.MainMenuWidgetTimerConflictsShow ) + widgets.push_back(std::make_pair(Config.MainMenuWidgetTimerConflictsPosition, "timer_conflicts")); + if( Config.MainMenuWidgetCommandShow ) + widgets.push_back(std::make_pair(Config.MainMenuWidgetCommandPosition, "custom_command")); + + std::sort(widgets.begin(), widgets.end(), pairCompareIntString); + + while( !widgets.empty() ) { + std::pair<int, std::string> pairWidget = widgets.back(); + widgets.pop_back(); + std::string widget = pairWidget.second; + + if( widget.compare("dvb_devices") == 0 ) { + int addHeight = DrawMainMenuWidgetDVBDevices(wLeft, wWidth, ContentTop); + if( addHeight > 0 ) + ContentTop = addHeight + marginItem; + } else if( widget.compare("active_timer") == 0 ) { + int addHeight = DrawMainMenuWidgetActiveTimers(wLeft, wWidth, ContentTop); + if( addHeight > 0 ) + ContentTop = addHeight + marginItem; + } else if( widget.compare("last_recordings") == 0 ) { + int addHeight = DrawMainMenuWidgetLastRecordings(wLeft, wWidth, ContentTop); + if( addHeight > 0 ) + ContentTop = addHeight + marginItem; + } else if( widget.compare("system_information") == 0 ) { + int addHeight = DrawMainMenuWidgetSystemInformation(wLeft, wWidth, ContentTop); + if( addHeight > 0 ) + ContentTop = addHeight + marginItem; + } else if( widget.compare("system_updates") == 0 ) { + int addHeight = DrawMainMenuWidgetSystemUpdates(wLeft, wWidth, ContentTop); + if( addHeight > 0 ) + ContentTop = addHeight + marginItem; + } else if( widget.compare("temperatures") == 0 ) { + int addHeight = DrawMainMenuWidgetTemperaturs(wLeft, wWidth, ContentTop); + if( addHeight > 0 ) + ContentTop = addHeight + marginItem; + } else if( widget.compare("timer_conflicts") == 0 ) { + int addHeight = DrawMainMenuWidgetTimerConflicts(wLeft, wWidth, ContentTop); + if( addHeight > 0 ) + ContentTop = addHeight + marginItem; + } else if( widget.compare("custom_command") == 0 ) { + int addHeight = DrawMainMenuWidgetCommand(wLeft, wWidth, ContentTop); + if( addHeight > 0 ) + ContentTop = addHeight + marginItem; + } + + } + + contentWidget.CreatePixmaps(false); + contentWidget.Draw(); + + DecorBorderDraw(wLeft, wTop, wWidth, contentWidget.ContentHeight(false), Config.decorBorderMenuContentSize, Config.decorBorderMenuContentType, + Config.decorBorderMenuContentFg, Config.decorBorderMenuContentBg); +} + +int cFlatDisplayMenu::DrawMainMenuWidgetDVBDevices(int wLeft, int wWidth, int ContentTop) { + int numDevices = cDevice::NumDevices(); + + if( ContentTop + fontHeight + 6 + fontSmlHeight > menuPixmap->ViewPort().Height() ) + return -1; + + cImage *img = imgLoader.LoadIcon("widgets/dvb_devices", fontHeight, fontHeight - marginItem*2); + if( img ) { + contentWidget.AddImage(img, cRect(marginItem, ContentTop + marginItem, fontHeight, fontHeight)); + } + contentWidget.AddText(tr("DVB Devices"), false, cRect(marginItem*2 + fontHeight, ContentTop, 0, 0), Theme.Color(clrMenuEventFontTitle), Theme.Color(clrMenuEventBg), font); + ContentTop += fontHeight; + contentWidget.AddRect(cRect(0, ContentTop, wWidth, 3), Theme.Color(clrMenuEventTitleLine)); + ContentTop += 6; + + // check device which currently displays live tv + int deviceLiveTV = -1; + cDevice *primaryDevice = cDevice::PrimaryDevice(); + if (primaryDevice) { + if (!primaryDevice->Replaying() || primaryDevice->Transferring()) + deviceLiveTV = cDevice::ActualDevice()->DeviceNumber(); + else + deviceLiveTV = primaryDevice->DeviceNumber(); + } + + // check currently recording devices + bool *recDevices = new bool[numDevices]; + for( int i=0; i < numDevices; i++ ) + recDevices[i] = false; + for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) { + if (!timer->Recording()) { + continue; + } + if (cRecordControl *RecordControl = cRecordControls::GetRecordControl(timer)) { + const cDevice *recDevice = RecordControl->Device(); + if (recDevice) { + recDevices[recDevice->DeviceNumber()] = true; + } + } + } + int actualNumDevices = 0; + for (int i = 0; i < numDevices; i++) { + if( ContentTop + marginItem > menuPixmap->ViewPort().Height() ) + continue; + const cDevice *device = cDevice::GetDevice(i); + if (!device || !device->NumProvidedSystems()) { + continue; + } + actualNumDevices++; + std::stringstream strDevice; + + strDevice << i << ": " << *(device->DeviceType()) << " - "; + + if( i == deviceLiveTV ) { + strDevice << tr("LiveTV") << "("; + const cChannel *channel = device->GetCurrentlyTunedTransponder(); + //const cSource *source = (channel) ? Sources.Get(channel->Source()) : NULL; + cString chanName; + if (channel && channel->Number() > 0) { + chanName = channel->Name(); + } else { + chanName = tr("Unknown"); + } + strDevice << *chanName; + strDevice << ")"; + } + else if( recDevices[i] ) { + strDevice << tr("recording") << "("; + const cChannel *channel = device->GetCurrentlyTunedTransponder(); + //const cSource *source = (channel) ? Sources.Get(channel->Source()) : NULL; + cString chanName; + if (channel && channel->Number() > 0) { + chanName = channel->Name(); + } else { + chanName = tr("Unknown"); + } + strDevice << *chanName; + strDevice << ")"; + } else { + const cChannel *channel = device->GetCurrentlyTunedTransponder(); + if( channel ) { + cString chanName = channel->Name(); + if( !strcmp(*chanName, "") ) + strDevice << tr("not used"); + else + strDevice << tr("Unknown") << "(" << *chanName << ")"; + } else + strDevice << tr("not used"); + } + + contentWidget.AddText(strDevice.str().c_str(), false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml); + ContentTop += fontSmlHeight; + } + + delete[] recDevices; + + return contentWidget.ContentHeight(false); +} + +int cFlatDisplayMenu::DrawMainMenuWidgetActiveTimers(int wLeft, int wWidth, int ContentTop) { + if( ContentTop + fontHeight + 6 + fontSmlHeight > menuPixmap->ViewPort().Height() ) + return -1; + + cImage *img = imgLoader.LoadIcon("widgets/active_timers", fontHeight, fontHeight - marginItem*2); + if( img ) { + contentWidget.AddImage(img, cRect(marginItem, ContentTop + marginItem, fontHeight, fontHeight)); + } + contentWidget.AddText(tr("Active Timer"), false, cRect(marginItem*2 + fontHeight, ContentTop, 0, 0), Theme.Color(clrMenuEventFontTitle), Theme.Color(clrMenuEventBg), font); + ContentTop += fontHeight; + contentWidget.AddRect(cRect(0, ContentTop, wWidth, 3), Theme.Color(clrMenuEventTitleLine)); + ContentTop += 6; + + // look for timers + time_t t; + time(&t); + int index = 0, numRec = 0; + for(cTimer *ti = Timers.First(); ti && index < Config.MainMenuWidgetActiveTimerMaxCount; ti = Timers.Next(ti), index++) { + if( ti->Matches(t) && ti->HasFlags(tfActive) ) { + numRec++; + } + } + if( numRec == 0 && Config.MainMenuWidgetActiveTimerHideEmpty ) + return 0; + else if( numRec == 0 ) { + contentWidget.AddText(tr("no active timer"), false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + } else { + index = 0; + for(cTimer *ti = Timers.First(); ti && index < Config.MainMenuWidgetActiveTimerMaxCount; ti = Timers.Next(ti), index++) { + if( ti->Matches(t) && ti->HasFlags(tfActive) ) { + if( ContentTop + marginItem > menuPixmap->ViewPort().Height() ) + continue; + + const cChannel *Channel = ti->Channel(); + //const cEvent *Event = Timer->Event(); + std::stringstream strTimer; + strTimer << index+1 << ": "; + if( Channel ) + strTimer << Channel->Name() << " - "; + else + strTimer << tr("Unknown") << " - "; + strTimer << ti->File(); + + contentWidget.AddText(strTimer.str().c_str(), false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + + ContentTop += fontSmlHeight; + } + } + } + + return contentWidget.ContentHeight(false); +} + +int cFlatDisplayMenu::DrawMainMenuWidgetLastRecordings(int wLeft, int wWidth, int ContentTop) { + if( ContentTop + fontHeight + 6 + fontSmlHeight > menuPixmap->ViewPort().Height() ) + return -1; + + cImage *img = imgLoader.LoadIcon("widgets/last_recordings", fontHeight, fontHeight - marginItem*2); + if( img ) { + contentWidget.AddImage(img, cRect(marginItem, ContentTop + marginItem, fontHeight, fontHeight)); + } + contentWidget.AddText(tr("Last Recordings"), false, cRect(marginItem*2 + fontHeight, ContentTop, 0, 0), Theme.Color(clrMenuEventFontTitle), Theme.Color(clrMenuEventBg), font); + ContentTop += fontHeight; + contentWidget.AddRect(cRect(0, ContentTop, wWidth, 3), Theme.Color(clrMenuEventTitleLine)); + ContentTop += 6; + + std::vector<std::pair<time_t, std::string> > Recs; + for(cRecording *rec = Recordings.First(); rec; rec = Recordings.Next(rec)) { + time_t RecStart = rec->Start(); + + int Minutes = (rec->LengthInSeconds() + 30) / 60; + cString Length = cString::sprintf("%02d:%02d", Minutes / 60, Minutes % 60); + cString DateTime = cString::sprintf("%s %s %s", *ShortDateString(rec->Start()), *TimeString(rec->Start()), *Length); + + std::string strRec = *(cString::sprintf("%s - %s", *DateTime, rec->Name())); + Recs.push_back(std::make_pair(RecStart, strRec)); + } + // Sort by RecStart + std::sort(Recs.begin(), Recs.end(), pairCompareTimeStringDesc); + int index = 0; + while( !Recs.empty() && index < Config.MainMenuWidgetLastRecMaxCount ) { + if( ContentTop + marginItem > menuPixmap->ViewPort().Height() ) + continue; + + std::pair<time_t, std::string> pairRec = Recs.back(); + Recs.pop_back(); + std::string Rec = pairRec.second; + + std::stringstream strRec; + strRec << Rec; + + contentWidget.AddText(strRec.str().c_str(), false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + ContentTop += fontSmlHeight; + index++; + } + return contentWidget.ContentHeight(false); +} + +int cFlatDisplayMenu::DrawMainMenuWidgetTimerConflicts(int wLeft, int wWidth, int ContentTop) { + if( ContentTop + fontHeight + 6 + fontSmlHeight > menuPixmap->ViewPort().Height() ) + return -1; + + cImage *img = imgLoader.LoadIcon("widgets/timer_conflicts", fontHeight, fontHeight - marginItem*2); + if( img ) { + contentWidget.AddImage(img, cRect(marginItem, ContentTop + marginItem, fontHeight, fontHeight)); + } + contentWidget.AddText(tr("Timer Conflicts"), false, cRect(marginItem*2 + fontHeight, ContentTop, 0, 0), Theme.Color(clrMenuEventFontTitle), Theme.Color(clrMenuEventBg), font); + ContentTop += fontHeight; + contentWidget.AddRect(cRect(0, ContentTop, wWidth, 3), Theme.Color(clrMenuEventTitleLine)); + ContentTop += 6; + + int numConflicts = 0; + cPlugin *p = cPluginManager::GetPlugin("epgsearch"); + if (p) { + Epgsearch_lastconflictinfo_v1_0 *serviceData = new Epgsearch_lastconflictinfo_v1_0; + if (serviceData) { + serviceData->nextConflict = 0; + serviceData->relevantConflicts = 0; + serviceData->totalConflicts = 0; + p->Service("Epgsearch-lastconflictinfo-v1.0", serviceData); + if (serviceData->relevantConflicts > 0) { + numConflicts = serviceData->relevantConflicts; + } + delete serviceData; + } + } + if( numConflicts == 0 && Config.MainMenuWidgetTimerConflictsHideEmpty ) { + return 0; + } else if( numConflicts == 0 ) { + contentWidget.AddText(tr("no timer conflicts"), false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + } else { + cString str = cString::sprintf("%s: %d", tr("timer conflicts"), numConflicts); + contentWidget.AddText(*str, false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + } + + return contentWidget.ContentHeight(false); +} + +int cFlatDisplayMenu::DrawMainMenuWidgetSystemInformation(int wLeft, int wWidth, int ContentTop) { + if( ContentTop + fontHeight + 6 + fontSmlHeight > menuPixmap->ViewPort().Height() ) + return -1; + + cImage *img = imgLoader.LoadIcon("widgets/system_information", fontHeight, fontHeight - marginItem*2); + if( img ) { + contentWidget.AddImage(img, cRect(marginItem, ContentTop + marginItem, fontHeight, fontHeight)); + } + contentWidget.AddText(tr("System Information"), false, cRect(marginItem*2 + fontHeight, ContentTop, 0, 0), Theme.Color(clrMenuEventFontTitle), Theme.Color(clrMenuEventBg), font); + ContentTop += fontHeight; + contentWidget.AddRect(cRect(0, ContentTop, wWidth, 3), Theme.Color(clrMenuEventTitleLine)); + ContentTop += 6; + + cString execFile = cString::sprintf("cd \"%s/widgets/system_information\"; \"%s/widgets/system_information/system_information\"", cPlugin::ConfigDirectory(PLUGIN_NAME_I18N), cPlugin::ConfigDirectory(PLUGIN_NAME_I18N)); + int r = system(*execFile); + r += 0; // prevent Warning for unused variable + + cString configsPath = cString::sprintf("%s/widgets/system_information/", cPlugin::ConfigDirectory(PLUGIN_NAME_I18N)); + std::vector<std::string> files; + + cReadDir d(configsPath); + struct dirent *e; + while ((e = d.Next()) != NULL) { + dsyslog("FILE: %s", e->d_name); + std::string fname = e->d_name; + std::size_t found = fname.find("_"); + if( found != std::string::npos ) { + std::string num = fname.substr(0, found); + if( atoi( num.c_str() ) > 0 ) { + files.push_back(e->d_name); + } + } + } + int Column = 1; + int ContentLeft = marginItem; + std::sort(files.begin(), files.end(), stringCompare); + if( files.size() == 0 ) { + cString str = cString::sprintf("%s - %s", tr("no information available please check the script"), *execFile); + contentWidget.AddText(*str, false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + } else { + for(unsigned i = 0; i < files.size(); i++) { + // check for height + if( ContentTop + marginItem > menuPixmap->ViewPort().Height() ) + break; + std::string fname = files[i]; + std::size_t found = fname.find("_"); + if( found != std::string::npos ) { + std::string num = fname.substr(0, found); + if( atoi( num.c_str() ) > 0 ) { + std::string item = fname.substr(found + 1, fname.length() - found); + cString itemFilename = cString::sprintf("%s/widgets/system_information/%s", cPlugin::ConfigDirectory(PLUGIN_NAME_I18N), fname.c_str() ); + std::ifstream file(*itemFilename, std::ifstream::in); + if( file.is_open() ) { + std::string item_content; + std::getline(file, item_content); + + if( !strcmp(item.c_str(), "sys_version") ) { + if( Column == 2 ) { + Column = 1; + ContentTop += fontSmlHeight; + ContentLeft = marginItem; + } + cString str = cString::sprintf("%s: %s", tr("System Version"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + ContentTop += fontSmlHeight; + } else if( ! item.compare("kernel_version") ) { + if( Column == 2 ) { + Column = 1; + ContentTop += fontSmlHeight; + ContentLeft = marginItem; + } + cString str = cString::sprintf("%s: %s", tr("Kernel Version"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + ContentTop += fontSmlHeight; + } else if( ! item.compare("uptime") ) { + cString str = cString::sprintf("%s: %s", tr("Uptime"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } else if( ! item.compare("load") ) { + cString str = cString::sprintf("%s: %s", tr("Load"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } else if( ! item.compare("processes") ) { + cString str = cString::sprintf("%s: %s", tr("Processes"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } else if( ! item.compare("mem_usage") ) { + cString str = cString::sprintf("%s: %s", tr("Memory Usage"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } else if( ! item.compare("swap_usage") ) { + cString str = cString::sprintf("%s: %s", tr("Swap Usage"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } else if( ! item.compare("root_usage") ) { + cString str = cString::sprintf("%s: %s", tr("Root Usage"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } else if( ! item.compare("video_usage") ) { + cString str = cString::sprintf("%s: %s", tr("Video Usage"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } else if( ! item.compare("vdr_cpu_usage") ) { + cString str = cString::sprintf("%s: %s", tr("VDR CPU Usage"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } else if( ! item.compare("cpu") ) { + cString str = cString::sprintf("%s: %s", tr("Temp CPU"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } else if( ! item.compare("gpu") ) { + cString str = cString::sprintf("%s: %s", tr("Temp GPU"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } else if( ! item.compare("pccase") ) { + cString str = cString::sprintf("%s: %s", tr("Temp PC-Case"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } else if( ! item.compare("updates") ) { + cString str = cString::sprintf("%s: %s", tr("Updates"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } else if( ! item.compare("security_updates") ) { + cString str = cString::sprintf("%s: %s", tr("Security Updates"), item_content.c_str()); + contentWidget.AddText(*str, false, cRect(ContentLeft, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + if( Column == 1 ) { + Column = 2; + ContentLeft = wWidth / 2; + } else { + Column = 1; + ContentLeft = marginItem; + ContentTop += fontSmlHeight; + } + } + file.close(); + } + } + } + } + } + + return contentWidget.ContentHeight(false); +} + +int cFlatDisplayMenu::DrawMainMenuWidgetSystemUpdates(int wLeft, int wWidth, int ContentTop) { + if( ContentTop + fontHeight + 6 + fontSmlHeight > menuPixmap->ViewPort().Height() ) + return -1; + + cImage *img = imgLoader.LoadIcon("widgets/system_updates", fontHeight, fontHeight - marginItem*2); + if( img ) { + contentWidget.AddImage(img, cRect(marginItem, ContentTop + marginItem, fontHeight, fontHeight)); + } + contentWidget.AddText(tr("System Updates"), false, cRect(marginItem*2 + fontHeight, ContentTop, 0, 0), Theme.Color(clrMenuEventFontTitle), Theme.Color(clrMenuEventBg), font); + ContentTop += fontHeight; + contentWidget.AddRect(cRect(0, ContentTop, wWidth, 3), Theme.Color(clrMenuEventTitleLine)); + ContentTop += 6; + + int updates = 0, securityUpdates = 0; + cString itemFilename = cString::sprintf("%s/widgets/system_updatestatus/updates", cPlugin::ConfigDirectory(PLUGIN_NAME_I18N) ); + std::ifstream file(*itemFilename, std::ifstream::in); + if( file.is_open() ) { + std::string cont; + std::getline(file, cont); + updates = atoi(cont.c_str()); + file.close(); + } else { + updates = -1; + } + + itemFilename = cString::sprintf("%s/widgets/system_updatestatus/security_updates", cPlugin::ConfigDirectory(PLUGIN_NAME_I18N) ); + std::ifstream file2(*itemFilename, std::ifstream::in); + if( file2.is_open() ) { + std::string cont; + std::getline(file2, cont); + securityUpdates = atoi(cont.c_str()); + file2.close(); + } else { + securityUpdates = -1; + } + + if(updates == -1 || securityUpdates == -1) { + contentWidget.AddText(tr("Updatestatus not available please check the widget"), false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + } else if( updates == 0 && securityUpdates == 0 && Config.MainMenuWidgetSystemUpdatesHideIfZero ) { + return 0; + } else { + cString str = cString::sprintf("%s: %d", tr("Updates"), updates); + contentWidget.AddText(*str, false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + str = cString::sprintf("%s: %d", tr("Security Updates"), securityUpdates); + contentWidget.AddText(*str, false, cRect(wWidth/2 + marginItem, ContentTop, wWidth/2 - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + } + + return contentWidget.ContentHeight(false); +} + +int cFlatDisplayMenu::DrawMainMenuWidgetTemperaturs(int wLeft, int wWidth, int ContentTop) { + if( ContentTop + fontHeight + 6 + fontSmlHeight > menuPixmap->ViewPort().Height() ) + return -1; + + cImage *img = imgLoader.LoadIcon("widgets/temperatures", fontHeight, fontHeight - marginItem*2); + if( img ) { + contentWidget.AddImage(img, cRect(marginItem, ContentTop + marginItem, fontHeight, fontHeight)); + } + contentWidget.AddText(tr("Temperatures"), false, cRect(marginItem*2 + fontHeight, ContentTop, 0, 0), Theme.Color(clrMenuEventFontTitle), Theme.Color(clrMenuEventBg), font); + ContentTop += fontHeight; + contentWidget.AddRect(cRect(0, ContentTop, wWidth, 3), Theme.Color(clrMenuEventTitleLine)); + ContentTop += 6; + + cString execFile = cString::sprintf("cd \"%s/widgets/temperatures\"; \"%s/widgets/temperatures/temperatures\"", cPlugin::ConfigDirectory(PLUGIN_NAME_I18N), cPlugin::ConfigDirectory(PLUGIN_NAME_I18N)); + int r = system(*execFile); + r += 0; // prevent Warning for unused variable + + std::string tempCPU, tempCase, tempGPU; + cString itemFilename = cString::sprintf("%s/widgets/temperatures/cpu", cPlugin::ConfigDirectory(PLUGIN_NAME_I18N) ); + std::ifstream file(*itemFilename, std::ifstream::in); + if( file.is_open() ) { + std::getline(file, tempCPU); + file.close(); + } else { + tempCPU = "-1"; + } + + itemFilename = cString::sprintf("%s/widgets/temperatures/pccase", cPlugin::ConfigDirectory(PLUGIN_NAME_I18N) ); + std::ifstream file2(*itemFilename, std::ifstream::in); + if( file2.is_open() ) { + std::string cont; + std::getline(file2, tempCase); + file2.close(); + } else { + tempCase = "-1"; + } + + itemFilename = cString::sprintf("%s/widgets/temperatures/gpu", cPlugin::ConfigDirectory(PLUGIN_NAME_I18N) ); + std::ifstream file3(*itemFilename, std::ifstream::in); + if( file3.is_open() ) { + std::string cont; + std::getline(file3, tempGPU); + file3.close(); + } else { + tempGPU = "-1"; + } + + if( !strcmp(tempCPU.c_str(), "-1") && !strcmp(tempCase.c_str(), "-1") && !strcmp(tempGPU.c_str(), "-1") ) { + contentWidget.AddText(tr("Temperatures not available please check the widget"), false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + } else { + cString str = cString::sprintf("%s: %s", tr("CPU"), tempCPU.c_str()); + contentWidget.AddText(*str, false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + str = cString::sprintf("%s: %s", tr("PC-Case"), tempCase.c_str()); + contentWidget.AddText(*str, false, cRect(wWidth/3 + marginItem, ContentTop, wWidth/3 - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + str = cString::sprintf("%s: %s", tr("GPU"), tempGPU.c_str()); + contentWidget.AddText(*str, false, cRect(wWidth/3*2 + marginItem, ContentTop, wWidth/3*2 - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + } + + return contentWidget.ContentHeight(false); +} + +int cFlatDisplayMenu::DrawMainMenuWidgetCommand(int wLeft, int wWidth, int ContentTop) { + if( ContentTop + fontHeight + 6 + fontSmlHeight > menuPixmap->ViewPort().Height() ) + return -1; + + cString execFile = cString::sprintf("cd \"%s/widgets/command_output\"; \"%s/widgets/command_output/command\"", cPlugin::ConfigDirectory(PLUGIN_NAME_I18N), cPlugin::ConfigDirectory(PLUGIN_NAME_I18N)); + int r = system(*execFile); + r += 0; // prevent Warning for unused variable + + std::string Title; + cString itemFilename = cString::sprintf("%s/widgets/command_output/title", cPlugin::ConfigDirectory(PLUGIN_NAME_I18N) ); + std::ifstream file(*itemFilename, std::ifstream::in); + if( file.is_open() ) { + std::getline(file, Title); + file.close(); + } else { + Title = tr("no title available"); + } + + cImage *img = imgLoader.LoadIcon("widgets/command_output", fontHeight, fontHeight - marginItem*2); + if( img ) { + contentWidget.AddImage(img, cRect(marginItem, ContentTop + marginItem, fontHeight, fontHeight)); + } + contentWidget.AddText(Title.c_str(), false, cRect(marginItem*2 + fontHeight, ContentTop, 0, 0), Theme.Color(clrMenuEventFontTitle), Theme.Color(clrMenuEventBg), font); + ContentTop += fontHeight; + contentWidget.AddRect(cRect(0, ContentTop, wWidth, 3), Theme.Color(clrMenuEventTitleLine)); + ContentTop += 6; + + std::string Output; + itemFilename = cString::sprintf("%s/widgets/command_output/output", cPlugin::ConfigDirectory(PLUGIN_NAME_I18N) ); + std::ifstream file2(*itemFilename, std::ifstream::in); + if( file2.is_open() ) { + for (; std::getline(file2, Output); ) { + if( ContentTop + marginItem > menuPixmap->ViewPort().Height() ) + break; + contentWidget.AddText(Output.c_str(), false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + ContentTop += fontSmlHeight; + } + file2.close(); + } else { + contentWidget.AddText(tr("no output available"), false, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, wWidth - marginItem*2); + } + + return contentWidget.ContentHeight(false); +} + +/* +int cFlatDisplayMenu::DrawMainMenuWidgetTimerConflicts(int wLeft, int wTop, int wWidth) { + int wHeight = fontHeight + 6 + (Config.MainMenuWidgetLastRecMaxCount * fontSmlHeight) + Config.decorBorderMenuContentSize*2; + int ContentTop = marginItem; + + contentWidgetTimerConflicts.Clear(); + contentWidgetTimerConflicts.SetOsd(osd); + contentWidgetTimerConflicts.SetPosition(cRect(wLeft, wTop, wWidth, wHeight)); + contentWidgetTimerConflicts.SetBGColor(Theme.Color(clrMenuRecBg)); + contentWidgetTimerConflicts.SetScrollingActive(false); + + contentWidgetTimerConflicts.AddText(tr("Last Recordings"), false, cRect(marginItem*10, ContentTop, 0, 0), Theme.Color(clrMenuEventFontTitle), Theme.Color(clrMenuEventBg), font); + ContentTop += fontHeight; + contentWidgetTimerConflicts.AddRect(cRect(0, ContentTop, wWidth, 3), Theme.Color(clrMenuEventTitleLine)); + ContentTop += 6; + + if( wTop + contentWidgetTimerConflicts.ContentHeight(false) + fontSmlHeight > menuPixmap->ViewPort().Height() ) + return 0; + + contentWidgetTimerConflicts.AddText(strRec.str().c_str(), true, cRect(marginItem, ContentTop, wWidth - marginItem*2, fontSmlHeight), + Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml); + ContentTop += fontSmlHeight; + + contentWidgetTimerConflicts.CreatePixmaps(false); + contentWidgetTimerConflicts.Draw(); + + DecorBorderDraw(wLeft, wTop, wWidth, contentWidgetTimerConflicts.ContentHeight(false), Config.decorBorderMenuContentSize, Config.decorBorderMenuContentType, + Config.decorBorderMenuContentFg, Config.decorBorderMenuContentBg); + + return contentWidgetTimerConflicts.ContentHeight(false); +} +*/ void cFlatDisplayMenu::PreLoadImages(void) { // menu icons cString Path = cString::sprintf("%s%s/menuIcons", *Config.iconPath, Setup.OSDTheme); diff --git a/displaymenu.h b/displaymenu.h index ed6afa9e..3d803820 100644 --- a/displaymenu.h +++ b/displaymenu.h @@ -2,6 +2,7 @@ #include "baserender.h" #include "complexcontent.h" +#include <vdr/menu.h> #include <list> #include <ctype.h> #include <iostream> @@ -45,6 +46,9 @@ class cFlatDisplayMenu : public cFlatBaseRender, public cSkinDisplayMenu { cComplexContent ComplexContent; + // Content for Widgets + cComplexContent contentWidget; + // TextScroller cTextScrollers menuItemScroller; @@ -86,6 +90,16 @@ class cFlatDisplayMenu : public cFlatBaseRender, public cSkinDisplayMenu { static cBitmap bmCNew, bmCRec, bmCArrowTurn, bmCHD, bmCVPS; void DrawItemExtraEvent(const cEvent *Event, cString EmptyText); void DrawItemExtraRecording(const cRecording *Recording, cString EmptyText); + void DrawMainMenuWidgets(void); + int DrawMainMenuWidgetDVBDevices(int wLeft, int wWidth, int ContentTop); + int DrawMainMenuWidgetActiveTimers(int wLeft, int wWidth, int ContentTop); + int DrawMainMenuWidgetLastRecordings(int wLeft, int wWidth, int ContentTop); + int DrawMainMenuWidgetTimerConflicts(int wLeft, int wWidth, int ContentTop); + int DrawMainMenuWidgetSystemInformation(int wLeft, int wWidth, int ContentTop); + int DrawMainMenuWidgetSystemUpdates(int wLeft, int wWidth, int ContentTop); + int DrawMainMenuWidgetTemperaturs(int wLeft, int wWidth, int ContentTop); + int DrawMainMenuWidgetCommand(int wLeft, int wWidth, int ContentTop); + public: cFlatDisplayMenu(void); virtual ~cFlatDisplayMenu(); diff --git a/icons/default/widgets/active_timers.png b/icons/default/widgets/active_timers.png Binary files differnew file mode 100644 index 00000000..8f319133 --- /dev/null +++ b/icons/default/widgets/active_timers.png diff --git a/icons/default/widgets/command_output.png b/icons/default/widgets/command_output.png Binary files differnew file mode 100644 index 00000000..58a3c302 --- /dev/null +++ b/icons/default/widgets/command_output.png diff --git a/icons/default/widgets/dvb_devices.png b/icons/default/widgets/dvb_devices.png Binary files differnew file mode 100644 index 00000000..95f28174 --- /dev/null +++ b/icons/default/widgets/dvb_devices.png diff --git a/icons/default/widgets/last_recordings.png b/icons/default/widgets/last_recordings.png Binary files differnew file mode 100644 index 00000000..602a6771 --- /dev/null +++ b/icons/default/widgets/last_recordings.png diff --git a/icons/default/widgets/system_information.png b/icons/default/widgets/system_information.png Binary files differnew file mode 100644 index 00000000..2a23f666 --- /dev/null +++ b/icons/default/widgets/system_information.png diff --git a/icons/default/widgets/system_updates.png b/icons/default/widgets/system_updates.png Binary files differnew file mode 100644 index 00000000..955ed447 --- /dev/null +++ b/icons/default/widgets/system_updates.png diff --git a/icons/default/widgets/temperatures.png b/icons/default/widgets/temperatures.png Binary files differnew file mode 100644 index 00000000..5ec1cd24 --- /dev/null +++ b/icons/default/widgets/temperatures.png diff --git a/icons/default/widgets/timer_conflicts.png b/icons/default/widgets/timer_conflicts.png Binary files differnew file mode 100644 index 00000000..c4d17d2e --- /dev/null +++ b/icons/default/widgets/timer_conflicts.png diff --git a/po/de_DE.po b/po/de_DE.po index 97938a0d..4b809506 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr-skinflat 0.4.3\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2014-10-21 18:38+0200\n" +"POT-Creation-Date: 2014-11-09 14:53+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -135,6 +135,117 @@ msgstr "Suchmuster" msgid "Recording information" msgstr "Aufnahme Informationen" +msgid "DVB Devices" +msgstr "" + +msgid "LiveTV" +msgstr "" + +msgid "Unknown" +msgstr "" + +msgid "recording" +msgstr "" + +msgid "not used" +msgstr "" + +msgid "Active Timer" +msgstr "" + +msgid "no active timer" +msgstr "" + +msgid "Last Recordings" +msgstr "" + +msgid "Timer Conflicts" +msgstr "" + +msgid "no timer conflicts" +msgstr "" + +msgid "timer conflicts" +msgstr "" + +msgid "System Information" +msgstr "" + +msgid "no information available please check the script" +msgstr "" + +msgid "System Version" +msgstr "" + +msgid "Kernel Version" +msgstr "" + +msgid "Uptime" +msgstr "" + +msgid "Load" +msgstr "" + +msgid "Processes" +msgstr "" + +msgid "Memory Usage" +msgstr "" + +msgid "Swap Usage" +msgstr "" + +msgid "Root Usage" +msgstr "" + +msgid "Video Usage" +msgstr "" + +msgid "VDR CPU Usage" +msgstr "" + +msgid "Temp CPU" +msgstr "" + +msgid "Temp GPU" +msgstr "" + +msgid "Temp PC-Case" +msgstr "" + +msgid "Updates" +msgstr "" + +msgid "Security Updates" +msgstr "" + +msgid "System Updates" +msgstr "" + +msgid "Updatestatus not available please check the widget" +msgstr "" + +msgid "Temperatures" +msgstr "" + +msgid "Temperatures not available please check the widget" +msgstr "" + +msgid "CPU" +msgstr "" + +msgid "PC-Case" +msgstr "" + +msgid "GPU" +msgstr "" + +msgid "no title available" +msgstr "" + +msgid "no output available" +msgstr "" + msgid "Audio Tracks" msgstr "Audio Spuren" @@ -291,6 +402,9 @@ msgstr "TVScraper / scraper2vdr Einstellungen" msgid "TVScraper / scraper2vdr not installed" msgstr "TVScraper / scraper2vdr nicht installiert" +msgid "Main menu widgets settings" +msgstr "" + msgid "configfile" msgstr "Konfigdatei" @@ -483,9 +597,6 @@ msgstr "Zeige Zusatzinfo bei EPG" msgid "Show reruns in EPG info" msgstr "Zeige Wiederholungen bei EPG" -msgid "Main menuitem scale" -msgstr "Hauptmenüeintrag Skalierung" - msgid "Menu draw background over the entire height" msgstr "Menü zeichne Hintergrund über gesamte Höhe" @@ -600,6 +711,9 @@ msgstr "Audiospur Rand Typ" msgid "Tracks border size" msgstr "Audiospur Rand Größe" +msgid "TVScraper settings" +msgstr "" + msgid "Channelinfo show poster?" msgstr "Kanalinfo zeige Poster?" @@ -617,3 +731,99 @@ msgstr "EPG-Info zeige Schauspieler?" msgid "recording info show actors?" msgstr "Aufnahmeinfo zeige Schauspieler?" + +msgid "Enable main menu widgets" +msgstr "" + +msgid "Main menu item scale" +msgstr "" + +msgid "Widget DVB devices: enable" +msgstr "" + +msgid "Widget DVB devices: position" +msgstr "" + +msgid "Widget active timer: enable" +msgstr "" + +msgid "Widget active timer: position" +msgstr "" + +msgid "Widget active timer: max show" +msgstr "" + +msgid "Widget active timer: hide if empty" +msgstr "" + +msgid "Widget last recordings: enable" +msgstr "" + +msgid "Widget last recordings: position" +msgstr "" + +msgid "Widget last recordings: max show" +msgstr "" + +msgid "Widget timer conflicts: enable" +msgstr "" + +msgid "Widget timer conflicts: position" +msgstr "" + +msgid "Widget timer conflicts: hide if empty" +msgstr "" + +msgid "Widget system information: enable" +msgstr "" + +msgid "Widget system information: position" +msgstr "" + +msgid "Widget system updates: enable" +msgstr "" + +msgid "Widget system updates: position" +msgstr "" + +msgid "Widget system updates: hide if empty" +msgstr "" + +msgid "Widget temperatures: enable" +msgstr "" + +msgid "Widget temperatures: position" +msgstr "" + +msgid "Widget custom commands: enable" +msgstr "" + +msgid "Widget custom commands: position" +msgstr "" + +msgid "Enable widget: DVB devices" +msgstr "" + +msgid "Enable widget: active timer" +msgstr "" + +msgid "Enable widget: last recordings" +msgstr "" + +msgid "Enable widget: timer conflicts" +msgstr "" + +msgid "Enable widget: system information" +msgstr "" + +msgid "Enable widget: system updates" +msgstr "" + +msgid "Enable widget: temperatures" +msgstr "" + +msgid "Enable widget: custom commands" +msgstr "" + +#~ msgid "Main menuitem scale" +#~ msgstr "Hauptmenüeintrag Skalierung" @@ -128,6 +128,8 @@ void cFlatSetup::Setup(void) { else Add(new cOsdItem(tr("TVScraper / scraper2vdr not installed"), osUnknown, false)); + Add(new cOsdItem(tr("Main menu widgets settings"), osUnknown, true)); + if( ItemLastSel >= 0 ) { SetCurrent(Get(ItemLastSel)); ItemLastSel = -1; @@ -158,6 +160,8 @@ eOSState cFlatSetup::ProcessKey(eKeys Key) { state = AddSubMenu(new cFlatSetupTracks(&SetupConfig)); if (strcmp(ItemText, tr("TVScraper / scraper2vdr settings")) == 0) state = AddSubMenu(new cFlatSetupTvsraper(&SetupConfig)); + if (strcmp(ItemText, tr("Main menu widgets settings")) == 0) + state = AddSubMenu(new cFlatSetupMMWidget(&SetupConfig)); } } return state; @@ -274,6 +278,28 @@ void cFlatSetup::Store(void) { SetupStore("MenuTimerShowCount", Config.MenuTimerShowCount); SetupStore("MenuChannelShowCount", Config.MenuChannelShowCount); SetupStore("ShortRecordingCount", Config.ShortRecordingCount); + SetupStore("MainMenuWidgetsEnable", Config.MainMenuWidgetsEnable); + SetupStore("MainMenuWidgetDVBDevicesShow", Config.MainMenuWidgetDVBDevicesShow); + SetupStore("MainMenuWidgetDVBDevicesPosition", Config.MainMenuWidgetDVBDevicesPosition); + SetupStore("MainMenuWidgetActiveTimerShow", Config.MainMenuWidgetActiveTimerShow); + SetupStore("MainMenuWidgetActiveTimerPosition", Config.MainMenuWidgetActiveTimerPosition); + SetupStore("MainMenuWidgetActiveTimerMaxCount", Config.MainMenuWidgetActiveTimerMaxCount); + SetupStore("MainMenuWidgetActiveTimerHideEmpty", Config.MainMenuWidgetActiveTimerHideEmpty); + SetupStore("MainMenuWidgetLastRecShow", Config.MainMenuWidgetLastRecShow); + SetupStore("MainMenuWidgetLastRecPosition", Config.MainMenuWidgetLastRecPosition); + SetupStore("MainMenuWidgetLastRecMaxCount", Config.MainMenuWidgetLastRecMaxCount); + SetupStore("MainMenuWidgetTimerConflictsShow", Config.MainMenuWidgetTimerConflictsShow); + SetupStore("MainMenuWidgetTimerConflictsPosition", Config.MainMenuWidgetTimerConflictsPosition); + SetupStore("MainMenuWidgetTimerConflictsHideEmpty", Config.MainMenuWidgetTimerConflictsHideEmpty); + SetupStore("MainMenuWidgetSystemInfoShow", Config.MainMenuWidgetSystemInfoShow); + SetupStore("MainMenuWidgetSystemInfoPosition", Config.MainMenuWidgetSystemInfoPosition); + SetupStore("MainMenuWidgetSystemUpdatesShow", Config.MainMenuWidgetSystemUpdatesShow); + SetupStore("MainMenuWidgetSystemUpdatesPosition", Config.MainMenuWidgetSystemUpdatesPosition); + SetupStore("MainMenuWidgetSystemUpdatesHideIfZero", Config.MainMenuWidgetSystemUpdatesHideIfZero); + SetupStore("MainMenuWidgetTemperaturesShow", Config.MainMenuWidgetTemperaturesShow); + SetupStore("MainMenuWidgetTemperaturesPosition", Config.MainMenuWidgetTemperaturesPosition); + SetupStore("MainMenuWidgetCommandShow", Config.MainMenuWidgetCommandShow); + SetupStore("MainMenuWidgetCommandPosition", Config.MainMenuWidgetCommandPosition); Config.Init(); } @@ -421,6 +447,28 @@ bool cFlatSetupGeneral::SetupParse(const char *Name, const char *Value) { else if (strcmp(Name, "MenuTimerShowCount") == 0) SetupConfig->MenuTimerShowCount = atoi(Value); else if (strcmp(Name, "MenuChannelShowCount") == 0) SetupConfig->MenuChannelShowCount = atoi(Value); else if (strcmp(Name, "ShortRecordingCount") == 0) SetupConfig->ShortRecordingCount = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetsEnable") == 0) SetupConfig->MainMenuWidgetsEnable = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetDVBDevicesShow") == 0) SetupConfig->MainMenuWidgetDVBDevicesShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetDVBDevicesPosition") == 0) SetupConfig->MainMenuWidgetDVBDevicesPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetActiveTimerShow") == 0) SetupConfig->MainMenuWidgetActiveTimerShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetActiveTimerPosition") == 0) SetupConfig->MainMenuWidgetActiveTimerPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetActiveTimerMaxCount") == 0) SetupConfig->MainMenuWidgetActiveTimerMaxCount = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetActiveTimerHideEmpty") == 0) SetupConfig->MainMenuWidgetActiveTimerHideEmpty = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetLastRecShow") == 0) SetupConfig->MainMenuWidgetLastRecShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetLastRecPosition") == 0) SetupConfig->MainMenuWidgetLastRecPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetLastRecMaxCount") == 0) SetupConfig->MainMenuWidgetLastRecMaxCount = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetTimerConflictsShow") == 0) SetupConfig->MainMenuWidgetTimerConflictsShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetTimerConflictsPosition") == 0) SetupConfig->MainMenuWidgetTimerConflictsPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetTimerConflictsHideEmpty") == 0)SetupConfig->MainMenuWidgetTimerConflictsHideEmpty = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetSystemInfoShow") == 0) SetupConfig->MainMenuWidgetSystemInfoShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetSystemInfoPosition") == 0) SetupConfig->MainMenuWidgetSystemInfoPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetSystemUpdatesShow") == 0) SetupConfig->MainMenuWidgetSystemUpdatesShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetSystemUpdatesPosition") == 0) SetupConfig->MainMenuWidgetSystemUpdatesPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetSystemUpdatesHideIfZero") == 0)SetupConfig->MainMenuWidgetSystemUpdatesHideIfZero = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetTemperaturesShow") == 0) SetupConfig->MainMenuWidgetTemperaturesShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetTemperaturesPosition") == 0) SetupConfig->MainMenuWidgetTemperaturesPosition = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetCommandShow") == 0) SetupConfig->MainMenuWidgetCommandShow = atoi(Value); + else if (strcmp(Name, "MainMenuWidgetCommandPosition") == 0) SetupConfig->MainMenuWidgetCommandPosition = atoi(Value); else return false; return true; @@ -550,6 +598,29 @@ void cFlatSetupGeneral::SaveCurrentSettings(void) { Config.Store("MenuChannelShowCount", SetupConfig->MenuChannelShowCount, *Filename); Config.Store("ShortRecordingCount", SetupConfig->ShortRecordingCount, *Filename); + Config.Store("MainMenuWidgetsEnable", SetupConfig->MainMenuWidgetsEnable, *Filename); + Config.Store("MainMenuWidgetDVBDevicesShow", SetupConfig->MainMenuWidgetDVBDevicesShow, *Filename); + Config.Store("MainMenuWidgetDVBDevicesPosition", SetupConfig->MainMenuWidgetDVBDevicesPosition, *Filename); + Config.Store("MainMenuWidgetActiveTimerShow", SetupConfig->MainMenuWidgetActiveTimerShow, *Filename); + Config.Store("MainMenuWidgetActiveTimerPosition", SetupConfig->MainMenuWidgetActiveTimerPosition, *Filename); + Config.Store("MainMenuWidgetActiveTimerMaxCount", SetupConfig->MainMenuWidgetActiveTimerMaxCount, *Filename); + Config.Store("MainMenuWidgetActiveTimerHideEmpty", SetupConfig->MainMenuWidgetActiveTimerHideEmpty, *Filename); + Config.Store("MainMenuWidgetLastRecShow", SetupConfig->MainMenuWidgetLastRecShow, *Filename); + Config.Store("MainMenuWidgetLastRecPosition", SetupConfig->MainMenuWidgetLastRecPosition, *Filename); + Config.Store("MainMenuWidgetLastRecMaxCount", SetupConfig->MainMenuWidgetLastRecMaxCount, *Filename); + Config.Store("MainMenuWidgetTimerConflictsShow", SetupConfig->MainMenuWidgetTimerConflictsShow, *Filename); + Config.Store("MainMenuWidgetTimerConflictsPosition", SetupConfig->MainMenuWidgetTimerConflictsPosition, *Filename); + Config.Store("MainMenuWidgetTimerConflictsHideEmpty", SetupConfig->MainMenuWidgetTimerConflictsHideEmpty, *Filename); + Config.Store("MainMenuWidgetSystemInfoShow", SetupConfig->MainMenuWidgetSystemInfoShow, *Filename); + Config.Store("MainMenuWidgetSystemInfoPosition", SetupConfig->MainMenuWidgetSystemInfoPosition, *Filename); + Config.Store("MainMenuWidgetSystemUpdatesShow", SetupConfig->MainMenuWidgetSystemUpdatesShow, *Filename); + Config.Store("MainMenuWidgetSystemUpdatesPosition", SetupConfig->MainMenuWidgetSystemUpdatesPosition, *Filename); + Config.Store("MainMenuWidgetSystemUpdatesHideIfZero", SetupConfig->MainMenuWidgetSystemUpdatesHideIfZero, *Filename); + Config.Store("MainMenuWidgetTemperaturesShow", SetupConfig->MainMenuWidgetTemperaturesShow, *Filename); + Config.Store("MainMenuWidgetTemperaturesPosition", SetupConfig->MainMenuWidgetTemperaturesPosition, *Filename); + Config.Store("MainMenuWidgetCommandShow", SetupConfig->MainMenuWidgetCommandShow, *Filename); + Config.Store("MainMenuWidgetCommandPosition", SetupConfig->MainMenuWidgetCommandPosition, *Filename); + cString msg = cString::sprintf("%s %s", tr("saved settings in file:"), *File); Skins.Message(mtInfo, msg); } @@ -817,7 +888,6 @@ void cFlatSetupMenu::Setup(void) { Add(new cMenuEditBoolItem(tr("Show additional recording info"), &SetupConfig->RecordingAdditionalInfoShow)); Add(new cMenuEditBoolItem(tr("Show additional EPG info"), &SetupConfig->EpgAdditionalInfoShow)); Add(new cMenuEditBoolItem(tr("Show reruns in EPG info"), &SetupConfig->EpgRerunsShow)); - Add(new cMenuEditPrcItem(tr("Main menuitem scale"), &SetupConfig->MainMenuItemScale, 0.2, 1, 0)); Add(new cMenuEditBoolItem(tr("Menu draw background over the entire height"), &SetupConfig->MenuFullOsd)); Add(new cMenuEditBoolItem(tr("Recording menu show recording count in title"), &SetupConfig->MenuRecordingShowCount)); @@ -1088,7 +1158,7 @@ eOSState cFlatSetupTracks::ProcessKey(eKeys Key) { } // TVScraper Settings -cFlatSetupTvsraper::cFlatSetupTvsraper(cFlatConfig* data) : cMenuSetupSubMenu(tr("Tracks settings"), data) { +cFlatSetupTvsraper::cFlatSetupTvsraper(cFlatConfig* data) : cMenuSetupSubMenu(tr("TVScraper settings"), data) { Setup(); } @@ -1120,15 +1190,108 @@ eOSState cFlatSetupTvsraper::ProcessKey(eKeys Key) { break; } } - /* + return state; +} + +// Main Menu Widgets Settings +cFlatSetupMMWidget::cFlatSetupMMWidget(cFlatConfig* data) : cMenuSetupSubMenu(tr("Main menu widgets settings"), data) { + Setup(); +} + +void cFlatSetupMMWidget::Setup(void) { + Clear(); + + Add(new cMenuEditBoolItem(tr("Enable main menu widgets"), &SetupConfig->MainMenuWidgetsEnable)); + if( SetupConfig->MainMenuWidgetsEnable ) { + Add(new cMenuEditPrcItem(tr("Main menu item scale"), &SetupConfig->MainMenuItemScale, 0.3, 0.7, 0)); + + Add(new cOsdItem("Widget DVB devices", osUnknown, false)); + Add(new cMenuEditBoolItem(tr("Widget DVB devices: enable"), &SetupConfig->MainMenuWidgetDVBDevicesShow)); + if( SetupConfig->MainMenuWidgetDVBDevicesShow ) { + Add(new cMenuEditIntItem(tr("Widget DVB devices: position"), &SetupConfig->MainMenuWidgetDVBDevicesPosition)); + } + + Add(new cOsdItem("Widget active timer", osUnknown, false)); + Add(new cMenuEditBoolItem(tr("Widget active timer: enable"), &SetupConfig->MainMenuWidgetActiveTimerShow)); + if( SetupConfig->MainMenuWidgetActiveTimerShow ) { + Add(new cMenuEditIntItem(tr("Widget active timer: position"), &SetupConfig->MainMenuWidgetActiveTimerPosition)); + Add(new cMenuEditIntItem(tr("Widget active timer: max show"), &SetupConfig->MainMenuWidgetActiveTimerMaxCount)); + Add(new cMenuEditBoolItem(tr("Widget active timer: hide if empty"), &SetupConfig->MainMenuWidgetActiveTimerHideEmpty)); + } + + Add(new cOsdItem("Widget last recordings", osUnknown, false)); + Add(new cMenuEditBoolItem(tr("Widget last recordings: enable"), &SetupConfig->MainMenuWidgetLastRecShow)); + if( SetupConfig->MainMenuWidgetLastRecShow ) { + Add(new cMenuEditIntItem(tr("Widget last recordings: position"), &SetupConfig->MainMenuWidgetLastRecPosition)); + Add(new cMenuEditIntItem(tr("Widget last recordings: max show"), &SetupConfig->MainMenuWidgetLastRecMaxCount)); + } + + Add(new cOsdItem("Widget timer conflicts", osUnknown, false)); + Add(new cMenuEditBoolItem(tr("Widget timer conflicts: enable"), &SetupConfig->MainMenuWidgetTimerConflictsShow)); + if( SetupConfig->MainMenuWidgetTimerConflictsShow ) { + Add(new cMenuEditIntItem(tr("Widget timer conflicts: position"), &SetupConfig->MainMenuWidgetTimerConflictsPosition)); + Add(new cMenuEditBoolItem(tr("Widget timer conflicts: hide if empty"), &SetupConfig->MainMenuWidgetTimerConflictsHideEmpty)); + } + + Add(new cOsdItem("Widget system information", osUnknown, false)); + Add(new cMenuEditBoolItem(tr("Widget system information: enable"), &SetupConfig->MainMenuWidgetSystemInfoShow)); + if( SetupConfig->MainMenuWidgetSystemInfoShow ) { + Add(new cMenuEditIntItem(tr("Widget system information: position"), &SetupConfig->MainMenuWidgetSystemInfoPosition)); + } + + Add(new cOsdItem("Widget system updates", osUnknown, false)); + Add(new cMenuEditBoolItem(tr("Widget system updates: enable"), &SetupConfig->MainMenuWidgetSystemUpdatesShow)); + if( SetupConfig->MainMenuWidgetSystemUpdatesShow ) { + Add(new cMenuEditIntItem(tr("Widget system updates: position"), &SetupConfig->MainMenuWidgetSystemUpdatesPosition)); + Add(new cMenuEditBoolItem(tr("Widget system updates: hide if empty"), &SetupConfig->MainMenuWidgetSystemUpdatesHideIfZero)); + } + + Add(new cOsdItem("Widget temperatures", osUnknown, false)); + Add(new cMenuEditBoolItem(tr("Widget temperatures: enable"), &SetupConfig->MainMenuWidgetTemperaturesShow)); + if( SetupConfig->MainMenuWidgetTemperaturesShow ) { + Add(new cMenuEditIntItem(tr("Widget temperatures: position"), &SetupConfig->MainMenuWidgetTemperaturesPosition)); + } + + Add(new cOsdItem("Widget custom commands", osUnknown, false)); + Add(new cMenuEditBoolItem(tr("Widget custom commands: enable"), &SetupConfig->MainMenuWidgetCommandShow)); + if( SetupConfig->MainMenuWidgetCommandShow ) { + Add(new cMenuEditIntItem(tr("Widget custom commands: position"), &SetupConfig->MainMenuWidgetCommandPosition)); + } + } + + if( ItemLastSel >= 0 ) { + SetCurrent(Get(ItemLastSel)); + ItemLastSel = -1; + } + + Display(); +} + +eOSState cFlatSetupMMWidget::ProcessKey(eKeys Key) { + eOSState state = cOsdMenu::ProcessKey(Key); + if (state == osUnknown) { + switch (Key) { + case kOk: + return osBack; + default: + break; + } + } if( Key == kLeft || Key == kRight ) { const char* ItemText = Get(Current())->Text(); - if( strstr(ItemText, tr("Tracks border by decor-file?")) != NULL + if( strstr(ItemText, tr("Enable main menu widgets")) != NULL || + strstr(ItemText, tr("Enable widget: DVB devices")) != NULL || + strstr(ItemText, tr("Enable widget: active timer")) != NULL || + strstr(ItemText, tr("Enable widget: last recordings")) != NULL || + strstr(ItemText, tr("Enable widget: timer conflicts")) != NULL || + strstr(ItemText, tr("Enable widget: system information")) != NULL || + strstr(ItemText, tr("Enable widget: system updates")) != NULL || + strstr(ItemText, tr("Enable widget: temperatures")) != NULL || + strstr(ItemText, tr("Enable widget: custom commands")) != NULL ) { ItemLastSel = Current(); Setup(); } } - */ return state; } @@ -88,3 +88,11 @@ class cFlatSetupTvsraper : public cMenuSetupSubMenu { cFlatSetupTvsraper(cFlatConfig *data); virtual eOSState ProcessKey(eKeys Key); }; + +class cFlatSetupMMWidget : public cMenuSetupSubMenu { + protected: + void Setup(void); + public: + cFlatSetupMMWidget(cFlatConfig *data); + virtual eOSState ProcessKey(eKeys Key); +}; diff --git a/widgets/command_output/README b/widgets/command_output/README new file mode 100644 index 00000000..f73a0326 --- /dev/null +++ b/widgets/command_output/README @@ -0,0 +1,5 @@ +This widget is for an own command +The command "command" will be executed every time the widget is drawn, so please keep it short and fast. +The command have to provide two output files: "title" and "output". +"title" is the title of the Widget. +The "output" file is read line by line. And every line is drawn without wrap the lines if they are to long. diff --git a/widgets/command_output/command b/widgets/command_output/command new file mode 100755 index 00000000..03b12b23 --- /dev/null +++ b/widgets/command_output/command @@ -0,0 +1,6 @@ +#!/bin/bash + +echo "MyTitle" > title + +echo "output line 1" > output +echo "output line 2" >> output diff --git a/widgets/system_information/README b/widgets/system_information/README new file mode 100644 index 00000000..946b5236 --- /dev/null +++ b/widgets/system_information/README @@ -0,0 +1,12 @@ +This widget provides several information about the current system state. + +The command "system_information" will be executed every time the widget is drawn, so please keep it short and fast. +The command "system_information" must provide several files with the infos. +The output files must begin with 01_ - 99_ for sort/position the info in the widget. For example "01_uptime", "02_load", etc.The values will be drawn in 2 columns except "system_version" and "kernel_version" they are drawn in a row. +For example: +System Version: Ubuntu 14.04.1 LTS +Load: 0.32 Uptime: 10:24:42 up 88 days + +You can include system_updatestatus and temperatures. But do not execute the system_updatestatus script (please read README of system_updatestatus) + +Please see the example!
\ No newline at end of file diff --git a/widgets/system_information/system_information b/widgets/system_information/system_information new file mode 120000 index 00000000..d61d4dfb --- /dev/null +++ b/widgets/system_information/system_information @@ -0,0 +1 @@ +system_information.ubuntu
\ No newline at end of file diff --git a/widgets/system_information/system_information.ubuntu b/widgets/system_information/system_information.ubuntu new file mode 100755 index 00000000..4222b602 --- /dev/null +++ b/widgets/system_information/system_information.ubuntu @@ -0,0 +1,134 @@ +#!/bin/bash + +# this script will be executed when the widget will be drawn +# so make it short and fast + +# enable/disable items +SHOW_SYS_VERSION=0 +SHOW_KERNEL_VERSION=0 +SHOW_UPTIME=1 +SHOW_LOAD=1 +SHOW_PROCESSES=1 +SHOW_MEM_USAGE=1 +SHOW_SWAP_USAGE=1 +SHOW_ROOT_USAGE=1 +SHOW_VIDEO_USAGE=1 +SHOW_VDR_CPU_USAGE=1 +SHOW_VDR_MEM_USAGE=1 + +SHOW_TEMPERATURES=0 +SHOW_SYSUPDATES=0 + +# Position of items +# sys_version & kernel_version are drawn in one line +# all others will be drawn in two column +# for example +# System Version: Ubuntu 14.04.1 LTS +# Uptime: 1:20 5m Load: 0.41 + +# must begin with 01 +SYS_VERSION_POS="01" +KERNEL_VERSION_POS="02" +UPTIME_POS="03" +LOAD_POS="04" +PROCESSES_POS="05" +MEM_USAGE_POS="06" +SWAP_USAGE_POS="07" +ROOT_USAGE_POS="08" +VIDEO_USAGE_POS="09" +VDR_CPU_USAGE_POS="10" +VDR_MEM_USAGE_POS="11" + +TEMP_CPU_POS=15 +TEMP_PCCASE_POS=16 +TEMP_GPU_POS=17 + +SYSUPD_POS=20 +SYSSECUPD_POS=21 + +# mount point of vdr video disk +VIDEO_MOUNT="/media/video" + + +# force english output for filters +LANG=en_EN + +# delete all files +rm -f [0-99]* + +if [ $SHOW_SYS_VERSION = 1 ]; then + cat /etc/os-release | grep "PRETTY_NAME=" | cut -d"\"" -f 2 > ./${SYS_VERSION_POS}_sys_version +fi + +if [ $SHOW_KERNEL_VERSION = 1 ]; then + uname -r > ./${KERNEL_VERSION_POS}_kernel_version +fi + +if [ $SHOW_UPTIME = 1 ]; then + uptime | grep -ohe 'up .*' | sed 's/,//g' | awk '{ printf $2" "$3 }' > ./${UPTIME_POS}_uptime +fi + +if [ $SHOW_LOAD = 1 ]; then + cat /proc/loadavg | awk '{print $1}' > ./${LOAD_POS}_load +fi + +if [ $SHOW_PROCESSES = 1 ]; then + ps aux | wc -l > ./${PROCESSES_POS}_processes +fi + +if [ $SHOW_MEM_USAGE = 1 ]; then + free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ { used=$3 } END { printf("%3.1f%%", used/total*100)}' > ./${MEM_USAGE_POS}_mem_usage +fi + +if [ $SHOW_SWAP_USAGE = 1 ]; then + SWAP=`free -m | awk '/Swap/ {print($2)}'` + if [ $SWAP -gt 0 ]; then + free -m | awk '/Swap/ { printf("%3.1f%%", $3/$2*100) }' > ./${SWAP_USAGE_POS}_swap_usage + fi +fi + +if [ $SHOW_ROOT_USAGE = 1 ]; then + df -h / | awk '/\// {print $(NF-1)}' > ./${ROOT_USAGE_POS}_root_usage +fi + +if [ $SHOW_VIDEO_USAGE = 1 ] && [ -d ${VIDEO_MOUNT} ]; then + df -h ${VIDEO_MOUNT} | awk '/\// {print $(NF-1)}' > ./${VIDEO_USAGE_POS}_video_usage +fi + +if [ $SHOW_VDR_CPU_USAGE = 1 ]; then + vdr_pid=`pidof vdr` + if [ $? = 0 ]; then + VALUE=`ps -p ${vdr_pid} -o %cpu | awk 'NR==2{print $0}' | tr -d ' '` + echo "${VALUE}%" > ./${VDR_CPU_USAGE_POS}_vdr_cpu_usage + fi +fi + +if [ $SHOW_VDR_MEM_USAGE = 1 ]; then + vdr_pid=`pidof vdr` + if [ $? = 0 ]; then + VALUE=`ps -p ${vdr_pid} -o %mem | awk 'NR==2{print $0}' | tr -d ' '` + echo "${VALUE}%" > ./${VDR_MEM_USAGE_POS}_vdr_mem_usage + fi +fi + +if [ $SHOW_TEMPERATURES = 1 ]; then + ./../temperatures/temperatures + if [ -f ./cpu ]; then + mv ./cpu ${TEMP_CPU_POS}_cpu + fi + if [ -f ./pccase ]; then + mv ./pccase ${TEMP_PCCASE_POS}_pccase + fi + if [ -f ./gpu ]; then + mv ./gpu ${TEMP_GPU_POS}_gpu + fi +fi + +if [ $SHOW_SYSUPDATES = 1 ]; then + if [ -f ./../system_updatestatus/updates ]; then + cp ./../system_updatestatus/updates ${SYSUPD_POS}_updates + fi + if [ -f ./../system_updatestatus/security_updates ]; then + cp ./../system_updatestatus/security_updates ${SYSSECUPD_POS}_security_updates + fi +fi diff --git a/widgets/system_updatestatus/README b/widgets/system_updatestatus/README new file mode 100644 index 00000000..3bcf7289 --- /dev/null +++ b/widgets/system_updatestatus/README @@ -0,0 +1,8 @@ +This widget provide information about available updates of the system. + +Since the command usually needs long time to execute this is not called from skin flatPlus. +You have to call the command from the system via cron or at system start. +For example call the command from cron.daily. + +The command can provide to output files: "updates" and "security_updates". The file "security_updates" is optional. + diff --git a/widgets/system_updatestatus/system_update_status b/widgets/system_updatestatus/system_update_status new file mode 100755 index 00000000..50bdc037 --- /dev/null +++ b/widgets/system_updatestatus/system_update_status @@ -0,0 +1,17 @@ +#!/bin/bash + +APTCHECK=/usr/lib/update-notifier/apt-check + +rm -f updates security_updates + +if [ ! -f ${APTCHECK} ] +then + exit +fi + +RET=$(${APTCHECK} 2>&1) + +# updates +echo $RET | cut -d";" -f1 > updates +# security updates +echo $RET | cut -d";" -f2 > security_updates diff --git a/widgets/system_updatestatus/system_update_status.ubuntu b/widgets/system_updatestatus/system_update_status.ubuntu new file mode 100755 index 00000000..23f4345a --- /dev/null +++ b/widgets/system_updatestatus/system_update_status.ubuntu @@ -0,0 +1,62 @@ +#!/bin/bash + +# this script must be call from cron +# please add a cron entry for this script +# skin flatPlus only read the file "update_status" + + +rm -f ./update_status + +# lent code from apticron, thank you! + +# Set $DIRCACHE +eval `/usr/bin/apt-config shell DIRCACHE Dir::Cache` + +NOTIFY_HOLDS="0" +NOTIFY_NEW="1" + +# get the list of packages which are pending an upgrade +PKGNAMES=`/usr/bin/apt-get -q -y --ignore-hold --allow-unauthenticated -s dist-upgrade | \ + /bin/grep ^Inst | /usr/bin/cut -d\ -f2 | /usr/bin/sort` + +# creating the future last_run file +TMPFILE="$(mktemp -t apticron.XXXXXXXXXX)" +for p in $PKGNAMES; do + echo $p >> $TMPFILE +done + +# workaround to handle apt-get installing packages hold by aptitude. See #137771. +APTITUDE_HOLDS=`grep "^State: 2" -B 2 /var/lib/aptitude/pkgstates 2>/dev/null |grep "^Package: .*$" |cut -d" " -f 2` +DSELECT_HOLDS=`dpkg --get-selections |grep "hold$" |cut -f1` + +if [ "$NOTIFY_HOLDS" = "0" ]; then + # packages hold by aptitude don't go to the upgrading candidates list + for p in $APTITUDE_HOLDS; do + PKGNAMES=`echo $PKGNAMES |sed "s/\(^\| \)$p\( \|$\)/ /g;s/^ //g"` + done + # packages hold by dselect don't go to the upgrading candidates list + for p in $DSELECT_HOLDS; do + PKGNAMES=`echo $PKGNAMES |sed "s/\(^\| \)$p\( \|$\)/ /g;s/^ //g"` + done +fi + +if [ "$NOTIFY_NEW" = "0" ]; then + # new packages don't go to the upgrading candidates list (see #531002) + for p in $PKGNAMES; do + if [ -z "`dpkg -s $p 2>/dev/null| grep '^Status: install ok installed'`" ] ; then + PKGNAMES=`echo $PKGNAMES |sed "s/\(^\| \)$p\( \|$\)/ /g;s/^ //g"` + fi + done +fi + + +PKGPATH="/${DIRCACHE}archives/" +for PKG in $PKGNAMES ; do + VER=`LC_ALL=C /usr/bin/apt-cache policy $PKG | /bin/grep Candidate: | /usr/bin/cut -f 4 -d \ ` + VERFILE=`echo "$VER" | /bin/sed -e "s/:/%3a/g"` + if ls ${PKGPATH}${PKG}_${VERFILE}_*.deb >& /dev/null ; then + DEBS="$DEBS ${PKGPATH}${PKG}_${VERFILE}_*.deb" + fi + echo $PKG $VER >> ./update_status +done + diff --git a/widgets/temperatures/README b/widgets/temperatures/README new file mode 100644 index 00000000..fc2247a8 --- /dev/null +++ b/widgets/temperatures/README @@ -0,0 +1,7 @@ +This Widget provide information about the system temperatures. + +The command "temperatures" will be executed every time the widget is drawn, so please keep it short and fast. +The command can provide three temperatures: cpu, pc case and gpu temperature +The command can also be called from system information widget. So the output files must also begin with 01_ - 99_ for sort/position. + +Please install lm-sensors and configure it for your system. See the default script for an example. diff --git a/widgets/temperatures/temperatures b/widgets/temperatures/temperatures new file mode 100755 index 00000000..75a35796 --- /dev/null +++ b/widgets/temperatures/temperatures @@ -0,0 +1,22 @@ +#!/bin/bash + +# please update this script to fit your needs +# this script is call every time the widget will be drawn, so keep it short and fast ;) + +# if the script is executed from system_information script set the locale back for "°C" +LANG=de_DE.UTF-8 + +# there can be 3 files, cpu, gpu, case + +rm -f ./cpu ./pccase ./gpu + +# intel core-i cpu temp +sensors -A coretemp-isa-0000 | grep "Core 0" | awk '{print $3}' | tr -d "+" > ./cpu + +# pc case temp +sensors -A acpitz-virtual-0 | grep "temp1" | awk '{print $2}' | tr -d "+" > ./pccase + +# nvidia gpu temp +# nvidia-settings must be run as the user of the x server +GPU=`nvidia-settings -c :0 -t -query GPUCoreTemp | head -n 1` +echo "$GPU°C" > ./gpu |