Rewrite plat_init_rom_paths in Qt frontend
This commit is contained in:
@@ -37,7 +37,6 @@
|
|||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <dispatch/dispatch.h>
|
#include <dispatch/dispatch.h>
|
||||||
#include "mac/macOSXGlue.h"
|
|
||||||
#ifdef __aarch64__
|
#ifdef __aarch64__
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -650,9 +649,7 @@ usage:
|
|||||||
|
|
||||||
{
|
{
|
||||||
char default_rom_path[1024] = { 0 };
|
char default_rom_path[1024] = { 0 };
|
||||||
#if defined(__APPLE__)
|
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||||
getDefaultROMPath(default_rom_path);
|
|
||||||
#elif !defined(_WIN32)
|
|
||||||
appimage = getenv("APPIMAGE");
|
appimage = getenv("APPIMAGE");
|
||||||
if (appimage && (appimage[0] != '\0')) {
|
if (appimage && (appimage[0] != '\0')) {
|
||||||
plat_get_dirname(default_rom_path, appimage);
|
plat_get_dirname(default_rom_path, appimage);
|
||||||
|
|||||||
@@ -19,17 +19,16 @@
|
|||||||
|
|
||||||
# Pick the bundle icon depending on the release channel
|
# Pick the bundle icon depending on the release channel
|
||||||
if(RELEASE_BUILD)
|
if(RELEASE_BUILD)
|
||||||
set(APP_ICON_MACOSX icons/release/86Box.icns)
|
target_sources(86Box PRIVATE icons/release/86Box.icns)
|
||||||
elseif(BETA_BUILD)
|
elseif(BETA_BUILD)
|
||||||
set(APP_ICON_MACOSX icons/beta/86Box.icns)
|
target_sources(86Box PRIVATE icons/beta/86Box.icns)
|
||||||
elseif(ALPHA_BUILD)
|
elseif(ALPHA_BUILD)
|
||||||
set(APP_ICON_MACOSX icons/dev/86Box.icns)
|
target_sources(86Box PRIVATE icons/dev/86Box.icns)
|
||||||
else()
|
else()
|
||||||
set(APP_ICON_MACOSX icons/branch/86Box.icns)
|
target_sources(86Box PRIVATE icons/branch/86Box.icns)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(86Box "-framework AppKit")
|
target_link_libraries(86Box "-framework AppKit")
|
||||||
target_sources(86Box PRIVATE macOSXGlue.m ${APP_ICON_MACOSX})
|
|
||||||
|
|
||||||
# Make sure the icon is copied to the bundle
|
# Make sure the icon is copied to the bundle
|
||||||
set_source_files_properties(${APP_ICON_MACOSX}
|
set_source_files_properties(${APP_ICON_MACOSX}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
|
#include <QStandardPaths>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
@@ -589,59 +590,18 @@ plat_chdir(char *path)
|
|||||||
void
|
void
|
||||||
plat_init_rom_paths()
|
plat_init_rom_paths()
|
||||||
{
|
{
|
||||||
#if defined __APPLE__
|
auto paths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
|
||||||
QDir::root().mkpath(QStringLiteral("%1/Documents/86Box/roms/").arg(QDir::homePath()));
|
|
||||||
add_rom_path(QStringLiteral("%1/Documents/86Box/roms/").arg(QDir::homePath()).toUtf8().constData());
|
|
||||||
#elif !defined _WIN32
|
|
||||||
if (getenv("XDG_DATA_HOME")) {
|
|
||||||
char xdg_rom_path[1024 + 1] = { 0 };
|
|
||||||
strncpy(xdg_rom_path, getenv("XDG_DATA_HOME"), 1024);
|
|
||||||
plat_path_slash(xdg_rom_path);
|
|
||||||
strncat(xdg_rom_path, "86Box/", 1024);
|
|
||||||
|
|
||||||
if (!plat_dir_check(xdg_rom_path))
|
#ifdef _WIN32
|
||||||
plat_dir_create(xdg_rom_path);
|
// HACK: The standard locations returned for GenericDataLocation include
|
||||||
strcat(xdg_rom_path, "roms/");
|
// the EXE path and a `data` directory within it as the last two entries.
|
||||||
|
|
||||||
if (!plat_dir_check(xdg_rom_path))
|
// Remove the entries as we don't need them.
|
||||||
plat_dir_create(xdg_rom_path);
|
paths.removeLast();
|
||||||
add_rom_path(xdg_rom_path);
|
paths.removeLast();
|
||||||
} else {
|
|
||||||
char home_rom_path[1024] = { 0 };
|
|
||||||
snprintf(home_rom_path, 1024, "%s/.local/share/86Box/", getenv("HOME") ? getenv("HOME") : QDir::homePath().toUtf8().constData());
|
|
||||||
|
|
||||||
if (!plat_dir_check(home_rom_path))
|
|
||||||
plat_dir_create(home_rom_path);
|
|
||||||
strcat(home_rom_path, "roms/");
|
|
||||||
|
|
||||||
if (!plat_dir_check(home_rom_path))
|
|
||||||
plat_dir_create(home_rom_path);
|
|
||||||
add_rom_path(home_rom_path);
|
|
||||||
}
|
|
||||||
if (getenv("XDG_DATA_DIRS")) {
|
|
||||||
char* xdg_rom_paths = strdup(getenv("XDG_DATA_DIRS"));
|
|
||||||
char* xdg_rom_paths_orig = xdg_rom_paths;
|
|
||||||
char* cur_xdg_rom_path = NULL;
|
|
||||||
if (xdg_rom_paths) {
|
|
||||||
while (xdg_rom_paths[strlen(xdg_rom_paths) - 1] == ':') {
|
|
||||||
xdg_rom_paths[strlen(xdg_rom_paths) - 1] = '\0';
|
|
||||||
}
|
|
||||||
QStringList path_list = QString(xdg_rom_paths).split(":");
|
|
||||||
for (auto& cur_path : path_list) {
|
|
||||||
if (cur_path.right(1) != '/')
|
|
||||||
cur_path.push_back('/');
|
|
||||||
add_rom_path((cur_path + "86Box/roms").toUtf8().constData());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(xdg_rom_paths_orig);
|
|
||||||
} else {
|
|
||||||
add_rom_path("/usr/local/share/86Box/roms/");
|
|
||||||
add_rom_path("/usr/share/86Box/roms/");
|
|
||||||
}
|
|
||||||
#elif _WIN32
|
|
||||||
auto appDataDir = QDir(qEnvironmentVariable("LOCALAPPDATA"));
|
|
||||||
appDataDir.mkdir("86Box");
|
|
||||||
appDataDir.mkdir("86Box/roms");
|
|
||||||
add_rom_path((appDataDir.path().replace("\\","/") + "/86Box/roms").toUtf8().constData());
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
for (auto& path : paths) {
|
||||||
|
add_rom_path(QDir(path).filePath("86Box/roms").toUtf8().constData());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,3 +28,7 @@ target_link_libraries(86Box Threads::Threads)
|
|||||||
add_library(ui OBJECT unix_sdl.c unix_cdrom.c)
|
add_library(ui OBJECT unix_sdl.c unix_cdrom.c)
|
||||||
target_compile_definitions(ui PUBLIC _FILE_OFFSET_BITS=64)
|
target_compile_definitions(ui PUBLIC _FILE_OFFSET_BITS=64)
|
||||||
target_link_libraries(ui ${CMAKE_DL_LIBS})
|
target_link_libraries(ui ${CMAKE_DL_LIBS})
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
target_sources(plat PRIVATE macOSXGlue.m)
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -36,6 +36,10 @@
|
|||||||
#include <86box/ui.h>
|
#include <86box/ui.h>
|
||||||
#include <86box/gdbstub.h>
|
#include <86box/gdbstub.h>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include "macOSXGlue.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static int first_use = 1;
|
static int first_use = 1;
|
||||||
static uint64_t StartingTime;
|
static uint64_t StartingTime;
|
||||||
static uint64_t Frequency;
|
static uint64_t Frequency;
|
||||||
@@ -797,12 +801,9 @@ plat_init_rom_paths()
|
|||||||
add_rom_path("/usr/share/86Box/roms/");
|
add_rom_path("/usr/share/86Box/roms/");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
char home_rom_path[1024] = { '\0' };
|
char default_rom_path[1024] = { '\0 '};
|
||||||
snprintf(home_rom_path, 1024, "%s/Documents/86Box/", getenv("HOME") ? getenv("HOME") : getpwuid(getuid())->pw_dir);
|
getDefaultROMPath(default_rom_path);
|
||||||
plat_dir_create(home_rom_path);
|
add_rom_path(default_rom_path);
|
||||||
strcat(home_rom_path, "roms/");
|
|
||||||
plat_dir_create(home_rom_path);
|
|
||||||
add_rom_path(home_rom_path);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user