Skip to content
Merged
Show file tree
Hide file tree
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
Binary file added IconResource/icon.icns
Binary file not shown.
5 changes: 3 additions & 2 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2034,7 +2034,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}../../ FILES ${MAIN_SOURCES})

if (APPLE)
# TODO: set up the correct application icon
# set(SerialPrograms_ICON ${CMAKE_CURRENT_SOURCE_DIR}/../Resources/icon.icns)
set(SerialPrograms_ICON ${CMAKE_CURRENT_SOURCE_DIR}/../IconResource/icon.icns)
# set_source_files_properties(SerialPrograms_ICON PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")

# Links on how to create a MacOS app bundle with cmake
Expand All @@ -2047,9 +2047,10 @@ if (APPLE)
MACOSX_BUNDLE_BUNDLE_NAME SerialPrograms
MACOSX_BUNDLE_BUNDLE_VERSION "0.1"
MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1"
# MACOSX_BUNDLE_ICON_FILE icon
MACOSX_BUNDLE_ICON_FILE "icon.icns"
# MacOSXBundleInfo.plist.in is modified from https://github.com/Kitware/CMake/blob/master/Modules/MacOSXBundleInfo.plist.in
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in
RESOURCE ${SerialPrograms_ICON}
)
else() # WIN and Linux:
add_executable(SerialPrograms WIN32 ${MAIN_SOURCES})
Expand Down
28 changes: 17 additions & 11 deletions SerialPrograms/Source/CommonFramework/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,22 @@ const std::string PROJECT_SOURCE_URL = "https://github.com/PokemonAutomation/Ard

namespace{

QString get_application_base_dir_path(){
QString application_dir_path = qApp->applicationDirPath();
if (application_dir_path.endsWith(".app/Contents/MacOS")){
// a macOS bundle. Change working directory to the folder that hosts the .app folder.
QString app_bundle_path = application_dir_path.chopped(15);
QString base_folder_path = QFileInfo(app_bundle_path).dir().absolutePath();
return base_folder_path;
}
return application_dir_path;
}
std::string get_resource_path(){
// Find the resource directory.
QString path = QCoreApplication::applicationDirPath();
QString path = get_application_base_dir_path();
for (size_t c = 0; c < 5; c++){
QString try_path = path + "/Resources/";
QFile file(try_path);
// cout << path.toUtf8().data() << endl;
if (file.exists()){
return try_path.toStdString();
}
Expand All @@ -70,12 +79,11 @@ std::string get_resource_path(){
return (QCoreApplication::applicationDirPath() + "/../Resources/").toStdString();
}
std::string get_training_path(){
// Find the resource directory.
QString path = QCoreApplication::applicationDirPath();
// Find the training data directory.
QString path = get_application_base_dir_path();
for (size_t c = 0; c < 5; c++){
QString try_path = path + "/TrainingData/";
QFile file(try_path);
// cout << path.toUtf8().data() << endl;
if (file.exists()){
return try_path.toStdString();
}
Expand All @@ -85,15 +93,13 @@ std::string get_training_path(){
}

std::string get_runtime_base_path(){
QString application_dir_path = qApp->applicationDirPath();
if (application_dir_path.endsWith(".app/Contents/MacOS")){
// a macOS bundle. Change working directory to the folder that hosts the .app folder.
QString app_bundle_path = application_dir_path.chopped(15);
QString base_folder_path = QFileInfo(app_bundle_path).dir().absolutePath();
return base_folder_path.toStdString() + "/";
if (QSysInfo::productType() == "macos" || QSysInfo::productType() == "osx"){
QString application_dir_path = get_application_base_dir_path();
return application_dir_path.toStdString() + "/";
}
return "./";
}

const std::string& RUNTIME_BASE_PATH(){
static std::string path = get_runtime_base_path();
return path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QCoreApplication>
#include <QMenuBar>
#include <QDir>
#include <CommonFramework/Globals.h>
#include "CommonFramework/Windows/DpiScaler.h"
#include "CommonFramework/Windows/WindowTracker.h"
#include "FileWindowLogger.h"
Expand All @@ -19,7 +20,7 @@ namespace PokemonAutomation{


Logger& global_logger_raw(){
static FileWindowLogger logger((QCoreApplication::applicationName() + ".log").toStdString());
static FileWindowLogger logger(USER_FILE_PATH() + (QCoreApplication::applicationName() + ".log").toStdString());
return logger;
}

Expand Down
Loading