Skip to content

Commit aeaa783

Browse files
committed
Added custom video menu, separated display and seeking functionality.
1 parent 3aa8d02 commit aeaa783

2 files changed

Lines changed: 48 additions & 39 deletions

File tree

src/neuroscope.cpp

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,6 @@ void NeuroscopeApp::initActions()
287287
mTimeTool->setShortcut(Qt::Key_T);
288288
connect(mTimeTool,SIGNAL(triggered()), this,SLOT(slotSelectTime()));
289289

290-
mSeekVideoToTimeTool = toolMenu->addAction(tr("Seek Video to Time"));
291-
mSeekVideoToTimeTool->setIcon(QIcon(":/icons/video_player"));
292-
mSeekVideoToTimeTool->setShortcut(Qt::Key_V);
293-
connect(mSeekVideoToTimeTool,SIGNAL(triggered()), this,SLOT(slotSeekVideoToTime()));
294-
295290
mEventTool = toolMenu->addAction(tr("Select Event"));
296291
mEventTool->setIcon(QIcon(":/icons/event_tool"));
297292
mEventTool->setShortcut(Qt::Key_E);
@@ -567,12 +562,28 @@ void NeuroscopeApp::initActions()
567562

568563
calibrationBar->setChecked(false);
569564

570-
571565
settingsMenu->addSeparator();
572566
mPreferenceAction = settingsMenu->addAction(tr("Preferences"));
573567
mPreferenceAction->setIcon(QIcon(":/shared-icons/configure"));
574568
connect(mPreferenceAction,SIGNAL(triggered()), this,SLOT(executePreferencesDlg()));
575569

570+
571+
// Video-Linking Menu:
572+
QMenu *videoLinkMenu = menuBar()->addMenu(tr("&Video"));
573+
mLinkVideo = videoLinkMenu->addAction(tr("Link Video"));
574+
mLinkVideo->setIcon(QIcon(":/icons/video_player"));
575+
//mLinkVideo->setShortcut(Qt::Key_V);
576+
connect(mLinkVideo,SIGNAL(triggered()), this,SLOT(slotDisplayVideoPlayer()));
577+
578+
mSeekVideoToTimeTool = videoLinkMenu->addAction(tr("Seek Video to Time"));
579+
mSeekVideoToTimeTool->setIcon(QIcon(":/icons/video_player"));
580+
mSeekVideoToTimeTool->setShortcut(Qt::Key_V);
581+
connect(mSeekVideoToTimeTool,SIGNAL(triggered()), this,SLOT(slotSeekVideoToTime()));
582+
583+
584+
585+
586+
576587
//Help menu
577588
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
578589
QAction *handbook = helpMenu->addAction(tr("Handbook"));
@@ -693,7 +704,7 @@ void NeuroscopeApp::initActions()
693704
mLinkedVideoToolBar = new QToolBar(tr("Linked Video Actions"));
694705
mLinkedVideoToolBar->setObjectName("Linked Video Actions");
695706
mLinkedVideoToolBar->addAction(mSeekVideoToTimeTool);
696-
addToolBar(Qt::RightToolBarArea, mLinkedVideoToolBar);
707+
addToolBar(Qt::LeftToolBarArea, mLinkedVideoToolBar);
697708

698709
readSettings();
699710

@@ -743,18 +754,6 @@ void NeuroscopeApp::executePreferencesDlg(){
743754
}
744755
}
745756

746-
void NeuroscopeApp::displayVideoPlayer() {
747-
if (videoPlayer == 0L) {
748-
videoPlayer = new VideoPlayer();
749-
videoPlayer->openFile();
750-
const QRect availableGeometry = QApplication::desktop()->availableGeometry(videoPlayer);
751-
videoPlayer->resize(availableGeometry.width() / 6, availableGeometry.height() / 4);
752-
}
753-
videoPlayer->show();
754-
// Set up any settings for the video player
755-
// Connect any signals for the video player
756-
}
757-
758757
void NeuroscopeApp::applyPreferences() {
759758
configuration().write();
760759

@@ -1806,18 +1805,19 @@ DataMovieLinkInfo* NeuroscopeApp::getDataMovieLinkInfo() {
18061805
return this->dataMovieLinkInfo;
18071806
}
18081807

1809-
void NeuroscopeApp::slotSeekVideoToTime(){
1810-
slotStatusMsg(tr("Trying to seek the video..."));
1811-
NeuroscopeView* view = activeView();
1812-
view->setMode(TraceView::DRAW_LINE,true);
1813-
1814-
select = false;
18151808

1816-
//VideoPlayer player;
1817-
this->displayVideoPlayer();
18181809

1810+
void NeuroscopeApp::slotDisplayVideoPlayer() {
1811+
if (videoPlayer == 0L) {
1812+
videoPlayer = new VideoPlayer();
1813+
videoPlayer->openFile();
1814+
const QRect availableGeometry = QApplication::desktop()->availableGeometry(videoPlayer);
1815+
videoPlayer->resize(availableGeometry.width() / 6, availableGeometry.height() / 4);
1816+
}
1817+
videoPlayer->show();
1818+
// Set up any settings for the video player
18191819
// Video File:
1820-
const QString videoURL = videoPlayer->getUrl().toDisplayString();
1820+
const QString videoURL = videoPlayer->getUrl().toDisplayString();
18211821
// Data File:
18221822
const QString dataURL = getDocument()->url();
18231823
// Perform the diff
@@ -1826,9 +1826,7 @@ void NeuroscopeApp::slotSeekVideoToTime(){
18261826
this->dataMovieLinkInfo = new DataMovieLinkInfo(this, videoURL, dataURL);
18271827
this->dataMovieLinkInfo->setDataDuration(dataRecordingLength);
18281828
this->dataMovieLinkInfo->setVideoDuration(videoPlayer->getDuration());
1829-
1830-
void setDataURL(const QString& dataFileUrl);
1831-
1829+
// Connect any signals for the video player
18321830
// Connect the videoPlayer's URL to the dataMovieLinkInfo so it updates whenever the video player changes media
18331831
QObject::connect(this->videoPlayer, &VideoPlayer::onMediaUrlChanged,
18341832
this->dataMovieLinkInfo, &DataMovieLinkInfo::setVideoURL);
@@ -1839,14 +1837,25 @@ void NeuroscopeApp::slotSeekVideoToTime(){
18391837
// const NeuroscopeDoc* currDoc = this->getDocument();
18401838
// currDoc->
18411839
// QObject::connect(this->getDocument(), &VideoPlayer::onMediaUrlChanged,
1842-
// this->dataMovieLinkInfo, &DataMovieLinkInfo::setVideoURL);
1840+
// this->dataMovieLinkInfo, &DataMovieLinkInfo::setDataURL);
18431841
// QObject::connect(this->videoPlayer, &VideoPlayer::onDurationChanged,
18441842
// this->dataMovieLinkInfo, &DataMovieLinkInfo::setVideoDuration);
1843+
}
18451844

1845+
void NeuroscopeApp::slotSeekVideoToTime(){
1846+
slotStatusMsg(tr("Trying to seek the video..."));
1847+
NeuroscopeView* view = activeView();
1848+
view->setMode(TraceView::DRAW_LINE,true);
1849+
1850+
select = false;
1851+
1852+
//VideoPlayer player;
1853+
this->slotDisplayVideoPlayer();
18461854

1847-
// Video Lag Time:
1848-
//int dataOffsetToVideo = dataFileTime.msecsTo(videoFileTime);
18491855

1856+
1857+
1858+
// Video Lag Time:
18501859
int dataOffsetToVideo = this->dataMovieLinkInfo->getDataOffsetToVideoMSec();
18511860
QString printable = QStringLiteral("Offset to video: %1 [msec].").arg(dataOffsetToVideo);
18521861
qInfo(qUtf8Printable(printable));

src/neuroscope.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,18 +438,17 @@ private Q_SLOTS:
438438
* for which the traces are going to be displayed.*/
439439
void slotSelectTime();
440440

441-
/**Chooses the selection time tool, enabling the user to select a time frame (subset of the currently shown)
442-
* which Matlab will be commanded to seek to.*/
443-
void slotSeekVideoToTime();
444-
445441
/**Chooses the tool to select an event, enabling the user to select an event in order to move or delete it.*/
446442
void slotSelectEvent();
447443

448444
/** Executes the preferences dialog.*/
449445
void executePreferencesDlg();
450446

451447
/** Displays the video player.*/
452-
void displayVideoPlayer();
448+
void slotDisplayVideoPlayer();
449+
450+
/** Chooses the selection time tool, enabling the user to select a time that the video will seek to.*/
451+
void slotSeekVideoToTime();
453452

454453
/** Updates the widgets so that new user settings take effect.*/
455454
void applyPreferences();
@@ -788,6 +787,7 @@ private Q_SLOTS:
788787
QAction* mSelectTool;
789788
QAction* mMeasureTool;
790789
QAction* mTimeTool;
790+
QAction* mLinkVideo;
791791
QAction* mSeekVideoToTimeTool;
792792
QAction* mEventTool;
793793
QAction* mDrawTimeLine;

0 commit comments

Comments
 (0)