mirror of
https://github.com/RGBCube/serenity
synced 2025-05-29 06:05:06 +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
1 changed files with 3 additions and 25 deletions
|
@ -28,18 +28,13 @@
|
||||||
#include "HackStudio.h"
|
#include "HackStudio.h"
|
||||||
#include "Project.h"
|
#include "Project.h"
|
||||||
#include <LibGUI/BoxLayout.h>
|
#include <LibGUI/BoxLayout.h>
|
||||||
|
#include <LibGUI/FileIconProvider.h>
|
||||||
#include <LibGUI/TableView.h>
|
#include <LibGUI/TableView.h>
|
||||||
#include <LibGUI/TextBox.h>
|
#include <LibGUI/TextBox.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
|
||||||
namespace HackStudio {
|
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 {
|
class LocatorSuggestionModel final : public GUI::Model {
|
||||||
public:
|
public:
|
||||||
explicit LocatorSuggestionModel(Vector<String>&& suggestions)
|
explicit LocatorSuggestionModel(Vector<String>&& suggestions)
|
||||||
|
@ -60,17 +55,8 @@ public:
|
||||||
if (role == GUI::ModelRole::Display) {
|
if (role == GUI::ModelRole::Display) {
|
||||||
if (index.column() == Column::Name)
|
if (index.column() == Column::Name)
|
||||||
return suggestion;
|
return suggestion;
|
||||||
if (index.column() == Column::Icon) {
|
if (index.column() == Column::Icon)
|
||||||
if (suggestion.ends_with(".cpp"))
|
return GUI::FileIconProvider::icon_for_path(suggestion);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -82,14 +68,6 @@ private:
|
||||||
|
|
||||||
Locator::Locator()
|
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_layout<GUI::VerticalBoxLayout>();
|
||||||
set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
set_preferred_size(0, 20);
|
set_preferred_size(0, 20);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue