aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--include/QuickMedia.hpp1
-rw-r--r--src/ImageViewer.cpp5
-rw-r--r--src/QuickMedia.cpp22
4 files changed, 28 insertions, 1 deletions
diff --git a/README.md b/README.md
index c951a8a..e213b78 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,7 @@ Type text and then wait and QuickMedia will automatically search.\
`End`: Scroll to the bottom (the last item).\
`Page up`: Scroll up an entire page.\
`Page down`: Scroll down an entire page.\
+`Ctrl+Q`: Close QuickMedia.\
`Ctrl+D`: Clear the input text.\
`Ctrl+C`: Copy the text in the selected item to your clipboard.\
`Ctrl+V`: Paste clipboard content into the search bar.\
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index 55d7870..f3ac88b 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -104,6 +104,7 @@ namespace QuickMedia {
private:
void init(Window parent_window, std::string &program_path);
void load_plugin_by_name(std::vector<Tab> &tabs, int &start_tab_index, FileManagerMimeType fm_mime_type, FileSelectionHandler file_selection_handler);
+ void common_event_handler(sf::Event &event);
void handle_x11_events();
void base_event_handler(sf::Event &event, PageType previous_page, Body *body, SearchBar *search_bar, bool handle_key_press = true, bool handle_searchbar = true);
void event_idle_handler(const sf::Event &event);
diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp
index 56378ac..a30dd40 100644
--- a/src/ImageViewer.cpp
+++ b/src/ImageViewer.cpp
@@ -208,6 +208,11 @@ namespace QuickMedia {
// TODO: Only redraw when scrolling and when image has finished downloading
sf::Event event;
while(window->pollEvent(event)) {
+ if(event.type == sf::Event::KeyPressed) {
+ if(event.key.code == sf::Keyboard::Q && event.key.control)
+ window->close();
+ }
+
if(event.type == sf::Event::Resized) {
window_size.x = event.size.width;
window_size.y = event.size.height;
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index acc1770..f7d35d9 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1319,6 +1319,13 @@ namespace QuickMedia {
}
}
+ void Program::common_event_handler(sf::Event &event) {
+ if(event.type == sf::Event::KeyPressed) {
+ if(event.key.code == sf::Keyboard::Q && event.key.control)
+ window.close();
+ }
+ }
+
void Program::handle_x11_events() {
window_closed = false;
@@ -2092,6 +2099,7 @@ namespace QuickMedia {
while (window.isOpen() && loop_running) {
sf::Int32 frame_time_ms = frame_timer.restart().asMilliseconds();
while (window.pollEvent(event)) {
+ common_event_handler(event);
const int selected_tab = ui_tabs.get_selected();
if(tabs[selected_tab].body->on_event(window, event))
@@ -2531,6 +2539,7 @@ namespace QuickMedia {
sf::Event event;
while(window.isOpen()) {
while(window.pollEvent(event)) {
+ common_event_handler(event);
if(event.type == sf::Event::Resized) {
window_size.x = event.size.width;
window_size.y = event.size.height;
@@ -3018,6 +3027,7 @@ namespace QuickMedia {
while (current_page == PageType::VIDEO_CONTENT && window.isOpen() && !go_to_previous_page) {
while (window.pollEvent(event)) {
+ common_event_handler(event);
if(event.type == sf::Event::Resized) {
window_size.x = event.size.width;
window_size.y = event.size.height;
@@ -3047,6 +3057,9 @@ namespace QuickMedia {
KeySym pressed_keysym = XKeycodeToKeysym(disp, xev.xkey.keycode, 0);
#pragma GCC diagnostic pop
bool pressing_ctrl = (CLEANMASK(xev.xkey.state) == ControlMask);
+ if(pressed_keysym && pressing_ctrl) {
+ window.close();
+ }
if(pressed_keysym == XK_Escape || pressed_keysym == XK_q || pressed_keysym == XK_BackSpace) {
if(window_is_fullscreen(disp, window.getSystemHandle())) {
window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::UNSET);
@@ -3506,6 +3519,7 @@ namespace QuickMedia {
while (current_page == current_manga_page && window.isOpen()) {
while(window.pollEvent(event)) {
+ common_event_handler(event);
if(event.type == sf::Event::Resized) {
window_size.x = event.size.width;
window_size.y = event.size.height;
@@ -3626,6 +3640,7 @@ namespace QuickMedia {
// 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)) {
+ common_event_handler(event);
if(event.type == sf::Event::Resized) {
window_size.x = event.size.width;
window_size.y = event.size.height;
@@ -4007,6 +4022,7 @@ namespace QuickMedia {
while (current_page == PageType::IMAGE_BOARD_THREAD && window.isOpen()) {
const float frame_elapsed_time_sec = frame_timer.restart().asSeconds();
while (window.pollEvent(event)) {
+ common_event_handler(event);
if(navigation_stage == NavigationStage::REPLYING || navigation_stage == NavigationStage::VIEWING_COMMENTS) {
if(thread_body->on_event(window, event, navigation_stage == NavigationStage::VIEWING_COMMENTS))
idle_active_handler();
@@ -4100,7 +4116,7 @@ namespace QuickMedia {
file_manager_tabs.push_back(Tab{std::move(file_manager_body), std::move(file_manager_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
sf::Event event;
- while(window.pollEvent(event)) {}
+ while(window.pollEvent(event)) { common_event_handler(event); }
selected_files.clear();
page_loop(file_manager_tabs);
@@ -4576,6 +4592,7 @@ namespace QuickMedia {
while (current_page == PageType::CHAT_LOGIN && window.isOpen()) {
while (window.pollEvent(event)) {
+ common_event_handler(event);
event_idle_handler(event);
if(event.type == sf::Event::Resized) {
@@ -6071,6 +6088,7 @@ namespace QuickMedia {
while (current_page == PageType::CHAT && window.isOpen() && !move_room) {
sf::Int32 frame_time_ms = frame_timer.restart().asMilliseconds();
while (window.pollEvent(event)) {
+ common_event_handler(event);
const int selected_tab = ui_tabs.get_selected();
if(chat_state == ChatState::NAVIGATING)
@@ -7280,6 +7298,7 @@ namespace QuickMedia {
while(window.isOpen()) {
while (window.pollEvent(event)) {
+ common_event_handler(event);
if(event.type == sf::Event::Resized) {
window_size.x = event.size.width;
window_size.y = event.size.height;
@@ -7487,6 +7506,7 @@ namespace QuickMedia {
while (window.isOpen()) {
while (window.pollEvent(event)) {
+ common_event_handler(event);
if(file_manager_body->on_event(window, event, !file_name_entry.is_editable()))
idle_active_handler();
else