diff options
author | chriszero <zerov83@gmail.com> | 2015-05-17 21:13:14 +0200 |
---|---|---|
committer | chriszero <zerov83@gmail.com> | 2015-05-17 21:13:14 +0200 |
commit | d15cd5a30174c7864051d42ba58cd31570fc8ed5 (patch) | |
tree | c3f62de9cf1f43ad28864012bbce168f323a3308 | |
parent | 80d1c613e8055567644abab38707378960b5d809 (diff) | |
download | vdr-plugin-plex-d15cd5a30174c7864051d42ba58cd31570fc8ed5.tar.gz vdr-plugin-plex-d15cd5a30174c7864051d42ba58cd31570fc8ed5.tar.bz2 |
...
-rw-r--r-- | Config.cpp | 117 | ||||
-rw-r--r-- | Config.h | 44 | ||||
-rw-r--r-- | Directory.cpp | 7 | ||||
-rw-r--r-- | PVideo.cpp | 9 | ||||
-rw-r--r-- | browserGrid.cpp | 203 | ||||
-rw-r--r-- | browserGrid.h | 10 | ||||
-rw-r--r-- | plex.cpp | 15 | ||||
-rw-r--r-- | plexSdOsd.cpp | 16 | ||||
-rw-r--r-- | plexSdOsd.h | 2 | ||||
-rw-r--r-- | po/de_DE.po | 51 | ||||
-rw-r--r-- | skins/blackhole/xmlfiles/plug-plex-root.xml | 6 | ||||
-rw-r--r-- | templates/plug-plex-root.xml | 3 | ||||
-rw-r--r-- | viewGridNavigator.cpp | 26 | ||||
-rw-r--r-- | viewGridNavigator.h | 9 |
14 files changed, 376 insertions, 142 deletions
@@ -1,11 +1,45 @@ #include "Config.h" +const char* Config::viewModeNames[] +{ + "Cover", + "List", + "Detail" +}; + Config::Config() { s_username = "username"; s_password = "password"; - GridColumns = 7; - GridRows = 2; + CoverGridColumns = 7; + CoverGridRows = 2; + ListGridColumns = 1; + ListGridRows = 12; + DetailGridColumns = 1; + DetailGridRows = 4; + + DefaultViewMode = ViewMode::Cover; + + ViewEntry en; + en.Name = "Recently Added"; + en.PlexPath = "/library/recentlyAdded"; + m_viewentries.push_back(en); + + ViewEntry en2; + en2.Name = "On Deck"; + en2.PlexPath = "/library/onDeck"; + m_viewentries.push_back(en2); + + ViewEntry en3; + en3.Name = "Library"; + en3.PlexPath = "/library/sections"; + m_serverViewentries.push_back(en3); + + ViewEntry en4; + en4.Name = "Video Channels"; + en4.PlexPath = "/video"; + m_serverViewentries.push_back(en4); + } std::string Config::GetUUID() { @@ -45,6 +79,37 @@ std::string Config::GetPassword() { return s_password; } + +bool Config::Parse(const char *name, const char *value) +{ + //dsyslog("[plex]%s: '%s' = '%s'\n", __FUNCTION__, name, value); + bool parsed = true; + if (strcasecmp(name, "HideMainMenuEntry") == 0) Config::GetInstance().HideMainMenuEntry = atoi(value) ? true : false; + else if (strcasecmp(name, "UsePlexAccount") == 0) Config::GetInstance().UsePlexAccount = atoi(value) ? true : false; + else if (strcasecmp(name, "UseCustomTranscodeProfile") == 0) Config::GetInstance().UseCustomTranscodeProfile = atoi(value) ? true : false; + else if (strcasecmp(name, "Username") == 0) Config::GetInstance().s_username = std::string(value); + else if (strcasecmp(name, "Password") == 0) Config::GetInstance().s_password = std::string(value); + else if (strcasecmp(name, "UUID") == 0) Config::GetInstance().SetUUID(value); + else if (strcasecmp(name, "UseConfiguredServer") == 0) Config::GetInstance().UseConfiguredServer = atoi(value) ? true : false; + else if (strcasecmp(name, "ServerHost") == 0) Config::GetInstance().s_serverHost = std::string(value); + else if (strcasecmp(name, "ServerPort") == 0) Config::GetInstance().ServerPort = atoi(value); + else if (strcasecmp(name, "CoverGridColumns") == 0) Config::GetInstance().CoverGridColumns = atoi(value); + else if (strcasecmp(name, "CoverGridRows") == 0) Config::GetInstance().CoverGridRows = atoi(value); + else if (strcasecmp(name, "DetailGridColumns") == 0) Config::GetInstance().DetailGridColumns = atoi(value); + else if (strcasecmp(name, "DetailGridRows") == 0) Config::GetInstance().DetailGridRows = atoi(value); + else if (strcasecmp(name, "ListGridColumns") == 0) Config::GetInstance().ListGridColumns = atoi(value); + else if (strcasecmp(name, "ListGridRows") == 0) Config::GetInstance().ListGridRows = atoi(value); + else parsed = false; + + if(!parsed) { + // Parse ViewEntries + + } + + return parsed; +} + + ////////////////////////////////////////////////////////////////////////////// // cMenuSetupPage ////////////////////////////////////////////////////////////////////////////// @@ -64,7 +129,7 @@ eOSState cMyMenuSetupPage::ProcessKey(eKeys key) */ cMyMenuSetupPage::cMyMenuSetupPage(void) { - strn0cpy(Username, Config::GetInstance().s_username.c_str(), STRING_SIZE); + strn0cpy(Username, Config::GetInstance().s_username.c_str(), STRING_SIZE); strn0cpy(Password, Config::GetInstance().s_password.c_str(), STRING_SIZE); strn0cpy(Uuid, Config::GetInstance().GetUUID().c_str(), STRING_SIZE); strn0cpy(ServerHost, Config::GetInstance().s_serverHost.c_str(), STRING_SIZE); @@ -72,8 +137,16 @@ cMyMenuSetupPage::cMyMenuSetupPage(void) UseConfiguredServer = Config::GetInstance().UseConfiguredServer; HideMainMenuEntry = Config::GetInstance().HideMainMenuEntry; UseCustomTranscodeProfile = Config::GetInstance().UseCustomTranscodeProfile; - GridColumns = Config::GetInstance().GridColumns; - GridRows = Config::GetInstance().GridRows; + UsePlexAccount = Config::GetInstance().UsePlexAccount; + CoverGridColumns = Config::GetInstance().CoverGridColumns; + CoverGridRows = Config::GetInstance().CoverGridRows; + DetailGridColumns = Config::GetInstance().DetailGridColumns; + DetailGridRows = Config::GetInstance().DetailGridRows; + ListGridColumns = Config::GetInstance().ListGridColumns; + ListGridRows = Config::GetInstance().ListGridRows; + + DefaultViewMode = Config::GetInstance().DefaultViewMode; + Add(new cMenuEditBoolItem(tr("Hide main menu entry"), (int*)&HideMainMenuEntry, trVDR("no"), trVDR("yes"))); Add(new cMenuEditBoolItem(tr("Use custom transcoding profile"), (int*)&UseCustomTranscodeProfile, trVDR("no"), trVDR("yes"))); @@ -85,8 +158,16 @@ cMyMenuSetupPage::cMyMenuSetupPage(void) Add(new cMenuEditStrItem(tr("Server Host"), ServerHost, STRING_SIZE)); Add(new cMenuEditIntItem(tr("Server Port"), &ServerPort)); - Add(new cMenuEditIntItem(tr("Grid Columns"), &GridColumns)); - Add(new cMenuEditIntItem(tr("Grid Rows"), &GridRows)); + Add(new cMenuEditStraItem(tr("Default View Mode"), &DefaultViewMode, 3, Config::viewModeNames)); + + Add(new cMenuEditIntItem(tr("Cover Grid Columns"), &CoverGridColumns)); + Add(new cMenuEditIntItem(tr("Cover Grid Rows"), &CoverGridRows)); + + Add(new cMenuEditIntItem(tr("Detail Grid Columns"), &DetailGridColumns)); + Add(new cMenuEditIntItem(tr("Detail Grid Rows"), &DetailGridRows)); + + Add(new cMenuEditIntItem(tr("List Grid Columns"), &ListGridColumns)); + Add(new cMenuEditIntItem(tr("List Grid Rows"), &ListGridRows)); cMenuEditStrItem* devUUID = new cMenuEditStrItem(tr("Current UUID"), Uuid, STRING_SIZE); devUUID->SetSelectable(false); @@ -106,11 +187,16 @@ void cMyMenuSetupPage::Store(void) Config::GetInstance().UseConfiguredServer = UseConfiguredServer; Config::GetInstance().s_serverHost = std::string(ServerHost); Config::GetInstance().ServerPort = ServerPort; - Config::GetInstance().GridColumns = GridColumns; - Config::GetInstance().GridRows = GridRows; + Config::GetInstance().CoverGridColumns = CoverGridColumns; + Config::GetInstance().CoverGridRows = CoverGridRows; + Config::GetInstance().DetailGridColumns = DetailGridColumns; + Config::GetInstance().DetailGridRows = DetailGridRows; + Config::GetInstance().ListGridColumns = ListGridColumns; + Config::GetInstance().ListGridRows = ListGridRows; + Config::GetInstance().DefaultViewMode = (ViewMode)DefaultViewMode; SetupStore("UseCustomTranscodeProfile", Config::GetInstance().UseCustomTranscodeProfile); - SetupStore("HideMainMenuEntry", Config::GetInstance().HideMainMenuEntry); + SetupStore("HideMainMenuEntry", Config::GetInstance().HideMainMenuEntry); SetupStore("UsePlexAccount", Config::GetInstance().UsePlexAccount); SetupStore("Username", Config::GetInstance().s_username.c_str()); SetupStore("Password", Config::GetInstance().s_password.c_str()); @@ -118,6 +204,11 @@ void cMyMenuSetupPage::Store(void) SetupStore("UseConfiguredServer", Config::GetInstance().UseConfiguredServer); SetupStore("ServerHost", Config::GetInstance().s_serverHost.c_str()); SetupStore("ServerPort", Config::GetInstance().ServerPort); - SetupStore("GridColumns", Config::GetInstance().GridColumns); - SetupStore("GridRows", Config::GetInstance().GridRows); -}
\ No newline at end of file + SetupStore("CoverGridColumns", Config::GetInstance().CoverGridColumns); + SetupStore("CoverGridRows", Config::GetInstance().CoverGridRows); + SetupStore("DetailGridColumns", Config::GetInstance().DetailGridColumns); + SetupStore("DetailGridRows", Config::GetInstance().DetailGridRows); + SetupStore("ListGridColumns", Config::GetInstance().ListGridColumns); + SetupStore("ListGridRows", Config::GetInstance().ListGridRows); + SetupStore("DefaultViewMode", Config::GetInstance().DefaultViewMode); +} @@ -4,6 +4,7 @@ #include <Poco/UUID.h> #include <Poco/UUIDGenerator.h> #include <string> +#include <vector> #include <stdio.h> #include <stdlib.h> @@ -15,6 +16,17 @@ #define STRING_SIZE 256 +struct ViewEntry { + std::string Name; + std::string PlexPath; +}; + +enum ViewMode { + Cover = 0, + List = 1, + Detail = 2 +}; + class Config { @@ -23,6 +35,7 @@ public: static Config instance; return instance; } + static const char* viewModeNames[]; std::string s_username; std::string s_password; @@ -33,8 +46,20 @@ public: bool UseCustomTranscodeProfile; bool UsePlexAccount; bool UseConfiguredServer; - int GridColumns; - int GridRows; + + int CoverGridColumns; + int CoverGridRows; + + int ListGridColumns; + int ListGridRows; + + int DetailGridColumns; + int DetailGridRows; + + ViewMode DefaultViewMode; + + std::vector<ViewEntry> m_viewentries; + std::vector<ViewEntry> m_serverViewentries; std::string GetUUID(); void SetUUID(const char* uuid); @@ -42,13 +67,15 @@ public: std::string GetLanguage(); std::string GetUsername(); std::string GetPassword(); - int ThumbHeight() { return 1080 / GridRows; }; - int ThumbWidth() { return 1920 / GridColumns; }; + int ThumbHeight() { return 1080 / CoverGridRows; }; + int ThumbWidth() { return 1920 / CoverGridColumns; }; int ArtHeight() { return 1080; }; int ArtWidth() { return 1920; }; int BannerHeight() { return 1080 / 2; }; int BannerWidth() { return 1920 / 2; }; + bool Parse(const char *name, const char *value); + private: Config(); @@ -76,8 +103,13 @@ class cMyMenuSetupPage:public cMenuSetupPage int HideMainMenuEntry; int UseCustomTranscodeProfile; int UsePlexAccount; - int GridColumns; - int GridRows; + int CoverGridColumns; + int CoverGridRows; + int DetailGridColumns; + int DetailGridRows; + int ListGridColumns; + int ListGridRows; + int DefaultViewMode; virtual void Store(void); diff --git a/Directory.cpp b/Directory.cpp index e09e86d..83a5f22 100644 --- a/Directory.cpp +++ b/Directory.cpp @@ -52,6 +52,7 @@ std::string Directory::GetTitle() void Directory::AddTokens(std::shared_ptr<skindesignerapi::cOsdElement> grid, bool clear, std::function<void(cGridElement*)> OnCached) { if(clear) grid->ClearTokens(); + grid->AddIntToken("viewmode", Config::GetInstance().DefaultViewMode); grid->AddStringToken("title", m_sTitle); grid->AddIntToken("viewgroup", m_pParent->m_eViewGroup); @@ -101,7 +102,8 @@ std::string Directory::ArtUri() { if(!m_sArt.empty()) { if(m_sArt.find("http://") != std::string::npos) return m_sArt; - return m_pServer->GetUri() + m_sArt; + if(m_sArt[0] == '/') return m_pServer->GetUri() + m_sArt; + return m_pServer->GetUri() + '/' + m_sArt; } if(m_pParent) return m_pParent->ArtUri(); return ""; @@ -111,7 +113,8 @@ std::string Directory::ThumbUri() { if(!m_sThumb.empty()) { if(m_sThumb.find("http://") != std::string::npos) return m_sThumb; - return m_pServer->GetUri() + m_sThumb; + if(m_sThumb[0] == '/') return m_pServer->GetUri() + m_sThumb; + return m_pServer->GetUri() + '/' + m_sThumb; } if(m_pParent) return m_pParent->ThumbUri(); return ""; @@ -214,6 +214,7 @@ bool Video::SetWatched() void Video::AddTokens(std::shared_ptr<skindesignerapi::cOsdElement> grid, bool clear, std::function<void(cGridElement*)> OnCached) { if(clear) grid->ClearTokens(); + grid->AddIntToken("viewmode", Config::GetInstance().DefaultViewMode); grid->AddStringToken("title", m_sTitle); grid->AddStringToken("orginaltitle", m_sOriginalTitle); grid->AddStringToken("summary", m_sSummary); @@ -273,20 +274,22 @@ void Video::AddTokens(std::shared_ptr<skindesignerapi::cOsdElement> grid, bool c } } } - + m_Media.AddTokens(grid); } std::string Video::ArtUri() { if(m_sArt.find("http://") != std::string::npos) return m_sArt; - return m_pServer->GetUri() + m_sArt; + if(m_sArt[0] == '/') return m_pServer->GetUri() + m_sArt; + return m_pServer->GetUri() + '/' + m_sArt; } std::string Video::ThumbUri() { if(m_sThumb.find("http://") != std::string::npos) return m_sThumb; - return m_pServer->GetUri() + m_sThumb; + if(m_sThumb[0] == '/') return m_pServer->GetUri() + m_sThumb; + return m_pServer->GetUri() + '/' + m_sThumb; } } // Namespace diff --git a/browserGrid.cpp b/browserGrid.cpp index 2b990e8..e336fee 100644 --- a/browserGrid.cpp +++ b/browserGrid.cpp @@ -9,17 +9,18 @@ cBrowserGrid::cBrowserGrid(skindesignerapi::cOsdView* rootView) : cViewGridNavigator(rootView, rootView->GetViewGrid(eViewGrids::vgBrowser) ) { m_pBackground = std::shared_ptr<skindesignerapi::cViewElement>(rootView->GetViewElement(eViewElementsRoot::verBackground)); - m_pViewHeader = std::shared_ptr<cViewHeader>( new cViewHeader(rootView->GetViewElement(eViewElementsRoot::verHeader))); + //m_pViewHeader = std::shared_ptr<cViewHeader>( new cViewHeader(rootView->GetViewElement(eViewElementsRoot::verHeader))); + m_pHeader = std::shared_ptr<skindesignerapi::cViewElement>(rootView->GetViewElement(eViewElementsRoot::verHeader)); m_pfooter = std::shared_ptr<skindesignerapi::cViewElement>(rootView->GetViewElement(eViewElementsRoot::verFooter)); m_pInfopane = std::shared_ptr<skindesignerapi::cViewElement>(rootView->GetViewElement(eViewElementsRoot::verInfopane)); m_pWatch = std::shared_ptr<skindesignerapi::cViewElement>(rootView->GetViewElement(eViewElementsRoot::verWatch)); m_lastsecond = 0; - m_rows = Config::GetInstance().GridRows; - m_columns = Config::GetInstance().GridColumns; m_pService = NULL; m_pContainer = NULL; - SwitchGrid(m_pViewHeader->CurrentTab()); + m_viewEntryIndex = 0; + SwitchGrid(m_viewEntryIndex); + SwitchView(); } cBrowserGrid::~cBrowserGrid() @@ -37,8 +38,8 @@ void cBrowserGrid::Clear() m_pGrid->Clear(); } -void cBrowserGrid::Flush() -{ +void cBrowserGrid::Flush() +{ cMutexLock MutexLock(&cPlexSdOsd::RedrawMutex); m_pBackground->Display(); m_pInfopane->Display(); @@ -46,31 +47,73 @@ void cBrowserGrid::Flush() m_pRootView->Display(); } -void cBrowserGrid::SwitchGrid(ePlexMenuTab currentTab) +void cBrowserGrid::SwitchView(ViewMode mode) +{ + Config *conf = &Config::GetInstance(); + conf->DefaultViewMode = mode; + if(conf->DefaultViewMode == ViewMode::Cover) { + SetGridDimensions(conf->CoverGridRows, conf->CoverGridColumns); + } else if(conf->DefaultViewMode == ViewMode::Detail) { + SetGridDimensions(conf->DetailGridRows, conf->DetailGridColumns); + } else if(conf->DefaultViewMode == ViewMode::List) { + SetGridDimensions(conf->ListGridRows, conf->ListGridColumns); + } + + int activePos = SelectedObject()->AbsolutePosition; + //ProcessData(); + + for(std::vector<cGridElement*>::iterator it = m_vElements.begin(); it != m_vElements.end(); ++it) { + cGridElement *elem = *it; + elem->Position = -1; + elem->Dirty(); + elem->SetPosition(-1,-1); + } + + m_pGrid->Clear(); + m_firstElementIter = m_vElements.begin() + activePos; + m_setIterator = true; + FilterElements(0); +} + +void cBrowserGrid::NextViewMode() +{ + ViewMode mode = Config::GetInstance().DefaultViewMode; + if(mode == ViewMode::Cover) { + mode = ViewMode::Detail; + } else if(mode == ViewMode::Detail) { + mode = ViewMode::List; + } else if(mode == ViewMode::List) { + mode = ViewMode::Cover; + } + SwitchView(mode); +} + +void cBrowserGrid::SwitchGrid(int index) { cPictureCache::GetInstance().RemoveAll(); - if(currentTab == ePlexMenuTab::pmtOnDeck) { - m_pService = std::shared_ptr<plexclient::Plexservice>(new plexclient::Plexservice( plexclient::plexgdm::GetInstance().GetFirstServer(), "/library/onDeck" ) ); - m_pContainer = m_pService->GetSection(m_pService->StartUri); - m_bServersAreRoot = false; - m_vServerElements.clear(); - ProcessData(); - } else if(currentTab == ePlexMenuTab::pmtRecentlyAdded) { - m_pService = std::shared_ptr<plexclient::Plexservice>(new plexclient::Plexservice( plexclient::plexgdm::GetInstance().GetFirstServer(), "/library/recentlyAdded" ) ); + m_pHeader->Clear(); + m_pHeader->ClearTokens(); + + if(m_viewEntryIndex < Config::GetInstance().m_viewentries.size()) { + ViewEntry entry = Config::GetInstance().m_viewentries[index]; + m_pHeader->AddStringToken("tabname", tr(entry.Name.c_str())); + m_pService = std::shared_ptr<plexclient::Plexservice>(new plexclient::Plexservice( plexclient::plexgdm::GetInstance().GetFirstServer(), entry.PlexPath ) ); m_pContainer = m_pService->GetSection(m_pService->StartUri); m_bServersAreRoot = false; m_vServerElements.clear(); - ProcessData(); - - } else if(currentTab == ePlexMenuTab::pmtLibrary) { + } else { //Server View + m_pHeader->AddStringToken("tabname", tr("Library")); m_pService = NULL; m_pContainer = NULL; m_bServersAreRoot = true; SetServerElements(); - ProcessData(); } + + ProcessData(); + + SelectedObject()->AddTokens(m_pHeader, false); } void cBrowserGrid::SetServerElements() @@ -78,8 +121,9 @@ void cBrowserGrid::SetServerElements() m_vServerElements.clear(); for(std::vector<plexclient::PlexServer>::iterator it = plexclient::plexgdm::GetInstance().GetPlexservers().begin(); it != plexclient::plexgdm::GetInstance().GetPlexservers().end(); ++it) { - m_vServerElements.push_back(cServerElement(&(*it), "/library/sections", "Bibliothek")); - m_vServerElements.push_back(cServerElement(&(*it), "/video", "Video Channels")); + for(std::vector<ViewEntry>::iterator vEntry = Config::GetInstance().m_serverViewentries.begin(); vEntry != Config::GetInstance().m_serverViewentries.end(); ++vEntry) { + m_vServerElements.push_back(cServerElement(&(*it), vEntry->PlexPath, vEntry->Name)); + } } } @@ -111,7 +155,13 @@ void cBrowserGrid::ProcessData() } } } - + + int pos = 0; + for(std::vector<cGridElement*>::iterator it = m_vElements.begin(); it != m_vElements.end(); ++it) { + cGridElement *elem = *it; + elem->AbsolutePosition = pos++; + } + m_firstElementIter = m_vElements.begin(); m_pGrid->Clear(); @@ -164,7 +214,7 @@ eOSState cBrowserGrid::NavigateBack() void cBrowserGrid::DrawGrid() { DrawBackground(); - m_pViewHeader->Draw(SelectedObject()); + m_pHeader->Display(); DrawInfopane(); DrawFooter(); } @@ -172,8 +222,9 @@ void cBrowserGrid::DrawGrid() void cBrowserGrid::DrawBackground() { m_pBackground->ClearTokens(); - - if(auto video = dynamic_cast<plexclient::Video*>(SelectedObject()) ) { + + auto video = dynamic_cast<plexclient::Video*>(SelectedObject()); + if(video) { bool cached = false; std::string path = cPictureCache::GetInstance().GetPath(video->ArtUri(), 1920, 1080, cached); m_pBackground->AddStringToken("selecteditembackground", path); @@ -181,6 +232,7 @@ void cBrowserGrid::DrawBackground() m_pBackground->AddIntToken("isdirectory", 1); m_pBackground->AddStringToken("currentdirectorybackground", "/path"); + m_pBackground->AddIntToken("viewmode", Config::GetInstance().DefaultViewMode); } void cBrowserGrid::DrawInfopane() @@ -193,11 +245,21 @@ void cBrowserGrid::DrawFooter() { //if (!active) // return; + cString nextTab = "Library"; + if(m_viewEntryIndex + 1 < Config::GetInstance().m_viewentries.size()) { + nextTab = Config::GetInstance().m_viewentries[m_viewEntryIndex + 1].Name.c_str(); + } else if(m_viewEntryIndex + 1 == Config::GetInstance().m_viewentries.size() + 1) { + nextTab = Config::GetInstance().m_viewentries[0].Name.c_str(); + } + cString prevTab = "Library"; + if(m_viewEntryIndex - 1 >= 0) { + prevTab = Config::GetInstance().m_viewentries[m_viewEntryIndex - 1].Name.c_str(); + } - string textGreen = tr("Prev. Tab"); - string textYellow = tr("Next Tab"); + string textGreen = tr(prevTab); + string textYellow = tr(nextTab); string textRed = ""; - string textBlue = ""; + string textBlue = tr("Switch View"); if(auto vid = dynamic_cast<plexclient::Video*>(SelectedObject()) ) { if(vid->m_iViewCount > 0) textRed = tr("Unscrobble"); @@ -251,49 +313,58 @@ void cBrowserGrid::DrawFooter() void cBrowserGrid::NextTab() { - SwitchGrid(m_pViewHeader->NextTab()); + m_viewEntryIndex++; + if(m_viewEntryIndex > Config::GetInstance().m_viewentries.size()) { + m_viewEntryIndex = 0; + } + SwitchGrid(m_viewEntryIndex); } void cBrowserGrid::PrevTab() { - SwitchGrid(m_pViewHeader->PrevTab()); + m_viewEntryIndex--; + if(m_viewEntryIndex < 0) { + m_viewEntryIndex = Config::GetInstance().m_viewentries.size(); + } + SwitchGrid(m_viewEntryIndex); } -bool cBrowserGrid::DrawTime() { - time_t t = time(0); // get time now - struct tm * now = localtime(&t); - int sec = now->tm_sec; - if (sec == m_lastsecond) - return false; - - int min = now->tm_min; - int hour = now->tm_hour; - int hourMinutes = hour%12 * 5 + min / 12; - - char monthname[20]; - char monthshort[10]; - strftime(monthshort, sizeof(monthshort), "%b", now); - strftime(monthname, sizeof(monthname), "%B", now); - - m_pWatch->Clear(); - m_pWatch->ClearTokens(); - m_pWatch->AddIntToken("sec", sec); - m_pWatch->AddIntToken("min", min); - m_pWatch->AddIntToken("hour", hour); - m_pWatch->AddIntToken("hmins", hourMinutes); - m_pWatch->AddIntToken("year", now->tm_year + 1900); - m_pWatch->AddIntToken("day", now->tm_mday); - m_pWatch->AddStringToken("time", *TimeString(t)); - m_pWatch->AddStringToken("monthname", monthname); - m_pWatch->AddStringToken("monthnameshort", monthshort); - m_pWatch->AddStringToken("month", *cString::sprintf("%02d", now->tm_mon + 1)); - m_pWatch->AddStringToken("dayleadingzero", *cString::sprintf("%02d", now->tm_mday)); - m_pWatch->AddStringToken("dayname", *WeekDayNameFull(now->tm_wday)); - m_pWatch->AddStringToken("daynameshort", *WeekDayName(now->tm_wday)); - m_pWatch->Display(); - - m_lastsecond = sec; - return true; +bool cBrowserGrid::DrawTime() +{ + time_t t = time(0); // get time now + struct tm * now = localtime(&t); + int sec = now->tm_sec; + if (sec == m_lastsecond) + return false; + + int min = now->tm_min; + int hour = now->tm_hour; + int hourMinutes = hour%12 * 5 + min / 12; + + char monthname[20]; + char monthshort[10]; + strftime(monthshort, sizeof(monthshort), "%b", now); + strftime(monthname, sizeof(monthname), "%B", now); + + m_pWatch->Clear(); + m_pWatch->ClearTokens(); + m_pWatch->AddIntToken("sec", sec); + m_pWatch->AddIntToken("min", min); + m_pWatch->AddIntToken("hour", hour); + m_pWatch->AddIntToken("hmins", hourMinutes); + m_pWatch->AddIntToken("year", now->tm_year + 1900); + m_pWatch->AddIntToken("day", now->tm_mday); + m_pWatch->AddStringToken("time", *TimeString(t)); + m_pWatch->AddStringToken("monthname", monthname); + m_pWatch->AddStringToken("monthnameshort", monthshort); + m_pWatch->AddStringToken("month", *cString::sprintf("%02d", now->tm_mon + 1)); + m_pWatch->AddStringToken("dayleadingzero", *cString::sprintf("%02d", now->tm_mday)); + m_pWatch->AddStringToken("dayname", *WeekDayNameFull(now->tm_wday)); + m_pWatch->AddStringToken("daynameshort", *WeekDayName(now->tm_wday)); + m_pWatch->Display(); + + m_lastsecond = sec; + return true; } /* @@ -305,6 +376,7 @@ void cDummyElement::AddTokens(std::shared_ptr<skindesignerapi::cOsdElement> grid if(clear) grid->ClearTokens(); grid->AddIntToken("isdummy", 1); grid->AddStringToken("title", "../"); + grid->AddIntToken("viewmode", Config::GetInstance().DefaultViewMode); } std::string cDummyElement::GetTitle() @@ -332,6 +404,7 @@ void cServerElement::AddTokens(std::shared_ptr<skindesignerapi::cOsdElement> gri grid->AddStringToken("serverip", m_pServer->GetIpAdress()); grid->AddIntToken("serverport", m_pServer->GetPort()); grid->AddStringToken("serverversion", m_pServer->GetVersion()); + grid->AddIntToken("viewmode", Config::GetInstance().DefaultViewMode); } std::string cServerElement::GetTitle() diff --git a/browserGrid.h b/browserGrid.h index a875149..b337a0b 100644 --- a/browserGrid.h +++ b/browserGrid.h @@ -8,7 +8,7 @@ #include "plexgdm.h" #include "PlexServer.h" #include "viewGridNavigator.h" -#include "viewHeader.h" +//#include "viewHeader.h" #include <libskindesignerapi/osdelements.h> class cDummyElement : public cGridElement @@ -35,13 +35,15 @@ public: class cBrowserGrid : public cViewGridNavigator { private: - std::shared_ptr<cViewHeader> m_pViewHeader; + //std::shared_ptr<cViewHeader> m_pViewHeader; + std::shared_ptr<skindesignerapi::cViewElement> m_pHeader; std::shared_ptr<skindesignerapi::cViewElement> m_pBackground; std::shared_ptr<skindesignerapi::cViewElement> m_pfooter; std::shared_ptr<skindesignerapi::cViewElement> m_pInfopane; std::shared_ptr<skindesignerapi::cViewElement> m_pScrollbar; std::shared_ptr<skindesignerapi::cViewElement> m_pWatch; int m_lastsecond; + int m_viewEntryIndex; bool m_bServersAreRoot; std::vector<cServerElement> m_vServerElements; @@ -62,7 +64,9 @@ public: std::shared_ptr<plexclient::MediaContainer> MediaContainer() { return m_pContainer; } void DrawGrid(); - void SwitchGrid(ePlexMenuTab currentTab); + void SwitchGrid(int index); + void SwitchView(ViewMode mode = Config::GetInstance().DefaultViewMode); + void NextViewMode(); virtual eOSState NavigateSelect(); virtual eOSState NavigateBack(); void NextTab(); @@ -154,20 +154,7 @@ bool cMyPlugin::SetupParse(const char *name, const char *value) { //dsyslog("[plex]%s: '%s' = '%s'\n", __FUNCTION__, name, value); - if (strcasecmp(name, "HideMainMenuEntry") == 0) Config::GetInstance().HideMainMenuEntry = atoi(value) ? true : false; - else if (strcasecmp(name, "UsePlexAccount") == 0) Config::GetInstance().UsePlexAccount = atoi(value) ? true : false; - else if (strcasecmp(name, "UseCustomTranscodeProfile") == 0) Config::GetInstance().UseCustomTranscodeProfile = atoi(value) ? true : false; - else if (strcasecmp(name, "Username") == 0) Config::GetInstance().s_username = std::string(value); - else if (strcasecmp(name, "Password") == 0) Config::GetInstance().s_password = std::string(value); - else if (strcasecmp(name, "UUID") == 0) Config::GetInstance().SetUUID(value); - else if (strcasecmp(name, "UseConfiguredServer") == 0) Config::GetInstance().UseConfiguredServer = atoi(value) ? true : false; - else if (strcasecmp(name, "ServerHost") == 0) Config::GetInstance().s_serverHost = std::string(value); - else if (strcasecmp(name, "ServerPort") == 0) Config::GetInstance().ServerPort = atoi(value); - else if (strcasecmp(name, "GridColumns") == 0) Config::GetInstance().GridColumns = atoi(value); - else if (strcasecmp(name, "GridRows") == 0) Config::GetInstance().GridRows = atoi(value); - else return false; - - return true; + return Config::GetInstance().Parse(name, value); } /** diff --git a/plexSdOsd.cpp b/plexSdOsd.cpp index 27f8157..a8dbdf2 100644 --- a/plexSdOsd.cpp +++ b/plexSdOsd.cpp @@ -86,20 +86,16 @@ eOSState cPlexSdOsd::ProcessKey(eKeys Key) switch (Key & ~k_Repeat) { case kUp: - m_pBrowserGrid->NavigateUp(); - Flush(); + if(m_pBrowserGrid->NavigateUp()) Flush(); break; case kDown: - m_pBrowserGrid->NavigateDown(); - Flush(); + if(m_pBrowserGrid->NavigateDown()) Flush(); break; case kLeft: - m_pBrowserGrid->NavigateLeft(); - Flush(); + if(m_pBrowserGrid->NavigateLeft()) Flush(); break; case kRight: - m_pBrowserGrid->NavigateRight(); - Flush(); + if(m_pBrowserGrid->NavigateRight()) Flush(); break; case kOk: // Play movie or change dir @@ -110,6 +106,10 @@ eOSState cPlexSdOsd::ProcessKey(eKeys Key) state = m_pBrowserGrid->NavigateBack(); Flush(); break; + case kBlue: + m_pBrowserGrid->NextViewMode(); + Flush(); + break; case kRed: if(vid) { if(vid->m_iViewCount > 0) vid->SetUnwatched(); diff --git a/plexSdOsd.h b/plexSdOsd.h index dc33160..706ee33 100644 --- a/plexSdOsd.h +++ b/plexSdOsd.h @@ -54,7 +54,7 @@ private: skindesignerapi::cOsdView* m_pRootView; void Flush(); - void SwitchGrid(ePlexMenuTab currentTab); + //void SwitchGrid(ePlexMenuTab currentTab); void DrawBackground(); void DrawFooter(); void DrawMessage(std::string message); diff --git a/po/de_DE.po b/po/de_DE.po index 9c82233..4f2d4f5 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-plex 0.1.0\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2015-05-03 17:16+0200\n" -"PO-Revision-Date: 2015-05-03 17:17+0200\n" +"POT-Creation-Date: 2015-05-17 20:27+0200\n" +"PO-Revision-Date: 2015-05-17 20:51+0200\n" "Last-Translator: Chris <zerov83@gmail.com>\n" "Language-Team: LANGUAGE <LL@li.org>\n" "Language: de\n" @@ -18,11 +18,11 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Virtaal 0.7.1\n" -msgid "Prev. Tab" -msgstr "Letzter Tab" +msgid "Library" +msgstr "Bibliothek" -msgid "Next Tab" -msgstr "Nächster Tab" +msgid "Switch View" +msgstr "Ansicht wechseln" msgid "Unscrobble" msgstr "Ungesehen" @@ -54,11 +54,26 @@ msgstr "Server Hostname/IP" msgid "Server Port" msgstr "Server Port" -msgid "Grid Columns" -msgstr "Raster Spalten" +msgid "Default View Mode" +msgstr "Standard Anzeige Modus" + +msgid "Cover Grid Columns" +msgstr "Spalten im Plakate Modus" + +msgid "Cover Grid Rows" +msgstr "Reihen im Plakate Modus" + +msgid "Detail Grid Columns" +msgstr "Spalten im Detail Modus" + +msgid "Detail Grid Rows" +msgstr "Reihen im Detail Modus" + +msgid "List Grid Columns" +msgstr "Spalten im Listen Modus" -msgid "Grid Rows" -msgstr "Raster Reihen" +msgid "List Grid Rows" +msgstr "Reihen im Listen Modus" msgid "Current UUID" msgstr "Aktuelle UUID" @@ -114,8 +129,7 @@ msgstr "Durchsuche Plex" #, c-format msgid "'Ok' to start from %ld minutes, 'Back' to start from beginning." -msgstr "" -"'Ok' um von %ld weiter zu schauen, 'Zurück' um von Beginn an zu starten." +msgstr "'Ok' um von %ld weiter zu schauen, 'Zurück' um von Beginn an zu starten." msgid "All Movies" msgstr "Alle Filme" @@ -192,5 +206,14 @@ msgstr "Kürzlich angesehene Folgen" msgid "Recently Viewed Shows" msgstr "Kürzlich angesehene Serien" -msgid "Library" -msgstr "Bibliothek" +#~ msgid "Grid Columns" +#~ msgstr "Raster Spalten" + +#~ msgid "Grid Rows" +#~ msgstr "Raster Reihen" + +#~ msgid "Prev. Tab" +#~ msgstr "Letzter Tab" + +#~ msgid "Next Tab" +#~ msgstr "Nächster Tab" diff --git a/skins/blackhole/xmlfiles/plug-plex-root.xml b/skins/blackhole/xmlfiles/plug-plex-root.xml index 64cbf60..05da2b7 100644 --- a/skins/blackhole/xmlfiles/plug-plex-root.xml +++ b/skins/blackhole/xmlfiles/plug-plex-root.xml @@ -35,6 +35,7 @@ </viewelement> <!-- Tokens available in background + {viewmode} int: enum Cover = 0, List = 1, Detail = 2 {selecteditembackground} image {isdirectory} @@ -52,9 +53,7 @@ <viewelement name="header"> <area layer="2" x="0" y="0" width="100%" height="15%"> <drawtext x="1%" y="5%" width="98%" font="{light}" fontsize="30%" color="{clrWhite}" text="Plex for VDR" /> - <drawtext condition="{istab1active}" x="1%" y="20%" width="98%" font="{light}" fontsize="30%" color="{clrWhite}" text="{tab1name}" /> - <drawtext condition="{istab2active}" x="1%" y="20%" width="98%" font="{light}" fontsize="30%" color="{clrWhite}" text="{tab2name}" /> - <drawtext condition="{istab3active}" x="1%" y="20%" width="98%" font="{light}" fontsize="30%" color="{clrWhite}" text="{tab3name}" /> + <drawtext x="1%" y="20%" width="98%" font="{light}" fontsize="30%" color="{clrWhite}" text="{tabname}" /> <drawimage condition="{hasbanner}" imagetype="image" path="{banner}" x="50%" y="5%" width="50%" height="90%" /> </area> </viewelement> @@ -71,6 +70,7 @@ </viewelement> <!-- Tokens available in browser + {viewmode} int: enum Cover = 0, List = 1, Detail = 2 {current} bool, currently active element {title} string, Name of the element {viewgroup} int: {UNDEF = 0, MOVIE = 1, SHOW = 2, SEASON = 3, EPISODE = 4, MUSIC, PHOTO}; diff --git a/templates/plug-plex-root.xml b/templates/plug-plex-root.xml index 506449e..e6be997 100644 --- a/templates/plug-plex-root.xml +++ b/templates/plug-plex-root.xml @@ -28,6 +28,7 @@ </viewelement> <!-- Tokens available in background + {viewmode} int: enum Cover = 0, List = 1, Detail = 2 {selecteditembackground} image {isdirectory} @@ -38,6 +39,7 @@ <!-- Tokens available in header and infopane Same as in browser + {tabname} Name of active Tab --> <viewelement name="header"> </viewelement> @@ -46,6 +48,7 @@ </viewelement> <!-- Tokens available in browser + {viewmode} int: enum Cover = 0, List = 1, Detail = 2 {current} bool, currently active element {title} string, Name of the element {viewgroup} int: {UNDEF = 0, MOVIE = 1, SHOW = 2, SEASON = 3, EPISODE = 4, MUSIC, PHOTO}; diff --git a/viewGridNavigator.cpp b/viewGridNavigator.cpp index 91d7540..938b49d 100644 --- a/viewGridNavigator.cpp +++ b/viewGridNavigator.cpp @@ -73,6 +73,7 @@ void cViewGridNavigator::FilterElements(int scrollOffset) std::vector<cGridElement*>::iterator begin = m_firstElementIter + startOffset; std::vector<cGridElement*>::iterator end = m_firstElementIter + endOffset; + if(begin < m_vElements.begin()) begin = m_vElements.begin(); if(end > m_vElements.end()) end = m_vElements.end(); int pos = 0; @@ -113,6 +114,9 @@ void cViewGridNavigator::SetGridElementData(cGridElement *obj) obj->AddTokens(m_pGrid, true, std::bind(&cViewGridNavigator::ReDraw, this, std::placeholders::_1)); m_pGrid->SetGrid(obj->GridElementId(), x, y, width, height); obj->InitFinished(); + // set GridDimensions + m_pGrid->AddIntToken("columns", m_columns); + m_pGrid->AddIntToken("rows", m_rows); } else { obj->SetPosition(x, y); m_pGrid->MoveGrid(obj->GridElementId(), x, y, width, height); @@ -126,10 +130,12 @@ void cViewGridNavigator::SetGridDimensions(int rows, int columns) m_newDimensions = true; } -void cViewGridNavigator::NavigateDown() +bool cViewGridNavigator::NavigateDown() { - if(m_activeElementIter + m_columns >= m_vElements.end()) return; + if (m_activeElementIter == m_vElements.end() - 1) return false; auto next = m_activeElementIter + m_columns; + if(next >= m_vElements.end()) next = m_vElements.end()-1; + // scroll down? if(!(*next)->IsVisible()) { FilterElements(m_columns); @@ -138,12 +144,15 @@ void cViewGridNavigator::NavigateDown() m_pGrid->SetCurrent((*m_activeElementIter)->GridElementId(), false); m_pGrid->SetCurrent((*next)->GridElementId(), true); m_activeElementIter = next; + return true; } -void cViewGridNavigator::NavigateUp() +bool cViewGridNavigator::NavigateUp() { - if(m_activeElementIter - m_columns < m_vElements.begin()) return; + if (m_activeElementIter == m_vElements.begin()) return false; auto next = m_activeElementIter - m_columns; + if(next < m_vElements.begin()) next = m_vElements.begin(); + //scroll up? if(!(*next)->IsVisible()) { FilterElements(-m_columns); @@ -152,10 +161,12 @@ void cViewGridNavigator::NavigateUp() m_pGrid->SetCurrent((*m_activeElementIter)->GridElementId(), false); m_pGrid->SetCurrent((*next)->GridElementId(), true); m_activeElementIter = next; + return true; } -void cViewGridNavigator::NavigateLeft() +bool cViewGridNavigator::NavigateLeft() { + if (m_activeElementIter == m_vElements.begin()) return false; auto next = m_activeElementIter - 1; if(next < m_vElements.begin()) next = m_vElements.begin(); @@ -168,10 +179,12 @@ void cViewGridNavigator::NavigateLeft() m_pGrid->SetCurrent((*m_activeElementIter)->GridElementId(), false); m_pGrid->SetCurrent((*next)->GridElementId(), true); m_activeElementIter = next; + return true; } -void cViewGridNavigator::NavigateRight() +bool cViewGridNavigator::NavigateRight() { + if (m_activeElementIter == m_vElements.end() - 1) return false; auto next = m_activeElementIter + 1; if(next >= m_vElements.end()) next = m_vElements.end()-1; @@ -182,4 +195,5 @@ void cViewGridNavigator::NavigateRight() m_pGrid->SetCurrent((*m_activeElementIter)->GridElementId(), false); m_pGrid->SetCurrent((*next)->GridElementId(), true); m_activeElementIter = next; + return true; } diff --git a/viewGridNavigator.h b/viewGridNavigator.h index 41b1f2b..3d82eca 100644 --- a/viewGridNavigator.h +++ b/viewGridNavigator.h @@ -29,6 +29,7 @@ public: void GetPosition(double &x, double &y) { x = m_posX; y = m_posY; }; virtual void AddTokens(std::shared_ptr<skindesignerapi::cOsdElement> osdElem, bool clear = true, std::function<void(cGridElement*)> OnCached = NULL) = 0; int Position; + int AbsolutePosition; }; class cViewGridNavigator @@ -56,10 +57,10 @@ public: void SetGridDimensions(int rows, int columns); virtual void Flush() { m_pGrid->Display(); }; virtual void Clear() { m_pGrid->Clear(); }; - virtual void NavigateLeft(); - virtual void NavigateRight(); - virtual void NavigateUp(); - virtual void NavigateDown(); + virtual bool NavigateLeft(); + virtual bool NavigateRight(); + virtual bool NavigateUp(); + virtual bool NavigateDown(); virtual eOSState NavigateSelect() = 0; virtual eOSState NavigateBack() = 0; virtual void ReDraw(cGridElement* element); |