Something went wrong. Try again.
plyght's own C++ browser for macOS
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758#pragma once
#include <QColor>#include <QPixmap>#include <QUrl>#include <QWidget>
class WebKitProfile;
// Thin QWidget wrapper around a native WKWebView. Mirrors the bits of// QWebEngineView's API that BrowserWindow uses.class WebView final : public QWidget { Q_OBJECTpublic: explicit WebView(WebKitProfile *profile, QWidget *parent = nullptr); ~WebView() override;
void load(const QUrl &url); void loadHtml(const QString &html); void back(); void forward(); void reload(); QUrl url() const; QString title() const; QPixmap snapshot(const QSize &size) const; void *nativeWebView() const;
// Internal: install an externally-created WKWebView (used by the // WKUIDelegate's createWebViewWithConfiguration: path so popups stay // wired to their opener's session). Takes ownership of the NSView. void adoptNativeWebView(void *wkWebView);
// Last colour reported by sniffTopColor() (or invalid if never sniffed). QColor cachedThemeColor() const; // Re-runs the sniff JS and (asynchronously) emits themeColorChanged. void sniffTopColor();
signals: void urlChanged(const QUrl &url); void titleChanged(const QString &title); void loadProgress(int progress); void loadFinished(bool ok); void newTabRequested(WebView *child, bool background); void closeRequested(); // Emitted after a navigation finishes, with the page's preferred chrome // colour. Invalid QColor when the page exposes nothing useful. void themeColorChanged(const QColor &color); void contentMouseDown();
protected: void resizeEvent(QResizeEvent *e) override; void showEvent(QShowEvent *e) override;
private: struct Impl; Impl *m_impl;};