TransfersView::TransfersView(QWidget *parent) : QWidget(parent), m_model(new TransferModel(this)), m_transferMenu(new QMenu(tr("&Transfer"), this)), m_categoryMenu(new QMenu(tr("&Category"), this)), m_priorityMenu(new QMenu(tr("&Priority"), this)), m_propertiesMenu(new QMenu(tr("&Properties"), this)), m_concurrentMenu(new QMenu(tr("Maximum &concurrent transfers"), this)), m_categoryGroup(new QActionGroup(this)), m_priorityGroup(new QActionGroup(this)), m_concurrentGroup(new QActionGroup(this)), m_startAction(new QAction(QIcon::fromTheme("media-playback-start"), tr("&Start all downloads"), this)), m_pauseAction(new QAction(QIcon::fromTheme("media-playback-pause"), tr("&Pause all downloads"), this)), m_propertiesAction(new QAction(QIcon::fromTheme("document-properties"), tr("&Properties"), this)), m_transferCommandAction(new QAction(QIcon::fromTheme("system-run"), tr("Set &custom command"), this)), m_transferStartAction(new QAction(QIcon::fromTheme("media-playback-start"), tr("&Start"), this)), m_transferPauseAction(new QAction(QIcon::fromTheme("media-playback-pause"), tr("&Pause"), this)), m_transferRemoveAction(new QAction(QIcon::fromTheme("edit-delete"), tr("&Remove"), this)), m_toolBar(new QToolBar(this)), m_view(new QTreeView(this)), m_layout(new QVBoxLayout(this)) { m_transferMenu->addAction(m_transferCommandAction); m_transferMenu->addAction(m_transferStartAction); m_transferMenu->addAction(m_transferPauseAction); m_transferMenu->addMenu(m_categoryMenu); m_transferMenu->addMenu(m_priorityMenu); m_transferMenu->addAction(m_transferRemoveAction); m_transferMenu->setEnabled(false); setCategoryMenuActions(); const QStringList priorities = QStringList() << tr("High") << tr("Normal") << tr("Low"); for (int i = 0; i < priorities.size(); i++) { QAction *action = m_priorityMenu->addAction(priorities.at(i), this, SLOT(setTransferPriority())); action->setCheckable(true); action->setData(i); m_priorityGroup->addAction(action); } const int max = Settings::maximumConcurrentTransfers(); for (int i = 1; i <= MAX_CONCURRENT_TRANSFERS; i++) { QAction *action = m_concurrentMenu->addAction(QString::number(i), this, SLOT(setMaximumConcurrentTransfers())); action->setCheckable(true); action->setChecked(i == max); action->setData(i); m_concurrentGroup->addAction(action); } m_propertiesMenu->addMenu(m_concurrentMenu); m_toolBar->setMovable(false); m_toolBar->addAction(m_startAction); m_toolBar->addAction(m_pauseAction); m_toolBar->addAction(m_propertiesAction); m_view->setModel(m_model); m_view->setItemDelegate(new TransferDelegate(m_view)); m_view->setAlternatingRowColors(true); m_view->setSelectionBehavior(QTreeView::SelectRows); m_view->setContextMenuPolicy(Qt::CustomContextMenu); m_view->setEditTriggers(QTreeView::NoEditTriggers); m_view->setItemsExpandable(false); m_view->setUniformRowHeights(true); m_view->setAllColumnsShowFocus(true); m_view->setRootIsDecorated(false); m_view->header()->restoreState(Settings::transfersHeaderViewState()); m_layout->addWidget(m_toolBar); m_layout->addWidget(m_view); m_layout->setContentsMargins(0, 0, 0, 0); connect(m_categoryMenu, SIGNAL(aboutToShow()), this, SLOT(setActiveCategoryMenuAction())); connect(m_priorityMenu, SIGNAL(aboutToShow()), this, SLOT(setActivePriorityMenuAction())); connect(m_startAction, SIGNAL(triggered()), Transfers::instance(), SLOT(start())); connect(m_pauseAction, SIGNAL(triggered()), Transfers::instance(), SLOT(pause())); connect(m_propertiesAction, SIGNAL(triggered()), this, SLOT(showPropertiesMenu())); connect(m_transferCommandAction, SIGNAL(triggered()), this, SLOT(setTransferCustomCommand())); connect(m_transferStartAction, SIGNAL(triggered()), this, SLOT(queueTransfer())); connect(m_transferPauseAction, SIGNAL(triggered()), this, SLOT(pauseTransfer())); connect(m_transferRemoveAction, SIGNAL(triggered()), this, SLOT(removeTransfer())); connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(m_view->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(onCurrentTransferChanged(QModelIndex))); connect(Settings::instance(), SIGNAL(categoriesChanged()), this, SLOT(setCategoryMenuActions())); connect(Settings::instance(), SIGNAL(maximumConcurrentTransfersChanged(int)), this, SLOT(onMaximumConcurrentTransfersChanged(int))); }
ExpTranWindow::ExpTranWindow(QMainWindow *window) { ui.setupUi(this); settings = new QDialog(); sUi.setupUi(settings); connect(sUi.buttonBox,SIGNAL(accepted()),this,SLOT(changeSettings())); face_widget1 = new FaceWidget(); face_widget2 = new FaceWidget(); face_widget3 = new CustomizableFaceWidget(); ui.verticalLayout->addWidget(face_widget1); f_dialog = new QFileDialog(); v_dialog = new QFileDialog(); picLabelV = new FeaturePointQLabel(); flowLabelV = new VectorFieldQLabel(); ui.verticalLayout_3->addWidget(picLabelV); ui.verticalLayout_4->addWidget(flowLabelV); face_widget2->setVisible(false); ui.verticalLayout_4->addWidget(face_widget2); ui.videoTabProgressBar->setVisible(false); //intialize transfer widget v_controller = new VideoTabController("obama.avi", picLabelV, flowLabelV, this, face_widget2); //ui.verticalLayoutWidget->setGeometry(10,10,650,650); sourceLabel = new FeaturePointQLabel(); targetLabel = new FeaturePointQLabel(); ui.srcLayout->addWidget(sourceLabel); ui.targetLayout->addWidget(targetLabel); face_widget3->setVisible(false); ui.targetLayout->addWidget(face_widget3); ui.transferTabProgressBar->setVisible(false); t_controller = new TransferTabController(sourceLabel,targetLabel,this, ui.srcText,ui.targetTxt, face_widget3); //tracking determines when value change signal is emitted //either after the user lets go (false) or as its being dragged (true) ui.expSlider->setTracking(true); //setup controllers f_controller = new FaceTabController(ui.expSlider,ui.identSlider,face_widget1); /*********************/ /* connect signals and slots*/ /*******************/ //2 ways how to do this ... depending on which dialog we want //connect(ui.action_Open,SIGNAL(triggered()),my_widget,SLOT(face_file_changed())); connect(ui.action_Open,SIGNAL(triggered()),f_dialog,SLOT(show())); connect(ui.actionVideo_File,SIGNAL(triggered()),v_dialog,SLOT(show())); connect(ui.actionPreferences,SIGNAL(triggered()),settings,SLOT(show())); //face controller connects connect(ui.expComboBox,SIGNAL(activated(QString)),f_controller,SLOT(expression_activated(QString))); connect(ui.expSlider,SIGNAL(valueChanged(int)),f_controller,SLOT(exp_slider_moved(int))); connect(ui.identSlider,SIGNAL(valueChanged(int)),f_controller,SLOT(id_slider_moved(int))); connect(ui.identSpinBox,SIGNAL(valueChanged(int)),f_controller,SLOT(identity_activated(int))); connect(ui.renderButton,SIGNAL(clicked()),f_controller,SLOT(render_action())); connect(ui.interExpRadio,SIGNAL(toggled(bool)),f_controller,SLOT(exp_inter_toggled(bool))); connect(ui.interIdRadio,SIGNAL(toggled(bool)),f_controller,SLOT(id_inter_toggled(bool))); //menu connect(f_dialog,SIGNAL(fileSelected(const QString)),f_controller,SLOT(face_file_changed(const QString))); connect(v_dialog,SIGNAL(fileSelected(const QString)),v_controller,SLOT(video_file_changed(const QString))); //face widget connects connect(ui.wireRadioButton,SIGNAL(toggled(bool)),face_widget1,SLOT(wireFrameChecked(bool))); connect(ui.featureRadio,SIGNAL(toggled(bool)),face_widget1,SLOT(featureToggled(bool))); connect(ui.mouthRadio,SIGNAL(toggled(bool)),face_widget1,SLOT(mouthToggled(bool))); //video controller connects connect(ui.restartButton,SIGNAL(clicked()),v_controller,SLOT(restartCapturing())); connect(ui.playButton,SIGNAL(clicked()),v_controller,SLOT(playTransfer())); connect(ui.pauseButton,SIGNAL(clicked()),v_controller,SLOT(pauseTransfer())); connect(ui.flowButton,SIGNAL(clicked()),v_controller,SLOT(findGoodFeaturePoints())); connect(ui.drawRadio,SIGNAL(clicked(bool)),v_controller,SLOT(toggleDrawable(bool))); connect(ui.extractBtn,SIGNAL(clicked()),v_controller,SLOT(extractPose())); connect(ui.dropButton,SIGNAL(clicked()),v_controller,SLOT(dropFrame())); connect(ui.modelButton,SIGNAL(clicked()),v_controller,SLOT(playBack())); connect(ui.cameraButton,SIGNAL(clicked()),v_controller,SLOT(calibrate())); connect(ui.detect,SIGNAL(clicked()),v_controller,SLOT(detect())); //transfer controller connects connect(ui.browseS,SIGNAL(clicked()),t_controller,SLOT(srcBrowse())); connect(ui.browseD,SIGNAL(clicked()),t_controller,SLOT(targetBrowse())); connect(ui.dropS,SIGNAL(clicked()),t_controller,SLOT(dropSrc())); connect(ui.dropT,SIGNAL(clicked()),t_controller,SLOT(dropTarget())); connect(ui.startT,SIGNAL(clicked()),t_controller,SLOT(beginTransfer())); connect(ui.restartTransferButton,SIGNAL(clicked()),t_controller,SLOT(restart())); connect(ui.srcFeat,SIGNAL(clicked()),t_controller,SLOT(selectGoodFeatureSrcPoints())); connect(ui.targetFeat,SIGNAL(clicked()),t_controller,SLOT(selectGoodFeatureTargetPoints())); //settings connects connect(sUi.optBox,SIGNAL(activated(int)),t_controller,SLOT(setOptType(int))); connect(sUi.regBox,SIGNAL(valueChanged(double)),t_controller,SLOT(setOptReg(double))); connect(sUi.nelder,SIGNAL(toggled(bool)),t_controller,SLOT(setOptNelder(bool))); connect(sUi.iterBox,SIGNAL(valueChanged(int)),t_controller,SLOT(setIterNum(int))); connect(sUi.frameBox,SIGNAL(valueChanged(int)),t_controller,SLOT(setFrameNum(int))); connect(sUi.optBox,SIGNAL(activated(int)),v_controller,SLOT(setOptType(int))); connect(sUi.regBox,SIGNAL(valueChanged(double)),v_controller,SLOT(setOptReg(double))); connect(sUi.nelder,SIGNAL(toggled(bool)),v_controller,SLOT(setOptNelder(bool))); connect(sUi.iterBox,SIGNAL(valueChanged(int)),v_controller,SLOT(setIterNum(int))); connect(sUi.frameBox,SIGNAL(valueChanged(int)),v_controller,SLOT(setFrameNum(int))); connect(sUi.constantId,SIGNAL(toggled(bool)),v_controller,SLOT(setConstID(bool))); connect(sUi.project2D,SIGNAL(toggled(bool)),v_controller,SLOT(setPointGen2D(bool))); connect(sUi.project3D,SIGNAL(toggled(bool)),v_controller,SLOT(setPointGen3D(bool))); connect(sUi.hybrid,SIGNAL(toggled(bool)),v_controller,SLOT(setHybrid(bool))); connect(sUi.none,SIGNAL(toggled(bool)),v_controller,SLOT(setNone(bool))); connect(sUi.projModel,SIGNAL(toggled(bool)),v_controller,SLOT(setProjModel(bool))); connect(sUi.firstFrame,SIGNAL(toggled(bool)),v_controller,SLOT(setWithFirstFrame(bool))); connect(sUi.pointsBox,SIGNAL(valueChanged(int)),v_controller,SLOT(setGenPoints(int))); //settings t_cont connect(sUi.poisson,SIGNAL(toggled(bool)),t_controller,SLOT(setPoisson(bool))); connect(sUi.interpolate,SIGNAL(toggled(bool)),t_controller,SLOT(setTexture(bool))); connect(sUi.background,SIGNAL(toggled(bool)),t_controller,SLOT(setUsingBackground(bool))); connect(sUi.constantId,SIGNAL(toggled(bool)),t_controller,SLOT(setConstID(bool))); connect(sUi.project2D,SIGNAL(toggled(bool)),t_controller,SLOT(setPointGen2D(bool))); connect(sUi.project3D,SIGNAL(toggled(bool)),t_controller,SLOT(setPointGen3D(bool))); connect(sUi.texture3d,SIGNAL(toggled(bool)),t_controller,SLOT(setTextured3D(bool))); connect(sUi.hybrid,SIGNAL(toggled(bool)),t_controller,SLOT(setHybrid(bool))); connect(sUi.projModel,SIGNAL(toggled(bool)),t_controller,SLOT(setProjModel(bool))); connect(sUi.none,SIGNAL(toggled(bool)),t_controller,SLOT(setNone(bool))); connect(sUi.firstFrame,SIGNAL(toggled(bool)),t_controller,SLOT(setWithFirstFrame(bool))); connect(sUi.pointsBox,SIGNAL(valueChanged(int)),t_controller,SLOT(setGenPoints(int))); }
void TransfersView::pauseTransfer() { if (m_view->currentIndex().isValid()) { pauseTransfer(m_view->currentIndex()); } }