mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 21:18:14 +00:00
Taskbar: Add a context menu to open clock settings from the clock widget
This commit is contained in:
parent
c64a5ccf29
commit
73fcaaeda4
2 changed files with 21 additions and 0 deletions
|
@ -6,10 +6,13 @@
|
|||
|
||||
#include "ClockWidget.h"
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/Process.h>
|
||||
#include <LibGUI/SeparatorWidget.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/Font/FontDatabase.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
|
||||
|
@ -196,6 +199,22 @@ void ClockWidget::mousedown_event(GUI::MouseEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
void ClockWidget::context_menu_event(GUI::ContextMenuEvent& event)
|
||||
{
|
||||
if (!m_context_menu) {
|
||||
m_context_menu = GUI::Menu::construct();
|
||||
|
||||
auto settings_icon = MUST(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"sv));
|
||||
auto open_clock_settings_action = GUI::Action::create("Clock &Settings", *settings_icon, [this](auto&) {
|
||||
GUI::Process::spawn_or_show_error(window(), "/bin/ClockSettings"sv, Array { "--open-tab", "clock" });
|
||||
});
|
||||
|
||||
m_context_menu->add_action(open_clock_settings_action);
|
||||
}
|
||||
|
||||
m_context_menu->popup(event.screen_position());
|
||||
}
|
||||
|
||||
void ClockWidget::open()
|
||||
{
|
||||
jump_to_current_date();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue