|
@@ -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);
|