summaryrefslogtreecommitdiff
path: root/src/gui/widgets/itemlinkhandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-07-22 16:06:06 +0300
committerAndrei Karas <akaras@inbox.ru>2012-07-22 16:06:06 +0300
commit7aa3784a5d62848af60aabc3f82b19fb068b9d79 (patch)
tree6e1538bf378c54a99ff02fe99d7e79ea6ac504f4 /src/gui/widgets/itemlinkhandler.cpp
parent147696620522270d51d15ff3fd1e7e2431ff61ae (diff)
downloadplus-7aa3784a5d62848af60aabc3f82b19fb068b9d79.tar.gz
plus-7aa3784a5d62848af60aabc3f82b19fb068b9d79.tar.bz2
plus-7aa3784a5d62848af60aabc3f82b19fb068b9d79.tar.xz
plus-7aa3784a5d62848af60aabc3f82b19fb068b9d79.zip
Add new chat commands.
/url LINK - put http link in chat. /openurl LINK - open link in browser.
Diffstat (limited to 'src/gui/widgets/itemlinkhandler.cpp')
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index 98d820164..c09aea04c 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -30,6 +30,8 @@
#include "gui/widgets/itemlinkhandler.h"
+#include "utils/process.h"
+
#include "resources/itemdb.h"
#include "debug.h"
@@ -48,23 +50,30 @@ ItemLinkHandler::~ItemLinkHandler()
void ItemLinkHandler::handleLink(const std::string &link,
gcn::MouseEvent *event A_UNUSED)
{
- if (!mItemPopup)
- return;
+ if (!strStartWith(link, "http://"))
+ {
+ if (!mItemPopup)
+ return;
- int id = 0;
- std::stringstream stream;
- stream << link;
- stream >> id;
+ int id = 0;
+ std::stringstream stream;
+ stream << link;
+ stream >> id;
- if (id > 0)
- {
- const ItemInfo &itemInfo = ItemDB::get(id);
- //+++ need add color to links?
- mItemPopup->setItem(itemInfo, 1, true);
+ if (id > 0)
+ {
+ const ItemInfo &itemInfo = ItemDB::get(id);
+ //+++ need add color to links?
+ mItemPopup->setItem(itemInfo, 1, true);
- if (mItemPopup->isVisible())
- mItemPopup->setVisible(false);
- else if (viewport)
- mItemPopup->position(viewport->getMouseX(), viewport->getMouseY());
+ if (mItemPopup->isVisible())
+ mItemPopup->setVisible(false);
+ else if (viewport)
+ mItemPopup->position(viewport->getMouseX(), viewport->getMouseY());
+ }
+ }
+ else
+ {
+ openBrowser(link);
}
}