diff --git a/mythtv/libs/libmythui/mythuiwebbrowser.cpp b/mythtv/libs/libmythui/mythuiwebbrowser.cpp index de338bee166..758fb67b47c 100644 --- a/mythtv/libs/libmythui/mythuiwebbrowser.cpp +++ b/mythtv/libs/libmythui/mythuiwebbrowser.cpp @@ -830,7 +830,8 @@ QWebView *MythWebView::createWindow(QWebPage::WebWindowType type) MythUIWebBrowser::MythUIWebBrowser(MythUIType *parent, const QString &name) : MythUIType(parent, name), m_parentScreen(NULL), - m_browser(NULL), m_image(NULL), + m_browser(NULL), m_browserArea(MythRect()), + m_actualBrowserArea(MythRect()), m_image(NULL), m_active(false), m_wasActive(false), m_initialized(false), m_lastUpdateTime(QTime()), m_updateInterval(0), m_zoom(1.0), @@ -850,8 +851,9 @@ MythUIWebBrowser::MythUIWebBrowser(MythUIType *parent, const QString &name) */ void MythUIWebBrowser::Finalize(void) { - Init(); MythUIType::Finalize(); + + Init(); } /** \fn MythUIWebBrowser::Init(void) @@ -866,14 +868,18 @@ void MythUIWebBrowser::Init(void) if (m_initialized) return; - if (!m_browserArea.isValid()) - m_browserArea = m_Area; + m_actualBrowserArea = m_browserArea; + m_actualBrowserArea.CalculateArea(m_Area); + m_actualBrowserArea.translate(m_Area.x(), m_Area.y()); + + if (!m_actualBrowserArea.isValid()) + m_actualBrowserArea = m_Area; m_browser = new MythWebView(GetMythMainWindow()->GetPaintWindow(), this); m_browser->setPalette(qApp->style()->standardPalette()); - m_browser->setGeometry(m_browserArea); - m_browser->setFixedSize(m_browserArea.size()); - m_browser->move(m_browserArea.x(), m_browserArea.y()); + m_browser->setGeometry(m_actualBrowserArea); + m_browser->setFixedSize(m_actualBrowserArea.size()); + m_browser->move(m_actualBrowserArea.x(), m_actualBrowserArea.y()); m_browser->page()->setLinkDelegationPolicy(QWebPage::DontDelegateLinks); bool err = false; @@ -987,7 +993,7 @@ void MythUIWebBrowser::Init(void) false); } - QImage image = QImage(m_browserArea.size(), QImage::Format_ARGB32); + QImage image = QImage(m_actualBrowserArea.size(), QImage::Format_ARGB32); m_image = GetPainter()->GetFormatImage(); m_image->Assign(image); @@ -1380,9 +1386,9 @@ void MythUIWebBrowser::UpdateScrollBars(void) { int maximum = m_browser->page()->currentFrame()->contentsSize().height() - - m_browserArea.height(); + m_actualBrowserArea.height(); m_verticalScrollbar->SetMaximum(maximum); - m_verticalScrollbar->SetPageStep(m_browserArea.height()); + m_verticalScrollbar->SetPageStep(m_actualBrowserArea.height()); m_verticalScrollbar->SetSliderPosition(position.y()); } @@ -1390,9 +1396,9 @@ void MythUIWebBrowser::UpdateScrollBars(void) { int maximum = m_browser->page()->currentFrame()->contentsSize().width() - - m_browserArea.width(); + m_actualBrowserArea.width(); m_horizontalScrollbar->SetMaximum(maximum); - m_horizontalScrollbar->SetPageStep(m_browserArea.width()); + m_horizontalScrollbar->SetPageStep(m_actualBrowserArea.width()); m_horizontalScrollbar->SetSliderPosition(position.x()); } } @@ -1450,7 +1456,7 @@ void MythUIWebBrowser::DrawSelf(MythPainter *p, int xoffset, int yoffset, if (!m_image || m_image->isNull() || !m_browser || m_browser->hasFocus()) return; - QRect area = m_browserArea; + QRect area = m_actualBrowserArea; area.translate(xoffset, yoffset); p->DrawImage(area.x(), area.y(), m_image, alphaMod); @@ -1490,7 +1496,7 @@ bool MythUIWebBrowser::keyPressEvent(QKeyEvent *event) if (pos > 0) { - Scroll(0, -m_browserArea.height() / 10); + Scroll(0, -m_actualBrowserArea.height() / 10); } else handled = false; @@ -1498,11 +1504,11 @@ bool MythUIWebBrowser::keyPressEvent(QKeyEvent *event) else if (action == "DOWN") { int pos = frame->scrollPosition().y(); - QSize maximum = frame->contentsSize() - m_browserArea.size(); + QSize maximum = frame->contentsSize() - m_actualBrowserArea.size(); if (pos != maximum.height()) { - Scroll(0, m_browserArea.height() / 10); + Scroll(0, m_actualBrowserArea.height() / 10); } else handled = false; @@ -1513,7 +1519,7 @@ bool MythUIWebBrowser::keyPressEvent(QKeyEvent *event) if (pos > 0) { - Scroll(-m_browserArea.width() / 10, 0); + Scroll(-m_actualBrowserArea.width() / 10, 0); } else handled = false; @@ -1521,22 +1527,22 @@ bool MythUIWebBrowser::keyPressEvent(QKeyEvent *event) else if (action == "RIGHT") { int pos = frame->scrollPosition().x(); - QSize maximum = frame->contentsSize() - m_browserArea.size(); + QSize maximum = frame->contentsSize() - m_actualBrowserArea.size(); if (pos != maximum.width()) { - Scroll(m_browserArea.width() / 10, 0); + Scroll(m_actualBrowserArea.width() / 10, 0); } else handled = false; } else if (action == "PAGEUP") { - Scroll(0, -m_browserArea.height()); + Scroll(0, -m_actualBrowserArea.height()); } else if (action == "PAGEDOWN") { - Scroll(0, m_browserArea.height()); + Scroll(0, m_actualBrowserArea.height()); } else if (action == "ZOOMIN") { @@ -1554,11 +1560,11 @@ bool MythUIWebBrowser::keyPressEvent(QKeyEvent *event) } else if (action == "PAGELEFT") { - Scroll(-m_browserArea.width(), 0); + Scroll(-m_actualBrowserArea.width(), 0); } else if (action == "PAGERIGHT") { - Scroll(m_browserArea.width(), 0); + Scroll(m_actualBrowserArea.width(), 0); } else if (action == "NEXTLINK") { @@ -1730,6 +1736,7 @@ void MythUIWebBrowser::CopyFrom(MythUIType *base) MythUIType::CopyFrom(base); + m_browserArea = browser->m_browserArea; m_zoom = browser->m_zoom; m_bgColor = browser->m_bgColor; m_widgetUrl = browser->m_widgetUrl; @@ -1738,8 +1745,6 @@ void MythUIWebBrowser::CopyFrom(MythUIType *base) m_defaultSaveDir = browser->m_defaultSaveDir; m_defaultSaveFilename = browser->m_defaultSaveFilename; m_scrollAnimation.setDuration(browser->m_scrollAnimation.duration()); - - Init(); } /** diff --git a/mythtv/libs/libmythui/mythuiwebbrowser.h b/mythtv/libs/libmythui/mythuiwebbrowser.h index 7295ec7778e..e81c0d4add5 100644 --- a/mythtv/libs/libmythui/mythuiwebbrowser.h +++ b/mythtv/libs/libmythui/mythuiwebbrowser.h @@ -235,6 +235,7 @@ class MUI_PUBLIC MythUIWebBrowser : public MythUIType MythWebView *m_browser; MythRect m_browserArea; + MythRect m_actualBrowserArea; MythImage *m_image;