From fd1ba8df97a73552a8bde706514a60c88362cac5 Mon Sep 17 00:00:00 2001 From: martii Date: Sun, 17 Nov 2013 10:48:04 +0100 Subject: [PATCH] gui/moviebrowser: add gui options for yt/nk cache directories Conflicts: src/gui/moviebrowser.cpp src/system/nkparser.cpp src/system/nkparser.h --- data/locale/deutsch.locale | 1 + data/locale/english.locale | 1 + src/gui/moviebrowser.cpp | 17 +++++++++++------ src/gui/moviebrowser.h | 1 + src/system/locals.h | 1 + src/system/locals_intern.h | 1 + src/system/ytparser.cpp | 5 +++++ src/system/ytparser.h | 1 + 8 files changed, 22 insertions(+), 6 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 05bc5f84e..d41ffe6b9 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -1491,6 +1491,7 @@ moviebrowser.browser_row_head Spalten Einstellungen moviebrowser.browser_row_item Spalteninfo moviebrowser.browser_row_nr Anzahl Spalten moviebrowser.browser_row_width Spaltenbreite [% der Gesamtbreite] +moviebrowser.cache_dir Cache-Verzeichnis moviebrowser.delete_info Lösche Dateien, bitte warten... moviebrowser.dir Pfad moviebrowser.dir_head Zusätzliche Verzeichnisse diff --git a/data/locale/english.locale b/data/locale/english.locale index afb0234e7..28b0d41c3 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -1491,6 +1491,7 @@ moviebrowser.browser_row_head Row settings moviebrowser.browser_row_item Row item moviebrowser.browser_row_nr Number of rows moviebrowser.browser_row_width Row width (% of screenwidth) +moviebrowser.cache_dir Cache directory moviebrowser.delete_info Delete files, please wait... moviebrowser.dir Path moviebrowser.dir_head Additional paths diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 743b22154..82edf4d8d 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -797,6 +797,7 @@ bool CMovieBrowser::loadSettings(MB_SETTINGS* settings) settings->ytconcconn = configfile.getInt32("mb_ytconcconn", 4); // concurrent connections settings->ytregion = configfile.getString("mb_ytregion", "default"); settings->ytsearch = configfile.getString("mb_ytsearch", ""); + settings->ytthumbnaildir = configfile.getString("mb_ytthumbnaildir", "/tmp/ytparser"); settings->ytvid = configfile.getString("mb_ytvid", ""); settings->ytsearch_history_max = configfile.getInt32("mb_ytsearch_history_max", 10); settings->ytsearch_history_size = configfile.getInt32("mb_ytsearch_history_size", 0); @@ -860,6 +861,7 @@ bool CMovieBrowser::saveSettings(MB_SETTINGS* settings) configfile.setInt32("mb_ytconcconn", settings->ytconcconn); configfile.setString("mb_ytregion", settings->ytregion); configfile.setString("mb_ytsearch", settings->ytsearch); + configfile.setString("mb_ytthumbnaildir", settings->ytthumbnaildir); configfile.setString("mb_ytvid", settings->ytvid); settings->ytsearch_history_size = settings->ytsearch_history.size(); @@ -3689,6 +3691,7 @@ void CMovieBrowser::loadYTitles(int mode, std::string search, std::string id) ytparser.SetMaxResults(m_settings.ytresults); ytparser.SetConcurrentDownloads(m_settings.ytconcconn); + ytparser.SetThumbnailDir(m_settings.ytthumbnaildir); if (!ytparser.Parsed() || (ytparser.GetFeedMode() != mode)) { if (ytparser.ParseFeed((cYTFeedParser::yt_feed_mode_t)mode, search, id, (cYTFeedParser::yt_feed_orderby_t)m_settings.ytorderby)) { @@ -3981,6 +3984,8 @@ bool CMovieBrowser::showYTMenu() mainMenu.addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_YT_PREF_QUALITY, &m_settings.ytquality, YT_QUALITY_OPTIONS, YT_QUALITY_OPTION_COUNT, true, NULL, CRCInput::RC_nokey, "", true)); mainMenu.addItem(new CMenuOptionNumberChooser(LOCALE_MOVIEBROWSER_YT_CONCURRENT_CONNECTIONS, &m_settings.ytconcconn, true, 1, 8)); + CFileChooser fc(&m_settings.ytthumbnaildir); + mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_CACHE_DIR, true, m_settings.ytthumbnaildir, &fc)); yt_menue = &mainMenu; yt_menue_end = yt_menue->getItemsCount(); @@ -3992,6 +3997,8 @@ bool CMovieBrowser::showYTMenu() mainMenu.exec(NULL, ""); ytparser.SetConcurrentDownloads(m_settings.ytconcconn); + ytparser.SetThumbnailDir(m_settings.ytthumbnaildir); + delete selector; bool reload = false; @@ -4158,13 +4165,11 @@ int CFileChooser::exec(CMenuTarget* parent, const std::string & /*actionKey*/) CFileBrowser browser; browser.Dir_Mode=true; - if (browser.exec(dirPath->c_str())) - { + std::string oldPath = *dirPath; + if (browser.exec(dirPath->c_str())) { *dirPath = browser.getSelectedFile()->Name; - short a = dirPath->compare(0,5,"/mnt/"); - short b = dirPath->compare(0,7,"/media/"); - if(a != 0 && b != 0) - *dirPath =""; // We clear the string if the selected folder is not at leaset /mnt/ or /hdd (There is no other possibility to clear this) + if (check_dir(dirPath->c_str(), true)) + *dirPath = oldPath; } return menu_return::RETURN_REPAINT; diff --git a/src/gui/moviebrowser.h b/src/gui/moviebrowser.h index 6b77fb958..c4429592d 100644 --- a/src/gui/moviebrowser.h +++ b/src/gui/moviebrowser.h @@ -238,6 +238,7 @@ typedef struct std::string ytregion; std::string ytvid; std::string ytsearch; + std::string ytthumbnaildir; std::list ytsearch_history; } MB_SETTINGS; diff --git a/src/system/locals.h b/src/system/locals.h index 6a89f049b..1eb382a8c 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -1518,6 +1518,7 @@ typedef enum LOCALE_MOVIEBROWSER_BROWSER_ROW_ITEM, LOCALE_MOVIEBROWSER_BROWSER_ROW_NR, LOCALE_MOVIEBROWSER_BROWSER_ROW_WIDTH, + LOCALE_MOVIEBROWSER_CACHE_DIR, LOCALE_MOVIEBROWSER_DELETE_INFO, LOCALE_MOVIEBROWSER_DIR, LOCALE_MOVIEBROWSER_DIR_HEAD, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 57dfe4819..a683d00dd 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -1518,6 +1518,7 @@ const char * locale_real_names[] = "moviebrowser.browser_row_item", "moviebrowser.browser_row_nr", "moviebrowser.browser_row_width", + "moviebrowser.cache_dir", "moviebrowser.delete_info", "moviebrowser.dir", "moviebrowser.dir_head", diff --git a/src/system/ytparser.cpp b/src/system/ytparser.cpp index ccb2146b1..a843cec9a 100644 --- a/src/system/ytparser.cpp +++ b/src/system/ytparser.cpp @@ -698,6 +698,11 @@ void cYTFeedParser::Cleanup(bool delete_thumbnails) feedmode = -1; } +void cYTFeedParser::SetThumbnailDir(std::string &_thumbnail_dir) +{ + thumbnail_dir = _thumbnail_dir; +} + void cYTFeedParser::Dump() { printf("feed: %d videos\n", (int)videos.size()); diff --git a/src/system/ytparser.h b/src/system/ytparser.h index 22a4920ee..988b93358 100644 --- a/src/system/ytparser.h +++ b/src/system/ytparser.h @@ -151,6 +151,7 @@ class cYTFeedParser void SetRegion(std::string reg) { region = reg; } void SetMaxResults(int count) { max_results = count; } void SetConcurrentDownloads(int count) { concurrent_downloads = count; } + void SetThumbnailDir(std::string &_thumbnail_dir); }; #endif