MythUIWebBrowser Class Reference
[MythUI Widget and theme handling]

Web browsing widget. More...

#include <mythuiwebbrowser.h>

Inheritance diagram for MythUIWebBrowser:
MythUIType XMLParseBase

List of all members.

Public Slots

void Back (void)
 Got backward in page history.
void Forward (void)
 Got forward in page history.
void ZoomIn (void)
 Increase the text size.
void ZoomOut (void)
 Decrease the text size.

Signals

void loadStarted (void)
void loadFinished (bool ok)
 a page is starting to load
void loadProgress (int progress)
 a page has finished loading
void titleChanged (const QString &title)
 % of page loaded
void statusBarMessage (const QString &text)
 a pages title has changed
void iconChanged (void)
 link hit test messages
void fileDownloaded (QString filename)
 a pages fav icon has changed

Public Member Functions

 MythUIWebBrowser (MythUIType *parent, const QString &name)
 the classes constructor
 ~MythUIWebBrowser ()
 the classes destructor
void Init (void)
 Initializes the widget ready for use.
void LoadPage (QUrl url)
 Loads the specified url and displays it.
void SetHtml (const QString &html, const QUrl &baseUrl=QUrl())
 Sets the content of the widget to the specified html.
void LoadUserStyleSheet (QUrl url)
 Sets the specified user style sheet.
virtual bool keyPressEvent (QKeyEvent *event)
virtual void Pulse (void)
void Scroll (int dx, int dy)
QIcon GetIcon (void)
 Gets the current page's fav icon.
QUrl GetUrl (void)
 Gets the current page's url.
QString GetTitle (void)
 Gets the current page's title.
void SetActive (bool active)
 Toggles the active state of the widget.
bool IsActive (void)
bool IsInputToggled (void)
 returns true if all keypresses are to be passed to the web page
void SetInputToggled (bool inputToggled)
void SetZoom (float zoom)
 Set the text size to specific size.
float GetZoom (void)
 Get the current zoom level.
bool CanGoForward (void)
 Can go forward in page history.
bool CanGoBack (void)
 Can we go backward in page history.
QVariant evaluateJavaScript (const QString &scriptSource)
 Evaluates the JavaScript code in scriptSource.
void SetDefaultSaveDirectory (const QString &saveDir)
QString GetDefaultSaveDirectory (void)
void SetDefaultSaveFilename (const QString &filename)
QString GetDefaultSaveFilename (void)

Protected Slots

void slotLoadStarted (void)
 a file has been downloaded
void slotLoadFinished (bool Ok)
void slotLoadProgress (int progress)
void slotTitleChanged (const QString &title)
void slotStatusBarMessage (const QString &text)
void slotIconChanged (void)
void slotLinkClicked (const QUrl &url)
void slotTopScreenChanged (MythScreenType *screen)

Protected Member Functions

void Finalize (void)
void UpdateBuffer (void)
void HandleMouseAction (const QString &action)
void SetBackgroundColor (QColor color)
 Sets the default background color.
void ResetScrollBars (void)
void UpdateScrollBars (void)
virtual void DrawSelf (MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRegion)
virtual bool ParseElement (const QString &filename, QDomElement &element, bool showWarnings)
virtual void CopyFrom (MythUIType *base)
virtual void CreateCopy (MythUIType *parent)

Protected Attributes

MythScreenTypem_parentScreen
MythWebViewm_browser
MythRect m_browserArea
MythImagem_image
bool m_active
bool m_wasActive
bool m_initialized
QTime m_lastUpdateTime
int m_updateInterval
float m_zoom
QColor m_bgColor
QUrl m_widgetUrl
QString m_userCssFile
QString m_defaultSaveDir
QString m_defaultSaveFilename
bool m_inputToggled
QString m_lastMouseAction
int m_mouseKeyCount
QTime m_lastMouseActionTime
MythUIScrollBarm_horizontalScrollbar
MythUIScrollBarm_verticalScrollbar
MythUIAnimation m_scrollAnimation
QPoint m_destinationScrollPos

Detailed Description

Web browsing widget.

Provide a web browser widget.

Can load and render local and remote html. Supports netscape plugins.

Uses QtWebKit and so requires Qt4.4.0 or later.

This widget can display HTML documents from the net, a file or passed to it as a QString.

This is how you would add the widget to a theme file :-

<webbrowser name="webbrowser"> <url>http://www.google.com/</url> <area>20,55,760,490</area> <zoom>1.4</zoom> <background color="white"> </webbrowser>

area is the screen area the widget should use. zoom is the initial text size. background is the default background color to use.

The widget has two modes of operation active and inactive. When it's active and has focus it will show the mouse pointer, links will respond when clicked, the highlighed link can be changed and activated using the keyboard. In inactive mode it will just display a static image of the web document, you can scroll it but that is all.

One thing to be aware of is you cannot show popups above this widget when it is in active mode and has focus so either call Active(false) or move the focus to another widget before showing the popup.

Definition at line 120 of file mythuiwebbrowser.h.


Constructor & Destructor Documentation

MythUIWebBrowser::MythUIWebBrowser ( MythUIType parent,
const QString &  name 
)

the classes constructor

Parameters:
parent the parent of this widget
name the name of this widget

Definition at line 825 of file mythuiwebbrowser.cpp.

Referenced by CreateCopy().

MythUIWebBrowser::~MythUIWebBrowser ( void   ) 

the classes destructor

Definition at line 1001 of file mythuiwebbrowser.cpp.


Member Function Documentation

void MythUIWebBrowser::Init ( void   ) 

Initializes the widget ready for use.

Note:
This is usually called for you when the widget is finalized during the theme file parsing but if you manually add this widget to a screen you will have to call this function *after* setting the widgets screen area.

Definition at line 859 of file mythuiwebbrowser.cpp.

Referenced by CopyFrom(), MythFlashPlayer::Create(), Finalize(), and WebPage::WebPage().

void MythUIWebBrowser::LoadPage ( QUrl  url  ) 

Loads the specified url and displays it.

Parameters:
url The url to load

Definition at line 1022 of file mythuiwebbrowser.cpp.

Referenced by MythFlashPlayer::Create(), Init(), MythBrowser::slotAddTab(), slotLinkClicked(), and MythBrowser::slotOpenURL().

void MythUIWebBrowser::SetHtml ( const QString &  html,
const QUrl &  baseUrl = QUrl() 
)

Sets the content of the widget to the specified html.

Parameters:
html the html to display
baseUrl External objects referenced in the HTML document are located relative to baseUrl.

Definition at line 1038 of file mythuiwebbrowser.cpp.

Referenced by ProgDetails::updatePage().

void MythUIWebBrowser::LoadUserStyleSheet ( QUrl  url  ) 

Sets the specified user style sheet.

Parameters:
url The url to the style sheet

Definition at line 1052 of file mythuiwebbrowser.cpp.

Referenced by Init().

bool MythUIWebBrowser::keyPressEvent ( QKeyEvent *  event  )  [virtual]

Key event handler.

Parameters:
event Keypress event

Reimplemented from MythUIType.

Definition at line 1454 of file mythuiwebbrowser.cpp.

Referenced by MythFlashPlayer::keyPressEvent().

void MythUIWebBrowser::Pulse ( void   )  [virtual]

Pulse is called 70 times a second to trigger a single frame of an animation. This changes the alpha value of the widget

Reimplemented from MythUIType.

Definition at line 1413 of file mythuiwebbrowser.cpp.

void MythUIWebBrowser::Scroll ( int  dx,
int  dy 
)

Definition at line 1276 of file mythuiwebbrowser.cpp.

Referenced by keyPressEvent().

QIcon MythUIWebBrowser::GetIcon ( void   ) 

Gets the current page's fav icon.

Returns:
return the icon if one is available

Definition at line 1225 of file mythuiwebbrowser.cpp.

Referenced by WebPage::slotIconChanged().

QUrl MythUIWebBrowser::GetUrl ( void   ) 

Gets the current page's url.

Returns:
return the url

Definition at line 1239 of file mythuiwebbrowser.cpp.

Referenced by MythBrowser::slotAddBookmark().

QString MythUIWebBrowser::GetTitle ( void   ) 

Gets the current page's title.

Returns:
return the page title

Definition at line 1253 of file mythuiwebbrowser.cpp.

Referenced by WebPage::slotLoadFinished().

void MythUIWebBrowser::SetActive ( bool  active  ) 

Toggles the active state of the widget.

Parameters:
active the new active state
Note:
When in an active state the widget will show the mouse pointer, generate status bar changed signals, allow the active link to be changed using the keyboard etc.
Warning:
If you want to show another screen or popup above the screen owning a MythUIWebBrowser you must first set the active state to false.

Definition at line 1093 of file mythuiwebbrowser.cpp.

Referenced by MythFlashPlayer::Create(), Init(), WebPage::SetActive(), and slotTopScreenChanged().

bool MythUIWebBrowser::IsActive ( void   )  [inline]

Definition at line 144 of file mythuiwebbrowser.h.

bool MythUIWebBrowser::IsInputToggled ( void   )  [inline]

returns true if all keypresses are to be passed to the web page

Definition at line 147 of file mythuiwebbrowser.h.

Referenced by MythWebView::keyPressEvent().

void MythUIWebBrowser::SetInputToggled ( bool  inputToggled  )  [inline]

Definition at line 148 of file mythuiwebbrowser.h.

void MythUIWebBrowser::SetZoom ( float  zoom  ) 

Set the text size to specific size.

Parameters:
zoom The size to use. Useful values are between 0.2 and 5.0

Reimplemented from MythUIType.

Definition at line 1137 of file mythuiwebbrowser.cpp.

Referenced by ProgDetails::Create(), MythBrowser::Create(), Init(), MythBrowser::slotAddTab(), ZoomIn(), and ZoomOut().

float MythUIWebBrowser::GetZoom ( void   ) 

Get the current zoom level.

Returns:
the zoom level

Definition at line 1168 of file mythuiwebbrowser.cpp.

Referenced by ProgDetails::~ProgDetails().

bool MythUIWebBrowser::CanGoForward ( void   ) 

Can go forward in page history.

Returns:
Return true if it is possible to go forward in the pages visited history

Definition at line 1178 of file mythuiwebbrowser.cpp.

bool MythUIWebBrowser::CanGoBack ( void   ) 

Can we go backward in page history.

Returns:
Return true if it is possible to go backward in the pages visited history

Definition at line 1191 of file mythuiwebbrowser.cpp.

QVariant MythUIWebBrowser::evaluateJavaScript ( const QString &  scriptSource  ) 

Evaluates the JavaScript code in scriptSource.

Returns:
QVariant

Definition at line 1265 of file mythuiwebbrowser.cpp.

Referenced by MythFlashPlayer::evaluateJavaScript(), and MythWebView::keyPressEvent().

void MythUIWebBrowser::SetDefaultSaveDirectory ( const QString &  saveDir  ) 

Definition at line 1148 of file mythuiwebbrowser.cpp.

Referenced by MythBrowser::Create().

QString MythUIWebBrowser::GetDefaultSaveDirectory ( void   )  [inline]

Definition at line 159 of file mythuiwebbrowser.h.

Referenced by MythWebView::doDownloadRequested().

void MythUIWebBrowser::SetDefaultSaveFilename ( const QString &  filename  ) 

Definition at line 1156 of file mythuiwebbrowser.cpp.

Referenced by MythBrowser::Create().

QString MythUIWebBrowser::GetDefaultSaveFilename ( void   )  [inline]

Definition at line 162 of file mythuiwebbrowser.h.

Referenced by MythWebView::doDownloadRequested().

void MythUIWebBrowser::Back ( void   )  [slot]

Got backward in page history.

Definition at line 1202 of file mythuiwebbrowser.cpp.

Referenced by keyPressEvent(), and MythBrowser::slotBack().

void MythUIWebBrowser::Forward ( void   )  [slot]

Got forward in page history.

Definition at line 1213 of file mythuiwebbrowser.cpp.

Referenced by keyPressEvent(), and MythBrowser::slotForward().

void MythUIWebBrowser::ZoomIn ( void   )  [slot]

Increase the text size.

Definition at line 1120 of file mythuiwebbrowser.cpp.

Referenced by ProgDetails::customEvent(), keyPressEvent(), and MythBrowser::slotZoomIn().

void MythUIWebBrowser::ZoomOut ( void   )  [slot]

Decrease the text size.

Definition at line 1128 of file mythuiwebbrowser.cpp.

Referenced by ProgDetails::customEvent(), keyPressEvent(), and MythBrowser::slotZoomOut().

void MythUIWebBrowser::loadStarted ( void   )  [signal]

Referenced by Init(), and slotLoadStarted().

void MythUIWebBrowser::loadFinished ( bool  ok  )  [signal]

a page is starting to load

Referenced by Init(), and slotLoadFinished().

void MythUIWebBrowser::loadProgress ( int  progress  )  [signal]

a page has finished loading

Referenced by Init(), and slotLoadProgress().

void MythUIWebBrowser::titleChanged ( const QString &  title  )  [signal]

% of page loaded

Referenced by Init(), and slotTitleChanged().

void MythUIWebBrowser::statusBarMessage ( const QString &  text  )  [signal]

a pages title has changed

Referenced by Init(), and slotStatusBarMessage().

void MythUIWebBrowser::iconChanged ( void   )  [signal]

link hit test messages

Referenced by Init(), and slotIconChanged().

void MythUIWebBrowser::fileDownloaded ( QString  filename  )  [signal]

a pages fav icon has changed

void MythUIWebBrowser::slotLoadStarted ( void   )  [protected, slot]

a file has been downloaded

Definition at line 1302 of file mythuiwebbrowser.cpp.

Referenced by Init().

void MythUIWebBrowser::slotLoadFinished ( bool  Ok  )  [protected, slot]

Definition at line 1308 of file mythuiwebbrowser.cpp.

Referenced by Init().

void MythUIWebBrowser::slotLoadProgress ( int  progress  )  [protected, slot]

Definition at line 1314 of file mythuiwebbrowser.cpp.

Referenced by Init().

void MythUIWebBrowser::slotTitleChanged ( const QString &  title  )  [protected, slot]

Definition at line 1319 of file mythuiwebbrowser.cpp.

Referenced by Init().

void MythUIWebBrowser::slotStatusBarMessage ( const QString &  text  )  [protected, slot]

Definition at line 1324 of file mythuiwebbrowser.cpp.

Referenced by Init().

void MythUIWebBrowser::slotIconChanged ( void   )  [protected, slot]

Definition at line 1334 of file mythuiwebbrowser.cpp.

Referenced by Init().

void MythUIWebBrowser::slotLinkClicked ( const QUrl &  url  )  [protected, slot]

Definition at line 1329 of file mythuiwebbrowser.cpp.

Referenced by Init().

void MythUIWebBrowser::slotTopScreenChanged ( MythScreenType screen  )  [protected, slot]

Definition at line 1339 of file mythuiwebbrowser.cpp.

Referenced by Init().

void MythUIWebBrowser::Finalize ( void   )  [protected, virtual]

Perform any post-xml parsing initialisation tasks. This is called after the widget has been created and it's state established by ParseElement() or CopyFrom(). A derived class should use this to perform any initialisation tasks which should occur after this point.

Reimplemented from MythUIType.

Definition at line 846 of file mythuiwebbrowser.cpp.

void MythUIWebBrowser::UpdateBuffer ( void   )  [protected]
void MythUIWebBrowser::HandleMouseAction ( const QString &  action  )  [protected]

Definition at line 1582 of file mythuiwebbrowser.cpp.

Referenced by keyPressEvent().

void MythUIWebBrowser::SetBackgroundColor ( QColor  color  )  [protected]

Sets the default background color.

Parameters:
color the color to use
Note:
This will only be used if the HTML document being displayed doesn't specify a background color to use.

Definition at line 1069 of file mythuiwebbrowser.cpp.

Referenced by Init().

void MythUIWebBrowser::ResetScrollBars ( void   )  [protected]

Definition at line 1644 of file mythuiwebbrowser.cpp.

Referenced by LoadPage(), SetHtml(), SetZoom(), and slotLoadStarted().

void MythUIWebBrowser::UpdateScrollBars ( void   )  [protected]

Definition at line 1371 of file mythuiwebbrowser.cpp.

Referenced by UpdateBuffer().

void MythUIWebBrowser::DrawSelf ( MythPainter p,
int  xoffset,
int  yoffset,
int  alphaMod,
QRect  clipRegion 
) [protected, virtual]

Reimplemented from MythUIType.

Definition at line 1439 of file mythuiwebbrowser.cpp.

bool MythUIWebBrowser::ParseElement ( const QString &  filename,
QDomElement &  element,
bool  showWarnings 
) [protected, virtual]

Parse the xml definition of this widget setting the state of the object accordingly.

Reimplemented from MythUIType.

Definition at line 1662 of file mythuiwebbrowser.cpp.

void MythUIWebBrowser::CopyFrom ( MythUIType base  )  [protected, virtual]

Copy this widgets state from another.

Reimplemented from MythUIType.

Definition at line 1709 of file mythuiwebbrowser.cpp.

Referenced by CreateCopy().

void MythUIWebBrowser::CreateCopy ( MythUIType parent  )  [protected, virtual]

Copy the state of this widget to the one given, it must be of the same type.

Reimplemented from MythUIType.

Definition at line 1736 of file mythuiwebbrowser.cpp.


Member Data Documentation

Definition at line 205 of file mythuiwebbrowser.h.

Referenced by Init(), and slotTopScreenChanged().

Definition at line 208 of file mythuiwebbrowser.h.

Referenced by DrawSelf(), Init(), keyPressEvent(), ParseElement(), and UpdateScrollBars().

Definition at line 210 of file mythuiwebbrowser.h.

Referenced by DrawSelf(), Init(), UpdateBuffer(), and ~MythUIWebBrowser().

Definition at line 212 of file mythuiwebbrowser.h.

Referenced by Init(), SetActive(), slotTopScreenChanged(), and UpdateBuffer().

Definition at line 213 of file mythuiwebbrowser.h.

Referenced by SetActive(), and slotTopScreenChanged().

Definition at line 214 of file mythuiwebbrowser.h.

Referenced by Init().

Definition at line 215 of file mythuiwebbrowser.h.

Referenced by Pulse().

Definition at line 216 of file mythuiwebbrowser.h.

Referenced by CopyFrom(), ParseElement(), and Pulse().

float MythUIWebBrowser::m_zoom [protected]

Definition at line 218 of file mythuiwebbrowser.h.

Referenced by CopyFrom(), GetZoom(), Init(), ParseElement(), SetZoom(), ZoomIn(), and ZoomOut().

QColor MythUIWebBrowser::m_bgColor [protected]

Definition at line 219 of file mythuiwebbrowser.h.

Referenced by CopyFrom(), Init(), and ParseElement().

Definition at line 220 of file mythuiwebbrowser.h.

Referenced by CopyFrom(), Init(), and ParseElement().

QString MythUIWebBrowser::m_userCssFile [protected]

Definition at line 221 of file mythuiwebbrowser.h.

Referenced by CopyFrom(), Init(), and ParseElement().

Definition at line 222 of file mythuiwebbrowser.h.

Referenced by CopyFrom(), and SetDefaultSaveDirectory().

Definition at line 223 of file mythuiwebbrowser.h.

Referenced by CopyFrom(), and SetDefaultSaveFilename().

Definition at line 225 of file mythuiwebbrowser.h.

Referenced by keyPressEvent().

Definition at line 226 of file mythuiwebbrowser.h.

Referenced by HandleMouseAction().

Definition at line 227 of file mythuiwebbrowser.h.

Referenced by HandleMouseAction().

Definition at line 228 of file mythuiwebbrowser.h.

Referenced by HandleMouseAction().

Definition at line 230 of file mythuiwebbrowser.h.

Referenced by Init(), ResetScrollBars(), and UpdateScrollBars().

Definition at line 231 of file mythuiwebbrowser.h.

Referenced by Init(), ResetScrollBars(), and UpdateScrollBars().

Definition at line 232 of file mythuiwebbrowser.h.

Referenced by CopyFrom(), MythUIWebBrowser(), ParseElement(), Pulse(), and Scroll().

Definition at line 233 of file mythuiwebbrowser.h.

Referenced by Pulse(), and Scroll().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Generated on Mon May 28 06:42:18 2012 for MythTV by  doxygen 1.6.3