void JokerWindow::on_actionChange_timestamp_triggered() { hideMediaPanel(); _strip.clock()->setRate(0); PhTime time; if(_synchronizer.videoClock()->time() < _videoEngine.timeIn()) time = _videoEngine.timeIn(); else if(_synchronizer.videoClock()->time() > _videoEngine.timeIn() + _videoEngine.length()) time = _videoEngine.timeOut(); else time = _synchronizer.videoClock()->time(); PhTimeCodeDialog dlg(_doc->videoTimeCodeType(), time); if(dlg.exec() == QDialog::Accepted) { PhTime timeStamp; if(_synchronizer.videoClock()->time() > _videoEngine.timeIn() + _videoEngine.length()) timeStamp = dlg.time() - (_videoEngine.length() - PhTimeCode::timePerFrame(_videoEngine.timeCodeType())); else if (_synchronizer.videoClock()->time() < _videoEngine.timeIn()) timeStamp = dlg.time(); else timeStamp = _videoEngine.timeIn() + dlg.time() - _synchronizer.videoClock()->time(); _videoEngine.setTimeIn(timeStamp); _strip.clock()->setTime(dlg.time()); _doc->setVideoTimeIn(timeStamp, _videoEngine.timeCodeType()); _mediaPanel.setTimeIn(timeStamp); _doc->setModified(true); } fadeInMediaPanel(); }
void JokerWindow::on_actionAbout_triggered() { hideMediaPanel(); AboutDialog menu; menu.exec(); fadeInMediaPanel(); }
void JokerWindow::on_actionTimecode_triggered() { hideMediaPanel(); PhTimeCodeDialog dlg(_videoEngine.timeCodeType(), _strip.clock()->time()); if(dlg.exec() == QDialog::Accepted) _strip.clock()->setTime(dlg.time()); fadeInMediaPanel(); }
void JokerWindow::on_actionTimecode_triggered() { hideMediaPanel(); PhTimeCodeDialog dlg(timeCodeType(), currentTime()); if(dlg.exec() == QDialog::Accepted) setCurrentTime(dlg.time()); fadeInMediaPanel(); }
void JokerWindow::on_actionAbout_triggered() { hideMediaPanel(); AboutDialog dlg; dlg.setTimePlayed(_settings->timePlayed()); dlg.exec(); fadeInMediaPanel(); }
void JokerWindow::on_actionPreferences_triggered() { hideMediaPanel(); int oldSynchroProtocol = _settings->synchroProtocol(); QString oldLTCInputDevice = _settings->ltcInputDevice(); PreferencesDialog dlg(_settings); dlg.exec(); if((oldSynchroProtocol != _settings->synchroProtocol()) || (oldLTCInputDevice != _settings->ltcInputDevice())) { PHDEBUG << "Set protocol:" << _settings->synchroProtocol(); setupSyncProtocol(); } fadeInMediaPanel(); }
void JokerWindow::on_actionOpen_Video_triggered() { hideMediaPanel(); QString lastFolder = _settings->lastVideoFolder(); QString filter = tr("Movie files") + " ("; foreach(QString type, _settings->videoFileType()) filter += "*." + type + " "; filter += ");;"; QFileDialog dlg(this, tr("Open a video..."), lastFolder, filter); if(dlg.exec()) { QString videoFile = dlg.selectedFiles()[0]; if(openVideoFile(videoFile)) _strip.clock()->setTime(_doc->videoTimeIn()); } fadeInMediaPanel(); }
void JokerWindow::on_actionOpen_triggered() { hideMediaPanel(); if(checkSaveFile()) { QString filter = tr("Rythmo files") + " ("; foreach(QString type, _settings->stripFileType()) filter += "*." + type + " "; filter += ");;"; QFileDialog dlg(this, tr("Open..."), _settings->lastDocumentFolder(), filter); dlg.setOption(QFileDialog::HideNameFilterDetails, false); dlg.setFileMode(QFileDialog::ExistingFile); if(dlg.exec()) { QString fileName = dlg.selectedFiles()[0]; openDocument(fileName); } } fadeInMediaPanel(); }
void JokerWindow::on_actionPreferences_triggered() { hideMediaPanel(); int oldSynchroProtocol = _settings->synchroProtocol(); #ifdef USE_LTC QString oldLtcInputPort = _settings->ltcInputPort(); #endif // USE_LTC #ifdef USE_MIDI QString oldMtcInputPort = _settings->mtcInputPort(); QString oldMtcVirtualInputPort = _settings->mtcVirtualInputPort(); bool oldMtcInputUseExistingPort = _settings->mtcInputUseExistingPort(); bool oldSendMmcMessage = _settings->sendMmcMessage(); QString oldMmcOutputPort = _settings->mmcOutputPort(); #endif // USE_MIDI PreferencesDialog dlg(_settings); if(dlg.exec() == QDialog::Accepted) { if((oldSynchroProtocol != _settings->synchroProtocol()) #ifdef USE_LTC || (oldLtcInputPort != _settings->ltcInputPort()) #endif // USE_LTC #ifdef USE_MIDI || (oldMtcInputPort != _settings->mtcInputPort()) || (oldMtcVirtualInputPort != _settings->mtcVirtualInputPort()) || (oldMtcInputUseExistingPort != _settings->mtcInputUseExistingPort()) || (oldSendMmcMessage != _settings->sendMmcMessage()) || (oldMmcOutputPort != _settings->mmcOutputPort()) #endif // USE_MIDI ) { PHDEBUG << "Set protocol:" << _settings->synchroProtocol(); setupSyncProtocol(); } #ifdef USE_MIDI _mtcReader.force24as2398(_settings->mtcForce24as2398()); #endif // USE_MIDI } fadeInMediaPanel(); }
bool JokerWindow::eventFilter(QObject * sender, QEvent *event) { /// The event filter catch the following event: switch (event->type()) { case QEvent::FileOpen: /// - FileOpen : To process a file dragged on the application dock icon (MacOS) { #warning /// @todo move to PhDocumentWindow QString filePath = static_cast<QFileOpenEvent *>(event)->file(); QString fileType = filePath.split(".").last().toLower(); // As the plist file list all the supported format // if the file is not a strip file, it's a video file, we don't need any protection if(_settings->stripFileType().contains(fileType)) { if(checkSaveFile()) openDocument(filePath); } else if(_settings->videoFileType().contains(fileType)) openVideoFile(filePath); break; } case QEvent::ApplicationDeactivate: /// - ApplicationDeactivate : to hide the mediapanel hideMediaPanel(); break; case QEvent::MouseMove: /// - Mouse move show the media panel { fadeInMediaPanel(); // Check if it is near the video/strip border QMouseEvent * mouseEvent = (QMouseEvent*)event; if(_resizingStrip) { QApplication::setOverrideCursor(Qt::SizeVerCursor); if(mouseEvent->buttons() & Qt::LeftButton) _settings->setStripHeight(1.0 - ((float) mouseEvent->pos().y() /(float) this->height())); } else QApplication::setOverrideCursor(Qt::ArrowCursor); break; } case QEvent::DragEnter: /// - Accept and process a file drop on the window event->accept(); break; case QEvent::Drop: { #warning /// @todo move to PhDocumentWindow const QMimeData* mimeData = static_cast<QDropEvent *>(event)->mimeData(); // If there is one file (not more) we open it if (mimeData->urls().length() == 1) { QString filePath = mimeData->urls().first().toLocalFile(); QString fileType = filePath.split(".").last().toLower(); if(fileType == "detx" or fileType == "strip" or fileType == "joker") { if(checkSaveFile()) openDocument(filePath); } else if (fileType == "avi" or fileType == "mov") openVideoFile(filePath); } break; } case QEvent::MouseButtonDblClick: /// - Double mouse click toggle fullscreen mode _resizingStrip = false; if(sender == this) toggleFullScreen(); break; case QEvent::MouseButtonRelease: QApplication::setOverrideCursor(Qt::ArrowCursor); break; case QEvent::MouseButtonPress: { QMouseEvent *mouseEvent = (QMouseEvent*)event; if((sender == this) && (mouseEvent->buttons() & Qt::RightButton)) { /// - Right mouse click on the video open the video file dialog. if(mouseEvent->y() < this->height() * (1.0f - _settings->stripHeight())) on_actionOpen_Video_triggered(); else /// - Left mouse click on the strip open the strip file dialog. on_actionOpen_triggered(); return true; } float stripHeight = this->height() * _settings->stripHeight(); if((mouseEvent->pos().y() > (this->height() - stripHeight) - 10) && (mouseEvent->pos().y() < (this->height() - stripHeight) + 10)) { QApplication::setOverrideCursor(Qt::SizeVerCursor); _resizingStrip = true; } } default: break; } return PhDocumentWindow::eventFilter(sender, event); }
void JokerWindow::onApplicationActivate() { PhDocumentWindow::onApplicationActivate(); fadeInMediaPanel(); }
bool JokerWindow::eventFilter(QObject * sender, QEvent *event) { /// The event filter catch the following event: switch (event->type()) { case QEvent::MouseMove: /// - Mouse move show the media panel case QEvent::HoverEnter: case QEvent::HoverMove: { fadeInMediaPanel(); QMouseEvent * mouseEvent = (QMouseEvent*)event; // Check if it is near the video/strip border float stripHeight = this->height() * _settings->stripHeight(); if((mouseEvent->pos().y() > (this->height() - stripHeight) - 10) && (mouseEvent->pos().y() < (this->height() - stripHeight) + 10)) QApplication::setOverrideCursor(Qt::SizeVerCursor); else QApplication::setOverrideCursor(Qt::ArrowCursor); if(_resizingStrip && (mouseEvent->buttons() & Qt::LeftButton)) { PHDEBUG << "resizing strip:" << mouseEvent->pos(); _settings->setStripHeight(1.0 - ((float) mouseEvent->pos().y() /(float) this->height())); } break; } case QEvent::MouseButtonDblClick: /// - Double mouse click toggle fullscreen mode if(sender == this) toggleFullScreen(); break; case QEvent::MouseButtonRelease: PHDEBUG << "end resizing strip"; _resizingStrip = false; break; case QEvent::MouseButtonPress: { QMouseEvent *mouseEvent = (QMouseEvent*)event; if((sender == this) && (mouseEvent->buttons() & Qt::RightButton)) { /// - Right mouse click on the video open the video file dialog. if(mouseEvent->y() < this->height() * (1.0f - _settings->stripHeight())) on_actionOpen_Video_triggered(); else /// - Left mouse click on the strip open the strip file dialog. on_actionOpen_triggered(); return true; } float stripHeight = this->height() * _settings->stripHeight(); if((mouseEvent->pos().y() > (this->height() - stripHeight) - 10) && (mouseEvent->pos().y() < (this->height() - stripHeight) + 10)) { PHDEBUG << "start resizing strip"; _resizingStrip = true; } break; } case QEvent::KeyPress: { QKeyEvent *keyEvent = (QKeyEvent*)event; if(keyEvent->key() == Qt::Key_Space) { on_actionPlay_pause_triggered(); } break; } default: break; } return PhDocumentWindow::eventFilter(sender, event); }
JokerWindow::JokerWindow(JokerSettings *settings) : PhEditableDocumentWindow(settings), ui(new Ui::JokerWindow), _settings(settings), _strip(settings), _doc(_strip.doc()), #ifdef USE_VIDEO _videoEngine(settings), #endif _synchronizer(settings), #ifdef USE_SONY _sonySlave(settings), #endif #ifdef USE_LTC _ltcReader(settings), #endif #ifdef USE_MIDI _mtcReader(PhTimeCodeType25), _mtcWriter(PhTimeCodeType25), #endif _mediaPanelState(MediaPanelHidden), _mediaPanelAnimation(&_mediaPanel, "windowOpacity"), _firstDoc(true), _resizingStrip(false) { // Setting up UI ui->setupUi(this); // Due to translation, Qt might not be able to link automatically the menu ui->actionPreferences->setMenuRole(QAction::PreferencesRole); ui->actionAbout->setMenuRole(QAction::AboutRole); connect(ui->actionFullscreen, &QAction::triggered, this, &JokerWindow::toggleFullScreen); ui->videoStripView->setGraphicSettings(_settings); // Initialize the synchronizer _synchronizer.setStripClock(_strip.clock()); // Initialize the property dialog _propertyDialog.setDoc(_doc); #ifdef USE_VIDEO _propertyDialog.setVideoEngine(&_videoEngine); _synchronizer.setVideoClock(_videoEngine.clock()); #else ui->actionOpen_Video->setEnabled(false); ui->actionClose_video->setEnabled(false); ui->actionDeinterlace_video->setEnabled(false); ui->actionForce_16_9_ratio->setEnabled(false); ui->actionUse_native_video_size->setEnabled(false); #endif #ifdef USE_SONY connect(&_sonySlave, &PhSonySlaveController::videoSync, this, &JokerWindow::onVideoSync); #endif #ifdef USE_MIDI _mtcReader.force24as2398(_settings->mtcForce24as2398()); #endif // USE_MIDI setupSyncProtocol(); // Setting up the media panel _mediaPanel.setClock(_doc->videoTimeCodeType(), _strip.clock()); #warning /// @todo move to CSS file _mediaPanel.setStyleSheet( "* {" " color: white;" " }" " PhMediaPanel { " " background: qlineargradient(x1: 1, y1: 0, x2: 1, y2: 1, stop: 0 rgb(40,40,40), stop: 1 black);" " border-style: solid; " " border-width: 4px; " " border-radius: 3px; " " border-color: white; " " } " " QPushButton, QComboBox{ " " background: grey; " " border-style: outset; " " border-width: 2px; " " border-radius: 5px; " " border-color: white; " " } " " QLabel#_timecodeLabel{ " " padding: 10px; " " } " ); ui->actionDisplay_the_control_panel->setChecked(_settings->displayControlPanel()); fadeInMediaPanel(); // Trigger a timer that will fade off the media panel after 3 seconds this->connect(&_mediaPanelTimer, &QTimer::timeout, this, &JokerWindow::fadeOutMediaPanel); _mediaPanelTimer.start(3000); this->setFocus(); ui->actionDisplay_the_information_panel->setChecked(_settings->displayNextText()); #warning /// @todo do we warn the user that test mode is on? ui->actionTest_mode->setChecked(_settings->stripTestMode()); #warning /// @todo move to PhDocumentWindow // This is for the drag and drop feature setAcceptDrops(true); ui->actionLoop->setChecked(_settings->syncLooping()); ui->actionInvert_colors->setChecked(_settings->invertColor()); ui->actionHide_the_rythmo->setChecked(_settings->hideStrip()); ui->actionDisplay_the_cuts->setChecked(_settings->displayCuts()); ui->actionDisplay_the_vertical_scale->setChecked(_settings->displayVerticalScale()); on_actionDisplay_feet_triggered(_settings->displayFeet()); this->connect(ui->videoStripView, &PhGraphicView::beforePaint, this, &JokerWindow::timeCounter); this->connect(ui->videoStripView, &PhGraphicView::beforePaint, _strip.clock(), &PhClock::elapse); this->connect(ui->videoStripView, &PhGraphicView::paint, this, &JokerWindow::onPaint); _videoLogo.setFilename(QCoreApplication::applicationDirPath() + PATH_TO_RESSOURCES + "/phonations.png"); }