Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions pdf_viewer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ void configure_paths_android() {
}
#endif

Path get_sioyek_data_path() {
char* APPDIR = std::getenv("XDG_DATA_HOME");
if (!APPDIR) {
APPDIR = std::getenv("HOME");
return Path(utf8_decode(APPDIR)).slash(L".local").slash(L"share").slash(L"sioyek");
}
return Path(utf8_decode(APPDIR)).slash(L"sioyek");
}

void configure_paths() {
#ifdef SIOYEK_ANDROID
configure_paths_android();
Expand Down Expand Up @@ -268,18 +277,7 @@ void configure_paths() {
last_opened_file_address_path = standard_data_path.slash(L"last_document_path.txt");
shader_path = read_only_data_path.slash(L"shaders");
#else
char* APPDIR = std::getenv("XDG_DATA_HOME");
Path linux_home_path(QDir::homePath().toStdWString());

if (!APPDIR) {
APPDIR = std::getenv("HOME");
standard_data_path = Path(utf8_decode(APPDIR));
standard_data_path = standard_data_path.slash(L".local").slash(L"share");
} else {
standard_data_path = Path(utf8_decode(APPDIR));
}

standard_data_path = standard_data_path.slash(L"sioyek");
standard_data_path = get_sioyek_data_path();
standard_data_path.create_directories();

default_config_path = parent_path.slash(L"prefs.config");
Expand All @@ -293,6 +291,7 @@ void configure_paths() {
tutorial_path = standard_data_path.slash(L"tutorial.pdf");
last_opened_file_address_path = standard_data_path.slash(L"last_document_path.txt");

Path linux_home_path(QDir::homePath().toStdWString());
Path linux_standard_config_path = linux_home_path.slash(L".config").slash(L"sioyek");
//user_keys_paths.push_back(mac_standard_config_path.slash(L"keys_user.config"));
//user_config_paths.push_back(mac_standard_config_path.slash(L"prefs_user.config"));
Expand All @@ -307,7 +306,12 @@ void configure_paths() {
#ifdef NDEBUG
//install_app(exe_path.c_str());
#endif
standard_data_path = Path(QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).at(0).toStdWString());
#ifdef Q_OS_MACOS
standard_data_path = get_sioyek_data_path();
#endif
if (!standard_data_path.dir_exists()) {
standard_data_path = Path(QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).at(0).toStdWString());
}
QStringList all_config_paths = QStandardPaths::standardLocations(QStandardPaths::AppConfigLocation);

standard_data_path.create_directories();
Expand Down
Loading