impr: Handle macOS Open with... correctly
This commit is contained in:
parent
07565eea63
commit
14341d611d
@ -283,4 +283,6 @@ namespace hex {
|
|||||||
return string.substr(0, maxLength - 3) + "...";
|
return string.substr(0, maxLength - 3) + "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<std::fs::path> getInitialFilePath();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -502,8 +502,13 @@ namespace hex {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::optional<std::fs::path> fileToOpen;
|
||||||
extern "C" void openFile(const char *path) {
|
extern "C" void openFile(const char *path) {
|
||||||
hex::EventManager::post<RequestOpenFile>(path);
|
fileToOpen = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::fs::path> getInitialFilePath() {
|
||||||
|
return fileToOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -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
|
// Render the main window
|
||||||
window.loop();
|
window.loop();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user