Show error status icon in feed list

This commit is contained in:
Jaidyn Ann 2021-02-27 20:51:41 -06:00
parent c80fd94452
commit 2834ed4227
13 changed files with 70 additions and 15 deletions

View File

@ -53,6 +53,8 @@ RDEFS = \
src/Pogger.rdef \ src/Pogger.rdef \
art/FeedIcon.rdef \ art/FeedIcon.rdef \
art/EntryIcon.rdef \ art/EntryIcon.rdef \
art/DownloadStatus.rdef \
art/ErrorStatus.rdef \
# Specify the resource files to use. Full or relative paths can be used. # Specify the resource files to use. Full or relative paths can be used.

View File

@ -1,5 +1,4 @@
Important Features: Important Features:
* Show progress in FeedView's feedlist as icons
* Show in desktray * Show in desktray
* Make archivable * Make archivable
* Get menu working * Get menu working
@ -19,6 +18,7 @@ Important improvements:
* General input sanitization * General input sanitization
* File error-handling * File error-handling
* e.g., Utils.cpp's userFileError * 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) * Check if arg is a file or not (treat appropriately)
* Make UI friendly to whatever font-size you throw at it * Make UI friendly to whatever font-size you throw at it
* Give a max size to the progress label in FeedsView * Give a max size to the progress label in FeedsView

BIN
art/DownloadStatus Normal file

Binary file not shown.

8
art/DownloadStatus.rdef Normal file
View File

@ -0,0 +1,8 @@
resource(3, "download-status") #'VICN' array {
$"6E6369660304006603BB5205020006020000003C6000C000000000004C000048"
$"A00000D58E05FFFFD27C010A07352248363E363E482C482C362236030A000100"
$"12C0A3232D8566AD8573C0A32D4BF6834BD6C801178322040A01010012C0A323"
$"2D8566AD8573C0A32D4BD0C34BD0ED01178322040A02010002C0A3232D8566AD"
$"8573C0A32D4BD0C34BD0ED"
};

View File

@ -1,5 +1,5 @@
resource(2, "entry-type-icon") #'VICN' array { resource(2, "entry-type") #'VICN' array {
$"6E636966090401740501020106023B32F3BB51843CAA363C91AA45272C4AD4C6" $"6E636966090401740501020106023B32F3BB51843CAA363C91AA45272C4AD4C6"
$"00FCFAF4FF808076020116023B32F3BB51843CAA363C91AA45272C4AD4C600AC" $"00FCFAF4FF808076020116023B32F3BB51843CAA363C91AA45272C4AD4C600AC"
$"FF01020106023B32F3BB51843CAA363C91AA45272C4AD4C600FF90AAFB6D021B" $"FF01020106023B32F3BB51843CAA363C91AA45272C4AD4C600FF90AAFB6D021B"

BIN
art/ErrorStatus Normal file

Binary file not shown.

7
art/ErrorStatus.rdef Normal file
View File

@ -0,0 +1,7 @@
resource(4, "error-status") #'VICN' array {
$"6E6369660304006603800000020006020000003C2000C000000000004C000048"
$"E00000FFABABFFD90000010A0C482A4022352D2A22222A2D3522402A48353D40"
$"4848403D35030A000100302C2C01178322040A010100302A2A01178322040A02"
$"0100202A2A"
};

View File

@ -1,5 +1,5 @@
resource(1, "feed-type-icon") #'VICN' array { resource(1, "feed-type") #'VICN' array {
$"6E6369660603010000020006023CC7EE389BC0BA16573E39B04977C842ADC700" $"6E6369660603010000020006023CC7EE389BC0BA16573E39B04977C842ADC700"
$"FFE2BAFFFF9500020016023CC7EE389BC0BA16573E39B04977C842ADC700FFFF" $"FFE2BAFFFF9500020016023CC7EE389BC0BA16573E39B04977C842ADC700FFFF"
$"E7020006023C96323A4D3FBAFC013D5A974B57A549844D00992600FFBF500002" $"E7020006023C96323A4D3FBAFC013D5A974B57A549844D00992600FFBF500002"

View File

@ -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/File_RSS_Feed
haiku/data/artwork/icons/Server_NewsFeed 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 They're under the MIT license, as per haiku/data/artwork/ReadMe

View File

@ -8,6 +8,7 @@
#include <View.h> #include <View.h>
#include "Feed.h" #include "Feed.h"
#include "Util.h"
FeedListItem::FeedListItem(Feed* feed) FeedListItem::FeedListItem(Feed* feed)
@ -25,22 +26,23 @@ FeedListItem::DrawItem(BView* owner, BRect frame, bool complete)
{ {
BStringItem::DrawItem(owner, frame, 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) { switch (fStatus) {
case kDownloadingStatus: case kDownloadingStatus:
{
owner->DrawString("");
break;
}
case kParsingStatus: case kParsingStatus:
{ {
owner->DrawString(""); owner->MovePenTo(frame.right - 20, frame.top + BaselineOffset());
owner->DrawString("");
break; break;
} }
case kErrorStatus: case kErrorStatus:
{ {
owner->DrawString("X"); owner->MovePenTo(frame.right - imageHeight, frame.top);
owner->DrawBitmap(loadVectorIcon("error-status", imageHeight,
imageHeight));
break; break;
} }
} }

View File

@ -31,7 +31,7 @@ feedMimeType()
BResources* res = BApplication::AppResources(); BResources* res = BApplication::AppResources();
size_t length = 0; 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.SetIcon((uint8*)data, length);
mime.SetPreferredApp("application/x-vnd.Pogger"); mime.SetPreferredApp("application/x-vnd.Pogger");
@ -61,7 +61,7 @@ feedEntryMimeType()
BResources* res = BApplication::AppResources(); BResources* res = BApplication::AppResources();
size_t length = 0; 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.SetIcon((uint8*)data, length);
mime.SetPreferredApp("application/x-vnd.Pogger"); mime.SetPreferredApp("application/x-vnd.Pogger");

View File

@ -1,5 +1,6 @@
/* /*
* Copyright 2020, Jaidyn Levesque <jadedctrl@teknik.io> * Copyright 2020, Jaidyn Levesque <jadedctrl@teknik.io>
* Copyight 2017 Akshay Agarwal, agarwal.akshay.akshay8@gmail.com
* All rights reserved. Distributed under the terms of the MIT license. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
@ -8,9 +9,13 @@
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <Application.h>
#include <Bitmap.h>
#include <Directory.h> #include <Directory.h>
#include <File.h> #include <File.h>
#include <IconUtils.h>
#include <OS.h> #include <OS.h>
#include <Resources.h>
#include <Url.h> #include <Url.h>
#include <UrlProtocolRoster.h> #include <UrlProtocolRoster.h>
#include <UrlRequest.h> #include <UrlRequest.h>
@ -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;
}

View File

@ -1,5 +1,6 @@
/* /*
* Copyright 2020, Jaidyn Levesque <jadedctrl@teknik.io> * Copyright 2020, Jaidyn Levesque <jadedctrl@teknik.io>
* Copyight 2017 Akshay Agarwal, agarwal.akshay.akshay8@gmail.com
* All rights reserved. Distributed under the terms of the MIT license. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#ifndef UTIL_H #ifndef UTIL_H
@ -9,6 +10,7 @@
#include "ProtocolListener.h" #include "ProtocolListener.h"
class BBitmap;
class BUrl; class BUrl;
@ -34,6 +36,9 @@ void userFileError(status_t status, const char* path);
// temporary copy. Returns an entry_ref to said temporary copy. // temporary copy. Returns an entry_ref to said temporary copy.
entry_ref tempHtmlFile(entry_ref* ref, const char* title); 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 #endif // UTIL_H