MythTV master
webpage.cpp
Go to the documentation of this file.
1#include <cstdlib>
2#include <iostream>
3
4// qt
5#include <QEvent>
6#include <QIcon>
7
8// MythTV
10
11// mythbrowser
12#include "mythbrowser.h"
13#include "webpage.h"
14
15WebPage::WebPage(MythBrowser *parent, QRect area, const char* name)
16 : m_parent(parent)
17{
18 m_listItem = new MythUIButtonListItem(parent->m_pageList, "", "", false,
20
21 m_browser = new MythUIWebBrowser(parent, name);
23 m_browser->Init();
24
31}
32
34 : m_parent(parent),
35 m_browser(browser)
36{
38
45}
46
48{
49 if (m_browser)
50 {
51 m_browser->disconnect();
53 m_browser = nullptr;
54 }
55
56 if (m_listItem)
57 {
58 delete m_listItem;
59 m_listItem = nullptr;
60 }
61}
62
63void WebPage::SetActive(bool active)
64{
65 if (active)
66 {
67 m_browser->SetActive(true);
68 m_browser->Show();
69 }
70 else
71 {
72 m_browser->SetActive(false);
73 m_browser->Hide();
74 }
75
76 m_active = active;
77}
78
79void WebPage::slotIconChanged(const QIcon &icon)
80{
81 if (!m_listItem)
82 return;
83
84 if (icon.isNull())
85 {
87 m_listItem->SetImage(mimage, "favicon");
88 mimage->DecrRef();
89 }
90 else
91 {
92 QPixmap pixmap = icon.pixmap(32, 32);
93 QImage image = pixmap.toImage();
94 image = image.scaled(
95 QSize(32,32), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
97 mimage->Assign(image);
98
99 m_listItem->SetImage(mimage, "favicon");
100 mimage->DecrRef();
101 }
102
104}
105
107{
108 m_listItem->SetText(tr("Loading..."));
109 m_listItem->DisplayState("loading", "loadingstate");
110 m_listItem->SetImage(nullptr, "favicon");
111 m_listItem->SetImage("", "favicon");
112
114}
115
117{
118 m_listItem->DisplayState("off", "loadingstate");
119
121
122 emit loadFinished(OK);
123}
124
126{
127 if (m_active)
129}
130
131void WebPage::slotStatusBarMessage(const QString &text)
132{
133 if (m_active)
134 emit statusBarMessage(text);
135}
136
137void WebPage::slotTitleChanged(const QString &title)
138{
139 m_listItem->SetText(title);
141}
MythImage * GetDefaultFavIcon(void)
Definition: mythbrowser.h:32
MythUIButtonList * m_pageList
Definition: mythbrowser.h:72
void Assign(const QImage &img)
Definition: mythimage.cpp:77
int DecrRef(void) override
Decrements reference count and deletes on 0.
Definition: mythimage.cpp:52
MythImage * GetFormatImage()
Returns a blank reference counted image in the format required for the Draw functions for this painte...
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Definition: mythrect.h:18
void DisplayState(const QString &state, const QString &name)
void SetImage(MythImage *image, const QString &name="")
Sets an image directly, should only be used in special circumstances since it bypasses the cache.
void SetText(const QString &text, const QString &name="", const QString &state="")
virtual void SetArea(const MythRect &rect)
Definition: mythuitype.cpp:610
void Hide(void)
void Refresh(void)
void DeleteChild(const QString &name)
Delete a named child of this UIType.
Definition: mythuitype.cpp:153
void Show(void)
Web browsing widget.
QString GetTitle(void)
Gets the current page's title.
void iconChanged(const QIcon &icon)
link hit test messages
void titleChanged(const QString &title)
% of page loaded
void Init(void)
Initializes the widget ready for use.
void SetActive(bool active)
Toggles the active state of the widget.
void statusBarMessage(const QString &text)
a pages title has changed
void loadProgress(int progress)
a page has finished loading
void loadStarted(void)
void loadFinished(bool ok)
a page is starting to load
~WebPage() override
Definition: webpage.cpp:47
bool m_active
Definition: webpage.h:47
MythUIWebBrowser * m_browser
Definition: webpage.h:50
void SetActive(bool active)
Definition: webpage.cpp:63
MythUIButtonListItem * m_listItem
Definition: webpage.h:51
void slotLoadStarted(void)
Definition: webpage.cpp:106
void slotLoadFinished(bool OK)
Definition: webpage.cpp:116
WebPage(MythBrowser *parent, QRect area, const char *name)
Definition: webpage.cpp:15
void slotIconChanged(const QIcon &icon)
Definition: webpage.cpp:79
void loadProgress(int progress)
void slotStatusBarMessage(const QString &text)
Definition: webpage.cpp:131
void loadFinished(bool OK)
void slotLoadProgress(int progress)
Definition: webpage.cpp:125
MythBrowser * m_parent
Definition: webpage.h:49
void statusBarMessage(const QString &text)
void slotTitleChanged(const QString &title)
Definition: webpage.cpp:137
static constexpr int OK
Definition: dvbci.cpp:69
MythPainter * GetMythPainter(void)