diff --git a/Modules/WebInteraction/include/mitkWebInteractionRegistry.h b/Modules/WebInteraction/include/mitkWebInteractionRegistry.h index c7eefd2e20..8c2c89b2e8 100644 --- a/Modules/WebInteraction/include/mitkWebInteractionRegistry.h +++ b/Modules/WebInteraction/include/mitkWebInteractionRegistry.h @@ -1,44 +1,44 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKWEBINTERACTIONREGISTRY_H #define MITKWEBINTERACTIONREGISTRY_H #include "MitkWebInteractionExports.h" //QT #include "qstring.h" namespace mitk { class MITKWEBINTERACTION_EXPORT WebInteractionRegistry { public: WebInteractionRegistry(); - static void PageLoaded(QString html); + static QString PageLoaded(QString address, QString html); private: //us::ModuleContext* m_Context; }; } // end of namespace mitk #endif // MITKWEBINTERACTIONREGISTRY_H diff --git a/Modules/WebInteraction/src/mitkWebInteractionRegistry.cpp b/Modules/WebInteraction/src/mitkWebInteractionRegistry.cpp index 7bcf0af17c..b3d168bc91 100644 --- a/Modules/WebInteraction/src/mitkWebInteractionRegistry.cpp +++ b/Modules/WebInteraction/src/mitkWebInteractionRegistry.cpp @@ -1,33 +1,43 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkWebInteractionRegistry.h" #include "mitkLogMacros.h" namespace mitk { WebInteractionRegistry::WebInteractionRegistry() { } - void WebInteractionRegistry::PageLoaded(QString html) + QString WebInteractionRegistry::PageLoaded(QString address, QString html) { - std::string s = html.toStdString(); - MITK_INFO << s; + QString target = "Download Raw File"; + QString urlPattern = "https://phabricator.mitk.org/diffusion/"; + if (address.contains(urlPattern)) + { + int index = html.indexOf(target); + if (index > 0) + { + html.insert(index + 34, "
Download Raw File
"); + MITK_INFO << html.toStdString(); + } + } + return html; } } // end of namespace mitk diff --git a/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.cpp b/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.cpp index cc51a43214..9a44de6d23 100644 --- a/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.cpp +++ b/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.cpp @@ -1,50 +1,58 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Qmitk #include "MitkWebView.h" #include const std::string MitkWebView::VIEW_ID = "org.mitk.views.mitkwebview"; void MitkWebView::SetFocus() { m_Controls.loadURLPushButton->setFocus(); } void MitkWebView::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); m_Controls.URLLineEdit->setText("http://www.mitk.org"); connect(m_Controls.loadURLPushButton, SIGNAL( clicked() ), this, SLOT( OnLoadURLPushButtonClicked()) ); connect(m_Controls.URLLineEdit, SIGNAL(returnPressed()), this, SLOT(OnLoadURLPushButtonClicked())); connect(m_Controls.contentHTMLWidget, SIGNAL(OnLoadFinished(QString)), this, SLOT(OnLoadFinished(QString))); } void MitkWebView::OnLoadURLPushButtonClicked() { QString url = m_Controls.URLLineEdit->text(); m_Controls.contentHTMLWidget->loadUrl(url); m_Controls.groupBox->setTitle(m_Controls.contentHTMLWidget->getTitle()); } void MitkWebView::OnLoadFinished(QString htmlContent) { - mitk::WebInteractionRegistry::PageLoaded(htmlContent); + if (!preventReload) + { + preventReload = true; + QString result = mitk::WebInteractionRegistry::PageLoaded(m_Controls.URLLineEdit->text(), htmlContent); + this->m_Controls.contentHTMLWidget->setHTMLContent(result); + } + else { + preventReload = false; + } } diff --git a/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.h b/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.h index 796cc1d803..3ef52773a1 100644 --- a/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.h +++ b/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.h @@ -1,52 +1,53 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MitkWebView_h #define MitkWebView_h #include #include "ui_MitkWebViewControls.h" /** \brief MitkWebView Simple web view for loading HTML and setting custom HTML content. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class MitkWebView : public QmitkAbstractView { Q_OBJECT public: static const std::string VIEW_ID; protected slots: void OnLoadURLPushButtonClicked(); void OnLoadFinished(QString htmlContent); protected: virtual void CreateQtPartControl(QWidget *parent) override; virtual void SetFocus() override; Ui::MitkWebViewControls m_Controls; + bool preventReload = true; }; #endif // MitkWebView_h