mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
FileSystemWatcher: Reloading local files when they changes
- implement with QFileSystemWatcher - only one tab with the same file will be watched
This commit is contained in:
parent
de3535b8db
commit
9be140ffa6
@ -39,6 +39,7 @@ WebPage::WebPage(WebView* parent, QupZilla* mainClass)
|
||||
, p_QupZilla(mainClass)
|
||||
, m_view(parent)
|
||||
, m_speedDial(mApp->plugins()->speedDial())
|
||||
, m_fileWatcher(0)
|
||||
, m_runningLoop(0)
|
||||
, m_blockAlerts(false)
|
||||
, m_secureStatus(false)
|
||||
@ -99,9 +100,33 @@ void WebPage::finished()
|
||||
mainFrame()->setZoomFactor(mainFrame()->zoomFactor() - 1);
|
||||
}
|
||||
|
||||
if (mainFrame()->url().scheme() == "file") {
|
||||
if (!m_fileWatcher) {
|
||||
m_fileWatcher = new QFileSystemWatcher(this);
|
||||
connect(m_fileWatcher, SIGNAL(fileChanged(QString)), this, SLOT(watchedFileChanged(QString)));
|
||||
}
|
||||
|
||||
QString absPath = mainFrame()->url().toLocalFile();
|
||||
|
||||
if (!m_fileWatcher->files().contains(absPath)) {
|
||||
m_fileWatcher->addPath(absPath);
|
||||
}
|
||||
}
|
||||
else if (m_fileWatcher) {
|
||||
m_fileWatcher->removePaths(m_fileWatcher->files());
|
||||
}
|
||||
|
||||
QTimer::singleShot(100, this, SLOT(cleanBlockedObjects()));
|
||||
}
|
||||
|
||||
void WebPage::watchedFileChanged(const QString &file)
|
||||
{
|
||||
qDebug() << file;
|
||||
if (mainFrame()->url().toLocalFile() == file) {
|
||||
triggerAction(QWebPage::Reload);
|
||||
}
|
||||
}
|
||||
|
||||
//void WebPage::loadingStarted()
|
||||
//{
|
||||
// m_adBlockedEntries.clear();
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <QStyle>
|
||||
#include <QFileDialog>
|
||||
#include <QWebInspector>
|
||||
#include <QFileSystemWatcher>
|
||||
|
||||
class QupZilla;
|
||||
class WebView;
|
||||
@ -86,6 +87,8 @@ private slots:
|
||||
void urlChanged(const QUrl &url);
|
||||
void addJavaScriptObject();
|
||||
|
||||
void watchedFileChanged(const QString &file);
|
||||
|
||||
private:
|
||||
virtual bool supportsExtension(Extension extension) const { return (extension == ErrorPageExtension); }
|
||||
virtual bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output = 0);
|
||||
@ -102,6 +105,7 @@ private:
|
||||
QSslCertificate m_SslCert;
|
||||
QList<QSslCertificate> m_SslCerts;
|
||||
QList<AdBlockedEntry> m_adBlockedEntries;
|
||||
QFileSystemWatcher* m_fileWatcher;
|
||||
|
||||
QEventLoop* m_runningLoop;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user