mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 04:55:15 +00:00
HackStudio: Use GUI::FileIconProvider::icon_for_path() for Locator icons
No need to duplicate file icon association logic as well as artificially limiting the number of recognized file types.
This commit is contained in:
parent
d773795195
commit
b1754bf8f8
Notes:
sideshowbarker
2024-07-19 02:29:22 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/b1754bf8f8e Pull-request: https://github.com/SerenityOS/serenity/pull/4074
1 changed files with 3 additions and 25 deletions
|
@ -28,18 +28,13 @@
|
|||
#include "HackStudio.h"
|
||||
#include "Project.h"
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/FileIconProvider.h>
|
||||
#include <LibGUI/TableView.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
#include <LibGUI/Window.h>
|
||||
|
||||
namespace HackStudio {
|
||||
|
||||
static RefPtr<Gfx::Bitmap> s_file_icon;
|
||||
static RefPtr<Gfx::Bitmap> s_cplusplus_icon;
|
||||
static RefPtr<Gfx::Bitmap> s_header_icon;
|
||||
static RefPtr<Gfx::Bitmap> s_form_icon;
|
||||
static RefPtr<Gfx::Bitmap> s_hackstudio_icon;
|
||||
|
||||
class LocatorSuggestionModel final : public GUI::Model {
|
||||
public:
|
||||
explicit LocatorSuggestionModel(Vector<String>&& suggestions)
|
||||
|
@ -60,17 +55,8 @@ public:
|
|||
if (role == GUI::ModelRole::Display) {
|
||||
if (index.column() == Column::Name)
|
||||
return suggestion;
|
||||
if (index.column() == Column::Icon) {
|
||||
if (suggestion.ends_with(".cpp"))
|
||||
return *s_cplusplus_icon;
|
||||
if (suggestion.ends_with(".frm"))
|
||||
return *s_form_icon;
|
||||
if (suggestion.ends_with(".h"))
|
||||
return *s_header_icon;
|
||||
if (suggestion.ends_with(".hsp"))
|
||||
return *s_hackstudio_icon;
|
||||
return *s_file_icon;
|
||||
}
|
||||
if (index.column() == Column::Icon)
|
||||
return GUI::FileIconProvider::icon_for_path(suggestion);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -82,14 +68,6 @@ private:
|
|||
|
||||
Locator::Locator()
|
||||
{
|
||||
if (!s_cplusplus_icon) {
|
||||
s_file_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png");
|
||||
s_cplusplus_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png");
|
||||
s_header_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-header.png");
|
||||
s_form_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-form.png");
|
||||
s_hackstudio_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-hackstudio.png");
|
||||
}
|
||||
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
set_preferred_size(0, 20);
|
||||
|
|
Loading…
Add table
Reference in a new issue