aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-16 21:22:40 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-16 21:22:40 +0200
commit5ba091235fef86fda675021812eb7559241c1b80 (patch)
tree6c85de6dd29b6ba2bc2ca5f88c518a9001d6d0a4 /src
parent8574d6c7da09f5d5929df8ff8c35cb4d82389459 (diff)
Allow setting video max height in config
Diffstat (limited to 'src')
-rw-r--r--src/Config.cpp8
-rw-r--r--src/QuickMedia.cpp20
-rw-r--r--src/Theme.cpp1
3 files changed, 22 insertions, 7 deletions
diff --git a/src/Config.cpp b/src/Config.cpp
index 146527a..f8dc3ed 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -52,6 +52,7 @@ namespace QuickMedia {
if(config_initialized)
return;
+ setlocale(LC_ALL, "C"); // Sigh... stupid C
config_initialized = true;
// Wtf? can't use static non-pointer config because it causes a segfault when setting config.theme.
// It looks like a libc bug??? crashes for both gcc and clang.
@@ -117,6 +118,13 @@ namespace QuickMedia {
config->input.font_size = font_size_json.asDouble();
}
+ const Json::Value &video_json = json_root["video"];
+ if(video_json.isObject()) {
+ const Json::Value &max_height_json = video_json["max_height"];
+ if(max_height_json.isNumeric())
+ config->video.max_height = max_height_json.asInt();
+ }
+
const Json::Value &use_system_fonts_json = json_root["use_system_fonts"];
if(use_system_fonts_json.isBool())
config->use_system_fonts = use_system_fonts_json.asBool();
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 4fd76c5..9bcdcca 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -2655,6 +2655,12 @@ namespace QuickMedia {
return url.find("yt_live_broadcast") != std::string::npos || url.find("manifest/") != std::string::npos;
}
+ static int video_get_max_height(Display *display) {
+ if(get_config().video.max_height > 0)
+ return get_config().video.max_height;
+ return get_largest_monitor_height(display);
+ }
+
#define CLEANMASK(mask) ((mask) & (ShiftMask|ControlMask|Mod1Mask|Mod4Mask|Mod5Mask))
void Program::video_content_page(Page *parent_page, VideoPage *video_page, std::string video_title, bool download_if_streaming_fails, Body *parent_body, int play_index, int *parent_body_page, const std::string &parent_page_search) {
@@ -2725,7 +2731,7 @@ namespace QuickMedia {
video_player_window = None;
bool is_audio_only = no_video;
- const int largest_monitor_height = get_largest_monitor_height(disp);
+ const int video_max_height = video_get_max_height(disp);
if(!reuse_media_source) {
std::string new_title;
@@ -2744,7 +2750,7 @@ namespace QuickMedia {
std::string ext;
if(!no_video)
- video_url = video_page->get_video_url(largest_monitor_height, has_embedded_audio, ext);
+ video_url = video_page->get_video_url(video_max_height, has_embedded_audio, ext);
if(video_url.empty() || no_video) {
video_url = video_page->get_audio_url(ext);
@@ -2886,7 +2892,7 @@ namespace QuickMedia {
}
}
- video_player = std::make_unique<VideoPlayer>(is_audio_only, get_config().use_system_mpv_config, is_matrix && !is_youtube, video_event_callback, on_window_create, resources_root, largest_monitor_height, plugin_name);
+ video_player = std::make_unique<VideoPlayer>(is_audio_only, get_config().use_system_mpv_config, is_matrix && !is_youtube, video_event_callback, on_window_create, resources_root, video_max_height, plugin_name);
VideoPlayer::Error err = video_player->load_video(v.c_str(), a.c_str(), window.getSystemHandle(), use_youtube_dl, video_title, start_time, media_chapters);
if(err != VideoPlayer::Error::OK) {
std::string err_msg = "Failed to play url: ";
@@ -2966,7 +2972,7 @@ namespace QuickMedia {
sf::Clock cursor_hide_timer;
auto save_video_url_to_clipboard = [this, video_page]() {
- std::string url = video_page->get_download_url(get_largest_monitor_height(disp));
+ std::string url = video_page->get_download_url(video_get_max_height(disp));
if(video_url_supports_timestamp(url)) {
double time_in_file = 0.0;
if(video_player && (video_player->get_time_in_file(&time_in_file) != VideoPlayer::Error::OK))
@@ -3027,7 +3033,7 @@ namespace QuickMedia {
} else if(pressed_keysym == XK_f && pressing_ctrl) {
window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::TOGGLE);
} else if(pressed_keysym == XK_s && pressing_ctrl) {
- video_page_download_video(video_page->get_download_url(get_largest_monitor_height(disp)), video_player_window);
+ video_page_download_video(video_page->get_download_url(video_get_max_height(disp)), video_player_window);
} else if(pressed_keysym == XK_F5) {
double resume_start_time = 0.0;
video_player->get_time_in_file(&resume_start_time);
@@ -7109,7 +7115,7 @@ namespace QuickMedia {
youtube_video_page = std::make_unique<YoutubeVideoPage>(this, url);
bool cancelled = false;
bool load_successful = false;
- const int largest_monitor_height = get_largest_monitor_height(disp);
+ const int video_max_height = video_get_max_height(disp);
std::string err_str;
for(int i = 0; i < 3; ++i) {
@@ -7122,7 +7128,7 @@ namespace QuickMedia {
std::string ext;
bool has_embedded_audio = true;
- video_url = no_video ? "" : youtube_video_page->get_video_url(largest_monitor_height, has_embedded_audio, ext);
+ video_url = no_video ? "" : youtube_video_page->get_video_url(video_max_height, has_embedded_audio, ext);
audio_url.clear();
if(!has_embedded_audio || no_video)
diff --git a/src/Theme.cpp b/src/Theme.cpp
index c0702d1..90e4b30 100644
--- a/src/Theme.cpp
+++ b/src/Theme.cpp
@@ -80,6 +80,7 @@ namespace QuickMedia {
if(theme_initialized)
return;
+ setlocale(LC_ALL, "C"); // Sigh... stupid C
theme_initialized = true;
// Wtf? can't use static non-pointer config because it causes a segfault.
// It looks like a libc bug??? crashes for both gcc and clang.