From 031b22e0bb0f1d132731aea3776917731a8ab4ce Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 25 Jul 2025 23:17:02 +0530 Subject: Add decorations.*.view lua api + support decoration views for open url --- src/widgets/Decorations.hpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/widgets/Decorations.hpp') diff --git a/src/widgets/Decorations.hpp b/src/widgets/Decorations.hpp index 30df104..57fc526 100644 --- a/src/widgets/Decorations.hpp +++ b/src/widgets/Decorations.hpp @@ -1,6 +1,7 @@ #pragma once #include "widgets/EdgeDecoration.hpp" +#include "widgets/WebViewStack.hpp" #include #include #include @@ -22,11 +23,40 @@ public: void set_enabled(DecorationType type, bool enabled); bool get_enabled(DecorationType type); + std::optional get_view_id(DecorationType type) { + auto decoration = get_decoration_widget(type); + return decoration.has_value() ? decoration.value()->get_view_id() : std::nullopt; + } + + bool has_webview(WebViewId view_id) { + for (auto *decoration : decorations()) + if (decoration->get_view_id() == view_id) + return true; + return false; + } + + void open_url(const QUrl &url, WebViewId view_id) { + for (auto *decoration : decorations()) { + if (decoration->get_view_id() == view_id) { + decoration->set_url(url); + return; + } + } + } + private: EdgeDecoration *decoration_top; EdgeDecoration *decoration_bottom; EdgeDecoration *decoration_left; EdgeDecoration *decoration_right; + std::vector decorations() { + return { + decoration_top, + decoration_bottom, + decoration_left, + decoration_right, + }; + } std::optional get_decoration_widget(DecorationType type); }; -- cgit v1.3.1