summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp23
-rw-r--r--src/gui/widgets/itemlinkhandler.h2
2 files changed, 20 insertions, 5 deletions
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index e15aa6d0..f596fc82 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -22,8 +22,13 @@
#include <sstream>
#include <string>
+#include <SDL.h>
+
+#if SDL_VERSION_ATLEAST(2, 0, 14)
#include "gui/confirmdialog.h"
+#endif
#include "gui/itempopup.h"
+#include "gui/okdialog.h"
#include "gui/viewport.h"
#include "gui/widgets/itemlinkhandler.h"
@@ -54,8 +59,13 @@ void ItemLinkHandler::handleLink(const std::string &link)
{
mLink = link;
- mConfirmDialog = new ConfirmDialog(_("Open URL?"), link, mParent);
- mConfirmDialog->addActionListener(this);
+#if SDL_VERSION_ATLEAST(2, 0, 14)
+ auto confirmDialog = new ConfirmDialog(_("Open URL?"), link, mParent);
+ confirmDialog->addActionListener(this);
+#else
+ new OkDialog(_("Open URL Failed"),
+ _("Opening of URLs requires SDL 2.0.14."), true, mParent);
+#endif
return;
}
@@ -78,5 +88,12 @@ void ItemLinkHandler::handleLink(const std::string &link)
void ItemLinkHandler::action(const gcn::ActionEvent &actionEvent)
{
if (actionEvent.getId() == "yes")
- SDL_OpenURL(mLink.c_str());
+ {
+#if SDL_VERSION_ATLEAST(2, 0, 14)
+ if (SDL_OpenURL(mLink.c_str()) == -1)
+ {
+ new OkDialog(_("Open URL Failed"), SDL_GetError(), true, mParent);
+ }
+#endif
+ }
}
diff --git a/src/gui/widgets/itemlinkhandler.h b/src/gui/widgets/itemlinkhandler.h
index 3bb0b557..28e9c11c 100644
--- a/src/gui/widgets/itemlinkhandler.h
+++ b/src/gui/widgets/itemlinkhandler.h
@@ -28,7 +28,6 @@
#include <memory>
-class ConfirmDialog;
class ItemPopup;
class Window;
@@ -46,7 +45,6 @@ class ItemLinkHandler : public LinkHandler, gcn::ActionListener
private:
std::unique_ptr<ItemPopup> mItemPopup;
- ConfirmDialog *mConfirmDialog = nullptr;
Window *mParent = nullptr;
std::string mLink;