mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 14:05:15 +00:00
LibDesktop: Add support for IconPath in AppFile
With `IconPath`, you can override the icon used for the application shortcut. This currently only supports resolving the icon through `GUI::FileIconProvider`, the implementation for pointing to actual image files is left as an exercise for the reader.
This commit is contained in:
parent
0ec39aafb6
commit
1a4b1ecd04
Notes:
sideshowbarker
2024-07-18 07:29:39 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/1a4b1ecd04e Pull-request: https://github.com/SerenityOS/serenity/pull/9203 Reviewed-by: https://github.com/linusg
2 changed files with 17 additions and 2 deletions
|
@ -87,6 +87,21 @@ String AppFile::category() const
|
||||||
return m_config->read_entry("App", "Category").trim_whitespace();
|
return m_config->read_entry("App", "Category").trim_whitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String AppFile::icon_path() const
|
||||||
|
{
|
||||||
|
return m_config->read_entry("App", "IconPath").trim_whitespace();
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI::Icon AppFile::icon() const
|
||||||
|
{
|
||||||
|
auto override_icon = icon_path();
|
||||||
|
// FIXME: support pointing to actual .ico files
|
||||||
|
if (!override_icon.is_empty())
|
||||||
|
return GUI::FileIconProvider::icon_for_path(override_icon);
|
||||||
|
|
||||||
|
return GUI::FileIconProvider::icon_for_path(executable());
|
||||||
|
}
|
||||||
|
|
||||||
bool AppFile::run_in_terminal() const
|
bool AppFile::run_in_terminal() const
|
||||||
{
|
{
|
||||||
return m_config->read_bool_entry("App", "RunInTerminal", false);
|
return m_config->read_bool_entry("App", "RunInTerminal", false);
|
||||||
|
|
|
@ -27,13 +27,13 @@ public:
|
||||||
String executable() const;
|
String executable() const;
|
||||||
String category() const;
|
String category() const;
|
||||||
String description() const;
|
String description() const;
|
||||||
|
String icon_path() const;
|
||||||
|
GUI::Icon icon() const;
|
||||||
bool run_in_terminal() const;
|
bool run_in_terminal() const;
|
||||||
Vector<String> launcher_file_types() const;
|
Vector<String> launcher_file_types() const;
|
||||||
Vector<String> launcher_protocols() const;
|
Vector<String> launcher_protocols() const;
|
||||||
bool spawn() const;
|
bool spawn() const;
|
||||||
|
|
||||||
GUI::Icon icon() const { return GUI::FileIconProvider::icon_for_path(executable()); };
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit AppFile(const StringView& path);
|
explicit AppFile(const StringView& path);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue