Просмотр исходного кода

ENH: hosted app path can be passed as a command line parameter to the host application

Marco Nolden лет назад: 15
Родитель
Сommit
ec48fd243c

+ 4 - 0
Applications/ctkExampleHost/ctkExampleHostMain.cpp

@@ -91,6 +91,10 @@ int main(int argv, char** argc)
   QMainWindow mainWindow;
   Ui::MainWindow ui;
   ui.setupUi(&mainWindow);
+  if ( QApplication::argc() > 1 )
+  {
+    ui.controlWidget->setAppFileName(QApplication::argv()[1]);
+  }
 
 //  mainWindow.addDockWidget(static_cast<Qt::DockWidgetArea>(4),new ctkHostAppExampleWidget());
 

+ 15 - 10
Applications/ctkExampleHost/ctkHostAppExampleWidget.cpp

@@ -23,6 +23,7 @@ ctkHostAppExampleWidget::ctkHostAppExampleWidget(QWidget *parent) :
   }
 
 
+
 ctkHostAppExampleWidget::~ctkHostAppExampleWidget()
 {
     delete ui;
@@ -55,18 +56,21 @@ void ctkHostAppExampleWidget::stopButtonClicked()
 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));
-    }
+    this->setAppFileName(QFileDialog::getOpenFileName(this,"Choose hosted application",QApplication::applicationDirPath()));
 }
 
-
+void ctkHostAppExampleWidget::setAppFileName(QString name)
+{
+  this->appFileName = name;
+  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));
+  }
+}
 
 
 
@@ -114,4 +118,5 @@ void ctkHostAppExampleWidget::appProcessStateChanged(QProcess::ProcessState stat
 void ctkHostAppExampleWidget::placeholderResized()
 {
   qDebug() << "resized";
+  ui->placeholderFrame->printPosition();
 }

+ 2 - 0
Applications/ctkExampleHost/ctkHostAppExampleWidget.h

@@ -17,6 +17,8 @@ class ctkHostAppExampleWidget : public QWidget
 
 public:
     explicit ctkHostAppExampleWidget(QWidget *parent = 0);
+    void setAppFileName(QString name);
+
     ~ctkHostAppExampleWidget();
 public slots:
     void loadButtonClicked();