summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-11-12 22:19:05 +0000
committerAndreas Kling <kling@serenityos.org>2020-11-14 10:11:26 +0100
commitb1754bf8f8e9a42c6a0803e2c2a19164153a38cc (patch)
treea3610435ccabbc2719e8ac417dfa2492e4497c14
parentd773795195cdaab4c8902bedafd1399f519d26e4 (diff)
downloadserenity-b1754bf8f8e9a42c6a0803e2c2a19164153a38cc.zip
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.
-rw-r--r--DevTools/HackStudio/Locator.cpp28
1 files changed, 3 insertions, 25 deletions
diff --git a/DevTools/HackStudio/Locator.cpp b/DevTools/HackStudio/Locator.cpp
index 8c856aa693..f207df2985 100644
--- a/DevTools/HackStudio/Locator.cpp
+++ b/DevTools/HackStudio/Locator.cpp
@@ -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);