diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake index 8e07308e30..805d9b500e 100644 --- a/Plugins/PluginList.cmake +++ b/Plugins/PluginList.cmake @@ -1,83 +1,84 @@ # Plug-ins must be ordered according to their dependencies set(MITK_PLUGINS org.blueberry.core.runtime:ON org.blueberry.core.expressions:OFF org.blueberry.core.commands:OFF org.blueberry.core.jobs:OFF org.blueberry.ui.qt:OFF org.blueberry.ui.qt.help:OFF org.blueberry.ui.qt.log:ON org.blueberry.ui.qt.objectinspector:OFF #org.blueberry.test:ON #org.blueberry.uitest:ON #Testing/org.blueberry.core.runtime.tests:ON #Testing/org.blueberry.osgi.tests:ON org.mitk.core.services:ON org.mitk.gui.common:ON org.mitk.planarfigure:ON org.mitk.core.ext:OFF org.mitk.core.jobs:OFF org.mitk.diffusionimaging:OFF org.mitk.simulation:OFF org.mitk.gui.qt.application:ON org.mitk.gui.qt.coreapplication:OFF org.mitk.gui.qt.ext:OFF org.mitk.gui.qt.extapplication:OFF org.mitk.gui.qt.common:ON org.mitk.gui.qt.stdmultiwidgeteditor:ON org.mitk.gui.qt.common.legacy:OFF org.mitk.gui.qt.cmdlinemodules:OFF org.mitk.gui.qt.diffusionimagingapp:OFF org.mitk.gui.qt.datamanager:ON org.mitk.gui.qt.datamanagerlight:OFF org.mitk.gui.qt.properties:ON org.mitk.gui.qt.basicimageprocessing:OFF org.mitk.gui.qt.dicom:OFF org.mitk.gui.qt.dicominspector:OFF org.mitk.gui.qt.diffusionimaging:OFF org.mitk.gui.qt.dosevisualization:OFF org.mitk.gui.qt.geometrytools:OFF org.mitk.gui.qt.igtexamples:OFF org.mitk.gui.qt.igttracking:OFF org.mitk.gui.qt.openigtlink:OFF org.mitk.gui.qt.imagecropper:OFF org.mitk.gui.qt.imagenavigator:ON org.mitk.gui.qt.viewnavigator:OFF org.mitk.gui.qt.materialeditor:OFF org.mitk.gui.qt.measurementtoolbox:OFF org.mitk.gui.qt.moviemaker:OFF org.mitk.gui.qt.pointsetinteraction:OFF org.mitk.gui.qt.pointsetinteractionmultispectrum:OFF org.mitk.gui.qt.python:OFF org.mitk.gui.qt.registration:OFF org.mitk.gui.qt.remeshing:OFF org.mitk.gui.qt.segmentation:OFF org.mitk.gui.qt.simulation:OFF org.mitk.gui.qt.aicpregistration:OFF org.mitk.gui.qt.toftutorial:OFF org.mitk.gui.qt.tofutil:OFF org.mitk.gui.qt.tubegraph:OFF org.mitk.gui.qt.ugvisualization:OFF org.mitk.gui.qt.ultrasound:OFF org.mitk.gui.qt.volumevisualization:OFF org.mitk.gui.qt.eventrecorder:OFF org.mitk.gui.qt.xnat:OFF org.mitk.gui.qt.igt.app.echotrack:OFF org.mitk.gui.qt.spectrocamrecorder:OFF org.mitk.gui.qt.classificationsegmentation:OFF org.mitk.gui.qt.overlaymanager:OFF org.mitk.gui.qt.multilabelsegmentation:ON org.mitk.matchpoint.core.helper:OFF org.mitk.gui.qt.matchpoint.algorithm.browser:OFF org.mitk.gui.qt.matchpoint.algorithm.control:OFF org.mitk.gui.qt.matchpoint.algorithm.batch:OFF org.mitk.gui.qt.matchpoint.mapper:OFF org.mitk.gui.qt.matchpoint.framereg:OFF org.mitk.gui.qt.matchpoint.visualizer:OFF + org.mitk.gui.qt.webview:OFF ) diff --git a/Plugins/org.mitk.gui.qt.webview/CMakeLists.txt b/Plugins/org.mitk.gui.qt.webview/CMakeLists.txt new file mode 100644 index 0000000000..7f21099107 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/CMakeLists.txt @@ -0,0 +1,8 @@ +project(org_mitk_gui_qt_webview) + +mitk_create_plugin( + EXPORT_DIRECTIVE WEBVIEW_EXPORT + EXPORTED_INCLUDE_SUFFIXES src + MODULE_DEPENDS MitkQtWidgetsExt + PACKAGE_DEPENDS Qt5|WebEngineWidgets +) diff --git a/Plugins/org.mitk.gui.qt.webview/documentation/UserManual/Manual.dox b/Plugins/org.mitk.gui.qt.webview/documentation/UserManual/Manual.dox new file mode 100644 index 0000000000..ec3be64248 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/documentation/UserManual/Manual.dox @@ -0,0 +1,17 @@ +/** +\page org_mitk_gui_qt_webview The Webview + +\imageMacro{icon.png,"Icon of Webview",2.00} + +\tableofcontents + +\section org_mitk_gui_qt_webviewOverview Overview +Describe the features of your awesome plugin here + + +*/ diff --git a/Plugins/org.mitk.gui.qt.webview/documentation/UserManual/icon.xpm b/Plugins/org.mitk.gui.qt.webview/documentation/UserManual/icon.xpm new file mode 100644 index 0000000000..9057c20bc6 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/documentation/UserManual/icon.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * icon_xpm[] = { +"16 16 2 1", +" c #FF0000", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/Plugins/org.mitk.gui.qt.webview/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.webview/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..541ddf30a1 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_webview org.mitk.gui.qt.webview + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_webview_internal Internal + \ingroup org_mitk_gui_qt_webview + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.webview plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.webview/files.cmake b/Plugins/org.mitk.gui.qt.webview/files.cmake new file mode 100644 index 0000000000..973cc1e9b9 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/files.cmake @@ -0,0 +1,44 @@ +set(SRC_CPP_FILES + +) + +set(INTERNAL_CPP_FILES + org_mitk_gui_qt_webview_Activator.cpp + MitkWebView.cpp + QmitkHTMLWidget.cpp +) + +set(UI_FILES + src/internal/MitkWebViewControls.ui +) + +set(MOC_H_FILES + src/internal/org_mitk_gui_qt_webview_Activator.h + src/internal/MitkWebView.h + src/internal/QmitkHTMLWidget.h +) + +# list of resource files which can be used by the plug-in +# system without loading the plug-ins shared library, +# for example the icon used in the menu and tabs for the +# plug-in views in the workbench +set(CACHED_RESOURCE_FILES + resources/world.svg + plugin.xml +) + +# list of Qt .qrc files which contain additional resources +# specific to this plugin +set(QRC_FILES + +) + +set(CPP_FILES ) + +foreach(file ${SRC_CPP_FILES}) + set(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + set(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.webview/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.webview/manifest_headers.cmake new file mode 100644 index 0000000000..f2d61be98b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "Webview") +set(Plugin-Version "0.1") +set(Plugin-Vendor "DKFZ") +set(Plugin-ContactAddress "") +set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Plugins/org.mitk.gui.qt.webview/plugin.xml b/Plugins/org.mitk.gui.qt.webview/plugin.xml new file mode 100644 index 0000000000..264443bb8c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/plugin.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.webview/resources/world.svg b/Plugins/org.mitk.gui.qt.webview/resources/world.svg new file mode 100644 index 0000000000..393ee89b1d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/resources/world.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.cpp b/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.cpp new file mode 100644 index 0000000000..36cad5fbaf --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.cpp @@ -0,0 +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. + +===================================================================*/ + + +// Qmitk +#include "MitkWebView.h" + +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())); +} + +void MitkWebView::OnLoadURLPushButtonClicked() +{ + QString url = m_Controls.URLLineEdit->text(); + m_Controls.contentHTMLWidget->loadUrl(url); + m_Controls.groupBox->setTitle(m_Controls.contentHTMLWidget->getTitle()); +} diff --git a/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.h b/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.h new file mode 100644 index 0000000000..30b44aecce --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebView.h @@ -0,0 +1,51 @@ +/*=================================================================== + +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(); + + protected: + + virtual void CreateQtPartControl(QWidget *parent) override; + virtual void SetFocus() override; + + Ui::MitkWebViewControls m_Controls; + +}; + +#endif // MitkWebView_h diff --git a/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebViewControls.ui b/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebViewControls.ui new file mode 100644 index 0000000000..f4e84d730c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/src/internal/MitkWebViewControls.ui @@ -0,0 +1,89 @@ + + + MitkWebViewControls + + + + 0 + 0 + 279 + 395 + + + + + 0 + 0 + + + + QmitkTemplate + + + + + + URL + + + + + + + + + + load + + + + + + + Web content + + + + + -20 + -20 + 261 + 154 + + + + + 0 + 0 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + QmitkHTMLWidget + QWidget +
QmitkHTMLWidget.h
+ 1 +
+
+ + +
diff --git a/Plugins/org.mitk.gui.qt.webview/src/internal/QmitkHTMLWidget.cpp b/Plugins/org.mitk.gui.qt.webview/src/internal/QmitkHTMLWidget.cpp new file mode 100644 index 0000000000..f28f22c5ca --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/src/internal/QmitkHTMLWidget.cpp @@ -0,0 +1,65 @@ +/*=================================================================== + +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 "QmitkHTMLWidget.h" + +#include + +QmitkHTMLWidget::QmitkHTMLWidget(QWidget* parent) + : m_WebEngineView(new QWebEngineView(parent)) +{ + //Set the webengineview to an initial page. + m_WebEngineView->setUrl(QUrl(QStringLiteral("http://www.mitk.org"))); + + m_htmlContent = new QPlainTextEdit(); + + auto layout = new QGridLayout(parent); + layout->setMargin(0); + layout->addWidget(m_WebEngineView); + + parent->setLayout(layout); +} + +QmitkHTMLWidget::~QmitkHTMLWidget() +{ + delete m_WebEngineView; + delete m_htmlContent; +} + +void QmitkHTMLWidget::loadUrl(const QString& url) +{ + //QUrl::fromUserInput returns a valid URL. If the user provides a non existing URL, an error page is loaded + QUrl urlToLoad = QUrl::fromUserInput(url); + m_WebEngineView->load(urlToLoad); +} + +QString QmitkHTMLWidget::getHTMLContent() const +{ + auto webPage = m_WebEngineView->page(); + //workaround from the Qt Examples (Qt Demo browser). It was not successful with setting QString + webPage->toHtml(invoke(m_htmlContent, &QPlainTextEdit::setPlainText)); + return m_htmlContent->toPlainText(); +} + +void QmitkHTMLWidget::setHTMLContent(const QString& content) +{ + m_WebEngineView->setHtml(content); +} + +QString QmitkHTMLWidget::getTitle() const +{ + return m_WebEngineView->page()->title(); +} diff --git a/Plugins/org.mitk.gui.qt.webview/src/internal/QmitkHTMLWidget.h b/Plugins/org.mitk.gui.qt.webview/src/internal/QmitkHTMLWidget.h new file mode 100644 index 0000000000..1a79d465ca --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/src/internal/QmitkHTMLWidget.h @@ -0,0 +1,66 @@ +/*=================================================================== + +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 +#include +#include "org_mitk_gui_qt_webview_Export.h" + + +//originating from the Qt demo browser as a workaround to get the HTML content of a WebEngineView +template +struct InvokeWrapper { + R *receiver; + void (C::*memberFun)(Arg); + void operator()(Arg result) { + (receiver->*memberFun)(result); + } +}; + +template +InvokeWrapper invoke(R *receiver, void (C::*memberFun)(Arg)) +{ + InvokeWrapper wrapper = { receiver, memberFun }; + return wrapper; +} + +/** +\brief QmitkHTMLWidget Widget for showing HTML content +\ingroup ${plugin_target}_internal +*/ +class WEBVIEW_EXPORT QmitkHTMLWidget : public QWidget +{ + Q_OBJECT +public: + explicit QmitkHTMLWidget(QWidget* parent); + ~QmitkHTMLWidget(); + + QmitkHTMLWidget(const QmitkHTMLWidget&) = delete; + QmitkHTMLWidget& operator=(const QmitkHTMLWidget&) = delete; + + /** + * @brief Loads the string url + * url is passed to a special function to convert the string to a valid URL + **/ + void loadUrl(const QString& url); + QString getHTMLContent() const; + QString getTitle() const; + void setHTMLContent(const QString& content); + +private: + QWebEngineView* m_WebEngineView; + QPlainTextEdit* m_htmlContent; +}; \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.webview/src/internal/org_mitk_gui_qt_webview_Activator.cpp b/Plugins/org.mitk.gui.qt.webview/src/internal/org_mitk_gui_qt_webview_Activator.cpp new file mode 100644 index 0000000000..cc19694566 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/src/internal/org_mitk_gui_qt_webview_Activator.cpp @@ -0,0 +1,33 @@ +/*=================================================================== + +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 "org_mitk_gui_qt_webview_Activator.h" +#include "MitkWebView.h" + +namespace mitk { + +void org_mitk_gui_qt_webview_Activator::start(ctkPluginContext* context) +{ + BERRY_REGISTER_EXTENSION_CLASS(MitkWebView, context) +} + +void org_mitk_gui_qt_webview_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} + +} diff --git a/Plugins/org.mitk.gui.qt.webview/src/internal/org_mitk_gui_qt_webview_Activator.h b/Plugins/org.mitk.gui.qt.webview/src/internal/org_mitk_gui_qt_webview_Activator.h new file mode 100644 index 0000000000..c7494948cf --- /dev/null +++ b/Plugins/org.mitk.gui.qt.webview/src/internal/org_mitk_gui_qt_webview_Activator.h @@ -0,0 +1,41 @@ +/*=================================================================== + +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 org_mitk_gui_qt_webview_Activator_h +#define org_mitk_gui_qt_webview_Activator_h + +#include + +namespace mitk { + +class org_mitk_gui_qt_webview_Activator : + public QObject, public ctkPluginActivator +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_webview") + Q_INTERFACES(ctkPluginActivator) + +public: + + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + +}; // org_mitk_gui_qt_webview_Activator + +} + +#endif // org_mitk_gui_qt_webview_Activator_h