aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-06-23 17:49:13 +0200
committerdec05eba <dec05eba@protonmail.com>2021-06-23 17:49:13 +0200
commit738f2b1a89a5445a1f0f94229f2fc0637b7c4e71 (patch)
treec0e449162f59851925351b9a32435f2114920774 /src
parente4792f46d545263d16db21bd0caf71345a69b63f (diff)
shuffle theme code
Diffstat (limited to 'src')
-rw-r--r--src/DownloadUtils.cpp3
-rw-r--r--src/Theme.cpp108
2 files changed, 59 insertions, 52 deletions
diff --git a/src/DownloadUtils.cpp b/src/DownloadUtils.cpp
index 756da10..5ab79bb 100644
--- a/src/DownloadUtils.cpp
+++ b/src/DownloadUtils.cpp
@@ -47,7 +47,7 @@ namespace QuickMedia {
static int accumulate_string_with_header(char *data, int size, void *userdata) {
DownloadUserdata *download_userdata = (DownloadUserdata*)userdata;
- if(download_userdata->header_finished || !download_userdata->header) {
+ if(download_userdata->header_finished) {
download_userdata->body->append(data, size);
} else {
download_userdata->header->append(data, size);
@@ -232,6 +232,7 @@ namespace QuickMedia {
download_userdata.header = header;
download_userdata.body = &result;
download_userdata.download_limit = download_limit;
+ download_userdata.header_finished = !header;
if(exec_program(args.data(), accumulate_string_with_header, &download_userdata) != 0)
return DownloadResult::NET_ERR;
diff --git a/src/Theme.cpp b/src/Theme.cpp
index 63c1dc8..86f4995 100644
--- a/src/Theme.cpp
+++ b/src/Theme.cpp
@@ -5,79 +5,85 @@
#include <assert.h>
namespace QuickMedia {
- static bool themes_initialized = false;
- static int current_theme = Theme::THEME_DARK;
+ enum {
+ THEME_DARK, // Default theme
+ THEME_NORD,
+
+ __NUM_THEMES__ // This should always be the last item
+ };
- static Theme themes[2];
+ static bool themes_initialized = false;
+ static int current_theme = THEME_DARK;
+ static Theme themes[__NUM_THEMES__];
static void init_theme_dark() {
- themes[Theme::THEME_DARK].background_color = sf::Color(21, 25, 30);
- themes[Theme::THEME_DARK].text_color = sf::Color(255, 255, 255);
- themes[Theme::THEME_DARK].faded_text_color = sf::Color(255, 255, 255, 179);
- themes[Theme::THEME_DARK].shade_color = sf::Color(33, 37, 44);
- themes[Theme::THEME_DARK].selected_color = sf::Color(55, 60, 68);
- themes[Theme::THEME_DARK].card_item_background_color = sf::Color(28, 32, 39);
- themes[Theme::THEME_DARK].replies_text_color = sf::Color(129, 162, 190);
- themes[Theme::THEME_DARK].placeholder_text_color = sf::Color(255, 255, 255, 100);
- themes[Theme::THEME_DARK].image_loading_background_color = sf::Color(52, 58, 70);
- themes[Theme::THEME_DARK].attention_alert_text_color = sf::Color(255, 100, 100);
- themes[Theme::THEME_DARK].cancel_button_background_color = sf::Color(41, 45, 50);
- themes[Theme::THEME_DARK].confirm_button_background_color = sf::Color(31, 117, 255);
- themes[Theme::THEME_DARK].loading_bar_color = sf::Color(31, 117, 255);
- themes[Theme::THEME_DARK].embedded_item_border_color = sf::Color(255, 255, 255);
- themes[Theme::THEME_DARK].provisional_message_color = sf::Color(255, 255, 255, 150);
- themes[Theme::THEME_DARK].failed_text_color = sf::Color(255, 0, 0);
- themes[Theme::THEME_DARK].timestamp_text_color = sf::Color(185, 190, 198, 100);
- themes[Theme::THEME_DARK].new_items_alert_color = sf::Color(128, 50, 50);
- themes[Theme::THEME_DARK].arrow_color = sf::Color(255, 255, 255, 175);
- themes[Theme::THEME_DARK].url_text_color = sf::Color(35, 140, 245);
- themes[Theme::THEME_DARK].loading_page_color = sf::Color(175, 180, 188);
- themes[Theme::THEME_DARK].blur_enabled = true;
+ themes[THEME_DARK].background_color = sf::Color(21, 25, 30);
+ themes[THEME_DARK].text_color = sf::Color(255, 255, 255);
+ themes[THEME_DARK].faded_text_color = sf::Color(255, 255, 255, 179);
+ themes[THEME_DARK].shade_color = sf::Color(33, 37, 44);
+ themes[THEME_DARK].selected_color = sf::Color(55, 60, 68);
+ themes[THEME_DARK].card_item_background_color = sf::Color(28, 32, 39);
+ themes[THEME_DARK].replies_text_color = sf::Color(129, 162, 190);
+ themes[THEME_DARK].placeholder_text_color = sf::Color(255, 255, 255, 100);
+ themes[THEME_DARK].image_loading_background_color = sf::Color(52, 58, 70);
+ themes[THEME_DARK].attention_alert_text_color = sf::Color(255, 100, 100);
+ themes[THEME_DARK].cancel_button_background_color = sf::Color(41, 45, 50);
+ themes[THEME_DARK].confirm_button_background_color = sf::Color(31, 117, 255);
+ themes[THEME_DARK].loading_bar_color = sf::Color(31, 117, 255);
+ themes[THEME_DARK].embedded_item_border_color = sf::Color(255, 255, 255);
+ themes[THEME_DARK].provisional_message_color = sf::Color(255, 255, 255, 150);
+ themes[THEME_DARK].failed_text_color = sf::Color(255, 0, 0);
+ themes[THEME_DARK].timestamp_text_color = sf::Color(185, 190, 198, 100);
+ themes[THEME_DARK].new_items_alert_color = sf::Color(128, 50, 50);
+ themes[THEME_DARK].arrow_color = sf::Color(255, 255, 255, 175);
+ themes[THEME_DARK].url_text_color = sf::Color(35, 140, 245);
+ themes[THEME_DARK].loading_page_color = sf::Color(175, 180, 188);
+ themes[THEME_DARK].blur_enabled = true;
}
static void init_theme_nord() {
- themes[Theme::THEME_NORD].background_color = sf::Color(46, 52, 64);
- themes[Theme::THEME_NORD].text_color = sf::Color(236, 239, 244);
- themes[Theme::THEME_NORD].faded_text_color = sf::Color(229, 233, 240);
- themes[Theme::THEME_NORD].shade_color = sf::Color(67, 76, 94);
- themes[Theme::THEME_NORD].selected_color = sf::Color(59, 66, 82);
- themes[Theme::THEME_NORD].card_item_background_color = sf::Color(76, 86, 106);
- themes[Theme::THEME_NORD].replies_text_color = sf::Color(136, 192, 208);
- themes[Theme::THEME_NORD].placeholder_text_color = sf::Color(236, 239, 244);
- themes[Theme::THEME_NORD].image_loading_background_color = sf::Color(216, 222, 233);
- themes[Theme::THEME_NORD].attention_alert_text_color = sf::Color(191, 97, 106);
- themes[Theme::THEME_NORD].cancel_button_background_color = sf::Color(229, 233, 240);
- themes[Theme::THEME_NORD].confirm_button_background_color = sf::Color(229, 233, 240);
- themes[Theme::THEME_NORD].loading_bar_color = sf::Color(136, 192, 208);
- themes[Theme::THEME_NORD].embedded_item_border_color = sf::Color(216, 222, 233);
- themes[Theme::THEME_NORD].provisional_message_color = sf::Color(236, 239, 244);
- themes[Theme::THEME_NORD].failed_text_color = sf::Color(191, 97, 106);
- themes[Theme::THEME_NORD].timestamp_text_color = sf::Color(76, 86, 106);
- themes[Theme::THEME_NORD].new_items_alert_color = sf::Color(235, 203, 139);
- themes[Theme::THEME_NORD].arrow_color = sf::Color(236, 239, 244);
- themes[Theme::THEME_NORD].url_text_color = sf::Color(136, 192, 208);
- themes[Theme::THEME_NORD].loading_page_color = sf::Color(229, 233, 240);
- themes[Theme::THEME_NORD].blur_enabled = false;
+ themes[THEME_NORD].background_color = sf::Color(46, 52, 64);
+ themes[THEME_NORD].text_color = sf::Color(236, 239, 244);
+ themes[THEME_NORD].faded_text_color = sf::Color(229, 233, 240);
+ themes[THEME_NORD].shade_color = sf::Color(67, 76, 94);
+ themes[THEME_NORD].selected_color = sf::Color(59, 66, 82);
+ themes[THEME_NORD].card_item_background_color = sf::Color(76, 86, 106);
+ themes[THEME_NORD].replies_text_color = sf::Color(136, 192, 208);
+ themes[THEME_NORD].placeholder_text_color = sf::Color(236, 239, 244);
+ themes[THEME_NORD].image_loading_background_color = sf::Color(216, 222, 233);
+ themes[THEME_NORD].attention_alert_text_color = sf::Color(191, 97, 106);
+ themes[THEME_NORD].cancel_button_background_color = sf::Color(229, 233, 240);
+ themes[THEME_NORD].confirm_button_background_color = sf::Color(229, 233, 240);
+ themes[THEME_NORD].loading_bar_color = sf::Color(136, 192, 208);
+ themes[THEME_NORD].embedded_item_border_color = sf::Color(216, 222, 233);
+ themes[THEME_NORD].provisional_message_color = sf::Color(236, 239, 244);
+ themes[THEME_NORD].failed_text_color = sf::Color(191, 97, 106);
+ themes[THEME_NORD].timestamp_text_color = sf::Color(76, 86, 106);
+ themes[THEME_NORD].new_items_alert_color = sf::Color(235, 203, 139);
+ themes[THEME_NORD].arrow_color = sf::Color(236, 239, 244);
+ themes[THEME_NORD].url_text_color = sf::Color(136, 192, 208);
+ themes[THEME_NORD].loading_page_color = sf::Color(229, 233, 240);
+ themes[THEME_NORD].blur_enabled = false;
}
void init_themes() {
if(themes_initialized)
return;
+ themes_initialized = true;
init_theme_dark();
init_theme_nord();
- themes_initialized = true;
char *theme = getenv("QM_THEME");
if(!theme)
return;
if(strcmp(theme, "default") == 0)
- set_current_theme(Theme::THEME_DARK);
+ current_theme = THEME_DARK;
else if(strcmp(theme, "nord") == 0)
- set_current_theme(Theme::THEME_NORD);
+ current_theme = THEME_NORD;
else
- fprintf(stderr, "Warning: Invalid theme %s, using the default theme...\n", theme);
+ fprintf(stderr, "Warning: Invalid theme %s, using the default theme\n", theme);
}
void set_current_theme(int theme) {