Skip to content

Commit

Permalink
Merge pull request #1832 from Joern-R/TRAIN
Browse files Browse the repository at this point in the history
TrainView
  • Loading branch information
liversedge committed Feb 5, 2016
2 parents 120b31d + ff1d7b9 commit bbdb82f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
35 changes: 30 additions & 5 deletions src/TrainSidebar.cpp
Expand Up @@ -123,7 +123,7 @@ TrainSidebar::TrainSidebar(Context *context) : GcWindow(context), context(contex
#endif



#ifdef GC_HAVE_VLC // RLV currently only support for VLC
videosyncModel = new QSqlTableModel(this, trainDB->connection());
videosyncModel->setTable("videosyncs");
videosyncModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
Expand Down Expand Up @@ -163,7 +163,9 @@ TrainSidebar::TrainSidebar(Context *context) : GcWindow(context), context(contex
videosyncTree->verticalScrollBar()->setStyle(cdevideosync);
#endif

#endif
#endif //GC_HAVE_VLC

#endif //GC_VIDEO_NONE

deviceTree = new QTreeWidget;
deviceTree->setFrameStyle(QFrame::NoFrame);
Expand Down Expand Up @@ -423,13 +425,15 @@ intensity->hide(); //XXX!!! temporary
mediaItem->addWidget(mediaTree);
trainSplitter->addWidget(mediaItem);

#ifdef GC_HAVE_VLC // RLV currently only support for VLC
videosyncItem = new GcSplitterItem(tr("VideoSync"), iconFromPNG(":images/sidebar/sync.png"), this);
QAction *moreVideoSyncAct = new QAction(iconFromPNG(":images/sidebar/extra.png"), tr("Menu"), this);
videosyncItem->addAction(moreVideoSyncAct);
connect(moreVideoSyncAct, SIGNAL(triggered(void)), this, SLOT(videosyncPopup(void)));
videosyncItem->addWidget(videosyncTree);
trainSplitter->addWidget(videosyncItem);
#endif
#endif //GC_HAVE_VLC
#endif //GC_VIDEO_NONE
trainSplitter->prepare(context->athlete->cyclist, "train");

#ifdef Q_OS_MAC
Expand All @@ -450,10 +454,12 @@ intensity->hide(); //XXX!!! temporary
connect(mediaTree->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this, SLOT(mediaTreeWidgetSelectionChanged()));
connect(context, SIGNAL(selectMedia(QString)), this, SLOT(selectVideo(QString)));
#ifdef GC_HAVE_VLC // RLV currently only support for VLC
connect(videosyncTree->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this, SLOT(videosyncTreeWidgetSelectionChanged()));
connect(context, SIGNAL(selectVideoSync(QString)), this, SLOT(selectVideoSync(QString)));
#endif
#endif //GC_HAVE_VLC
#endif //GC_VIDEO_NONE
connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32)));
connect(context, SIGNAL(selectWorkout(QString)), this, SLOT(selectWorkout(QString)));
connect(trainDB, SIGNAL(dataChanged()), this, SLOT(refresh()));
Expand Down Expand Up @@ -522,13 +528,16 @@ TrainSidebar::refresh()
row = mediaTree->currentIndex().row();
QString videoPath = mediaTree->model()->data(mediaTree->model()->index(row,0)).toString();

#ifdef GC_HAVE_VLC // RLV currently only support for VLC
// refresh data
videoModel->select();
while (videoModel->canFetchMore(QModelIndex())) videoModel->fetchMore(QModelIndex());
#endif

// restore selection
selectVideo(videoPath);

#ifdef GC_HAVE_VLC // RLV currently only support for VLC
// remember selection
row = videosyncTree->currentIndex().row();
QString videosyncPath = videosyncTree->model()->data(videosyncTree->model()->index(row,0)).toString();
Expand All @@ -539,7 +548,9 @@ TrainSidebar::refresh()

// restore selection
selectVideoSync(videosyncPath);
#endif
#endif // GC_HAVE_VLC

#endif // GC_VIDEO_NONE

row = workoutTree->currentIndex().row();
QString workoutPath = workoutTree->model()->data(workoutTree->model()->index(row,0)).toString();
Expand Down Expand Up @@ -712,7 +723,9 @@ TrainSidebar::configChanged(qint32)
setProperty("color", GColor(CTRAINPLOTBACKGROUND));
#if !defined GC_VIDEO_NONE
mediaTree->setStyleSheet(GCColor::stylesheet());
#ifdef GC_HAVE_VLC // RLV currently only support for VLC
videosyncTree->setStyleSheet(GCColor::stylesheet());
#endif
#endif
workoutTree->setStyleSheet(GCColor::stylesheet());
deviceTree->setStyleSheet(GCColor::stylesheet());
Expand Down Expand Up @@ -1160,7 +1173,9 @@ void TrainSidebar::Start() // when start button is pressed

#if !defined GC_VIDEO_NONE
mediaTree->setEnabled(false);
#ifdef GC_HAVE_VLC // RLV currently only support for VLC
videosyncTree->setEnabled(false);
#endif
#endif

// tell the world
Expand All @@ -1185,7 +1200,9 @@ void TrainSidebar::Start() // when start button is pressed
#if !defined GC_VIDEO_NONE
// enable media tree so we can change movie - mid workout
mediaTree->setEnabled(true);
#ifdef GC_HAVE_VLC // RLV currently only support for VLC
videosyncTree->setEnabled(true);
#endif
#endif

// tell the world
Expand All @@ -1200,7 +1217,9 @@ void TrainSidebar::Start() // when start button is pressed

#if !defined GC_VIDEO_NONE
mediaTree->setEnabled(false);
#ifdef GC_HAVE_VLC // RLV currently only support for VLC
videosyncTree->setEnabled(false);
#endif
#endif
workoutTree->setEnabled(false);
deviceTree->setEnabled(false);
Expand Down Expand Up @@ -1292,7 +1311,9 @@ void TrainSidebar::Pause() // pause capture to recalibrate

#if !defined GC_VIDEO_NONE
mediaTree->setEnabled(false);
#ifdef GC_HAVE_VLC // RLV currently only support for VLC
videosyncTree->setEnabled(false);
#endif
#endif

// tell the world
Expand All @@ -1312,7 +1333,9 @@ void TrainSidebar::Pause() // pause capture to recalibrate
// enable media tree so we can change movie
#if !defined GC_VIDEO_NONE
mediaTree->setEnabled(true);
#ifdef GC_HAVE_VLC // RLV currently only support for VLC
videosyncTree->setEnabled(true);
#endif
#endif

// tell the world
Expand All @@ -1330,7 +1353,9 @@ void TrainSidebar::Stop(int deviceStatus) // when stop button is pressed
// media or workouts whilst a workout is in progress
#if !defined GC_VIDEO_NONE
mediaTree->setEnabled(true);
#ifdef GC_HAVE_VLC // RLV currently only support for VLC
videosyncTree->setEnabled(true);
#endif
#endif
workoutTree->setEnabled(true);
deviceTree->setEnabled(true);
Expand Down
11 changes: 6 additions & 5 deletions src/VideoWindow.cpp
Expand Up @@ -484,16 +484,17 @@ void VideoWindow::mediaSelected(QString filename)

if (filename.endsWith("/DVD") || (filename != "" && QFile(filename).exists())) {

// properly encode the filename as URL (with all special characters)
filename = QUrl::toPercentEncoding(filename, "/\\", "");
#ifdef Q_OS_LINUX
QString fileURL = "file://" + filename.replace(" ","%20").replace("\\", "/");
QString fileURL = "file://" + filename.replace("\\", "/");
#else
// A Windows "c:\xyz\abc def.avi" filename should become file:///c:/xyz/abc%20def.avi
QString fileURL = "file:///" + filename.replace(" ","%20").replace("\\", "/");
#endif
QString fileURL = "file:///" + filename.replace("\\", "/");
#endif
//qDebug()<<"file url="<<fileURL;

/* open media */
m = libvlc_media_new_location(inst, filename.endsWith("/DVD") ? "dvd://" : fileURL.toLatin1());
m = libvlc_media_new_location(inst, filename.endsWith("/DVD") ? "dvd://" : fileURL.toLocal8Bit());

/* set the media to playback */
if (m) libvlc_media_player_set_media (mp, m);
Expand Down

0 comments on commit bbdb82f

Please sign in to comment.