1
0
mirror of synced 2025-01-31 03:53:44 +01:00

impr: Handle macOS Open with... correctly

This commit is contained in:
WerWolv 2023-05-15 18:07:49 +02:00
parent 07565eea63
commit 14341d611d
3 changed files with 13 additions and 1 deletions

View File

@ -283,4 +283,6 @@ namespace hex {
return string.substr(0, maxLength - 3) + "...";
}
std::optional<std::fs::path> getInitialFilePath();
}

View File

@ -502,8 +502,13 @@ namespace hex {
return value;
}
static std::optional<std::fs::path> fileToOpen;
extern "C" void openFile(const char *path) {
hex::EventManager::post<RequestOpenFile>(path);
fileToOpen = path;
}
std::optional<std::fs::path> getInitialFilePath() {
return fileToOpen;
}
}

View File

@ -70,6 +70,11 @@ int main(int argc, char **argv, char **envp) {
}
}
// Open file that has been requested to be opened through other, OS-specific means
if (auto path = hex::getInitialFilePath(); path.has_value()) {
EventManager::post<RequestOpenFile>(path.value());
}
// Render the main window
window.loop();
}