From 5fadfbab5faec52d5ba22fae5046b26740955d52 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 27 Sep 2016 01:02:06 +0300 Subject: Use for links in updater window ItemLinkHandler. --- src/gui/windows/updaterwindow.cpp | 14 ++++---------- src/gui/windows/updaterwindow.h | 7 ++----- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 9d93c7020..037a5aad6 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -30,6 +30,7 @@ #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" #include "gui/widgets/containerplacer.h" +#include "gui/widgets/itemlinkhandler.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/layouttype.h" @@ -184,6 +185,7 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost, mUpdateFiles(), mTempUpdateFiles(), mUpdateServerPath(mUpdateHost), + mItemLinkHandler(new ItemLinkHandler), // TRANSLATORS: updater window label mLabel(new Label(this, _("Connecting..."))), // TRANSLATORS: updater window button @@ -217,7 +219,7 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost, mProgressBar->setSmoothProgress(false); mBrowserBox->setOpaque(Opaque_false); - mBrowserBox->setLinkHandler(this); + mBrowserBox->setLinkHandler(mItemLinkHandler); mBrowserBox->setProcessVars(true); mBrowserBox->setEnableKeys(true); mBrowserBox->setEnableTabs(true); @@ -270,6 +272,7 @@ UpdaterWindow::~UpdaterWindow() delete2(mDownload) } free(mMemoryBuffer); + delete2(mItemLinkHandler); } void UpdaterWindow::setProgress(const float p) @@ -1069,15 +1072,6 @@ unsigned long UpdaterWindow::getFileHash(const std::string &filePath) return Net::Download::adlerBuffer(buf, size); } -void UpdaterWindow::handleLink(const std::string &link, - MouseEvent *const event A_UNUSED) -{ - if (strStartWith(link, "http://") || strStartWith(link, "https://")) - openBrowser(link); - else if (link == "news") - loadFile("news"); -} - void UpdaterWindow::loadFile(std::string file) { mBrowserBox->clearRows(); diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h index 0d322dccf..30b3ca264 100644 --- a/src/gui/windows/updaterwindow.h +++ b/src/gui/windows/updaterwindow.h @@ -30,7 +30,6 @@ #include "enums/simpletypes/append.h" -#include "gui/widgets/linkhandler.h" #include "gui/widgets/window.h" #include "resources/updatefile.h" @@ -42,6 +41,7 @@ class BrowserBox; class Button; +class ItemLinkHandler; class Label; class ProgressBar; class ScrollArea; @@ -58,7 +58,6 @@ namespace Net */ class UpdaterWindow final : public Window, public ActionListener, - public LinkHandler, public KeyListener { public: @@ -114,9 +113,6 @@ class UpdaterWindow final : public Window, void logic() override final; - void handleLink(const std::string &link, - MouseEvent *const event A_UNUSED) override final; - void loadFile(std::string file); void deleteSelf(); @@ -210,6 +206,7 @@ class UpdaterWindow final : public Window, std::string mUpdateServerPath; + ItemLinkHandler *mItemLinkHandler A_NONNULLPOINTER; Label *mLabel A_NONNULLPOINTER; Button *mCancelButton A_NONNULLPOINTER; Button *mPlayButton A_NONNULLPOINTER; -- cgit v1.2.3-60-g2f50