Implement platform-agnostic OpenURL().

This commit is contained in:
2025-06-16 02:19:22 -05:00
parent a9ca448a10
commit f64734c632
2 changed files with 20 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(cmake/CPM.cmake)
CPMAddPackage(NAME mcolor
URL https://git.redacted.cc/maxine/mcolor/archive/Prerelease-7.3.zip)
URL https://git.redacted.cc/maxine/mcolor/archive/Release-1.zip)
CPMAddPackage(NAME jlog
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-18.zip)

View File

@@ -105,6 +105,15 @@ void FractalInspectorApp::UnloadJulia() {
juliaset_dialog->Close();
}
void OpenURL(const std::string &url) {
#ifdef _WIN32
system(std::format("start {}", url).c_str());
#endif
#ifdef linux
system(std::format("xdg-open {}", url).c_str());
#endif
}
JUI::Window * FractalInspectorApp::CreateAppInfoDialogWindow(JUI::Widget *parent) {
// TODO: Implement JUI structure that makes blocks of text easy to impelement.
auto window = new JUI::Window(parent);
@@ -112,6 +121,8 @@ JUI::Window * FractalInspectorApp::CreateAppInfoDialogWindow(JUI::Widget *parent
window->Size({300_px, 375_px});
window->MinSize({300, 375});
window->Position({100_percent - 325_px, 100_percent - 400_px});
auto* layout = new JUI::VerticalListLayout(window->Content());
layout->Padding(0_px);
@@ -156,18 +167,23 @@ JUI::Window * FractalInspectorApp::CreateAppInfoDialogWindow(JUI::Widget *parent
auto* btn_layout = new JUI::HorizontalListLayout(btn_box);
btn_layout->Padding(8_px);
auto btn_item = [&] (const std::string& text) -> JUI::TextButton* {
auto btn_item = [&] (const std::string& text, const std::function<void()>& callback = {}) -> JUI::TextButton* {
JUI::TextButton* btn = new JUI::TextButton(btn_layout);
btn->SetContent(text);
btn->Size({32_percent, 100_percent});
btn->SetTextColor(Colors::Black);
btn->Center();
btn->OnClickEvent += [callback] (auto a, auto b) {
callback();
};
return btn;
};
auto* btn_a = btn_item("License");
auto* btn_b = btn_item("Wiki");
auto* btn_c = btn_item("Source");
auto* btn_c = btn_item("Source", []() {
OpenURL("https://git.redacted.cc/josh/FractalInspector");
});
return window;
@@ -285,6 +301,7 @@ void FractalInspectorApp::CreateMenu() {
console->OnInput += [this] (const std::string& message) {
ParseCmdLineMessage(message);
};
console->Close();
mandelbrotset_dialog = new JUI::Window(scene);