aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index ea1292d..8a500fe 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -32,6 +32,7 @@
#include <cmath>
#include <string.h>
#include <signal.h>
+#include <malloc.h>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Window/Clipboard.hpp>
@@ -1047,6 +1048,8 @@ namespace QuickMedia {
}
void Program::page_loop(std::vector<Tab> &tabs, int start_tab_index, PageLoopSubmitHandler after_submit_handler) {
+ malloc_trim(0);
+
if(tabs.empty()) {
show_notification("QuickMedia", "No tabs provided!", Urgency::CRITICAL);
return;
@@ -1177,6 +1180,7 @@ namespace QuickMedia {
}
}
window.setKeyRepeatEnabled(true);
+ malloc_trim(0);
} else if(new_tabs.size() == 1 && new_tabs[0].page->get_type() == PageTypez::IMAGE_BOARD_THREAD) {
current_page = PageType::IMAGE_BOARD_THREAD;
image_board_thread_page(static_cast<ImageBoardThreadPage*>(new_tabs[0].page.get()), new_tabs[0].body.get());
@@ -1920,6 +1924,8 @@ namespace QuickMedia {
} else if(event.type == sf::Event::KeyPressed && (event.key.code == sf::Keyboard::Escape || event.key.code == sf::Keyboard::Q || event.key.code == sf::Keyboard::Backspace)) {
// To be able to close the video player while the video is loading
current_page = previous_page;
+ } else if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::C && event.key.control) {
+ save_video_url_to_clipboard();
}
}
@@ -2244,15 +2250,15 @@ namespace QuickMedia {
if(try_backup_url) {
image_content.clear();
if(download_to_string(new_url, image_content, extra_args, true) != DownloadResult::OK || image_content.size() <= 255) {
- show_notification("QuickMedia", "Failed to download image: " + new_url, Urgency::CRITICAL);
+ if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + new_url, Urgency::CRITICAL);
return true;
}
} else {
- show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
+ if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
return true;
}
} else {
- show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
+ if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
return true;
}
}
@@ -2397,6 +2403,8 @@ namespace QuickMedia {
// Consume events sent during above call to get_number_of_images which sends a request to server which may take a while. We dont want pages to be skipped when pressing arrow up/down
while(window.pollEvent(event)) {}
+ malloc_trim(0);
+
// TODO: Show to user if a certain page is missing (by checking page name (number) and checking if some are skipped)
while (current_page == PageType::IMAGES && window.isOpen()) {
while(window.pollEvent(event)) {
@@ -2459,11 +2467,11 @@ namespace QuickMedia {
}
const float font_height = chapter_text.getCharacterSize() + 8.0f;
- const float background_height = font_height + 6.0f;
+ const float bottom_panel_height = font_height + 6.0f;
sf::Vector2f content_size;
content_size.x = window_size.x;
- content_size.y = window_size.y - background_height;
+ content_size.y = window_size.y - bottom_panel_height;
if(redraw) {
redraw = false;
@@ -2492,12 +2500,12 @@ namespace QuickMedia {
window.draw(image);
}
- chapter_text_background.setSize(sf::Vector2f(window_size.x, background_height));
- chapter_text_background.setPosition(0.0f, std::floor(window_size.y - background_height));
+ chapter_text_background.setSize(sf::Vector2f(window_size.x, bottom_panel_height));
+ chapter_text_background.setPosition(0.0f, std::floor(window_size.y - bottom_panel_height));
window.draw(chapter_text_background);
auto text_bounds = chapter_text.getLocalBounds();
- chapter_text.setPosition(std::floor(window_size.x * 0.5f - text_bounds.width * 0.5f), std::floor(window_size.y - background_height * 0.5f - font_height * 0.5f));
+ chapter_text.setPosition(std::floor(window_size.x * 0.5f - text_bounds.width * 0.5f), std::floor(window_size.y - bottom_panel_height * 0.5f - font_height * 0.5f));
window.draw(chapter_text);
window.display();