#include "networkaccess.h"
#include "videowidget.h"
#include "minisplitter.h"
-#include "flickcharm.h"
+#include "constants.h"
+#include "downloadmanager.h"
namespace The {
QMap<QString, QAction*>* globalActions();
videoAreaWidget = new VideoAreaWidget(this);
videoAreaWidget->setMinimumSize(320,240);
-#ifdef Q_WS_MAC
+#ifdef APP_MAC
// mouse autohide does not work on the Mac (no mouseMoveEvent)
videoWidget = new Phonon::VideoWidget(this);
#else
workaroundTimer->setInterval(3000);
connect(workaroundTimer, SIGNAL(timeout()), SLOT(timerPlay()));
- // TODO Enable this on touch devices
- // FlickCharm *flickCharm = new FlickCharm(this);
- // flickCharm->activateOn(listView);
-
-}
-
-MediaView::~MediaView() {
+#ifdef APP_DEMO
+ demoTimer = new QTimer(this);
+ demoTimer->setSingleShot(true);
+ demoTimer->setInterval(60000);
+ connect(demoTimer, SIGNAL(timeout()), SLOT(demoMessage()));
+#endif
}
void MediaView::search(SearchParams *searchParams) {
reallyStopped = false;
+#ifdef APP_DEMO
+ demoTimer->stop();
+#endif
+
videoAreaWidget->clear();
workaroundTimer->stop();
errorTimer->stop();
// but Phonon on Linux needs a little more help to start playback
if (!reallyStopped) mediaObject->play();
-#ifdef Q_WS_MAC
+#ifdef APP_MAC
// Workaround for Mac playback start problem
if (!timerPlayFlag) {
workaroundTimer->start();
QMainWindow* mainWindow = dynamic_cast<QMainWindow*>(window());
if (mainWindow) mainWindow->statusBar()->showMessage(video->title());
+ The::globalActions()->value("download")->setEnabled(DownloadManager::instance()->itemForVideo(video) == 0);
+
// see you in gotStreamUrl...
}
void MediaView::gotStreamUrl(QUrl streamUrl) {
if (reallyStopped) return;
+ Video *video = static_cast<Video *>(sender());
+ if (!video) {
+ qDebug() << "Cannot get sender";
+ return;
+ }
+ video->disconnect(this);
+
// go!
+ qDebug() << "Playing" << streamUrl.toString();
mediaObject->setCurrentSource(streamUrl);
mediaObject->play();
QModelIndex index = listModel->index(row, 0, QModelIndex());
listView->scrollTo(index, QAbstractItemView::EnsureVisible);
}
+
+#ifdef APP_DEMO
+ demoTimer->start();
+#endif
+
}
void MediaView::itemActivated(const QModelIndex &index) {
else listModel->searchMore();
}
-void MediaView::currentSourceChanged(const Phonon::MediaSource source) {
- qDebug() << "Playing" << source.url().toString();
+void MediaView::currentSourceChanged(const Phonon::MediaSource /* source */ ) {
+
}
void MediaView::skipVideo() {
void MediaView::moveUpSelected() {
if (!listView->selectionModel()->hasSelection()) return;
+
QModelIndexList indexes = listView->selectionModel()->selectedIndexes();
+ qStableSort(indexes.begin(), indexes.end());
listModel->move(indexes, true);
+
+ // set current index after row moves to something more intuitive
+ int row = indexes.first().row();
+ listView->selectionModel()->setCurrentIndex(listModel->index(row>1?row:1), QItemSelectionModel::NoUpdate);
}
void MediaView::moveDownSelected() {
if (!listView->selectionModel()->hasSelection()) return;
+
QModelIndexList indexes = listView->selectionModel()->selectedIndexes();
+ qStableSort(indexes.begin(), indexes.end(), qGreater<QModelIndex>());
listModel->move(indexes, false);
+
+ // set current index after row moves to something more intuitive (respect 1 static item on bottom)
+ int row = indexes.first().row()+1, max = listModel->rowCount() - 2;
+ listView->selectionModel()->setCurrentIndex(listModel->index(row>max?max:row), QItemSelectionModel::NoUpdate);
}
void MediaView::showVideoContextMenu(QPoint point) {
QSettings settings;
settings.setValue("splitter", splitter->saveState());
}
+
+#ifdef APP_DEMO
+void MediaView::demoMessage() {
+ if (mediaObject->state() != Phonon::PlayingState) return;
+ mediaObject->pause();
+
+ QMessageBox msgBox;
+ msgBox.setIconPixmap(QPixmap(":/images/app.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ msgBox.setText(tr("This is just the demo version of %1.").arg(Constants::APP_NAME));
+ msgBox.setInformativeText(tr("It allows you to test the application and see if it works for you."));
+ msgBox.setModal(true);
+
+ QPushButton *quitButton = msgBox.addButton(tr("Continue"), QMessageBox::RejectRole);
+ QPushButton *buyButton = msgBox.addButton(tr("Get the full version"), QMessageBox::ActionRole);
+
+ msgBox.exec();
+
+ if (msgBox.clickedButton() == buyButton) {
+ QDesktopServices::openUrl(QString(Constants::WEBSITE) + "#download");
+ } else {
+ mediaObject->play();
+ }
+}
+#endif
+
+void MediaView::downloadVideo() {
+ Video* video = listModel->activeVideo();
+ if (!video) return;
+
+ DownloadManager::instance()->addItem(video);
+
+ // TODO animate
+
+ The::globalActions()->value("downloads")->setVisible(true);
+
+ // The::globalActions()->value("download")->setEnabled(DownloadManager::instance()->itemForVideo(video) == 0);
+
+ QMainWindow* mainWindow = dynamic_cast<QMainWindow*>(window());
+ QString message = tr("Downloading %1").arg(video->title());
+ if (mainWindow) mainWindow->statusBar()->showMessage(message);
+}
+
+void MediaView::fullscreen() {
+ videoAreaWidget->setParent(0);
+ videoAreaWidget->showFullScreen();
+}