diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-07-26 11:59:38 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-07-26 11:59:38 +0530 |
| commit | 2078c60477842d7cf6991148e23979565737a8b5 (patch) | |
| tree | 980e2aea150e85c6b87f2b521fce1006486244d8 /src/widgets/Decorations.cpp | |
| parent | 68448538172663279919b29dd09b5faa51e0628a (diff) | |
| download | null-browser-2078c60477842d7cf6991148e23979565737a8b5.tar.gz null-browser-2078c60477842d7cf6991148e23979565737a8b5.zip | |
Refactor heavy + extras.tabline module (incomplete)
Diffstat (limited to 'src/widgets/Decorations.cpp')
| -rw-r--r-- | src/widgets/Decorations.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/widgets/Decorations.cpp b/src/widgets/Decorations.cpp index 9df4c23..223e19a 100644 --- a/src/widgets/Decorations.cpp +++ b/src/widgets/Decorations.cpp @@ -6,6 +6,7 @@ #include <qwidget.h> #include "Decorations.hpp" +#include "WebViewData.hpp" #include "widgets/EdgeDecoration.hpp" Decorations::Decorations(QWidget *content_widget, QWebEngineProfile *profile, QWidget *parent) @@ -36,17 +37,17 @@ Decorations::Decorations(QWidget *content_widget, QWebEngineProfile *profile, QW } void Decorations::set_enabled(DecorationType type, bool enabled) { - auto decoration = get_decoration_widget(type); + auto decoration = get_decoration_widget_type(type); if (decoration.has_value()) decoration.value()->set_enabled(enabled); } bool Decorations::get_enabled(DecorationType type) { - auto decoration = get_decoration_widget(type); + auto decoration = get_decoration_widget_type(type); return decoration.has_value() && decoration.value()->is_enabled(); } -std::optional<EdgeDecoration *> Decorations::get_decoration_widget(DecorationType type) { +std::optional<EdgeDecoration *> Decorations::get_decoration_widget_type(DecorationType type) { switch (type) { case DecorationType::DecorationTop: return decoration_top; @@ -59,3 +60,31 @@ std::optional<EdgeDecoration *> Decorations::get_decoration_widget(DecorationTyp } return nullptr; } + +std::optional<EdgeDecoration *> Decorations::get_decoration_widget_by_view_id(WebViewId view_id) { + for (auto *decoration : decorations()) + if (decoration->get_view_id() == view_id) + return std::make_optional(decoration); + return std::nullopt; +} + +bool Decorations::has_webview(WebViewId view_id) { + return get_decoration_widget_by_view_id(view_id).has_value(); +} + +void Decorations::open_url(const QUrl &url, OpenType /*unused*/, WebViewId view_id) { + auto decoration = get_decoration_widget_by_view_id(view_id); + if (decoration.has_value()) + decoration.value()->set_url(url); +} + +void Decorations::set_html(const QString &html, WebViewId view_id) { + auto decoration = get_decoration_widget_by_view_id(view_id); + if (decoration.has_value()) + decoration.value()->set_html(html); +} + +std::optional<WebViewId> Decorations::get_view_id(DecorationType type) { + auto decoration = get_decoration_widget_type(type); + return decoration.has_value() ? decoration.value()->get_view_id() : std::nullopt; +} |
