diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-06-21 06:25:13 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-06-21 06:25:17 +0200 |
commit | 933ceeabb339cdf0583a8687528941593381a268 (patch) | |
tree | e3963cd74eb726a63f6e91f2f22f485fac65084a /src/plugins | |
parent | d137dcfa6dd248ffa94e58e7aef4487682bc12dc (diff) |
Add color themeing, (Theme.hpp/Theme.cpp) and the env var QM_THEME
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/FileManager.cpp | 3 | ||||
-rw-r--r-- | src/plugins/MangaGeneric.cpp | 3 | ||||
-rw-r--r-- | src/plugins/Mangadex.cpp | 5 | ||||
-rw-r--r-- | src/plugins/Manganelo.cpp | 5 | ||||
-rw-r--r-- | src/plugins/Matrix.cpp | 19 | ||||
-rw-r--r-- | src/plugins/Soundcloud.cpp | 3 | ||||
-rw-r--r-- | src/plugins/Youtube.cpp | 7 |
7 files changed, 26 insertions, 19 deletions
diff --git a/src/plugins/FileManager.cpp b/src/plugins/FileManager.cpp index 6532f3a..f78265b 100644 --- a/src/plugins/FileManager.cpp +++ b/src/plugins/FileManager.cpp @@ -1,6 +1,7 @@ #include "../../plugins/FileManager.hpp" #include "../../include/FileAnalyzer.hpp" #include "../../include/ResourceLoader.hpp" +#include "../../include/Theme.hpp" #include "../../include/QuickMedia.hpp" namespace QuickMedia { @@ -139,7 +140,7 @@ namespace QuickMedia { description += "\nDirectory"; } body_item->set_description(std::move(description)); - body_item->set_description_color(sf::Color(179, 179, 179)); + body_item->set_description_color(get_current_theme().faded_text_color); result_items.push_back(std::move(body_item)); } diff --git a/src/plugins/MangaGeneric.cpp b/src/plugins/MangaGeneric.cpp index e6fc11d..2d0df6a 100644 --- a/src/plugins/MangaGeneric.cpp +++ b/src/plugins/MangaGeneric.cpp @@ -1,5 +1,6 @@ #include "../../plugins/MangaGeneric.hpp" #include "../../include/StringUtils.hpp" +#include "../../include/Theme.hpp" #include <quickmedia/HtmlSearch.h> #include <assert.h> @@ -103,7 +104,7 @@ namespace QuickMedia { std::string field_stripped = strip(field_value); const char *prefix = merge_userdata->desc_prefix ? merge_userdata->desc_prefix : ""; (*body_item_image_context.body_items)[body_item_image_context.index]->set_description(prefix + field_stripped); - (*body_item_image_context.body_items)[body_item_image_context.index]->set_description_color(sf::Color(179, 179, 179)); + (*body_item_image_context.body_items)[body_item_image_context.index]->set_description_color(get_current_theme().faded_text_color); } body_item_image_context.index++; } diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp index 3953215..477608e 100644 --- a/src/plugins/Mangadex.cpp +++ b/src/plugins/Mangadex.cpp @@ -1,5 +1,6 @@ #include "../../plugins/Mangadex.hpp" #include "../../include/Utils.hpp" +#include "../../include/Theme.hpp" #include <json/writer.h> namespace QuickMedia { @@ -194,7 +195,7 @@ namespace QuickMedia { const Json::Value &en_json = description_json["en"]; if(en_json.isString()) { body_item->set_description(en_json.asString()); - body_item->set_description_color(sf::Color(179, 179, 179)); + body_item->set_description_color(get_current_theme().faded_text_color); } } result_items.push_back(std::move(body_item)); @@ -282,7 +283,7 @@ namespace QuickMedia { time_t unix_time = iso_utc_to_unix_time(publish_at_json.asCString()); if(unix_time != 0) { body_item->set_description("Uploaded: " + unix_time_to_local_time_str(unix_time)); - body_item->set_description_color(sf::Color(179, 179, 179)); + body_item->set_description_color(get_current_theme().faded_text_color); } } diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp index caa3f9a..094d096 100644 --- a/src/plugins/Manganelo.cpp +++ b/src/plugins/Manganelo.cpp @@ -2,6 +2,7 @@ #include "../../include/Notification.hpp" #include "../../include/StringUtils.hpp" #include "../../include/NetUtils.hpp" +#include "../../include/Theme.hpp" #include <quickmedia/HtmlSearch.h> namespace QuickMedia { @@ -62,7 +63,7 @@ namespace QuickMedia { if(text && class_attr && strstr(class_attr, "chapter-time") && item_data->index < item_data->body_items->size()) { std::string uploaded_date = strip(text); (*item_data->body_items)[item_data->index]->set_description("Uploaded: " + uploaded_date); - (*item_data->body_items)[item_data->index]->set_description_color(sf::Color(179, 179, 179)); + (*item_data->body_items)[item_data->index]->set_description_color(get_current_theme().faded_text_color); item_data->index++; } }, &body_item_context); @@ -127,7 +128,7 @@ namespace QuickMedia { item->url = "https://manganelo.com/manga/" + url_param_encode(nameunsigned.asString()); if(lastchapter.isString() && lastchapter.asCString()[0] != '\0') { item->set_description("Latest chapter: " + lastchapter.asString()); - item->set_description_color(sf::Color(179, 179, 179)); + item->set_description_color(get_current_theme().faded_text_color); } Json::Value image = child.get("image", ""); if(image.isString() && image.asCString()[0] != '\0') diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 1e20bf6..9f5faf0 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -8,6 +8,7 @@ #include "../../include/Json.hpp" #include "../../include/AsyncImageLoader.hpp" #include "../../include/Utils.hpp" +#include "../../include/Theme.hpp" #include <rapidjson/document.h> #include <rapidjson/writer.h> #include <rapidjson/stringbuffer.h> @@ -624,20 +625,20 @@ namespace QuickMedia { int unread_notification_count = room->unread_notification_count; if(unread_notification_count > 0 && set_room_as_unread) { room_desc += "\n** " + std::to_string(unread_notification_count) + " unread mention(s) **"; // TODO: Better notification? - room->body_item->set_description_color(sf::Color(255, 100, 100)); + room->body_item->set_description_color(get_current_theme().attention_alert_text_color); } else { - room->body_item->set_description_color(sf::Color(179, 179, 179)); + room->body_item->set_description_color(get_current_theme().faded_text_color); } room->body_item->set_description(std::move(room_desc)); if(set_room_as_unread) - room->body_item->set_title_color(sf::Color(255, 100, 100)); + room->body_item->set_title_color(get_current_theme().attention_alert_text_color); room->last_message_read = false; rooms_page->move_room_to_top(room); room_tags_page->move_room_to_top(room); } else if(is_initial_sync) { room->body_item->set_description(extract_first_line_remove_newline_elipses(matrix->message_get_author_displayname(last_new_message.get()), AUTHOR_MAX_LENGTH) + ": " + message_to_room_description_text(last_new_message.get())); - room->body_item->set_description_color(sf::Color(179, 179, 179)); + room->body_item->set_description_color(get_current_theme().faded_text_color); } } @@ -910,7 +911,7 @@ namespace QuickMedia { body_item->set_author(std::move(display_name)); body_item->set_author_color(user_id_to_color(user_info.user_id)); body_item->set_description(user_info.user_id); - body_item->set_description_color(sf::Color(179, 179, 179)); + body_item->set_description_color(get_current_theme().faded_text_color); if(user_info.avatar_url) body_item->thumbnail_url = user_info.avatar_url.value(); body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; @@ -1056,8 +1057,8 @@ namespace QuickMedia { body_item->url = notification.event_id; if(!notification.read) { - body_item->set_author_color(sf::Color(255, 100, 100)); - body_item->set_description_color(sf::Color(255, 100, 100)); + body_item->set_author_color(get_current_theme().attention_alert_text_color); + body_item->set_description_color(get_current_theme().attention_alert_text_color); } body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; @@ -1116,8 +1117,8 @@ namespace QuickMedia { NotificationsExtraData *extra_data = static_cast<NotificationsExtraData*>(body_item->extra.get()); if(!extra_data->read && extra_data->room == room) { extra_data->read = true; - body_item->set_author_color(sf::Color::White); - body_item->set_description_color(sf::Color::White); + body_item->set_author_color(get_current_theme().text_color); + body_item->set_description_color(get_current_theme().text_color); } } } diff --git a/src/plugins/Soundcloud.cpp b/src/plugins/Soundcloud.cpp index 01d12a8..abc8c18 100644 --- a/src/plugins/Soundcloud.cpp +++ b/src/plugins/Soundcloud.cpp @@ -3,6 +3,7 @@ #include "../../include/StringUtils.hpp" #include "../../include/Utils.hpp" #include "../../include/Scale.hpp" +#include "../../include/Theme.hpp" #include <quickmedia/HtmlSearch.h> namespace QuickMedia { @@ -203,7 +204,7 @@ namespace QuickMedia { } body_item->set_description(std::move(description)); - body_item->set_description_color(sf::Color(179, 179, 179)); + body_item->set_description_color(get_current_theme().faded_text_color); return body_item; } diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index 2be4f8d..79eb3d5 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -7,6 +7,7 @@ #include "../../include/Notification.hpp" #include "../../include/VideoPlayer.hpp" #include "../../include/Utils.hpp" +#include "../../include/Theme.hpp" #include <json/reader.h> extern "C" { #include <HtmlParser.h> @@ -282,7 +283,7 @@ R"END( desc += std::move(description_snippet_stripped); } body_item->set_description(std::move(desc)); - body_item->set_description_color(sf::Color(179, 179, 179)); + body_item->set_description_color(get_current_theme().faded_text_color); if(scheduled_text.empty()) body_item->url = "https://www.youtube.com/watch?v=" + video_id_str; @@ -341,7 +342,7 @@ R"END( desc += std::move(description_snippet_stripped); } body_item->set_description(std::move(desc)); - body_item->set_description_color(sf::Color(179, 179, 179)); + body_item->set_description_color(get_current_theme().faded_text_color); body_item->url = "https://www.youtube.com/channel/" + channel_id_json.asString(); if(thumbnail) { if(string_starts_with(thumbnail->url, "https:")) @@ -1529,7 +1530,7 @@ R"END( description += subscription_data.author; } body_item->set_description(std::move(description)); - body_item->set_description_color(sf::Color(179, 179, 179)); + body_item->set_description_color(get_current_theme().faded_text_color); body_item->url = "https://www.youtube.com/watch?v=" + subscription_entry.video_id; body_item->thumbnail_url = "https://img.youtube.com/vi/" + subscription_entry.video_id + "/mqdefault.jpg"; body_item->thumbnail_size = sf::Vector2i(192, 108); |