aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp22
1 files changed, 21 insertions, 1 deletions
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