mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02: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_menu(new Menu(this))
|
||||
, m_mouseTrack(false)
|
||||
, m_hasRss(false)
|
||||
, m_rssChecked(false)
|
||||
{
|
||||
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
|
||||
connect(this, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
|
||||
@ -128,9 +126,7 @@ void TabbedWebView::urlChanged(const QUrl &url)
|
||||
|
||||
void TabbedWebView::loadProgress(int prog)
|
||||
{
|
||||
if (prog > 60) {
|
||||
checkRss();
|
||||
}
|
||||
Q_UNUSED(prog)
|
||||
|
||||
if (isCurrent()) {
|
||||
p_QupZilla->updateLoadingActions();
|
||||
@ -147,9 +143,6 @@ void TabbedWebView::userLoadAction(const QUrl &url)
|
||||
|
||||
void TabbedWebView::slotLoadStarted()
|
||||
{
|
||||
m_rssChecked = false;
|
||||
emit rssChanged(false);
|
||||
|
||||
m_tabWidget->startTabAnimation(tabIndex());
|
||||
|
||||
if (title().isNull()) {
|
||||
@ -239,20 +232,6 @@ void TabbedWebView::closeView()
|
||||
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)
|
||||
{
|
||||
m_menu->clear();
|
||||
|
@ -43,9 +43,7 @@ public:
|
||||
TabWidget* tabWidget() const;
|
||||
|
||||
QString getIp() const;
|
||||
|
||||
int tabIndex() const;
|
||||
bool hasRss() { return m_hasRss; }
|
||||
|
||||
QWidget* overlayForJsAlert();
|
||||
void disconnectObjects();
|
||||
@ -53,7 +51,6 @@ public:
|
||||
signals:
|
||||
void wantsCloseTab(int);
|
||||
void ipChanged(QString);
|
||||
void rssChanged(bool);
|
||||
void changed();
|
||||
|
||||
public slots:
|
||||
@ -78,7 +75,6 @@ private slots:
|
||||
void urlChanged(const QUrl &url);
|
||||
void linkHovered(const QString &link, const QString &title, const QString &content);
|
||||
void setIp(const QHostInfo &info);
|
||||
void checkRss();
|
||||
void slotIconChanged();
|
||||
|
||||
void inspectElement();
|
||||
@ -98,8 +94,6 @@ private:
|
||||
Menu* m_menu;
|
||||
|
||||
bool m_mouseTrack;
|
||||
bool m_hasRss;
|
||||
bool m_rssChecked;
|
||||
|
||||
};
|
||||
|
||||
|
@ -59,6 +59,8 @@ WebView::WebView(QWidget* parent)
|
||||
, m_actionsInitialized(false)
|
||||
, m_disableTouchMocking(false)
|
||||
, m_isReloading(false)
|
||||
, m_hasRss(false)
|
||||
, m_rssChecked(false)
|
||||
{
|
||||
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
|
||||
connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
|
||||
@ -218,6 +220,11 @@ void WebView::fakeLoadingProgress(int progress)
|
||||
emit loadProgress(progress);
|
||||
}
|
||||
|
||||
bool WebView::hasRss() const
|
||||
{
|
||||
return m_hasRss;
|
||||
}
|
||||
|
||||
bool WebView::isUrlValid(const QUrl &url)
|
||||
{
|
||||
const QString &urlScheme = url.scheme();
|
||||
@ -359,11 +366,18 @@ void WebView::slotLoadStarted()
|
||||
m_actionStop->setEnabled(true);
|
||||
m_actionReload->setEnabled(false);
|
||||
}
|
||||
|
||||
m_rssChecked = false;
|
||||
emit rssChanged(false);
|
||||
}
|
||||
|
||||
void WebView::slotLoadProgress(int progress)
|
||||
{
|
||||
m_progress = progress;
|
||||
|
||||
if (m_progress > 60) {
|
||||
checkRss();
|
||||
}
|
||||
}
|
||||
|
||||
void WebView::slotLoadFinished()
|
||||
@ -395,6 +409,20 @@ void WebView::emitChangedUrl()
|
||||
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()
|
||||
{
|
||||
if (!loadingError()) {
|
||||
|
@ -46,6 +46,8 @@ public:
|
||||
int loadingProgress() const;
|
||||
void fakeLoadingProgress(int progress);
|
||||
|
||||
bool hasRss() const;
|
||||
|
||||
void addNotification(QWidget* notif);
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
@ -59,6 +61,7 @@ signals:
|
||||
void viewportResized(QSize);
|
||||
void showNotification(QWidget*);
|
||||
void privacyChanged(bool);
|
||||
void rssChanged(bool);
|
||||
|
||||
public slots:
|
||||
void zoomIn();
|
||||
@ -150,6 +153,7 @@ private slots:
|
||||
void muteMedia();
|
||||
void frameStateChanged();
|
||||
void emitChangedUrl();
|
||||
void checkRss();
|
||||
|
||||
private:
|
||||
QList<int> m_zoomLevels;
|
||||
@ -174,6 +178,9 @@ private:
|
||||
|
||||
bool m_disableTouchMocking;
|
||||
bool m_isReloading;
|
||||
|
||||
bool m_hasRss;
|
||||
bool m_rssChecked;
|
||||
};
|
||||
|
||||
#endif // WEBVIEW_H
|
||||
|
Loading…
Reference in New Issue
Block a user