void MainWindow::showSubtitle() { disconnect(m_ui->subtitleTextEdit, SIGNAL(textChanged()), this, SLOT(updateSubtitle())); disconnect(m_ui->xPositionSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateSubtitle())); disconnect(m_ui->yPositionSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateSubtitle())); disconnect(m_ui->beginTimeEdit, SIGNAL(timeChanged(QTime)), this, SLOT(updateSubtitle())); disconnect(m_ui->lengthTimeEdit, SIGNAL(timeChanged(QTime)), this, SLOT(updateSubtitle())); if (m_currentTrack < 0 || m_currentTrack > 1) { m_currentTrack = 0; } if (m_currentSubtitle < 0) { if (m_subtitles[m_currentTrack].count() > 0) { m_currentSubtitle = (m_subtitles[m_currentTrack].count() - 1); } else { m_currentSubtitle = 0; } } else if (m_currentSubtitle >= m_subtitles[m_currentTrack].count()) { m_currentSubtitle = 0; } if (m_currentSubtitle < m_subtitles[m_currentTrack].count()) { QTime nullTime(0, 0, 0, 0); m_ui->subtitleTextEdit->setPlainText(m_subtitles[m_currentTrack].at(m_currentSubtitle).text); m_ui->beginTimeEdit->setTime(nullTime.addMSecs((m_subtitles[m_currentTrack].at(m_currentSubtitle).beginTime * 1000))); m_ui->lengthTimeEdit->setTime(nullTime.addMSecs(((m_subtitles[m_currentTrack].at(m_currentSubtitle).endTime * 1000) - (m_subtitles[m_currentTrack].at(m_currentSubtitle).beginTime * 1000)))); m_ui->xPositionSpinBox->setValue(m_subtitles[m_currentTrack].at(m_currentSubtitle).positionX); m_ui->yPositionSpinBox->setValue(m_subtitles[m_currentTrack].at(m_currentSubtitle).positionY); } else { m_ui->subtitleTextEdit->clear(); m_ui->beginTimeEdit->setTime(QTime()); m_ui->lengthTimeEdit->setTime(QTime()); m_ui->xPositionSpinBox->setValue(0); m_ui->yPositionSpinBox->setValue(0); } connect(m_ui->subtitleTextEdit, SIGNAL(textChanged()), this, SLOT(updateSubtitle())); connect(m_ui->xPositionSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateSubtitle())); connect(m_ui->yPositionSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateSubtitle())); connect(m_ui->beginTimeEdit, SIGNAL(timeChanged(QTime)), this, SLOT(updateSubtitle())); connect(m_ui->lengthTimeEdit, SIGNAL(timeChanged(QTime)), this, SLOT(updateSubtitle())); }
void MainWindow::startSensorThread() { sensorThread = new SensorThread(); //QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), this, SLOT(printData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), this, SLOT(updateCursors(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), getWidget(WidgetType::settingsWidget), SLOT(displayData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), getWidget(WidgetType::homeWidget), SLOT(switchMenu(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), getWidget(WidgetType::desktopWidget), SLOT(switchMenu(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), getWidget(WidgetType::galleryWidget), SLOT(displayData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(sensorThread, SIGNAL(connectionChanged(QString)), getWidget(WidgetType::loadingWidget), SLOT(updateSubtitle(QString))); QObject::connect(sensorThread, SIGNAL(initializationChanged(WidgetType)), this, SLOT(setActiveWidget(WidgetType))); QObject::connect(getWidget(WidgetType::homeWidget), SIGNAL(menuSelected(WidgetType)), this, SLOT(setActiveWidget(WidgetType))); QObject::connect(sensorThread, SIGNAL(finished()), sensorThread, SLOT(deleteLater())); for (int i = 0; i < widgetsList.size(); i++){ QObject::connect(sensorThread, SIGNAL(receivedData(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>)), widgetsList[i], SLOT(collapse(QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>,QPair<SensorData*,SensorData*>))); QObject::connect(widgetsList[i], SIGNAL(returnHome(WidgetType)), this, SLOT(setActiveWidget(WidgetType)));} sensorThread->start(); }