Add a property zimId in the WebView.

This commit is contained in:
Matthieu Gautier 2018-07-23 15:25:15 +02:00
parent 5e80464128
commit b3fbeccfbc
2 changed files with 4 additions and 0 deletions

View File

@ -37,6 +37,7 @@ QWebEngineView* WebView::createWindow(QWebEnginePage::WebWindowType type)
void WebView::onUrlChanged(const QUrl& url) {
if (m_currentHost != url.host() ) {
m_currentHost = url.host();
emit zimIdChanged(m_currentHost);
auto app = KiwixApp::instance();
auto reader = app->getLibrary()->getReader(m_currentHost);
std::string favicon, _mimetype;

View File

@ -10,6 +10,7 @@ class WebView : public QWebEngineView
{
Q_OBJECT
Q_PROPERTY(const QIcon icon READ icon NOTIFY iconChanged);
Q_PROPERTY(QString zimId READ zimId NOTIFY zimIdChanged)
public:
WebView(QWidget *parent = Q_NULLPTR);
@ -17,12 +18,14 @@ public:
bool isWebActionEnabled(QWebEnginePage::WebAction webAction) const;
const QIcon &icon() { return m_icon; }
const QString &zimId() { return m_currentHost; }
public slots:
void onUrlChanged(const QUrl& url);
signals:
void iconChanged(const QIcon& icon);
void zimIdChanged(const QString& zimId);
protected:
virtual QWebEngineView* createWindow(QWebEnginePage::WebWindowType type);