コード例 #1
0
void MythBrowser::slotAddTab(const QString &url, bool doSwitch)
{
    QString name = QString("browser%1").arg(m_browserList.size() + 1);
    WebPage *page = new WebPage(this, m_browserList[0]->getBrowser()->GetArea(),
                                name.toAscii().constData());
    m_browserList.append(page);

    QString newUrl = url;

    if (newUrl.isEmpty())
        newUrl = "http://www.google.com"; // TODO: add a user definable home page

    if (!newUrl.startsWith("http://") && !newUrl.startsWith("https://") &&
            !newUrl.startsWith("file:/") )
        newUrl.prepend("http://");
    page->getBrowser()->LoadPage(QUrl::fromEncoded(newUrl.toLocal8Bit()));

    page->SetActive(false);

    connect(page, SIGNAL(loadProgress(int)),
            this, SLOT(slotLoadProgress(int)));
    connect(page, SIGNAL(statusBarMessage(const QString&)),
            this, SLOT(slotStatusBarMessage(const QString&)));
    connect(page, SIGNAL(loadFinished(bool)),
            this, SLOT(slotLoadFinished(bool)));

    if (doSwitch)
        m_pageList->SetItemCurrent(m_browserList.size() -1);
}
コード例 #2
0
bool MythBrowser::Create(void)
{
    // Load the theme for this screen
    if (!LoadWindowFromXML("browser-ui.xml", "browser", this))
        return false;

    bool err = false;
    MythUIWebBrowser *browser = NULL;

    UIUtilE::Assign(this, browser,         "webbrowser", &err);
    UIUtilE::Assign(this, m_pageList,      "pagelist", &err);
    UIUtilW::Assign(this, m_progressBar,   "progressbar");
    UIUtilW::Assign(this, m_statusText,    "status");
    UIUtilW::Assign(this, m_titleText,     "title");
    UIUtilW::Assign(this, m_backButton,    "back");
    UIUtilW::Assign(this, m_forwardButton, "forward");
    UIUtilW::Assign(this, m_exitButton,    "exit");

    if (err)
    {
        LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'browser'");
        return false;
    }

    connect(m_pageList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            this, SLOT(slotTabSelected(MythUIButtonListItem*)));

    // create the default favicon
    QString favIcon = "mb_default_favicon.png";
    if (GetMythUI()->FindThemeFile(favIcon))
    {
        if (QFile::exists(favIcon))
        {
            QImage image(favIcon);
            m_defaultFavIcon = GetMythPainter()->GetFormatImage();
            m_defaultFavIcon->Assign(image);
        }
    }

    // this is the template for all other browser tabs
    WebPage *page = new WebPage(this, browser);

    m_browserList.append(page);
    page->getBrowser()->SetDefaultSaveDirectory(m_defaultSaveDir);
    page->getBrowser()->SetDefaultSaveFilename(m_defaultSaveFilename);

    page->SetActive(true);

    connect(page, SIGNAL(loadProgress(int)),
            this, SLOT(slotLoadProgress(int)));
    connect(page, SIGNAL(statusBarMessage(const QString&)),
            this, SLOT(slotStatusBarMessage(const QString&)));
    connect(page, SIGNAL(loadFinished(bool)),
            this, SLOT(slotLoadFinished(bool)));

    if (m_progressBar)
        m_progressBar->SetTotal(100);

    if (m_exitButton)
    {
        m_exitButton->SetEnabled(false);
        m_exitButton->SetEnabled(true);
        connect(m_exitButton, SIGNAL(Clicked()), this, SLOT(Close()));
    }

    if (m_backButton)
    {
        m_backButton->SetEnabled(false);
        connect(m_backButton, SIGNAL(Clicked()), this, SLOT(slotBack()));
    }

    if (m_forwardButton)
    {
        m_forwardButton->SetEnabled(false);
        connect(m_forwardButton, SIGNAL(Clicked()), this, SLOT(slotForward()));
    }

    BuildFocusList();

    SetFocusWidget(browser);

    slotOpenURL(m_urlList[0]);

    for (int x = 1; x < m_urlList.size(); x++)
        slotAddTab(m_urlList[x], false);

    switchTab(0);

    return true;
}
コード例 #3
0
ファイル: mythbrowser.cpp プロジェクト: camdbug/mythtv
bool MythBrowser::Create(void)
{
    bool foundtheme = false;

    // Load the theme for this screen
    foundtheme = LoadWindowFromXML("browser-ui.xml", "browser", this);

    if (!foundtheme)
        return false;

    MythUIWebBrowser *browser = dynamic_cast<MythUIWebBrowser *> (GetChild("webbrowser"));
    m_progressBar = dynamic_cast<MythUIProgressBar *>(GetChild("progressbar"));
    m_statusText = dynamic_cast<MythUIText *>(GetChild("status"));
    m_titleText = dynamic_cast<MythUIText *>(GetChild("title"));
    m_pageList = dynamic_cast<MythUIButtonList *>(GetChild("pagelist"));

    if (!browser || !m_pageList)
    {
        LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
        return false;
    }

    connect(m_pageList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            this, SLOT(slotTabSelected(MythUIButtonListItem*)));

    // create the default favicon
    QString favIcon = "mb_default_favicon.png";
    GetMythUI()->FindThemeFile(favIcon);
    if (QFile::exists(favIcon))
    {
        QImage image(favIcon);
        m_defaultFavIcon = GetMythPainter()->GetFormatImage();
        m_defaultFavIcon->Assign(image);
        m_defaultFavIcon->UpRef();
    }

    // this is the template for all other browser tabs
    WebPage *page = new WebPage(this, browser);

    m_browserList.append(page);
    page->getBrowser()->SetZoom(m_zoom);
    page->getBrowser()->SetDefaultSaveDirectory(m_defaultSaveDir);
    page->getBrowser()->SetDefaultSaveFilename(m_defaultSaveFilename);

    page->SetActive(true);

    connect(page, SIGNAL(loadProgress(int)),
            this, SLOT(slotLoadProgress(int)));
    connect(page, SIGNAL(statusBarMessage(const QString&)),
            this, SLOT(slotStatusBarMessage(const QString&)));

    if (m_progressBar)
        m_progressBar->SetTotal(100);

    BuildFocusList();

    SetFocusWidget(browser);

    slotOpenURL(m_urlList[0]);

    for (int x = 1; x < m_urlList.size(); x++)
        slotAddTab(m_urlList[x], false);

    switchTab(0);

    return true;
}