HackStudio: Add little icons for ".cpp" and ".h" files

This makes it easier to tell them apart in locator suggestions. :^)
This commit is contained in:
Andreas Kling 2019-10-28 19:05:56 +01:00
parent 272c59e6d8
commit d24164ac6a
3 changed files with 12 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

View file

@ -8,6 +8,8 @@
extern RefPtr<Project> g_project;
extern void open_file(const String&);
static RefPtr<GraphicsBitmap> s_file_icon;
static RefPtr<GraphicsBitmap> s_cplusplus_icon;
static RefPtr<GraphicsBitmap> s_header_icon;
class LocatorSuggestionModel final : public GModel {
public:
@ -30,9 +32,10 @@ public:
if (index.column() == Column::Name)
return suggestion;
if (index.column() == Column::Icon) {
if (!s_file_icon) {
s_file_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-unknown.png");
}
if (suggestion.ends_with(".cpp"))
return *s_cplusplus_icon;
if (suggestion.ends_with(".h"))
return *s_header_icon;
return *s_file_icon;
}
}
@ -72,6 +75,12 @@ private:
Locator::Locator(GWidget* parent)
: GWidget(parent)
{
if (!s_cplusplus_icon) {
s_file_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-unknown.png");
s_cplusplus_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png");
s_header_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-header.png");
}
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
set_preferred_size(0, 20);
@ -124,7 +133,6 @@ Locator::Locator(GWidget* parent)
m_suggestion_view->set_headers_visible(false);
m_popup_window->set_main_widget(m_suggestion_view);
m_suggestion_view->on_activation = [this](auto& index) {
open_suggestion(index);
};