Permalink
Browse files

MythUIWebBrowser: fix inheriting from a base definition

  • Loading branch information...
1 parent 8d92208 commit 417a4e4c9ea603b837cb5b0dbfc819eb3a33afb6 Paul Harrison committed Mar 29, 2013
Showing with 31 additions and 25 deletions.
  1. +30 −25 mythtv/libs/libmythui/mythuiwebbrowser.cpp
  2. +1 −0 mythtv/libs/libmythui/mythuiwebbrowser.h
@@ -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,19 +1386,19 @@ 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());
}
if (m_horizontalScrollbar)
{
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,19 +1496,19 @@ bool MythUIWebBrowser::keyPressEvent(QKeyEvent *event)
if (pos > 0)
{
- Scroll(0, -m_browserArea.height() / 10);
+ Scroll(0, -m_actualBrowserArea.height() / 10);
}
else
handled = false;
}
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,30 +1519,30 @@ bool MythUIWebBrowser::keyPressEvent(QKeyEvent *event)
if (pos > 0)
{
- Scroll(-m_browserArea.width() / 10, 0);
+ Scroll(-m_actualBrowserArea.width() / 10, 0);
}
else
handled = false;
}
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();
}
/**
@@ -235,6 +235,7 @@ class MUI_PUBLIC MythUIWebBrowser : public MythUIType
MythWebView *m_browser;
MythRect m_browserArea;
+ MythRect m_actualBrowserArea;
MythImage *m_image;

0 comments on commit 417a4e4

Please sign in to comment.