diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-07-25 20:27:44 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-07-25 20:28:05 +0530 |
| commit | 81dcf7de91c1866d565f7aa9eb38f7fbd1cd7ad7 (patch) | |
| tree | aa24bcea93d19ce6298ad6aed499d324fac2ceae /src/widgets | |
| parent | 2c7d36b4aa53ffa638a7aa7046767f10e7a152bf (diff) | |
| download | null-browser-81dcf7de91c1866d565f7aa9eb38f7fbd1cd7ad7.tar.gz null-browser-81dcf7de91c1866d565f7aa9eb38f7fbd1cd7ad7.zip | |
Add decoration is_enabled api + allowed specifying win_id for enabled
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/BrowserApp.cpp | 5 | ||||
| -rw-r--r-- | src/widgets/BrowserWindow.hpp | 1 | ||||
| -rw-r--r-- | src/widgets/Decorations.cpp | 8 | ||||
| -rw-r--r-- | src/widgets/Decorations.hpp | 1 | ||||
| -rw-r--r-- | src/widgets/EdgeDecoration.hpp | 3 |
5 files changed, 16 insertions, 2 deletions
diff --git a/src/widgets/BrowserApp.cpp b/src/widgets/BrowserApp.cpp index 49054b8..d096f01 100644 --- a/src/widgets/BrowserApp.cpp +++ b/src/widgets/BrowserApp.cpp @@ -6,6 +6,7 @@ #include "LuaRuntime.hpp" #include "WindowActionRouter.hpp" #include "events/NotificationReceivedEvent.hpp" +#include "events/WinCreatedEvent.hpp" #include "widgets/BrowserWindow.hpp" #include "widgets/BrowserApp.hpp" @@ -59,6 +60,10 @@ BrowserWindow *BrowserApp::create_window(const QStringList &urls) { WindowActionRouter::instance().add_window(window); window->show(); + + auto *event = new WinCreatedEvent(window->get_id()); + WindowActionRouter::instance().dispatch_event(event); + return window; } diff --git a/src/widgets/BrowserWindow.hpp b/src/widgets/BrowserWindow.hpp index 98686fd..2927683 100644 --- a/src/widgets/BrowserWindow.hpp +++ b/src/widgets/BrowserWindow.hpp @@ -32,6 +32,7 @@ public: DELEGATE(webview_stack, scroll_to_top, scroll_to_top) DELEGATE(webview_stack, scroll_to_bottom, scroll_to_bottom) DELEGATE(decorations, set_enabled, set_decoration_enabled) + DELEGATE(decorations, get_enabled, get_decoration_enabled) bool on_window_key_event(QKeyEvent *event); diff --git a/src/widgets/Decorations.cpp b/src/widgets/Decorations.cpp index d559776..82c1a65 100644 --- a/src/widgets/Decorations.cpp +++ b/src/widgets/Decorations.cpp @@ -45,12 +45,16 @@ Decorations::Decorations(QWidget *content_widget, QWebEngineProfile *profile, QW } void Decorations::set_enabled(DecorationType type, bool enabled) { - std::optional<EdgeDecoration *> decoration = get_decoration_widget(type); - + auto decoration = get_decoration_widget(type); if (decoration.has_value()) decoration.value()->set_enabled(enabled); } +bool Decorations::get_enabled(DecorationType type) { + auto decoration = get_decoration_widget(type); + return decoration.has_value() && decoration.value()->is_enabled(); +} + std::optional<EdgeDecoration *> Decorations::get_decoration_widget(DecorationType type) { switch (type) { case DecorationType::DecorationTop: diff --git a/src/widgets/Decorations.hpp b/src/widgets/Decorations.hpp index d58ee7f..30df104 100644 --- a/src/widgets/Decorations.hpp +++ b/src/widgets/Decorations.hpp @@ -20,6 +20,7 @@ public: Decorations(QWidget *content_widget, QWebEngineProfile *profile, QWidget *parent = nullptr); void set_enabled(DecorationType type, bool enabled); + bool get_enabled(DecorationType type); private: EdgeDecoration *decoration_top; diff --git a/src/widgets/EdgeDecoration.hpp b/src/widgets/EdgeDecoration.hpp index 59390dc..3ee0ab5 100644 --- a/src/widgets/EdgeDecoration.hpp +++ b/src/widgets/EdgeDecoration.hpp @@ -7,6 +7,7 @@ #include <qwebengineprofile.h> #include <qwebengineview.h> +#include "utils.hpp" #include "widgets/WebView.hpp" class EdgeDecoration : public QWidget { @@ -19,6 +20,8 @@ public: void set_html(const QString &content); void set_enabled(bool enabled_value); + DEFINE_GETTER(is_enabled, enabled) + private: bool vertical; std::optional<WebView *> webview = std::nullopt; |
