summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-18 15:34:03 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-18 16:10:31 +0300
commit0e21b478636fac986a5e2276662da6a6e1692f9e (patch)
tree8c442eb9ea5118ba9fbab14831aa12dbe42a58ab /src/gui
parente714f084284e14ff8a338d68c15088ab7662a42f (diff)
downloadplus-0e21b478636fac986a5e2276662da6a6e1692f9e.tar.gz
plus-0e21b478636fac986a5e2276662da6a6e1692f9e.tar.bz2
plus-0e21b478636fac986a5e2276662da6a6e1692f9e.tar.xz
plus-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')
-rw-r--r--src/gui/helpwindow.cpp9
-rw-r--r--src/gui/helpwindow.h2
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp59
3 files changed, 45 insertions, 25 deletions
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index c035b2a24..712d9fa6a 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -36,6 +36,7 @@
#include "utils/gettext.h"
#include "utils/langs.h"
+#include "utils/paths.h"
#include "utils/process.h"
#include "utils/translation/podict.h"
@@ -101,18 +102,19 @@ void HelpWindow::handleLink(const std::string &link,
void HelpWindow::loadHelp(const std::string &helpFile)
{
+ if (!checkPath(helpFile))
+ return;
mBrowserBox->clearRows();
-
loadFile("header");
loadFile(helpFile);
loadFile("footer");
-
mScrollArea->setVerticalScrollAmount(0);
setVisible(true);
}
-void HelpWindow::loadFile(const std::string &file)
+void HelpWindow::loadFile(std::string file)
{
+ trim(file);
std::string helpPath = branding.getStringValue("helpPath");
if (helpPath.empty())
helpPath = paths.getStringValue("help");
@@ -144,6 +146,7 @@ void HelpWindow::loadTags()
void HelpWindow::search(const std::string &text0)
{
std::string text = text0;
+ trim(text);
toLower(text);
if (mTagFileMap.find(text) == mTagFileMap.end())
{
diff --git a/src/gui/helpwindow.h b/src/gui/helpwindow.h
index 998164b62..4e27a61e2 100644
--- a/src/gui/helpwindow.h
+++ b/src/gui/helpwindow.h
@@ -79,7 +79,7 @@ class HelpWindow final : public Window, public LinkHandler,
private:
void loadTags();
- void loadFile(const std::string &file);
+ void loadFile(std::string file);
BrowserBox *mBrowserBox;
ScrollArea *mScrollArea;
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);
- }
- }
}