diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-09-26 21:47:37 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-09-26 21:47:37 +0300 |
commit | ed3a977346009c22c30908a9e7b81f409d310b59 (patch) | |
tree | 0101284761788307a5c231fe0f0466810ee651a1 /src | |
parent | 4b517a69de505e5f3b0eec2e42d2f5bc5d913faa (diff) | |
download | mv-ed3a977346009c22c30908a9e7b81f409d310b59.tar.gz mv-ed3a977346009c22c30908a9e7b81f409d310b59.tar.bz2 mv-ed3a977346009c22c30908a9e7b81f409d310b59.tar.xz mv-ed3a977346009c22c30908a9e7b81f409d310b59.zip |
Add support for links "news" and "copyright".
Use for links in didyouknow window ItemLinkHandler.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/itemlinkhandler.cpp | 9 | ||||
-rw-r--r-- | src/gui/windows/didyouknowwindow.cpp | 17 | ||||
-rw-r--r-- | src/gui/windows/didyouknowwindow.h | 12 | ||||
-rw-r--r-- | src/gui/windows/helpwindow.cpp | 10 | ||||
-rw-r--r-- | src/gui/windows/helpwindow.h | 2 |
5 files changed, 34 insertions, 16 deletions
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 47314ca5c..6207775f0 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -198,6 +198,15 @@ void ItemLinkHandler::handleLink(const std::string &link, { handleCommandLink(link, "="); } + else if (link == "news") + { + if (helpWindow) + helpWindow->loadHelpSimple("news"); + } + if (link == "copyright") + { + inputManager.executeAction(InputAction::WINDOW_ABOUT); + } else { handleItemLink(link); diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index db9352243..04921cac3 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -31,10 +31,12 @@ #include "gui/widgets/button.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/checkbox.h" +#include "gui/widgets/itemlinkhandler.h" #include "gui/widgets/layout.h" #include "gui/widgets/layouttype.h" #include "gui/widgets/scrollarea.h" +#include "utils/delete2.h" #include "utils/gettext.h" #include "utils/process.h" @@ -52,6 +54,7 @@ DidYouKnowWindow::DidYouKnowWindow() : // TRANSLATORS: did you know window name Window(_("Did You Know?"), Modal_false, nullptr, "didyouknow.xml"), ActionListener(), + mItemLinkHandler(new ItemLinkHandler), mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, Opaque_true, "browserbox.xml")), mScrollArea(new ScrollArea(this, mBrowserBox, @@ -80,7 +83,7 @@ DidYouKnowWindow::DidYouKnowWindow() : // TRANSLATORS: did you know window button Button *const okButton = new Button(this, _("Close"), "close", this); - mBrowserBox->setLinkHandler(this); + mBrowserBox->setLinkHandler(mItemLinkHandler); if (gui) mBrowserBox->setFont(gui->getHelpFont()); mBrowserBox->setProcessVars(true); @@ -107,6 +110,11 @@ void DidYouKnowWindow::postInit() widgetResized(Event(nullptr)); } +DidYouKnowWindow::~DidYouKnowWindow() +{ + delete2(mItemLinkHandler); +} + void DidYouKnowWindow::action(const ActionEvent &event) { const std::string &eventId = event.getId(); @@ -133,13 +141,6 @@ void DidYouKnowWindow::action(const ActionEvent &event) } } -void DidYouKnowWindow::handleLink(const std::string &link, - MouseEvent *const event A_UNUSED) -{ - if (strStartWith(link, "http://") || strStartWith(link, "https://")) - openBrowser(link); -} - void DidYouKnowWindow::loadData(int num) { mBrowserBox->clearRows(); diff --git a/src/gui/windows/didyouknowwindow.h b/src/gui/windows/didyouknowwindow.h index c63b2d421..8a9ee9c1f 100644 --- a/src/gui/windows/didyouknowwindow.h +++ b/src/gui/windows/didyouknowwindow.h @@ -23,7 +23,6 @@ #ifndef GUI_WINDOWS_DIDYOUKNOWWINDOW_H #define GUI_WINDOWS_DIDYOUKNOWWINDOW_H -#include "gui/widgets/linkhandler.h" #include "gui/widgets/window.h" #include "listeners/actionlistener.h" @@ -31,13 +30,13 @@ class Button; class BrowserBox; class CheckBox; +class ItemLinkHandler; class ScrollArea; /** * The help dialog. */ class DidYouKnowWindow final : public Window, - public LinkHandler, public ActionListener { public: @@ -46,6 +45,8 @@ class DidYouKnowWindow final : public Window, */ DidYouKnowWindow(); + ~DidYouKnowWindow(); + A_DELETE_COPY(DidYouKnowWindow) void postInit() override final; @@ -55,12 +56,6 @@ class DidYouKnowWindow final : public Window, */ void action(const ActionEvent &event) override final; - /** - * Handles link action. - */ - void handleLink(const std::string &link, - MouseEvent *const event) override final; - void loadData(int num = 0); void setVisible(Visible visible) override final; @@ -68,6 +63,7 @@ class DidYouKnowWindow final : public Window, private: void loadFile(const int num); + ItemLinkHandler *mItemLinkHandler A_NONNULLPOINTER; BrowserBox *mBrowserBox A_NONNULLPOINTER; ScrollArea *mScrollArea A_NONNULLPOINTER; Button *mButtonPrev A_NONNULLPOINTER; diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 54172e1ed..8629c878e 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -127,6 +127,16 @@ void HelpWindow::loadHelp(const std::string &helpFile) setVisible(Visible_true); } +void HelpWindow::loadHelpSimple(const std::string &helpFile) +{ + if (!checkPath(helpFile)) + return; + mBrowserBox->clearRows(); + loadFile(helpFile); + mScrollArea->setVerticalScrollAmount(0); + setVisible(Visible_true); +} + void HelpWindow::loadFile(std::string file) { trim(file); diff --git a/src/gui/windows/helpwindow.h b/src/gui/windows/helpwindow.h index ec0b88d93..5e27eb0af 100644 --- a/src/gui/windows/helpwindow.h +++ b/src/gui/windows/helpwindow.h @@ -69,6 +69,8 @@ class HelpWindow final : public Window, */ void loadHelp(const std::string &helpFile); + void loadHelpSimple(const std::string &helpFile); + /** * Seach for given text in tags. */ |