diff --git a/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.cpp b/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.cpp index 3a5a479ec1..e538a255ed 100644 --- a/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.cpp +++ b/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.cpp @@ -1,87 +1,87 @@ $(license) // Blueberry #include #include // Qmitk #include "$(view-file-name).h" // Qt #include // mitk image #include const std::string $(view-class-name)::VIEW_ID = "$(view-id)"; void $(view-class-name)::SetFocus() { m_Controls.buttonPerformImageProcessing->setFocus(); } void $(view-class-name)::CreateQtPartControl(QWidget *parent) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi(parent); - connect(m_Controls.buttonPerformImageProcessing, SIGNAL(clicked()), this, SLOT(DoImageProcessing())); + connect(m_Controls.buttonPerformImageProcessing, &QPushButton::clicked, this, &$(view-class-name)::DoImageProcessing); } void $(view-class-name)::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*source*/, const QList &nodes) { // iterate all selected objects, adjust warning visibility foreach (mitk::DataNode::Pointer node, nodes) { if (node.IsNotNull() && dynamic_cast(node->GetData())) { m_Controls.labelWarning->setVisible(false); m_Controls.buttonPerformImageProcessing->setEnabled(true); return; } } m_Controls.labelWarning->setVisible(true); m_Controls.buttonPerformImageProcessing->setEnabled(false); } void $(view-class-name)::DoImageProcessing() { QList nodes = this->GetDataManagerSelection(); if (nodes.empty()) return; mitk::DataNode *node = nodes.front(); if (!node) { // Nothing selected. Inform the user and return QMessageBox::information(nullptr, "Template", "Please load and select an image before starting image processing."); return; } // here we have a valid mitk::DataNode // a node itself is not very useful, we need its data item (the image) mitk::BaseData *data = node->GetData(); if (data) { // test if this data item is an image or not (could also be a surface or something totally different) mitk::Image *image = dynamic_cast(data); if (image) { std::stringstream message; std::string name; message << "Performing image processing for image "; if (node->GetName(name)) { // a property called "name" was found for this DataNode message << "'" << name << "'"; } message << "."; MITK_INFO << message.str(); // actually do something here... } } } diff --git a/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.h b/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.h index 4dfc824c98..7009ec6c2e 100644 --- a/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.h +++ b/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.h @@ -1,46 +1,44 @@ $(license) #ifndef $(view-file-name)_h #define $(view-file-name)_h #include #include #include "ui_$(view-file-name)Controls.h" /** \brief $(view-class-name) \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class $(view-class-name) : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; -protected slots: - - /// \brief Called when the user clicks the GUI button - void DoImageProcessing(); - protected: virtual void CreateQtPartControl(QWidget *parent) override; virtual void SetFocus() override; /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList &nodes) override; + /// \brief Called when the user clicks the GUI button + void DoImageProcessing(); + Ui::$(view-file-name)Controls m_Controls; }; #endif // $(view-file-name)_h