From 5a154d7765f691c86841d5f9bd02f011d3e57364 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Thu, 14 Nov 2024 17:24:07 +0000 Subject: [PATCH 1/7] Refactor variable --- src/MenuBar/MenuBar.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MenuBar/MenuBar.php b/src/MenuBar/MenuBar.php index 9885233..63c4fca 100644 --- a/src/MenuBar/MenuBar.php +++ b/src/MenuBar/MenuBar.php @@ -20,7 +20,7 @@ class MenuBar protected string $label = ''; - protected bool $onlyShowContextWindow = false; + protected bool $onlyShowContextMenu = false; protected ?Menu $contextMenu = null; @@ -51,7 +51,7 @@ public function icon(string $icon): self public function onlyShowContextMenu(bool $onlyContextMenu = true): self { - $this->onlyShowContextWindow = $onlyContextMenu; + $this->onlyShowContextMenu = $onlyContextMenu; return $this; } @@ -106,7 +106,7 @@ public function toArray(): array 'showDockIcon' => $this->showDockIcon, 'transparency' => $this->transparent, 'backgroundColor' => $this->backgroundColor, - 'onlyShowContextWindow' => $this->onlyShowContextWindow, + 'onlyShowContextMenu' => $this->onlyShowContextMenu, 'contextMenu' => ! is_null($this->contextMenu) ? $this->contextMenu->toArray()['submenu'] : null, 'alwaysOnTop' => $this->alwaysOnTop, ]; From 68a7867c27e19151f5e83a1c324a7c2b6b6f19d8 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Thu, 14 Nov 2024 17:31:32 +0000 Subject: [PATCH 2/7] Remove override method `url` is already available from the `HasUrl` trait --- src/MenuBar/MenuBar.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/MenuBar/MenuBar.php b/src/MenuBar/MenuBar.php index 63c4fca..622c7b6 100644 --- a/src/MenuBar/MenuBar.php +++ b/src/MenuBar/MenuBar.php @@ -56,13 +56,6 @@ public function onlyShowContextMenu(bool $onlyContextMenu = true): self return $this; } - public function url(string $url): self - { - $this->url = $url; - - return $this; - } - public function showDockIcon($value = true): self { $this->showDockIcon = $value; From bdef6a9594512ccc1df1f3bac1a1d29558f7aebd Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Thu, 14 Nov 2024 17:32:08 +0000 Subject: [PATCH 3/7] Add tooltip setting --- src/MenuBar/MenuBar.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/MenuBar/MenuBar.php b/src/MenuBar/MenuBar.php index 622c7b6..4ae73df 100644 --- a/src/MenuBar/MenuBar.php +++ b/src/MenuBar/MenuBar.php @@ -20,6 +20,8 @@ class MenuBar protected string $label = ''; + protected string $tooltip = ''; + protected bool $onlyShowContextMenu = false; protected ?Menu $contextMenu = null; @@ -70,6 +72,13 @@ public function label(string $label = ''): self return $this; } + public function tooltip(string $tooltip = ''): self + { + $this->tooltip = $tooltip; + + return $this; + } + public function alwaysOnTop($alwaysOnTop = true): self { $this->alwaysOnTop = $alwaysOnTop; @@ -93,6 +102,7 @@ public function toArray(): array 'x' => $this->x, 'y' => $this->y, 'label' => $this->label, + 'tooltip' => $this->tooltip, 'width' => $this->width, 'height' => $this->height, 'vibrancy' => $this->vibrancy, From 1e2ea1697fa8b294d17bfa9e5e9695be93a19ad1 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Thu, 14 Nov 2024 17:32:16 +0000 Subject: [PATCH 4/7] Add resizable setting --- src/MenuBar/MenuBar.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/MenuBar/MenuBar.php b/src/MenuBar/MenuBar.php index 4ae73df..13a5709 100644 --- a/src/MenuBar/MenuBar.php +++ b/src/MenuBar/MenuBar.php @@ -22,6 +22,8 @@ class MenuBar protected string $tooltip = ''; + protected bool $resizable = true; + protected bool $onlyShowContextMenu = false; protected ?Menu $contextMenu = null; @@ -79,6 +81,13 @@ public function tooltip(string $tooltip = ''): self return $this; } + public function resizable(bool $resizable = true): static + { + $this->resizable = $resizable; + + return $this; + } + public function alwaysOnTop($alwaysOnTop = true): self { $this->alwaysOnTop = $alwaysOnTop; @@ -103,6 +112,7 @@ public function toArray(): array 'y' => $this->y, 'label' => $this->label, 'tooltip' => $this->tooltip, + 'resizable' => $this->resizable, 'width' => $this->width, 'height' => $this->height, 'vibrancy' => $this->vibrancy, From ad88ff8f43b7e2d05d3e9db714b99f40088cb2cc Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Thu, 14 Nov 2024 17:32:34 +0000 Subject: [PATCH 5/7] Allow updating of tooltip --- src/MenuBar/MenuBarManager.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/MenuBar/MenuBarManager.php b/src/MenuBar/MenuBarManager.php index 04aedb0..591f6ac 100644 --- a/src/MenuBar/MenuBarManager.php +++ b/src/MenuBar/MenuBarManager.php @@ -31,6 +31,13 @@ public function label(string $label) ]); } + public function tooltip(string $tooltip) + { + $this->client->post('menu-bar/tooltip', [ + 'tooltip' => $tooltip, + ]); + } + public function contextMenu(Menu $contextMenu) { $this->client->post('menu-bar/context-menu', [ From 6d531acced9ce5649799f84f3a7c9df20e725c13 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Thu, 14 Nov 2024 17:32:43 +0000 Subject: [PATCH 6/7] Allow updating of icon --- src/MenuBar/MenuBarManager.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/MenuBar/MenuBarManager.php b/src/MenuBar/MenuBarManager.php index 591f6ac..b10992d 100644 --- a/src/MenuBar/MenuBarManager.php +++ b/src/MenuBar/MenuBarManager.php @@ -38,6 +38,13 @@ public function tooltip(string $tooltip) ]); } + public function icon(string $icon) + { + $this->client->post('menu-bar/icon', [ + 'icon' => $icon, + ]); + } + public function contextMenu(Menu $contextMenu) { $this->client->post('menu-bar/context-menu', [ From 8a978958452a44e51f7f524bd388680ad26ebde2 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Thu, 14 Nov 2024 18:04:52 +0000 Subject: [PATCH 7/7] Support firing a custom event on click --- src/MenuBar/MenuBar.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/MenuBar/MenuBar.php b/src/MenuBar/MenuBar.php index 13a5709..cfc2873 100644 --- a/src/MenuBar/MenuBar.php +++ b/src/MenuBar/MenuBar.php @@ -30,6 +30,8 @@ class MenuBar protected bool $alwaysOnTop = false; + protected ?string $event = null; + protected bool $showDockIcon = false; protected Client $client; @@ -95,6 +97,13 @@ public function alwaysOnTop($alwaysOnTop = true): self return $this; } + public function event(string $event): self + { + $this->event = $event; + + return $this; + } + public function withContextMenu(Menu $menu): self { $this->contextMenu = $menu; @@ -122,6 +131,7 @@ public function toArray(): array 'onlyShowContextMenu' => $this->onlyShowContextMenu, 'contextMenu' => ! is_null($this->contextMenu) ? $this->contextMenu->toArray()['submenu'] : null, 'alwaysOnTop' => $this->alwaysOnTop, + 'event' => $this->event, ]; } }