Explorar o código

ENH: basic control widget for the application host

Marco Nolden %!s(int64=14) %!d(string=hai) anos
pai
achega
219002bd74

+ 25 - 2
Applications/ctkExampleHost/ctkHostAppExampleWidget.cpp

@@ -1,15 +1,20 @@
 #include "ctkHostAppExampleWidget.h"
 #include "ui_ctkHostAppExampleWidget.h"
+#include "ctkDicomExampleHost.h"
 
 #include <QDebug>
+#include <QFileDialog>
 
 ctkHostAppExampleWidget::ctkHostAppExampleWidget(QWidget *parent) :
-    QDockWidget(parent),
+    QWidget(parent),
     ui(new Ui::ctkHostAppExampleWidget)
 {
     qDebug() << "setup ui";
     ui->setupUi(this);
-}
+    this->host = new ctkDicomExampleHost();
+
+  }
+
 
 ctkHostAppExampleWidget::~ctkHostAppExampleWidget()
 {
@@ -19,9 +24,27 @@ ctkHostAppExampleWidget::~ctkHostAppExampleWidget()
 void ctkHostAppExampleWidget::startButtonClicked()
 {
     qDebug() << "start button clicked";
+    if (host)
+    {
+      // host->StartApplication(appFileName);
+    }
 }
 
 void ctkHostAppExampleWidget::stopButtonClicked()
 {
     qDebug() << "stop button clicked";
 }
+
+void ctkHostAppExampleWidget::loadButtonClicked()
+{
+    qDebug() << "load button clicked";
+    this->appFileName = QFileDialog::getOpenFileName(this,"Choose hosted application",QApplication::applicationDirPath());
+    if (QFile(this->appFileName).permissions() & QFile::ExeUser )
+    {
+     this->ui->applicationPathLabel->setText(this->appFileName);
+    }
+    else
+    {
+      this->ui->applicationPathLabel->setText(QString("<font color='red'>Not executable:</font>").append(this->appFileName));
+    }
+}

+ 9 - 2
Applications/ctkExampleHost/ctkHostAppExampleWidget.h

@@ -1,13 +1,15 @@
 #ifndef CTKHOSTAPPEXAMPLEWIDGET_H
 #define CTKHOSTAPPEXAMPLEWIDGET_H
 
-#include <QDockWidget>
+#include <QWidget>
+
+class ctkDicomExampleHost;
 
 namespace Ui {
     class ctkHostAppExampleWidget;
 }
 
-class ctkHostAppExampleWidget : public QDockWidget
+class ctkHostAppExampleWidget : public QWidget
 {
     Q_OBJECT
 
@@ -17,9 +19,14 @@ public:
 public slots:
     void startButtonClicked();
     void stopButtonClicked();
+    void loadButtonClicked();
+protected:
+    ctkDicomExampleHost* host;
+    QString appFileName;
 
 private:
     Ui::ctkHostAppExampleWidget *ui;
+
 };
 
 #endif // CTKHOSTWIDGET_H

+ 193 - 66
Applications/ctkExampleHost/ctkHostAppExampleWidget.ui

@@ -1,75 +1,169 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
  <class>ctkHostAppExampleWidget</class>
- <widget class="QDockWidget" name="ctkHostAppExampleWidget">
+ <widget class="QWidget" name="ctkHostAppExampleWidget">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>386</width>
-    <height>70</height>
+    <width>583</width>
+    <height>572</height>
    </rect>
   </property>
-  <property name="features">
-   <set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
   </property>
-  <property name="allowedAreas">
-   <set>Qt::BottomDockWidgetArea|Qt::TopDockWidgetArea</set>
-  </property>
-  <property name="windowTitle">
-   <string>Host Application Example2</string>
-  </property>
-  <widget class="QWidget" name="dockWidgetContents">
-   <layout class="QHBoxLayout" name="horizontalLayout">
-    <item>
-     <widget class="QPushButton" name="startButton">
-      <property name="text">
-       <string>Start</string>
-      </property>
-     </widget>
-    </item>
-    <item>
-     <widget class="QPushButton" name="stopButton">
-      <property name="text">
-       <string>Stop</string>
-      </property>
-     </widget>
-    </item>
-    <item>
-     <spacer name="horizontalSpacer">
-      <property name="orientation">
-       <enum>Qt::Horizontal</enum>
-      </property>
-      <property name="sizeHint" stdset="0">
-       <size>
-        <width>107</width>
-        <height>20</height>
-       </size>
-      </property>
-     </spacer>
-    </item>
-    <item>
-     <widget class="QLabel" name="label">
-      <property name="text">
-       <string>Status:</string>
-      </property>
-     </widget>
-    </item>
-    <item>
-     <widget class="QLabel" name="label_2">
-      <property name="font">
-       <font>
-        <weight>75</weight>
-        <bold>true</bold>
-       </font>
-      </property>
-      <property name="text">
-       <string>IDLE</string>
-      </property>
-     </widget>
-    </item>
-   </layout>
-  </widget>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QPushButton" name="loadButton">
+       <property name="text">
+        <string>Load</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Application Path:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="applicationPathLabel">
+       <property name="text">
+        <string>None</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_3">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QPushButton" name="startButton">
+       <property name="text">
+        <string>Start</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="stopButton">
+       <property name="text">
+        <string>Stop</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Status:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="statusLabel">
+       <property name="font">
+        <font>
+         <weight>75</weight>
+         <bold>true</bold>
+        </font>
+       </property>
+       <property name="text">
+        <string>IDLE</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>107</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="Line" name="line">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QCheckBox" name="checkBox">
+       <property name="text">
+        <string>Show Messages</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>107</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QTextEdit" name="messageOutput">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QFrame" name="placeholderFrame">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+       <horstretch>0</horstretch>
+       <verstretch>1</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="frameShape">
+      <enum>QFrame::StyledPanel</enum>
+     </property>
+     <property name="frameShadow">
+      <enum>QFrame::Raised</enum>
+     </property>
+    </widget>
+   </item>
+  </layout>
  </widget>
  <resources/>
  <connections>
@@ -80,8 +174,8 @@
    <slot>startButtonClicked()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>53</x>
-     <y>57</y>
+     <x>54</x>
+     <y>70</y>
     </hint>
     <hint type="destinationlabel">
      <x>269</x>
@@ -96,8 +190,8 @@
    <slot>stopButtonClicked()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>146</x>
-     <y>48</y>
+     <x>185</x>
+     <y>70</y>
     </hint>
     <hint type="destinationlabel">
      <x>238</x>
@@ -105,9 +199,42 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>loadButton</sender>
+   <signal>clicked()</signal>
+   <receiver>ctkHostAppExampleWidget</receiver>
+   <slot>loadButtonClicked()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>55</x>
+     <y>35</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>87</x>
+     <y>25</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkBox</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>messageOutput</receiver>
+   <slot>setVisible(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>28</x>
+     <y>123</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>151</x>
+     <y>184</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>startButtonClicked()</slot>
   <slot>stopButtonClicked()</slot>
+  <slot>loadButtonClicked()</slot>
  </slots>
 </ui>