initial unfinished impl, lots of bugs.
splitter = new MiniSplitter(this);
splitter->setChildrenCollapsible(false);
- // splitter->setBackgroundRole(QPalette::Text);
- // splitter->setAutoFillBackground(true);
sortBar = new THBlackBar(this);
mostRelevantAction = new THAction(tr("Most relevant"), this);
this, SLOT(selectionChanged ( const QItemSelection & , const QItemSelection & )));
playlistWidget = new PlaylistWidget(this, sortBar, listView);
+ // playlistWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
splitter->addWidget(playlistWidget);
videoWidget = new VideoWidget(this);
videoWidget->setMinimumSize(320,240);
+ // videoWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+ videoWidget->hide();
splitter->addWidget(videoWidget);
- // expand video by default
- // splitter->setStretchFactor (1, 2);
+
+ loadingWidget = new LoadingWidget(this);
+ loadingWidget->setMinimumSize(320,240);
+ // loadingWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+ splitter->addWidget(loadingWidget);
+
+ QList<int> sizes;
+ sizes << 320 << 640 << 640;
+ splitter->setSizes(sizes);
layout->addWidget(splitter);
setLayout(layout);
connect(mediaObject, SIGNAL(currentSourceChanged(Phonon::MediaSource)),
this, SLOT(currentSourceChanged(Phonon::MediaSource)));
// connect(mediaObject, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
+ connect(mediaObject, SIGNAL(bufferStatus(int)), loadingWidget, SLOT(bufferStatus(int)));
}
void MediaView::search(SearchParams *searchParams) {
case Phonon::PlayingState:
qDebug("playing");
+ loadingWidget->hide();
+ videoWidget->show();
break;
case Phonon::StoppedState:
qDebug("stopped");
- // Play() has already been called when setting the source
+ // play() has already been called when setting the source
// but Phonon on Linux needs a little more help to start playback
mediaObject->play();
break;
void MediaView::activeRowChanged(int row) {
Video *video = listModel->videoAt(row);
if (!video) return;
+
+ // immediately show the loading widget
+ videoWidget->hide();
+ loadingWidget->setVideo(video);
+ loadingWidget->show();
+
QUrl streamUrl = video->streamUrl();
// qDebug() << "setCurrentSource" << streamUrl.toString();
#include "thblackbar.h"
#include "searchparams.h"
#include "playlistwidget.h"
+#include "loadingwidget.h"
class MediaView : public QWidget, public View {
Q_OBJECT
Phonon::MediaObject *mediaObject;
Phonon::VideoWidget *videoWidget;
+ // loadingWidget
+ LoadingWidget *loadingWidget;
+
QNetworkReply *networkReply;
};
--- /dev/null
+#include "loadingwidget.h"
+
+LoadingWidget::LoadingWidget(QWidget *parent) : QWidget(parent) {
+
+ QPalette p = palette();
+ p.setBrush(QPalette::Window, Qt::black);
+ p.setBrush(QPalette::Text, Qt::white);
+ setPalette(p);
+
+ setAutoFillBackground(true);
+
+ QBoxLayout *layout = new QVBoxLayout();
+ layout->setAlignment(Qt::AlignCenter);
+
+ QFont bigFont;
+ bigFont.setPointSize(bigFont.pointSize()*4);
+
+ titleLabel = new QLabel(this);
+ titleLabel->setAlignment(Qt::AlignCenter);
+ titleLabel->setForegroundRole(QPalette::Text);
+ titleLabel->setWordWrap(true);
+ titleLabel->setFont(bigFont);
+ titleLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ layout->addWidget(titleLabel);
+
+ QFont biggerFont;
+ biggerFont.setPointSize(biggerFont.pointSize()*2);
+
+ descriptionLabel = new QLabel(this);
+ descriptionLabel->setAlignment(Qt::AlignCenter);
+ descriptionLabel->setForegroundRole(QPalette::Text);
+ descriptionLabel->setWordWrap(true);
+ descriptionLabel->setFont(biggerFont);
+ descriptionLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ layout->addWidget(descriptionLabel);
+
+ progressBar = new QProgressBar(this);
+ progressBar->hide();
+ layout->addWidget(progressBar);
+
+ setLayout(layout);
+}
+
+void LoadingWidget::setVideo(Video *video) {
+ QString title = video->title();
+ // enhance legibility by splitting the title
+ title = title.replace(" - ", "<p>");
+ title = title.replace("] ", "]<p>");
+ titleLabel->setText(title);
+ descriptionLabel->setText(video->description());
+ progressBar->hide();
+}
+
+void LoadingWidget::bufferStatus(int percent) {
+ qDebug() << percent;
+ progressBar->setShown(percent > 0);
+ progressBar->setValue(percent);
+}
+
+void LoadingWidget::paintEvent(QPaintEvent *) {
+
+ /*
+ QPainter painter(this);
+ painter.fillRect(0, 0, width(), height(), Qt::black);
+ */
+
+}
--- /dev/null
+#ifndef LOADINGWIDGET_H
+#define LOADINGWIDGET_H
+
+#include <QtGui>
+#include "video.h"
+
+class LoadingWidget : public QWidget {
+
+ Q_OBJECT
+
+public:
+ LoadingWidget(QWidget *parent);
+ void setVideo(Video *video);
+
+public slots:
+ void bufferStatus(int);
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private:
+ QLabel *titleLabel;
+ QLabel *descriptionLabel;
+ QProgressBar *progressBar;
+
+};
+
+#endif // LOADINGWIDGET_H
// qDebug() << "Title: " << title;
video->setTitle(title);
}
- /*
else if (name() == "description") {
QString desc = readElementText();
- qDebug() << "Description: " << desc;
+ // qDebug() << "Description: " << desc;
video->setDescription(desc);
- } */
+ }
else if (name() == "duration") {
QString duration = attributes().value("seconds").toString();
// qDebug() << "Duration: " << duration;