From cefa2e3dd2455f40f7484a061ef02744149669a6 Mon Sep 17 00:00:00 2001 From: ForLoveOfCats Date: Mon, 28 Jun 2021 21:00:12 -0400 Subject: [PATCH] Taskbar: Add show desktop button to toggle showing of the desktop --- Userland/Services/Taskbar/TaskbarWindow.cpp | 11 +++++++++++ Userland/Services/Taskbar/TaskbarWindow.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp index a69dd1ec31d..59e7f295035 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.cpp +++ b/Userland/Services/Taskbar/TaskbarWindow.cpp @@ -88,6 +88,12 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr start_menu) main_widget.add(); + m_show_desktop_button = GUI::Button::construct(); + m_show_desktop_button->set_tooltip("Show Desktop"); + m_show_desktop_button->set_fixed_size(12, 21); + m_show_desktop_button->on_click = TaskbarWindow::show_desktop_button_clicked; + main_widget.add_child(*m_show_desktop_button); + auto af_path = String::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, "Assistant.af"); m_assistant_app_file = Desktop::AppFile::open(af_path); } @@ -96,6 +102,11 @@ TaskbarWindow::~TaskbarWindow() { } +void TaskbarWindow::show_desktop_button_clicked(unsigned) +{ + GUI::WindowManagerServerConnection::the().async_toggle_show_desktop(); +} + void TaskbarWindow::create_quick_launch_bar() { auto& quick_launch_bar = main_widget()->add(); diff --git a/Userland/Services/Taskbar/TaskbarWindow.h b/Userland/Services/Taskbar/TaskbarWindow.h index b89c604243a..2fbb17d4022 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.h +++ b/Userland/Services/Taskbar/TaskbarWindow.h @@ -21,6 +21,7 @@ public: private: explicit TaskbarWindow(NonnullRefPtr start_menu); + static void show_desktop_button_clicked(unsigned); void create_quick_launch_bar(); void on_screen_rects_change(const Vector&, size_t); NonnullRefPtr create_button(const WindowIdentifier&); @@ -44,6 +45,7 @@ private: Gfx::IntSize m_applet_area_size; RefPtr m_applet_area_container; RefPtr m_start_button; + RefPtr m_show_desktop_button; RefPtr m_assistant_app_file;