mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
WorkspacePicker: Allow opening workspace settings via a context menu
Previously you had to open Display Settings and navigate to the "Workspaces" tab in order to edit workspace settings. This patch adds a context menu shortcut to the same place.
This commit is contained in:
parent
c3eaa73113
commit
2121760700
2 changed files with 37 additions and 3 deletions
|
@ -7,8 +7,10 @@
|
|||
*/
|
||||
|
||||
#include "DesktopStatusWindow.h"
|
||||
#include <LibCore/Process.h>
|
||||
#include <LibGUI/ConnectionToWindowManagerServer.h>
|
||||
#include <LibGUI/Desktop.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
|
@ -58,6 +60,9 @@ public:
|
|||
|
||||
virtual void mousedown_event(GUI::MouseEvent& event) override
|
||||
{
|
||||
if (event.button() != GUI::MouseButton::Primary)
|
||||
return;
|
||||
|
||||
auto base_rect = rect_for_desktop(0, 0);
|
||||
auto row = event.y() / (base_rect.height() + gap());
|
||||
auto column = event.x() / (base_rect.width() + gap());
|
||||
|
@ -95,7 +100,31 @@ public:
|
|||
GUI::ConnectionToWindowManagerServer::the().async_set_workspace(row, column);
|
||||
}
|
||||
|
||||
unsigned current_row() const { return m_current_row; }
|
||||
virtual void context_menu_event(GUI::ContextMenuEvent& event) override
|
||||
{
|
||||
event.accept();
|
||||
|
||||
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_workspace_settings_action = GUI::Action::create("Workspace &Settings", *settings_icon, [](auto&) {
|
||||
auto result = Core::Process::spawn("/bin/DisplaySettings"sv, Array { "--open-tab", "workspaces" }.span());
|
||||
if (result.is_error()) {
|
||||
dbgln("Failed to launch DisplaySettings");
|
||||
}
|
||||
});
|
||||
m_context_menu->add_action(open_workspace_settings_action);
|
||||
}
|
||||
|
||||
m_context_menu->popup(event.screen_position());
|
||||
}
|
||||
|
||||
unsigned
|
||||
current_row() const
|
||||
{
|
||||
return m_current_row;
|
||||
}
|
||||
void set_current_row(unsigned row) { m_current_row = row; }
|
||||
unsigned current_column() const { return m_current_column; }
|
||||
void set_current_column(unsigned column) { m_current_column = column; }
|
||||
|
@ -109,6 +138,8 @@ private:
|
|||
|
||||
unsigned m_current_row { 0 };
|
||||
unsigned m_current_column { 0 };
|
||||
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
};
|
||||
|
||||
DesktopStatusWindow::DesktopStatusWindow()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue