mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-24 04:36:34 +01:00
[code] Moved checking for RSS into WebView.
This commit is contained in:
parent
49b1e4c43c
commit
23690d4154
@ -44,8 +44,6 @@ TabbedWebView::TabbedWebView(QupZilla* mainClass, WebTab* webTab)
|
|||||||
, m_webTab(webTab)
|
, m_webTab(webTab)
|
||||||
, m_menu(new Menu(this))
|
, m_menu(new Menu(this))
|
||||||
, m_mouseTrack(false)
|
, m_mouseTrack(false)
|
||||||
, m_hasRss(false)
|
|
||||||
, m_rssChecked(false)
|
|
||||||
{
|
{
|
||||||
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
|
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
|
||||||
connect(this, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
|
connect(this, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
|
||||||
@ -128,9 +126,7 @@ void TabbedWebView::urlChanged(const QUrl &url)
|
|||||||
|
|
||||||
void TabbedWebView::loadProgress(int prog)
|
void TabbedWebView::loadProgress(int prog)
|
||||||
{
|
{
|
||||||
if (prog > 60) {
|
Q_UNUSED(prog)
|
||||||
checkRss();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isCurrent()) {
|
if (isCurrent()) {
|
||||||
p_QupZilla->updateLoadingActions();
|
p_QupZilla->updateLoadingActions();
|
||||||
@ -147,9 +143,6 @@ void TabbedWebView::userLoadAction(const QUrl &url)
|
|||||||
|
|
||||||
void TabbedWebView::slotLoadStarted()
|
void TabbedWebView::slotLoadStarted()
|
||||||
{
|
{
|
||||||
m_rssChecked = false;
|
|
||||||
emit rssChanged(false);
|
|
||||||
|
|
||||||
m_tabWidget->startTabAnimation(tabIndex());
|
m_tabWidget->startTabAnimation(tabIndex());
|
||||||
|
|
||||||
if (title().isNull()) {
|
if (title().isNull()) {
|
||||||
@ -239,20 +232,6 @@ void TabbedWebView::closeView()
|
|||||||
emit wantsCloseTab(tabIndex());
|
emit wantsCloseTab(tabIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabbedWebView::checkRss()
|
|
||||||
{
|
|
||||||
if (m_rssChecked) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_rssChecked = true;
|
|
||||||
QWebFrame* frame = page()->mainFrame();
|
|
||||||
const QWebElementCollection &links = frame->findAllElements("link[type=\"application/rss+xml\"]");
|
|
||||||
|
|
||||||
m_hasRss = links.count() != 0;
|
|
||||||
emit rssChanged(m_hasRss);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabbedWebView::contextMenuEvent(QContextMenuEvent* event)
|
void TabbedWebView::contextMenuEvent(QContextMenuEvent* event)
|
||||||
{
|
{
|
||||||
m_menu->clear();
|
m_menu->clear();
|
||||||
|
@ -43,9 +43,7 @@ public:
|
|||||||
TabWidget* tabWidget() const;
|
TabWidget* tabWidget() const;
|
||||||
|
|
||||||
QString getIp() const;
|
QString getIp() const;
|
||||||
|
|
||||||
int tabIndex() const;
|
int tabIndex() const;
|
||||||
bool hasRss() { return m_hasRss; }
|
|
||||||
|
|
||||||
QWidget* overlayForJsAlert();
|
QWidget* overlayForJsAlert();
|
||||||
void disconnectObjects();
|
void disconnectObjects();
|
||||||
@ -53,7 +51,6 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void wantsCloseTab(int);
|
void wantsCloseTab(int);
|
||||||
void ipChanged(QString);
|
void ipChanged(QString);
|
||||||
void rssChanged(bool);
|
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -78,7 +75,6 @@ private slots:
|
|||||||
void urlChanged(const QUrl &url);
|
void urlChanged(const QUrl &url);
|
||||||
void linkHovered(const QString &link, const QString &title, const QString &content);
|
void linkHovered(const QString &link, const QString &title, const QString &content);
|
||||||
void setIp(const QHostInfo &info);
|
void setIp(const QHostInfo &info);
|
||||||
void checkRss();
|
|
||||||
void slotIconChanged();
|
void slotIconChanged();
|
||||||
|
|
||||||
void inspectElement();
|
void inspectElement();
|
||||||
@ -98,8 +94,6 @@ private:
|
|||||||
Menu* m_menu;
|
Menu* m_menu;
|
||||||
|
|
||||||
bool m_mouseTrack;
|
bool m_mouseTrack;
|
||||||
bool m_hasRss;
|
|
||||||
bool m_rssChecked;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ WebView::WebView(QWidget* parent)
|
|||||||
, m_actionsInitialized(false)
|
, m_actionsInitialized(false)
|
||||||
, m_disableTouchMocking(false)
|
, m_disableTouchMocking(false)
|
||||||
, m_isReloading(false)
|
, m_isReloading(false)
|
||||||
|
, m_hasRss(false)
|
||||||
|
, m_rssChecked(false)
|
||||||
{
|
{
|
||||||
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
|
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
|
||||||
connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
|
connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
|
||||||
@ -218,6 +220,11 @@ void WebView::fakeLoadingProgress(int progress)
|
|||||||
emit loadProgress(progress);
|
emit loadProgress(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WebView::hasRss() const
|
||||||
|
{
|
||||||
|
return m_hasRss;
|
||||||
|
}
|
||||||
|
|
||||||
bool WebView::isUrlValid(const QUrl &url)
|
bool WebView::isUrlValid(const QUrl &url)
|
||||||
{
|
{
|
||||||
const QString &urlScheme = url.scheme();
|
const QString &urlScheme = url.scheme();
|
||||||
@ -359,11 +366,18 @@ void WebView::slotLoadStarted()
|
|||||||
m_actionStop->setEnabled(true);
|
m_actionStop->setEnabled(true);
|
||||||
m_actionReload->setEnabled(false);
|
m_actionReload->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_rssChecked = false;
|
||||||
|
emit rssChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::slotLoadProgress(int progress)
|
void WebView::slotLoadProgress(int progress)
|
||||||
{
|
{
|
||||||
m_progress = progress;
|
m_progress = progress;
|
||||||
|
|
||||||
|
if (m_progress > 60) {
|
||||||
|
checkRss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::slotLoadFinished()
|
void WebView::slotLoadFinished()
|
||||||
@ -395,6 +409,20 @@ void WebView::emitChangedUrl()
|
|||||||
emit urlChanged(url());
|
emit urlChanged(url());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebView::checkRss()
|
||||||
|
{
|
||||||
|
if (m_rssChecked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_rssChecked = true;
|
||||||
|
QWebFrame* frame = page()->mainFrame();
|
||||||
|
const QWebElementCollection &links = frame->findAllElements("link[type=\"application/rss+xml\"]");
|
||||||
|
|
||||||
|
m_hasRss = links.count() != 0;
|
||||||
|
emit rssChanged(m_hasRss);
|
||||||
|
}
|
||||||
|
|
||||||
void WebView::slotIconChanged()
|
void WebView::slotIconChanged()
|
||||||
{
|
{
|
||||||
if (!loadingError()) {
|
if (!loadingError()) {
|
||||||
|
@ -46,6 +46,8 @@ public:
|
|||||||
int loadingProgress() const;
|
int loadingProgress() const;
|
||||||
void fakeLoadingProgress(int progress);
|
void fakeLoadingProgress(int progress);
|
||||||
|
|
||||||
|
bool hasRss() const;
|
||||||
|
|
||||||
void addNotification(QWidget* notif);
|
void addNotification(QWidget* notif);
|
||||||
bool eventFilter(QObject* obj, QEvent* event);
|
bool eventFilter(QObject* obj, QEvent* event);
|
||||||
|
|
||||||
@ -59,6 +61,7 @@ signals:
|
|||||||
void viewportResized(QSize);
|
void viewportResized(QSize);
|
||||||
void showNotification(QWidget*);
|
void showNotification(QWidget*);
|
||||||
void privacyChanged(bool);
|
void privacyChanged(bool);
|
||||||
|
void rssChanged(bool);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
@ -150,6 +153,7 @@ private slots:
|
|||||||
void muteMedia();
|
void muteMedia();
|
||||||
void frameStateChanged();
|
void frameStateChanged();
|
||||||
void emitChangedUrl();
|
void emitChangedUrl();
|
||||||
|
void checkRss();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<int> m_zoomLevels;
|
QList<int> m_zoomLevels;
|
||||||
@ -174,6 +178,9 @@ private:
|
|||||||
|
|
||||||
bool m_disableTouchMocking;
|
bool m_disableTouchMocking;
|
||||||
bool m_isReloading;
|
bool m_isReloading;
|
||||||
|
|
||||||
|
bool m_hasRss;
|
||||||
|
bool m_rssChecked;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WEBVIEW_H
|
#endif // WEBVIEW_H
|
||||||
|
Loading…
Reference in New Issue
Block a user