summaryrefslogtreecommitdiff
path: root/Userland/Services/Taskbar/QuickLaunchWidget.h
diff options
context:
space:
mode:
authorMaciej <sppmacd@pm.me>2021-12-29 16:34:57 +0100
committerAndreas Kling <kling@serenityos.org>2022-01-21 13:44:36 +0100
commit2e8e959896aed1802b03b82eab37aa0b4c36d159 (patch)
tree71d49f9c3bfc019dcc318bd80740a65ade4e401d /Userland/Services/Taskbar/QuickLaunchWidget.h
parentccb83744342956f8900395fd3aca99a8a003da95 (diff)
downloadserenity-2e8e959896aed1802b03b82eab37aa0b4c36d159.zip
Taskbar: Abstract out quick launch entries
... into QuickLaunchEntry class. It will be used to implement adding plain executables to the taskbar. For now, it adds TRY() error handling to app launching :^)
Diffstat (limited to 'Userland/Services/Taskbar/QuickLaunchWidget.h')
-rw-r--r--Userland/Services/Taskbar/QuickLaunchWidget.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/Userland/Services/Taskbar/QuickLaunchWidget.h b/Userland/Services/Taskbar/QuickLaunchWidget.h
index 6f90c67c2f..fccecf88d9 100644
--- a/Userland/Services/Taskbar/QuickLaunchWidget.h
+++ b/Userland/Services/Taskbar/QuickLaunchWidget.h
@@ -13,6 +13,32 @@
namespace Taskbar {
+class QuickLaunchEntry {
+public:
+ virtual ~QuickLaunchEntry() = default;
+ virtual ErrorOr<void> launch() const = 0;
+ virtual GUI::Icon icon() const = 0;
+ virtual String name() const = 0;
+
+ static OwnPtr<QuickLaunchEntry> create_from_config_value(StringView path);
+ static OwnPtr<QuickLaunchEntry> create_from_path(StringView path);
+};
+
+class QuickLaunchEntryAppFile : public QuickLaunchEntry {
+public:
+ explicit QuickLaunchEntryAppFile(NonnullRefPtr<Desktop::AppFile> file)
+ : m_app_file(move(file))
+ {
+ }
+
+ virtual ErrorOr<void> launch() const override;
+ virtual GUI::Icon icon() const override { return m_app_file->icon(); }
+ virtual String name() const override { return m_app_file->name(); }
+
+private:
+ NonnullRefPtr<Desktop::AppFile> m_app_file;
+};
+
class QuickLaunchWidget : public GUI::Frame
, public Config::Listener {
C_OBJECT(QuickLaunchWidget);
@@ -27,7 +53,7 @@ public:
private:
QuickLaunchWidget();
- void add_or_adjust_button(String const&, NonnullRefPtr<Desktop::AppFile>);
+ void add_or_adjust_button(String const&, NonnullOwnPtr<QuickLaunchEntry>&&);
RefPtr<GUI::Menu> m_context_menu;
RefPtr<GUI::Action> m_context_menu_default_action;
String m_context_menu_app_name;