diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-02-18 15:34:03 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-02-18 16:10:31 +0300 |
commit | 0e21b478636fac986a5e2276662da6a6e1692f9e (patch) | |
tree | 8c442eb9ea5118ba9fbab14831aa12dbe42a58ab /src/gui/widgets | |
parent | e714f084284e14ff8a338d68c15088ab7662a42f (diff) | |
download | manaverse-0e21b478636fac986a5e2276662da6a6e1692f9e.tar.gz manaverse-0e21b478636fac986a5e2276662da6a6e1692f9e.tar.bz2 manaverse-0e21b478636fac986a5e2276662da6a6e1692f9e.tar.xz manaverse-0e21b478636fac986a5e2276662da6a6e1692f9e.zip |
Add support for help seach links.
To add link to search text: /url ?text
Also add support for links in format: help://topic
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/itemlinkhandler.cpp | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 24b487f53..e708eb507 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -25,6 +25,7 @@ #include "item.h" #include "gui/confirmdialog.h" +#include "gui/helpwindow.h" #include "gui/itempopup.h" #include "gui/viewport.h" @@ -64,7 +65,43 @@ ItemLinkHandler::~ItemLinkHandler() void ItemLinkHandler::handleLink(const std::string &link, gcn::MouseEvent *event) { - if (!strStartWith(link, "http://") && !strStartWith(link, "https://")) + if (strStartWith(link, "http://") || strStartWith(link, "https://")) + { + if (!event) + return; + std::string url = link; + replaceAll(url, " ", ""); + listener.url = url; + const int button = event->getButton(); + if (button == gcn::MouseInput::LEFT) + { + ConfirmDialog *const confirmDlg = new ConfirmDialog( + _("Open url"), url, false, true); + confirmDlg->addActionListener(&listener); + } + else if (button == gcn::MouseInput::RIGHT) + { + if (viewport) + viewport->showLinkPopup(url); + } + } + else if (!link.empty() && link[0] == '?') + { + if (helpWindow) + { + helpWindow->search(link.substr(1)); + helpWindow->requestMoveToTop(); + } + } + else if (strStartWith(link, "help://")) + { + if (helpWindow) + { + helpWindow->loadHelp(link.substr(7)); + helpWindow->requestMoveToTop(); + } + } + else { if (!mItemPopup) return; @@ -91,24 +128,4 @@ void ItemLinkHandler::handleLink(const std::string &link, } } } - else - { - if (!event) - return; - std::string url = link; - replaceAll(url, " ", ""); - listener.url = url; - const int button = event->getButton(); - if (button == gcn::MouseInput::LEFT) - { - ConfirmDialog *const confirmDlg = new ConfirmDialog( - _("Open url"), url, false, true); - confirmDlg->addActionListener(&listener); - } - else if (button == gcn::MouseInput::RIGHT) - { - if (viewport) - viewport->showLinkPopup(url); - } - } } |