From e625d3fcca7c735ed98570bc1acbcaa840541e61 Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Wed, 16 Aug 2023 19:40:47 -0400 Subject: Display status type icons in status list These icons allow users to identify the type of status with ease. I had to make — hand draw — custom icons as I didn't find any suitable icons in the Free Desktop Icon Theme Specification. Note that these icons are currently suitable only for a light theme. Support for a dark theme shouldn't be too hard to add. --- res/icons/globe.png | Bin 0 -> 737 bytes res/icons/letter.png | Bin 0 -> 434 bytes res/icons/padlock-locked.png | Bin 0 -> 546 bytes res/icons/question.png | Bin 0 -> 529 bytes res/icons/repeat.png | Bin 0 -> 759 bytes res/icons/unlisted.png | Bin 0 -> 701 bytes src/list_item.cpp | 24 +++++++++++++++++------- 7 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 res/icons/globe.png create mode 100644 res/icons/letter.png create mode 100644 res/icons/padlock-locked.png create mode 100644 res/icons/question.png create mode 100644 res/icons/repeat.png create mode 100644 res/icons/unlisted.png diff --git a/res/icons/globe.png b/res/icons/globe.png new file mode 100644 index 0000000..c369171 Binary files /dev/null and b/res/icons/globe.png differ diff --git a/res/icons/letter.png b/res/icons/letter.png new file mode 100644 index 0000000..4266531 Binary files /dev/null and b/res/icons/letter.png differ diff --git a/res/icons/padlock-locked.png b/res/icons/padlock-locked.png new file mode 100644 index 0000000..9d162b2 Binary files /dev/null and b/res/icons/padlock-locked.png differ diff --git a/res/icons/question.png b/res/icons/question.png new file mode 100644 index 0000000..2ab53c7 Binary files /dev/null and b/res/icons/question.png differ diff --git a/res/icons/repeat.png b/res/icons/repeat.png new file mode 100644 index 0000000..8e24121 Binary files /dev/null and b/res/icons/repeat.png differ diff --git a/res/icons/unlisted.png b/res/icons/unlisted.png new file mode 100644 index 0000000..69f9ff7 Binary files /dev/null and b/res/icons/unlisted.png differ diff --git a/src/list_item.cpp b/src/list_item.cpp index 020ccde..b235d2b 100644 --- a/src/list_item.cpp +++ b/src/list_item.cpp @@ -1,21 +1,31 @@ #include "list_item.h" +#include "src/types.h" -QIcon* choose_icon(StatusType status_type) { +#define ICON_PATH_PREFIX "res/icons" +QIcon& choose_icon(StatusType status_type) { // via the use of `static' in the following switch block, the idea is to only initialize each QIcon type once in the program's lifetime. - switch (status_type) { - // TODO: only null icon for the moment - default: - static QIcon* icon = new QIcon(); - return icon; + case StatusType::PUBLIC: + static QIcon public_icon(ICON_PATH_PREFIX"/globe.png"); return public_icon; + case StatusType::UNLISTED: + static QIcon unlisted_icon(ICON_PATH_PREFIX"/unlisted.png"); return unlisted_icon; + case StatusType::PRIVATE: + static QIcon private_icon(ICON_PATH_PREFIX"/padlock-locked.png"); return private_icon; + case StatusType::DIRECT: + static QIcon direct_icon(ICON_PATH_PREFIX"/letter.png"); return direct_icon; + case StatusType::REBLOG: + static QIcon reblog_icon(ICON_PATH_PREFIX"/repeat.png"); return reblog_icon; + case StatusType::UNKNOWN: + static QIcon unknown_icon(ICON_PATH_PREFIX"/question.png"); return unknown_icon; } } +#undef ICON_PATH_PREFIX StatusListItem::StatusListItem(const QString &text, StatusType status_type, bool has_attachement, Archive* data_archive, QListWidget *parent, int index) : status_index(index), has_attachement(has_attachement), status_type(status_type), data_archive(data_archive) { setText(text); - setIcon(*choose_icon(status_type)); + setIcon(choose_icon(status_type)); parent->addItem(this); #ifndef NDEBUG QString tool_tip; -- cgit v1.2.3-54-g00ecf