From 2834ed422725caf342ec50039a4fa004b551bf0f Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Sat, 27 Feb 2021 20:51:41 -0600 Subject: [PATCH] Show error status icon in feed list --- Makefile | 2 ++ TODO.txt | 2 +- art/DownloadStatus | Bin 0 -> 3899 bytes art/DownloadStatus.rdef | 8 ++++++++ art/EntryIcon.rdef | 2 +- art/ErrorStatus | Bin 0 -> 4024 bytes art/ErrorStatus.rdef | 7 +++++++ art/FeedIcon.rdef | 2 +- art/README.txt | 7 ++++--- src/FeedListItem.cpp | 16 +++++++++------- src/Mimetypes.cpp | 4 ++-- src/Util.cpp | 30 ++++++++++++++++++++++++++++++ src/Util.h | 5 +++++ 13 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 art/DownloadStatus create mode 100644 art/DownloadStatus.rdef create mode 100644 art/ErrorStatus create mode 100644 art/ErrorStatus.rdef diff --git a/Makefile b/Makefile index 77c7a55..2ebd54c 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,8 @@ RDEFS = \ src/Pogger.rdef \ art/FeedIcon.rdef \ art/EntryIcon.rdef \ + art/DownloadStatus.rdef \ + art/ErrorStatus.rdef \ # Specify the resource files to use. Full or relative paths can be used. diff --git a/TODO.txt b/TODO.txt index 8fe8557..89aed6c 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,5 +1,4 @@ Important Features: -* Show progress in FeedView's feedlist as icons * Show in desktray * Make archivable * Get menu working @@ -19,6 +18,7 @@ Important improvements: * General input sanitization * File error-handling * e.g., Utils.cpp's userFileError +* Fix background of Feeds List error status icon (it's black, not transparent) * Check if arg is a file or not (treat appropriately) * Make UI friendly to whatever font-size you throw at it * Give a max size to the progress label in FeedsView diff --git a/art/DownloadStatus b/art/DownloadStatus new file mode 100644 index 0000000000000000000000000000000000000000..41dc104caf56d41e9abd0cb5b05d8e7797364dff GIT binary patch literal 3899 zcmeHJ&ubiY6n~R(H?1ydEr?ow%|W!19Bic^5|U|JyA_h%(&XS_MaIo+cbeImWoB#* z6wJl8h_)z#hYH?`;=vxoODO>>dg(>QQYk9<2WT$AOJV(dzO&!W%#y&+dJyb`@6LWd z-#72Q@B2Bg%*|Ji%pKk0km1W520RJ5V z_Th}jS^T|iB9D|){;rd>W7z|iB3508I%?EbX|4Ja22Qk9-;)uwWBkm`2Ql-PAtA_%Jv*y1I`PWa(@oL0PMa# zK3lIVIh6GSRw}0=#Hp9-k3Jqa9T#2~ndCL6q#Jrcg6(Gq@MDWuGa{Gqe+^4NiP_le zCvoy#KA_&Vya4;V5fHw4=O#46AaI+ByC_CVyqDGV!?x1};O7 zljzAT=|pA(m-z$Yxl$vHNf9lNfo}v$CnhCet2FaJ6I16*g$E$w%$aJfK1&N3`v?2D ziYdxOCY2pi(hU7D!d_bcF_W$wEA{HQdJ!+N0_kGyC3=j++uwD zhar_gUZ2OcCV)}ba87-PvosgB9 zwK;*=tactoTx6*&J#org#23nytG8hN4!h%_Of28S6KABIcKSm0sp zN?Z=?lm?MWtL*CT&u={S==$o}izjaGA8$BZg~p6?~gR@`)aS83=tZ*6w4V&AKyH2*g0h_Ss_N2dG_ z>gXe@`RkKsYWBCU-TvD%F literal 0 HcmV?d00001 diff --git a/art/DownloadStatus.rdef b/art/DownloadStatus.rdef new file mode 100644 index 0000000..3b27163 --- /dev/null +++ b/art/DownloadStatus.rdef @@ -0,0 +1,8 @@ + +resource(3, "download-status") #'VICN' array { + $"6E6369660304006603BB5205020006020000003C6000C000000000004C000048" + $"A00000D58E05FFFFD27C010A07352248363E363E482C482C362236030A000100" + $"12C0A3232D8566AD8573C0A32D4BF6834BD6C801178322040A01010012C0A323" + $"2D8566AD8573C0A32D4BD0C34BD0ED01178322040A02010002C0A3232D8566AD" + $"8573C0A32D4BD0C34BD0ED" +}; diff --git a/art/EntryIcon.rdef b/art/EntryIcon.rdef index 059854b..088b59e 100644 --- a/art/EntryIcon.rdef +++ b/art/EntryIcon.rdef @@ -1,5 +1,5 @@ -resource(2, "entry-type-icon") #'VICN' array { +resource(2, "entry-type") #'VICN' array { $"6E636966090401740501020106023B32F3BB51843CAA363C91AA45272C4AD4C6" $"00FCFAF4FF808076020116023B32F3BB51843CAA363C91AA45272C4AD4C600AC" $"FF01020106023B32F3BB51843CAA363C91AA45272C4AD4C600FF90AAFB6D021B" diff --git a/art/ErrorStatus b/art/ErrorStatus new file mode 100644 index 0000000000000000000000000000000000000000..f606af87b3b6b9614b1894bce8b4939b25a44b23 GIT binary patch literal 4024 zcmeHJ&x;&I6n?#JHc^+|L=Zs{`mpGVIYc}JWZCVkYbFc3nZ@0Mhd|QK_GBvC(>-*z z(FMV|C=&7m1@Yj)lOd8r{s0k0A@>|5hg?18;!PO8ud1u3d)S3mBLvKYn(6xL)qAhr zud20;t=5^1({BjK!5AGt3v(ha)(=haV5;{yGA*sv)&^yKKSk8Ya^!G{KY)NcSmSaP zzj{REt7*eO2=ZPg-+`rxRcqj*Mr)PTY7gOH#agvWwIHrhi}($dM9={1N+lFPK~zkc zRPyfj*4vyvi$S8RTjU&(!b-z@94b^>$m!p{zA1 zGIC~wIQ4RzFYq|%hw!?{B9FNwgG9wSrrrw1DSY5xe34uD-o(%t=EV3-jBA{eml*dF z`<*zkV(^>Tty5Zyr(&$@#ez{Fgc~2VqU3}B{z#o9j>AqK?ub(%I@Rk$Nk%-&_o6V9 z`-pdweEkG`4m`wglNiP-*(zfC?C}T0b*)BjVAe#-OW>QruvI|`m}<@Zt|lxKibR|V z+dA7`r-e+sV+F1g3Nq#+K{#?hO2=~o<+F1B8x$4ET=Kk<@- zvbMeETL@tkDCYq0jfTU~#WdJaA&T=G@Hesf4rH>jZT?u>$2L#vR>ZTsh(V$auFT0h z>np3|JAvV0kjF-x-wg11jS)XA+wJw!7ViT$tqA?Jk|7@hXKQq2wuXNS%;H z@J!(8Hhf-_0);^}lTT z=KrK`@^f_i_UJd*k#xIR$ZkOzF6VoLP=BH;hUp-Qj1EF7?uDt!y$SVB)(Zxx^3UO- zCQ&*LK6=_lhob2XOVuiWg>Em_wHjGPQZ~`z!xh|2EhI{3ycj29yiTgI0;H|t^;5-X zfitHjy8`o<_2I}&nb+5GtmD9_Yci+qV$I~jky^|T!6?K3yv`|lhBnR~fWKPcy4QGV z*afeM?z(nTDJe!~Ny>nQsa$~q`foSQGwP!5{pd5SS^trbz9Z3hw6E%q`n6v7-}qXu z`}<|cpk5b`f~vn?2X6c{UDhP+c&p@}so`fz{J9!_4mjiH;uN;FDTmJq>MfrETX~x7 zh7zeb^g6*nA5>2+;bEX>3in*<=_x(&q1wUo=!YNgL&}`rS11!NQuxOj>8NiuR99X* zcjK2o79K8Vy(G;;z5)!Dkr`JRDz~U$%Vhs8zTg{V!SA6+ReVvTuVU}A%GCQRQu&^j zb%H3=O#R@a{T7D)lR7eaFs>uU_DLPN^1rF0`J#^I|4kiziL_~QAKgTDRo^D;LF}o# zL(JQu-X8%UcptGpR{JkssrEfJdGGK(GWT8m-q{6C8(gX1JM3cn;nxa$Trae~VZHpF J?)FHc@)yQYQOy7V literal 0 HcmV?d00001 diff --git a/art/ErrorStatus.rdef b/art/ErrorStatus.rdef new file mode 100644 index 0000000..a159907 --- /dev/null +++ b/art/ErrorStatus.rdef @@ -0,0 +1,7 @@ + +resource(4, "error-status") #'VICN' array { + $"6E6369660304006603800000020006020000003C2000C000000000004C000048" + $"E00000FFABABFFD90000010A0C482A4022352D2A22222A2D3522402A48353D40" + $"4848403D35030A000100302C2C01178322040A010100302A2A01178322040A02" + $"0100202A2A" +}; diff --git a/art/FeedIcon.rdef b/art/FeedIcon.rdef index 76b02ef..1b72b7e 100644 --- a/art/FeedIcon.rdef +++ b/art/FeedIcon.rdef @@ -1,5 +1,5 @@ -resource(1, "feed-type-icon") #'VICN' array { +resource(1, "feed-type") #'VICN' array { $"6E6369660603010000020006023CC7EE389BC0BA16573E39B04977C842ADC700" $"FFE2BAFFFF9500020016023CC7EE389BC0BA16573E39B04977C842ADC700FFFF" $"E7020006023C96323A4D3FBAFC013D5A974B57A549844D00992600FFBF500002" diff --git a/art/README.txt b/art/README.txt index 6d79cb6..03967e3 100644 --- a/art/README.txt +++ b/art/README.txt @@ -1,8 +1,9 @@ -These cons are copied over from Haiku's source tree at +The mimetype icons (FeedIcon and EntryIcon) and status icons (DownloadStatus, +ErrorStatus) are all copied over from Haiku's source tree at: haiku/data/artwork/icons/File_RSS_Feed haiku/data/artwork/icons/Server_NewsFeed + haiku/data/artwork/icons/Action_GoDown_3 + haiku/data/artwork/icons/Action_Stop_1 -As far as I can tell, they aren't included in base installs. We just use them -as the mimetype icons for application/x-feed-source and text/x-feed-entry. They're under the MIT license, as per haiku/data/artwork/ReadMe diff --git a/src/FeedListItem.cpp b/src/FeedListItem.cpp index e5387f6..82754ad 100644 --- a/src/FeedListItem.cpp +++ b/src/FeedListItem.cpp @@ -8,6 +8,7 @@ #include #include "Feed.h" +#include "Util.h" FeedListItem::FeedListItem(Feed* feed) @@ -25,22 +26,23 @@ FeedListItem::DrawItem(BView* owner, BRect frame, bool complete) { BStringItem::DrawItem(owner, frame, complete); - owner->MovePenTo(frame.right - 20, frame.top + BaselineOffset()); + font_height fontHeight; + owner->GetFontHeight(&fontHeight); + int16 imageHeight = int16(fontHeight.ascent + fontHeight.descent + 6); switch (fStatus) { case kDownloadingStatus: - { - owner->DrawString("…"); - break; - } case kParsingStatus: { - owner->DrawString("―"); + owner->MovePenTo(frame.right - 20, frame.top + BaselineOffset()); + owner->DrawString("…"); break; } case kErrorStatus: { - owner->DrawString("X"); + owner->MovePenTo(frame.right - imageHeight, frame.top); + owner->DrawBitmap(loadVectorIcon("error-status", imageHeight, + imageHeight)); break; } } diff --git a/src/Mimetypes.cpp b/src/Mimetypes.cpp index 9ac6fc6..efeace5 100644 --- a/src/Mimetypes.cpp +++ b/src/Mimetypes.cpp @@ -31,7 +31,7 @@ feedMimeType() BResources* res = BApplication::AppResources(); size_t length = 0; - const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, "feed-type-icon", &length); + const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, "feed-type", &length); mime.SetIcon((uint8*)data, length); mime.SetPreferredApp("application/x-vnd.Pogger"); @@ -61,7 +61,7 @@ feedEntryMimeType() BResources* res = BApplication::AppResources(); size_t length = 0; - const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, "entry-type-icon", &length); + const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, "entry-type", &length); mime.SetIcon((uint8*)data, length); mime.SetPreferredApp("application/x-vnd.Pogger"); diff --git a/src/Util.cpp b/src/Util.cpp index 4a737ba..e2e4a7c 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -1,5 +1,6 @@ /* * Copyright 2020, Jaidyn Levesque + * Copyight 2017 Akshay Agarwal, agarwal.akshay.akshay8@gmail.com * All rights reserved. Distributed under the terms of the MIT license. */ @@ -8,9 +9,13 @@ #include #include +#include +#include #include #include +#include #include +#include #include #include #include @@ -191,3 +196,28 @@ tempHtmlFile(entry_ref* ref, const char* title) } +BBitmap* +loadVectorIcon(const char* name, int32 iconSize, int32 cropSize) +{ + BResources* res = BApplication::AppResources(); + size_t length = 0; + const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, name, &length); + BBitmap* temp = new BBitmap(BRect(0, 0, iconSize - 1, iconSize - 1), + B_BITMAP_NO_SERVER_LINK, B_RGBA32); + BBitmap* dest = new BBitmap(BRect(0, 0, cropSize - 1, cropSize - 1), + B_RGBA32); + if (data != NULL + && BIconUtils::GetVectorIcon((uint8*)data, length, temp) + == B_OK + && dest->ImportBits(temp, BPoint(0, 0), BPoint(0, 0), + cropSize, cropSize) == B_OK) { + delete temp; + return dest; + } + + delete temp; + delete dest; + return NULL; +} + + diff --git a/src/Util.h b/src/Util.h index e135f03..2eea903 100644 --- a/src/Util.h +++ b/src/Util.h @@ -1,5 +1,6 @@ /* * Copyright 2020, Jaidyn Levesque + * Copyight 2017 Akshay Agarwal, agarwal.akshay.akshay8@gmail.com * All rights reserved. Distributed under the terms of the MIT license. */ #ifndef UTIL_H @@ -9,6 +10,7 @@ #include "ProtocolListener.h" +class BBitmap; class BUrl; @@ -34,6 +36,9 @@ void userFileError(status_t status, const char* path); // temporary copy. Returns an entry_ref to said temporary copy. entry_ref tempHtmlFile(entry_ref* ref, const char* title); +// Ripped from Calendar (utils/ResourceLoader.cpp) +BBitmap* loadVectorIcon(const char* name, int32 iconSize = 32, + int32 cropSize = 22); #endif // UTIL_H