Browse Source

ENH: use a resizing-aware placeholder widget in the hosting application

Marco Nolden 15 years ago
parent
commit
776f8c180b

+ 6 - 1
Applications/ctkExampleHost/ctkHostAppExampleWidget.cpp

@@ -14,10 +14,11 @@ ctkHostAppExampleWidget::ctkHostAppExampleWidget(QWidget *parent) :
     ui->setupUi(this);
     ui->crashLabel->setVisible(false);
     ui->messageOutput->setVisible(false);
-    this->host = new ctkDicomExampleHost();
+    this->host = new ctkDicomExampleHost(ui->placeholderFrame);
 
     connect(&this->host->getAppProcess(),SIGNAL(error(QProcess::ProcessError)),SLOT(appProcessError(QProcess::ProcessError)));
     connect(&this->host->getAppProcess(),SIGNAL(stateChanged(QProcess::ProcessState)),SLOT(appProcessStateChanged(QProcess::ProcessState)));
+    connect(ui->placeholderFrame,SIGNAL(resized()),SLOT(placeholderResized()));
   }
 
 
@@ -99,3 +100,7 @@ void ctkHostAppExampleWidget::appProcessStateChanged(QProcess::ProcessState stat
     ;
   }
   }
+void ctkHostAppExampleWidget::placeholderResized()
+{
+  qDebug() << "resized";
+}

+ 2 - 0
Applications/ctkExampleHost/ctkHostAppExampleWidget.h

@@ -25,6 +25,8 @@ public slots:
     void appProcessError(QProcess::ProcessError error);
     void appProcessStateChanged(QProcess::ProcessState state);
 
+    void placeholderResized();
+
 protected:
     ctkDicomExampleHost* host;
     QString appFileName;

+ 10 - 2
Applications/ctkExampleHost/ctkHostAppExampleWidget.ui

@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>583</width>
-    <height>572</height>
+    <height>593</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -177,7 +177,7 @@
     </widget>
    </item>
    <item>
-    <widget class="QFrame" name="placeholderFrame">
+    <widget class="ctkHostedAppPlaceholderWidget" name="placeholderFrame">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
        <horstretch>0</horstretch>
@@ -241,6 +241,14 @@
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>ctkHostedAppPlaceholderWidget</class>
+   <extends>QFrame</extends>
+   <header>ctkHostedAppPlaceholderWidget.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
  <resources/>
  <connections>
   <connection>

+ 2 - 0
Plugins/org.commontk.dicom.examplehost/CMakeLists.txt

@@ -5,12 +5,14 @@ SET(PLUGIN_export_directive "org_commontk_dicom_examplehost_EXPORT")
 SET(PLUGIN_SRCS
   ctkDicomExampleHostPlugin.cpp
   ctkDicomExampleHost.cpp
+  ctkHostedAppPlaceholderWidget.cpp
 )
 
 # Files which should be processed by Qts moc
 SET(PLUGIN_MOC_SRCS
   ctkDicomExampleHostPlugin_p.h
   ctkDicomExampleHost.h
+  ctkHostedAppPlaceholderWidget.h
 )
 
 # Qt Designer files which should be processed by Qts uic

+ 1 - 1
Plugins/org.commontk.dicom.examplehost/ctkDicomExampleHost.cpp

@@ -2,7 +2,7 @@
 #include <QProcess>
 #include <QtDebug>
 
-ctkDicomExampleHost::ctkDicomExampleHost() : ctkDicomAbstractHost(8080)
+ctkDicomExampleHost::ctkDicomExampleHost(QWidget* placeholderWidget) : placeholderWidget(placeholderWidget),ctkDicomAbstractHost(8080)
 {
 }
 

+ 4 - 2
Plugins/org.commontk.dicom.examplehost/ctkDicomExampleHost.h

@@ -10,7 +10,7 @@
 class org_commontk_dicom_examplehost_EXPORT ctkDicomExampleHost : public ctkDicomAbstractHost{
     Q_OBJECT
 public:
-    ctkDicomExampleHost();
+    ctkDicomExampleHost(QWidget* placeholderWidget);
 
     virtual void StartApplication(QString AppPath, const QUrl& App_URL = QUrl("http://localhost:8081/"));
     virtual QString generateUID() { return ""; }
@@ -25,8 +25,10 @@ signals:
     void statusReceived(const ctkDicomWG23::Status& status);
     void giveAvailableScreen(QRect rect);
 
-  protected:
+protected:
     QProcess appProcess;
+    QWidget* placeholderWidget;
+
 };
 
 #endif // CTKDICOMEXAMPLEHOST_H

+ 6 - 0
Plugins/org.commontk.dicom.examplehost/ctkHostedAppPlaceholderWidget.cpp

@@ -0,0 +1,6 @@
+#include "ctkHostedAppPlaceholderWidget.h"
+
+ctkHostedAppPlaceholderWidget::ctkHostedAppPlaceholderWidget(QWidget *parent) :
+    QFrame(parent)
+{
+}

+ 18 - 0
Plugins/org.commontk.dicom.examplehost/ctkHostedAppPlaceholderWidget.h

@@ -0,0 +1,18 @@
+#ifndef CTKHOSTEDAPPPLACEHOLDERWIDGET_H
+#define CTKHOSTEDAPPPLACEHOLDERWIDGET_H
+
+#include <QFrame>
+#include <org_commontk_dicom_examplehost_Export.h>
+
+class org_commontk_dicom_examplehost_EXPORT ctkHostedAppPlaceholderWidget : public QFrame
+{
+  Q_OBJECT
+public:
+    explicit ctkHostedAppPlaceholderWidget(QWidget *parent = 0);
+signals:
+  void resized();
+protected:
+  void resizeEvent(QResizeEvent* event) { emit resized(); }
+};
+
+#endif // CTKHOSTEDAPPPLACEHOLDERWIDGET_H