From d24164ac6a07afadd5efacafbcbc6aea2c5eb3e7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 28 Oct 2019 19:05:56 +0100 Subject: [PATCH] HackStudio: Add little icons for ".cpp" and ".h" files This makes it easier to tell them apart in locator suggestions. :^) --- Base/res/icons/16x16/filetype-cplusplus.png | Bin 0 -> 337 bytes Base/res/icons/16x16/filetype-header.png | Bin 0 -> 245 bytes DevTools/HackStudio/Locator.cpp | 16 ++++++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 Base/res/icons/16x16/filetype-cplusplus.png create mode 100644 Base/res/icons/16x16/filetype-header.png diff --git a/Base/res/icons/16x16/filetype-cplusplus.png b/Base/res/icons/16x16/filetype-cplusplus.png new file mode 100644 index 0000000000000000000000000000000000000000..9805fb180e748980c9c9f9f9c608cceeb7681f69 GIT binary patch literal 337 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7B|KdmLo7}&4Ytl>G8Cxo zD`K2AMRVstC9x?=9sz-G%$9WQX!^~v#N^sGkK*<((E%58RJeP#WEL}eaX(SEa23h6 zzt=h;{A|y${Iq*LjrC2UvJ*L8dq?flyXl&vB)E-hBFAkP9tQJ$3WALtbL^{ROv}n& za~GZSuDih>+kUlhj`2KMZ_#Ck%L~pOl*qo?Cn_(k8|yaDm7(F}WllHmCy^{$!z-do z6So|B?taEgN`*Kemw z=o8%qK^6p6lAXG?f5FxePiWZ r)`V#Olh>aeoxk$bzxML$kEKiIELc>z>z^hA0|SGntDnm{r-UW|0tt)t literal 0 HcmV?d00001 diff --git a/Base/res/icons/16x16/filetype-header.png b/Base/res/icons/16x16/filetype-header.png new file mode 100644 index 0000000000000000000000000000000000000000..cd27752a03e539da295d179dd2a9878f0504b40b GIT binary patch literal 245 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7_ISEDhFF|VPFNsdpi~@n zE9zfza7b|IVUH=9y1BalFFJZhpRSK#Gd3_VFh~@hW0EO!c!}ra2Q}*M>T}j5A5@z$ zeR}($?OQgq>=w9d9l?9!&BKEqzQ2ubYq-2z@(Z6_+Kmn8rYL?mBRS(s{gVyJN@iRB z|Nno!;LQ)iM~4_JbvA75G-`;9nBiD>+icE5rwa}H^Y0to`Tj}iKI@BZlin~T9d1bQ za$!5(C;ywj*X_>B2R}L=KS@_Bx$Jqt-Hw4_WpGi()ztZF3=9kmp00i_>zopr0Hk7U AVgLXD literal 0 HcmV?d00001 diff --git a/DevTools/HackStudio/Locator.cpp b/DevTools/HackStudio/Locator.cpp index e3ea657c7a..4a692d0a83 100644 --- a/DevTools/HackStudio/Locator.cpp +++ b/DevTools/HackStudio/Locator.cpp @@ -8,6 +8,8 @@ extern RefPtr g_project; extern void open_file(const String&); static RefPtr s_file_icon; +static RefPtr s_cplusplus_icon; +static RefPtr 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(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); };