Skip to content

Commit

Permalink
libgui|GuiApp: Added a helper method for opening browser URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 12, 2019
1 parent f795aa2 commit 34751eb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doomsday/libs/gui/include/de/gui/guiapp.h
Expand Up @@ -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;

Expand Down
19 changes: 19 additions & 0 deletions doomsday/libs/gui/src/guiapp.cpp
Expand Up @@ -362,13 +362,32 @@ 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");
}
#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);
Expand Down

0 comments on commit 34751eb

Please sign in to comment.