aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/QuickMedia.hpp1
-rw-r--r--plugins/Fourchan.hpp5
-rw-r--r--src/QuickMedia.cpp23
-rw-r--r--src/plugins/Fourchan.cpp4
4 files changed, 21 insertions, 12 deletions
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index cd410c3..dc81425 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -81,5 +81,6 @@ namespace QuickMedia {
std::string downloading_chapter_url;
bool image_download_cancel = false;
int exit_code = 0;
+ std::string resources_root;
};
} \ No newline at end of file
diff --git a/plugins/Fourchan.hpp b/plugins/Fourchan.hpp
index 33c6579..c9d649f 100644
--- a/plugins/Fourchan.hpp
+++ b/plugins/Fourchan.hpp
@@ -6,9 +6,11 @@
#include <condition_variable>
namespace QuickMedia {
+ class Program;
+
class Fourchan : public ImageBoard {
public:
- Fourchan();
+ Fourchan(const std::string &resources_root);
~Fourchan() override;
PluginResult get_front_page(BodyItems &result_items) override;
SearchResult search(const std::string &url, BodyItems &result_items) override;
@@ -40,5 +42,6 @@ namespace QuickMedia {
bool thread_list_cached = false;
bool running = true;
std::vector<std::string> cached_media_urls;
+ std::string resources_root;
};
} \ No newline at end of file
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index f878497..750ea3c 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -56,12 +56,17 @@ namespace QuickMedia {
if (!disp)
throw std::runtime_error("Failed to open display to X11 server");
+ resources_root = "../../../";
+ if(get_file_type("/usr/share/quickmedia/") == FileType::DIRECTORY) {
+ resources_root = "/usr/share/quickmedia/";
+ }
+
window.setVerticalSyncEnabled(true);
- if(!font.loadFromFile("../../../fonts/Lato-Regular.ttf")) {
+ if(!font.loadFromFile(resources_root + "fonts/Lato-Regular.ttf")) {
fprintf(stderr, "Failed to load font: Lato-Regular.ttf\n");
abort();
}
- if(!bold_font.loadFromFile("../../../fonts/Lato-Bold.ttf")) {
+ if(!bold_font.loadFromFile(resources_root + "fonts/Lato-Bold.ttf")) {
fprintf(stderr, "Failed to load font: Lato-Bold.ttf\n");
abort();
}
@@ -141,22 +146,22 @@ namespace QuickMedia {
if(!current_plugin) {
if(strcmp(argv[i], "manganelo") == 0) {
current_plugin = new Manganelo();
- plugin_logo_path = "../../../images/manganelo_logo.png";
+ plugin_logo_path = resources_root + "images/manganelo_logo.png";
} else if(strcmp(argv[i], "mangatown") == 0) {
current_plugin = new Mangatown();
- plugin_logo_path = "../../../images/mangatown_logo.png";
+ plugin_logo_path = resources_root + "images/mangatown_logo.png";
} else if(strcmp(argv[i], "mangadex") == 0) {
current_plugin = new Mangadex();
- plugin_logo_path = "../../../images/mangadex_logo.png";
+ plugin_logo_path = resources_root + "images/mangadex_logo.png";
} else if(strcmp(argv[i], "youtube") == 0) {
current_plugin = new Youtube();
- plugin_logo_path = "../../../images/yt_logo_rgb_dark_small.png";
+ plugin_logo_path = resources_root + "images/yt_logo_rgb_dark_small.png";
} else if(strcmp(argv[i], "pornhub") == 0) {
current_plugin = new Pornhub();
- plugin_logo_path = "../../../images/pornhub_logo.png";
+ plugin_logo_path = resources_root + "images/pornhub_logo.png";
} else if(strcmp(argv[i], "4chan") == 0) {
- current_plugin = new Fourchan();
- plugin_logo_path = "../../../images/4chan_logo.png";
+ current_plugin = new Fourchan(resources_root);
+ plugin_logo_path = resources_root + "images/4chan_logo.png";
} else if(strcmp(argv[i], "dmenu") == 0) {
current_plugin = new Dmenu();
}
diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp
index 073356b..22a3faf 100644
--- a/src/plugins/Fourchan.cpp
+++ b/src/plugins/Fourchan.cpp
@@ -12,7 +12,7 @@ static const std::string fourchan_url = "https://a.4cdn.org/";
static const std::string fourchan_image_url = "https://i.4cdn.org/";
namespace QuickMedia {
- Fourchan::Fourchan() : ImageBoard("4chan") {
+ Fourchan::Fourchan(const std::string &resources_root) : ImageBoard("4chan"), resources_root(resources_root) {
thread_list_update_thread = std::thread([this]() {
BodyItems new_thread_list_items;
while(running) {
@@ -52,7 +52,7 @@ namespace QuickMedia {
return PluginResult::NET_ERR;
#else
std::string server_response;
- if(file_get_content("../../../boards.json", server_response) != 0) {
+ if(file_get_content(resources_root + "boards.json", server_response) != 0) {
fprintf(stderr, "failed to read boards.json\n");
return PluginResult::ERR;
}