From 3214251ec07a17b961d81d2fc28b47690ac3e65e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 4 Mar 2022 23:26:20 +0100 Subject: Add window icon and launcher icon --- README.md | 2 ++ TODO | 4 +++- icons/qm_logo.png | Bin 0 -> 1834 bytes images/qm_logo.png | Bin 0 -> 3120 bytes launcher/QuickMedia.desktop | 1 + launcher/QuickMedia_tabbed.desktop | 1 + src/QuickMedia.cpp | 31 +++++++++++++++++++++++++++++++ 7 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 icons/qm_logo.png create mode 100644 images/qm_logo.png diff --git a/README.md b/README.md index 0077409..ea274d8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![](https://dec05eba.com/images/qm_logo.png) + # QuickMedia A rofi inspired native client for web services. Currently supported web services: `youtube`, `peertube`, `lbry`, `soundcloud`, `nyaa.si`, `manganelo`, `manganelos`, `mangatown`, `mangakatana`, `mangadex`, `readm`, `onimanga`, `4chan`, `matrix`, `saucenao`, `hotexamples`, `anilist` and _others_.\ diff --git a/TODO b/TODO index c40e839..458297e 100644 --- a/TODO +++ b/TODO @@ -219,4 +219,6 @@ Local anime history. Replace youtube subscriptions page (rss) with youtube api. This allows us to get get video status for videos (and description). Add watch progress to youtube (and maybe also lbry and peertube?). Ctrl+R set chapter to finished reading in chapters page. -Zero clear password memory after use. \ No newline at end of file +Zero clear password memory after use. +Periodically cleanup old cache files (especially manga images, thumbnails and media). Maybe have a file that says when we last checked for old files, + and if its X days old then check and remove old files again and update the file. \ No newline at end of file diff --git a/icons/qm_logo.png b/icons/qm_logo.png new file mode 100644 index 0000000..ed2949d Binary files /dev/null and b/icons/qm_logo.png differ diff --git a/images/qm_logo.png b/images/qm_logo.png new file mode 100644 index 0000000..73a99b0 Binary files /dev/null and b/images/qm_logo.png differ diff --git a/launcher/QuickMedia.desktop b/launcher/QuickMedia.desktop index 4bd614b..a9cffaa 100644 --- a/launcher/QuickMedia.desktop +++ b/launcher/QuickMedia.desktop @@ -6,3 +6,4 @@ Comment=A rofi inspired native client for web services. Supports youtube, peertu Exec=quickmedia launcher Terminal=false Keywords=4chan;manga;matrix;nyaa;torrent;soundcloud;podcast;youtube;music;quickmedia; +Icon=/usr/share/quickmedia/images/qm_logo.png \ No newline at end of file diff --git a/launcher/QuickMedia_tabbed.desktop b/launcher/QuickMedia_tabbed.desktop index 72100a4..3b1b41f 100644 --- a/launcher/QuickMedia_tabbed.desktop +++ b/launcher/QuickMedia_tabbed.desktop @@ -6,3 +6,4 @@ Comment=Launch QuickMedia with tabs Exec=tabbed -c -k quickmedia launcher -e Terminal=false Keywords=4chan;manga;matrix;nyaa;torrent;soundcloud;podcast;youtube;music;quickmedia; +Icon=/usr/share/quickmedia/images/qm_logo.png \ No newline at end of file diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index b788e0b..8d6e4a2 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -197,6 +197,35 @@ static std::string base64_url_decode(const std::string &data) { return cppcodec::base64_url::decode(data); } +static void set_window_icon(Display *display, Window window, const std::string &icon_filepath) { + mgl::Image image; + if(!image.load_from_file(icon_filepath.c_str()) || image.get_num_channels() != 4) { + fprintf(stderr, "Warning: failed to load window icon: %s\n", icon_filepath.c_str()); + return; + } + + const size_t icon_buffer_size = 2 + image.get_size().x * image.get_size().y; + unsigned long *icon_buffer = new unsigned long[icon_buffer_size]; + icon_buffer[0] = image.get_size().x; + icon_buffer[1] = image.get_size().y; + + const unsigned char *image_data = image.data(); + for(size_t i = 0; i < (size_t)image.get_size().x * (size_t)image.get_size().y; ++i) { + const size_t image_data_index = i * 4; + icon_buffer[2 + i] = + (long)image_data[image_data_index + 0] << 16 + | (long)image_data[image_data_index + 1] << 8 + | (long)image_data[image_data_index + 2] << 0 + | (long)image_data[image_data_index + 3] << 24; + } + + Atom net_wm_icon = XInternAtom(display, "_NET_WM_ICON", False); + XChangeProperty(display, window, net_wm_icon, XA_CARDINAL, 32, PropModeReplace, (const unsigned char*)icon_buffer, icon_buffer_size); + XFlush(display); + + delete []icon_buffer; +} + namespace QuickMedia { static Json::Value load_recommended_json(const char *plugin_name); static void fill_recommended_items_from_json(const char *plugin_name, const Json::Value &recommended_json, BodyItems &body_items); @@ -668,6 +697,8 @@ namespace QuickMedia { set_use_system_fonts(get_config().use_system_fonts); init_body_themes(); + set_window_icon(disp, window.get_system_handle(), resources_root + "icons/qm_logo.png"); + if(!is_touch_enabled()) { if(!circle_mask_shader.load_from_file((resources_root + "shaders/circle_mask.glsl").c_str(), mgl::Shader::Type::Fragment)) { show_notification("QuickMedia", "Failed to load " + resources_root + "/shaders/circle_mask.glsl", Urgency::CRITICAL); -- cgit v1.2.3