Skip to content

Commit

Permalink
MythBrowser: Allow the default save directory to be passed to the med…
Browse files Browse the repository at this point in the history
…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
Paul Harrison committed Feb 27, 2011
1 parent 58f8352 commit 739a807
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
28 changes: 20 additions & 8 deletions mythplugins/mythbrowser/mythbrowser/main.cpp
Expand Up @@ -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())
{
Expand All @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions mythplugins/mythbrowser/mythbrowser/mythbrowser.cpp
Expand Up @@ -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)),
Expand Down Expand Up @@ -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")
{
Expand Down
3 changes: 3 additions & 0 deletions mythplugins/mythbrowser/mythbrowser/mythbrowser.h
Expand Up @@ -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);

Expand Down Expand Up @@ -68,6 +70,7 @@ class MythBrowser : public MythScreenType
int m_currentBrowser;
QUrl m_url;
float m_zoom;
QString m_defaultSaveDir;

Bookmark m_editBookmark;

Expand Down

0 comments on commit 739a807

Please sign in to comment.