splitter->setChildrenCollapsible(false);
sortBar = new THBlackBar(this);
- mostRelevantAction = new THAction(tr("Most relevant"), this);
+ mostRelevantAction = new QAction(tr("Most relevant"), this);
+ mostRelevantAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_1));
+ addAction(mostRelevantAction);
connect(mostRelevantAction, SIGNAL(triggered()), this, SLOT(searchMostRelevant()), Qt::QueuedConnection);
sortBar->addAction(mostRelevantAction);
- mostRecentAction = new THAction(tr("Most recent"), this);
+ mostRecentAction = new QAction(tr("Most recent"), this);
+ mostRecentAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_2));
+ addAction(mostRecentAction);
connect(mostRecentAction, SIGNAL(triggered()), this, SLOT(searchMostRecent()), Qt::QueuedConnection);
sortBar->addAction(mostRecentAction);
- mostViewedAction = new THAction(tr("Most viewed"), this);
+ mostViewedAction = new QAction(tr("Most viewed"), this);
+ mostViewedAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_3));
+ addAction(mostViewedAction);
connect(mostViewedAction, SIGNAL(triggered()), this, SLOT(searchMostViewed()), Qt::QueuedConnection);
sortBar->addAction(mostViewedAction);
listView = new QListView(this);
- listView->setItemDelegate(new Playlist::PrettyItemDelegate(this));
+ listView->setItemDelegate(new PrettyItemDelegate(this));
listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
// dragndrop
listView->setDragEnabled(true);
listView->setAcceptDrops(true);
listView->setDropIndicatorShown(true);
- listView->setDragDropMode(QAbstractItemView::InternalMove);
+ listView->setDragDropMode(QAbstractItemView::DragDrop);
// cosmetics
listView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
videoWidget = new Phonon::VideoWidget(this);
videoAreaWidget->setVideoWidget(videoWidget);
+ videoAreaWidget->setListModel(listModel);
loadingWidget = new LoadingWidget(this);
videoAreaWidget->setLoadingWidget(loadingWidget);
void MediaView::search(SearchParams *searchParams) {
this->searchParams = searchParams;
+ // start serching for videos
+ listModel->search(searchParams);
+
// this implies that the enum and the bar action order is the same
sortBar->setCheckedAction(searchParams->sortBy()-1);
- listModel->search(searchParams);
listView->setFocus();
+
+ loadingWidget->clear();
}
void MediaView::disappear() {
timerPlayFlag = true;
}
-void MediaView::stateChanged(Phonon::State newState, Phonon::State oldState)
+void MediaView::stateChanged(Phonon::State newState, Phonon::State /*oldState*/)
{
- qDebug() << "Phonon state: " << newState << oldState;
+ // qDebug() << "Phonon state: " << newState << oldState;
switch (newState) {
case Phonon::ErrorState:
qDebug() << "Phonon error:" << mediaObject->errorString() << mediaObject->errorType();
+ videoAreaWidget->showError(mediaObject->errorString());
// recover from errors by skipping to the next video
skip();
break;
// play() has already been called when setting the source
// but Phonon on Linux needs a little more help to start playback
mediaObject->play();
+
+ // Workaround for Mac playback start problem
if (!timerPlayFlag) {
QTimer::singleShot(1000, this, SLOT(timerPlay()));
}
+
break;
case Phonon::PausedState:
}
void MediaView::pause() {
+ // qDebug() << "pause() called" << mediaObject->state();
switch( mediaObject->state() ) {
case Phonon::PlayingState:
mediaObject->pause();
}
}
-void MediaView::fullscreen() {
- splitterState = splitter->saveState();
- videoAreaWidget->setParent(0);
- videoAreaWidget->showFullScreen();
-}
-
-void MediaView::exitFullscreen() {
- // videoAreaWidget->setParent(this);
- splitter->addWidget(videoAreaWidget);
- // Just calling show() on the Mac won't work
- videoAreaWidget->showNormal();
- splitter->restoreState(splitterState);
-}
-
void MediaView::stop() {
listModel->abortSearch();
mediaObject->stop();
// mediaObject->pause();
connect(video, SIGNAL(gotStreamUrl(QUrl)), SLOT(gotStreamUrl(QUrl)));
+ // TODO handle signal in a proper slot and impl item error status
+ connect(video, SIGNAL(errorStreamUrl()), SLOT(skip()));
video->loadStreamUrl();
// reset the timer flag
timerPlayFlag = false;
+ // video title in the statusbar
+ QMainWindow* mainWindow = dynamic_cast<QMainWindow*>(qApp->topLevelWidgets().first());
+ if (mainWindow) mainWindow->statusBar()->showMessage(video->title());
+
// see you in gotStreamUrl...
}
QModelIndex index = listModel->index(row, 0, QModelIndex());
listView->scrollTo(index, QAbstractItemView::EnsureVisible);
}
+
}
void MediaView::itemActivated(const QModelIndex &index) {
}
void MediaView::timerPlay() {
- qDebug() << mediaObject->currentTime();
+ // qDebug() << mediaObject->currentTime();
// Workaround Phonon bug on Mac OSX
if (mediaObject->currentTime() <= 0 && mediaObject->state() == Phonon::PlayingState) {
mediaObject->pause();