From b6216bad1cdd523992c4f3b95c3ba703959d8568 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 8 Feb 2021 23:37:37 +0100 Subject: Matrix: add QM_PHONE_FACTOR to hide room list side panel, do not render room list tabs when viewing room --- README.md | 6 ++++-- include/QuickMedia.hpp | 1 + src/QuickMedia.cpp | 19 ++++++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a075a10..03d572b 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Press `E` to edit a message on matrix, press `ESC` to cancel. Currently only wor Press `Ctrl + D` to delete a message on matrix. Currently deleting a message only deletes the event, so if you delete an edit then the original message wont be deleted.\ Press `Ctrl + C` to copy the message of the selected item in matrix to the clipboard.\ Press `Ctrl + V` to upload media to room in matrix if the clipboard contains a valid absolute filepath.\ -Press `Ctrl+Alt+Arrow up` / `Ctrl+Alt+Arrow down` or `Ctrl+Alt+K` / `Ctrl+Alt+J` to select another room in matrix when you are in a room. Press `Ctrl+Alt+Enter` to go to the selected room. +Press `Ctrl+Alt+Arrow up` / `Ctrl+Alt+Arrow down` or `Ctrl+Alt+K` / `Ctrl+Alt+J` to select another room in matrix when you are viewing a room. Press `Ctrl+Alt+Enter` to view the selected room. In matrix you can select a message with enter to open the url in the message (or if there are multiple urls then a menu will appear for selecting which to open). ## Matrix commands @@ -63,7 +63,7 @@ In matrix you can select a message with enter to open the url in the message (or `/leave` to leave the current room.\ `/me [text]` to send a message of type "m.emote".\ `/react [text]` to react to the selected message. -# Mangadex +## Mangadex To search for manga with mangadex, you need to be logged into mangadex in your browser and copy the `mangadex_rememberme_token` cookie from developer tools and store it in `$HOME/.config/quickmedia/credentials/mangadex.json` under the key `rememberme_token`. Here is an example what the file should look like: ``` @@ -71,6 +71,8 @@ and store it in `$HOME/.config/quickmedia/credentials/mangadex.json` under the k "rememberme_token": "21s9d3f7ad224a131239Dsfaf033029d2e390dAsfd3ldadb3a39dk43jfldj35das" } ``` +## Environment variables +Set `QM_PHONE_FACTOR=1` to disable the room list side panel in matrix. # Dependencies ## Compile See project.conf \[dependencies]. diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp index 665c7e9..5203c5b 100644 --- a/include/QuickMedia.hpp +++ b/include/QuickMedia.hpp @@ -176,6 +176,7 @@ namespace QuickMedia { sf::Vertex gradient_points[4]; sf::Vector2f body_pos; sf::Vector2f body_size; + bool show_room_side_panel = true; std::thread::id main_thread_id; }; } \ No newline at end of file diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index ec33b3e..0eb40c3 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -397,6 +397,11 @@ namespace QuickMedia { fprintf(stderr, "Failed to create thumbnails directory\n"); } + const char *qm_phone_factor = getenv("QM_PHONE_FACTOR"); + if(qm_phone_factor && atoi(qm_phone_factor) == 1) + show_room_side_panel = false; + else + show_room_side_panel = true; main_thread_id = std::this_thread::get_id(); } @@ -4486,9 +4491,9 @@ namespace QuickMedia { body_padding_horizontal = 0.0f; } - this->body_pos = sf::Vector2f(0.0f, body_padding_vertical + tab_shade_height); - if(body_width > 640.0f) { - this->body_size = sf::Vector2f(300.0f, window_size.y - body_padding_vertical - tab_shade_height); + this->body_pos = sf::Vector2f(0.0f, tab_shade_height); + if(body_width > 640.0f && show_room_side_panel) { + this->body_size = sf::Vector2f(300.0f, window_size.y - tab_shade_height); draw_room_list = true; } else { this->body_size = sf::Vector2f(0.0f, 0.0f); @@ -4614,10 +4619,10 @@ namespace QuickMedia { room_list_background.setPosition(this->body_pos); room_list_background.setFillColor(sf::Color(31, 35, 41)); window.draw(room_list_background); - page_loop_render(window, room_tabs, room_selected_tab, room_tab_associated_data, &Json::Value::nullSingleton()); + room_tabs[room_selected_tab].body->draw(window, this->body_pos, this->body_size, Json::Value::nullSingleton()); } - const float width_per_tab = window_size.x / tabs.size(); + const float width_per_tab = body_size.x / tabs.size(); tab_background.setSize(sf::Vector2f(std::floor(width_per_tab - tab_margin_x * 2.0f), tab_height)); if(chat_state == ChatState::URL_SELECTION) @@ -4646,10 +4651,10 @@ namespace QuickMedia { int i = 0; for(ChatTab &tab : tabs) { if(i == selected_tab) { - tab_background.setPosition(std::floor(i * width_per_tab + tab_margin_x), tab_spacer_height + std::floor(tab_vertical_offset) + room_name_padding_y); + tab_background.setPosition(std::floor(body_pos.x + i * width_per_tab + tab_margin_x), tab_spacer_height + std::floor(tab_vertical_offset) + room_name_padding_y); window.draw(tab_background); } - const float center = (i * width_per_tab) + (width_per_tab * 0.5f); + const float center = body_pos.x + (i * width_per_tab) + (width_per_tab * 0.5f); tab.text.setPosition(std::floor(center - tab.text.getLocalBounds().width * 0.5f), tab_y); window.draw(tab.text); ++i; -- cgit v1.2.3