mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
Merge branch 'Falkon/3.0'
This commit is contained in:
commit
d5fc3ebc88
|
@ -89,8 +89,7 @@ FalkonSchemeReply::FalkonSchemeReply(QWebEngineUrlRequestJob *job, QObject *pare
|
||||||
{
|
{
|
||||||
m_pageName = m_job->requestUrl().path();
|
m_pageName = m_job->requestUrl().path();
|
||||||
|
|
||||||
open(QIODevice::ReadOnly);
|
QTimer::singleShot(0, this, &FalkonSchemeReply::loadPage);
|
||||||
m_buffer.open(QIODevice::ReadWrite);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FalkonSchemeReply::loadPage()
|
void FalkonSchemeReply::loadPage()
|
||||||
|
@ -98,38 +97,40 @@ void FalkonSchemeReply::loadPage()
|
||||||
if (m_loaded)
|
if (m_loaded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QTextStream stream(&m_buffer);
|
QString contents;
|
||||||
stream.setCodec("UTF-8");
|
|
||||||
|
|
||||||
if (m_pageName == QLatin1String("about")) {
|
if (m_pageName == QLatin1String("about")) {
|
||||||
stream << aboutPage();
|
contents = aboutPage();
|
||||||
}
|
} else if (m_pageName == QLatin1String("start")) {
|
||||||
else if (m_pageName == QLatin1String("start")) {
|
contents = startPage();
|
||||||
stream << startPage();
|
} else if (m_pageName == QLatin1String("speeddial")) {
|
||||||
}
|
contents = speeddialPage();
|
||||||
else if (m_pageName == QLatin1String("speeddial")) {
|
} else if (m_pageName == QLatin1String("config")) {
|
||||||
stream << speeddialPage();
|
contents = configPage();
|
||||||
}
|
} else if (m_pageName == QLatin1String("restore")) {
|
||||||
else if (m_pageName == QLatin1String("config")) {
|
contents = restorePage();
|
||||||
stream << configPage();
|
|
||||||
}
|
|
||||||
else if (m_pageName == QLatin1String("restore")) {
|
|
||||||
stream << restorePage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.flush();
|
QMutexLocker lock(&m_mutex);
|
||||||
m_buffer.reset();
|
m_buffer.setData(contents.toUtf8());
|
||||||
|
m_buffer.open(QIODevice::ReadOnly);
|
||||||
|
lock.unlock();
|
||||||
|
|
||||||
|
open(QIODevice::ReadOnly);
|
||||||
|
emit readyRead();
|
||||||
|
|
||||||
m_loaded = true;
|
m_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 FalkonSchemeReply::bytesAvailable() const
|
qint64 FalkonSchemeReply::bytesAvailable() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker lock(&m_mutex);
|
||||||
return m_buffer.bytesAvailable();
|
return m_buffer.bytesAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 FalkonSchemeReply::readData(char *data, qint64 maxSize)
|
qint64 FalkonSchemeReply::readData(char *data, qint64 maxSize)
|
||||||
{
|
{
|
||||||
loadPage();
|
QMutexLocker lock(&m_mutex);
|
||||||
return m_buffer.read(data, maxSize);
|
return m_buffer.read(data, maxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#ifndef FALKONSCHEMEHANDLER_H
|
#ifndef FALKONSCHEMEHANDLER_H
|
||||||
#define FALKONSCHEMEHANDLER_H
|
#define FALKONSCHEMEHANDLER_H
|
||||||
|
|
||||||
|
#include <QMutex>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QWebEngineUrlSchemeHandler>
|
#include <QWebEngineUrlSchemeHandler>
|
||||||
|
@ -60,6 +61,7 @@ private:
|
||||||
QBuffer m_buffer;
|
QBuffer m_buffer;
|
||||||
QString m_pageName;
|
QString m_pageName;
|
||||||
QWebEngineUrlRequestJob *m_job;
|
QWebEngineUrlRequestJob *m_job;
|
||||||
|
mutable QMutex m_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FALKONSCHEMEHANDLER_H
|
#endif // FALKONSCHEMEHANDLER_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user