diff --git a/doomsday/libs/gui/include/de/gui/guiapp.h b/doomsday/libs/gui/include/de/gui/guiapp.h index dc0c23ac94..d9e9bf79ab 100644 --- a/doomsday/libs/gui/include/de/gui/guiapp.h +++ b/doomsday/libs/gui/include/de/gui/guiapp.h @@ -124,6 +124,13 @@ class LIBGUI_PUBLIC GuiApp : public App */ static void revealFile(const NativePath &fileOrFolder); + /** + * Opens an URL in the operating system's default web browser. + * + * @param url URL to open. + */ + static void openBrowserUrl(const String &url); + protected: NativePath appDataPath() const override; diff --git a/doomsday/libs/gui/src/guiapp.cpp b/doomsday/libs/gui/src/guiapp.cpp index d2a27f0054..60e11207e1 100644 --- a/doomsday/libs/gui/src/guiapp.cpp +++ b/doomsday/libs/gui/src/guiapp.cpp @@ -362,6 +362,12 @@ void GuiApp::revealFile(const NativePath &fileOrFolder) // static CommandLine{{"/usr/bin/osascript", scriptPath, fileOrFolder}}.execute(); } } + #elif defined (DE_X11) + { + String path = (fileOrFolder.isDirectory() ? fileOrFolder.toString() + : fileOrFolder.fileNamePath().toString()); + CommandLine({"/usr/bin/xdg-open", path}).execute(); + } #else { DE_ASSERT_FAIL("File revealing not implemented on this platform"); @@ -369,6 +375,19 @@ void GuiApp::revealFile(const NativePath &fileOrFolder) // static #endif } +void GuiApp::openBrowserUrl(const String &url) +{ + #if defined (DE_X11) + { + CommandLine({"/usr/bin/x-www-browser", url}).execute(); + } +#else + { + DE_ASSERT_FAIL("Browser URL opening not implemented on this platform"); + } + #endif +} + void GuiApp::quitRequested() { quit(0);