Quellcode durchsuchen

Change frontend tab when clicking on a progress widget.

Sascha Zelzer vor 12 Jahren
Ursprung
Commit
c10e011688

+ 4 - 0
Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerMainWindow.cpp

@@ -93,6 +93,8 @@ ctkCLModuleExplorerMainWindow::ctkCLModuleExplorerMainWindow(QWidget *parent) :
   connect(tabList.data(), SIGNAL(tabClosed(ctkCmdLineModuleFrontend*)), ui->outputText, SLOT(frontendRemoved(ctkCmdLineModuleFrontend*)));
   connect(tabList.data(), SIGNAL(tabClosed(ctkCmdLineModuleFrontend*)), ui->progressListWidget, SLOT(removeProgressWidget(ctkCmdLineModuleFrontend*)));
 
+  connect(ui->progressListWidget, SIGNAL(progressWidgetClicked(ctkCmdLineModuleFrontend*)), tabList.data(), SLOT(setActiveTab(ctkCmdLineModuleFrontend*)));
+
   connect(ui->ClearButton, SIGNAL(clicked()), ui->progressListWidget, SLOT(clearList()));
 
   // Listen to future events for the currently active tab
@@ -325,7 +327,9 @@ void ctkCLModuleExplorerMainWindow::moduleTabActivated(ctkCmdLineModuleFrontend
   {
     ui->actionRun->setEnabled(!module->isRunning());
     ui->actionPause->setEnabled(module->future().canPause() && module->isRunning());
+    ui->actionPause->blockSignals(true);
     ui->actionPause->setChecked(module->isPaused());
+    ui->actionPause->blockSignals(false);
     ui->actionCancel->setEnabled(module->future().canCancel() && module->isRunning());
     ui->actionReset->setEnabled(true);
     ui->outputText->setActiveFrontend(module);

+ 13 - 0
Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerProgressListWidget.cpp

@@ -47,6 +47,7 @@ void ctkCmdLineModuleExplorerProgressListWidget::addProgressWidget(ctkCmdLineMod
     FrontendToProgressWidgetMap[frontend] = progressWidget;
     ProgressWidgetToFrontendMap[progressWidget] = frontend;
 
+    connect(progressWidget, SIGNAL(clicked()), SLOT(progressWidgetClicked()));
     connect(progressWidget, SIGNAL(destroyed(QObject*)), SLOT(progressWidgetDestroyed(QObject*)));
 
     this->layout()->addWidget(progressWidget);
@@ -99,6 +100,18 @@ void ctkCmdLineModuleExplorerProgressListWidget::setCurrentProgressWidget(ctkCmd
   CurrentWidget = progressWidget;
 }
 
+void ctkCmdLineModuleExplorerProgressListWidget::progressWidgetClicked()
+{
+  ctkCmdLineModuleExplorerProgressWidget* progressWidget =
+      static_cast<ctkCmdLineModuleExplorerProgressWidget*>(this->sender());
+
+  ctkCmdLineModuleFrontend* frontend = ProgressWidgetToFrontendMap[progressWidget];
+  Q_ASSERT(frontend);
+
+  this->setCurrentProgressWidget(frontend);
+  emit progressWidgetClicked(frontend);
+}
+
 void ctkCmdLineModuleExplorerProgressListWidget::clearList()
 {
   QList<ctkCmdLineModuleExplorerProgressWidget*> widgetsToRemove;

+ 3 - 1
Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerProgressListWidget.h

@@ -40,7 +40,7 @@ public:
 
 signals:
 
-  void progressWidgetDoubleClicked(ctkCmdLineModuleFrontend* frontend);
+  void progressWidgetClicked(ctkCmdLineModuleFrontend* frontend);
 
 public slots:
 
@@ -48,6 +48,8 @@ public slots:
 
   void setCurrentProgressWidget(ctkCmdLineModuleFrontend* frontend);
 
+  void progressWidgetClicked();
+
   void clearList();
   
 private slots:

+ 5 - 0
Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerProgressWidget.cpp

@@ -81,6 +81,11 @@ void ctkCmdLineModuleExplorerProgressWidget::setHighlightStyle(bool highlight)
   ui->ProgressBar->setEnabled(highlight);
 }
 
+void ctkCmdLineModuleExplorerProgressWidget::mouseReleaseEvent(QMouseEvent*)
+{
+  emit clicked();
+}
+
 void ctkCmdLineModuleExplorerProgressWidget::on_PauseButton_toggled(bool toggled)
 {
   this->FutureWatcher.setPaused(toggled);

+ 8 - 0
Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerProgressWidget.h

@@ -54,6 +54,14 @@ public:
 
   void setHighlightStyle(bool highlight);
 
+Q_SIGNALS:
+
+  void clicked();
+
+protected:
+
+  void mouseReleaseEvent(QMouseEvent*);
+
 private Q_SLOTS:
 
   void on_PauseButton_toggled(bool toggled);

+ 5 - 0
Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerTabList.cpp

@@ -60,6 +60,11 @@ QList<ctkCmdLineModuleFrontend *> ctkCmdLineModuleExplorerTabList::tabs() const
   return this->TabIndexToFrontend;
 }
 
+void ctkCmdLineModuleExplorerTabList::setActiveTab(ctkCmdLineModuleFrontend *frontend)
+{
+  this->TabWidget->setCurrentIndex(this->TabIndexToFrontend.indexOf(frontend));
+}
+
 void ctkCmdLineModuleExplorerTabList::addTab(ctkCmdLineModuleFrontend* moduleFrontend)
 {
   QWidget* widget = qobject_cast<QWidget*>(moduleFrontend->guiHandle());

+ 2 - 0
Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerTabList.h

@@ -48,6 +48,8 @@ public:
 
   QList<ctkCmdLineModuleFrontend*> tabs() const;
 
+  Q_SLOT void setActiveTab(ctkCmdLineModuleFrontend* frontend);
+
   Q_SLOT void addTab(ctkCmdLineModuleFrontend* frontend);
 
   Q_SIGNAL void tabActivated(ctkCmdLineModuleFrontend* module);