Permalink
Browse files

MythBrowser: Allow the default save directory to be passed to the med…

…ia handler.

This is mainly for use by the MythMusic metadata editor to tell the browser
where it should save any downloaded cover art.
  • Loading branch information...
1 parent 58f8352 commit 739a807bf4c81874b4e9bef525e0dfbf91949c07 Paul Harrison committed Feb 27, 2011
@@ -19,7 +19,7 @@
using namespace std;
-static int handleMedia(const QString &url, const QString &, const QString &, const QString &, const QString &, int, int, int, const QString &)
+static int handleMedia(const QString &url, const QString &plot, const QString &, const QString &, const QString &, int, int, int, const QString &)
{
if (url.isEmpty())
{
@@ -31,16 +31,28 @@ static int handleMedia(const QString &url, const QString &, const QString &, con
float zoom = gCoreContext->GetSetting("WebBrowserZoomLevel", "1.4").toFloat();
MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
- MythScreenType *mythbrowser;
+
if (urls[0].startsWith("mythflash://"))
- mythbrowser = new MythFlashPlayer(mainStack, urls);
+ {
+ MythFlashPlayer *flashplayer = new MythFlashPlayer(mainStack, urls);
+ if (flashplayer->Create())
+ mainStack->AddScreen(flashplayer);
+ else
+ delete flashplayer;
+ }
else
- mythbrowser = new MythBrowser(mainStack, urls, zoom);
+ {
+ MythBrowser *mythbrowser = new MythBrowser(mainStack, urls, zoom);
- if (mythbrowser->Create())
- mainStack->AddScreen(mythbrowser);
- else
- delete mythbrowser;
+ // plot is used to set a default save directory
+ if (!plot.isEmpty())
+ mythbrowser->setDefaultSaveDirectory(plot);
+
+ if (mythbrowser->Create())
+ mainStack->AddScreen(mythbrowser);
+ else
+ delete mythbrowser;
+ }
return 0;
}
@@ -62,6 +62,8 @@ bool MythBrowser::Create(void)
m_browserList.append(page);
page->getBrowser()->SetZoom(m_zoom);
+ page->getBrowser()->SetDefaultSaveDirectory(m_defaultSaveDir);
+
page->SetActive(true);
connect(page, SIGNAL(loadProgress(int)),
@@ -371,10 +373,9 @@ bool MythBrowser::keyPressEvent(QKeyEvent *event)
else
SetFocusWidget(m_pageList);
}
-
else if (action == "ESCAPE")
{
- GetScreenStack()->PopScreen(false, true);
+ GetScreenStack()->PopScreen(true, true);
}
else if (action == "PREVTAB")
{
@@ -25,6 +25,8 @@ class MythBrowser : public MythScreenType
bool Create(void);
bool keyPressEvent(QKeyEvent *);
+ void setDefaultSaveDirectory(const QString saveDir) { m_defaultSaveDir = saveDir; }
+
public slots:
void slotOpenURL(const QString &url);
@@ -68,6 +70,7 @@ class MythBrowser : public MythScreenType
int m_currentBrowser;
QUrl m_url;
float m_zoom;
+ QString m_defaultSaveDir;
Bookmark m_editBookmark;

0 comments on commit 739a807

Please sign in to comment.