]> git.sur5r.net Git - minitube/commitdiff
Enhanced fullscreen mode
authorFlavio Tordini <flavio.tordini@gmail.com>
Fri, 8 Jan 2010 21:00:50 +0000 (22:00 +0100)
committerFlavio Tordini <flavio.tordini@gmail.com>
Fri, 8 Jan 2010 21:00:50 +0000 (22:00 +0100)
Removed commented code for video download

CHANGES
TODO
src/MainWindow.cpp
src/MainWindow.h
src/loadingwidget.cpp
src/videoareawidget.cpp
src/videoareawidget.h
src/videowidget.cpp

diff --git a/CHANGES b/CHANGES
index 7b10903482142a5cc895099b8b90ac49f57b6148..b5bb252a1122948f86f872e8e11ea795d59cf8e2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,7 @@
 0.9 - ?
+- Clear recent keywords
+- Show the toolbar when mouse hits the top of the screen in Fullscreen mode
+- Show the playlist when mouse hits the left side of the screen in Fullscreen mode
 - Fixed toolbar search suggestions working just once (Thanks to Salvatore Benedetto)
 - Fixed time formatting bug with videos longer than 1 hour (Thanks to Rene Bogusch)
 - Norwegian translation by Jan W. Skjoldal
diff --git a/TODO b/TODO
index efc2faea1c373fbfa6fcf70e8d2f51431b4ebb46..030e86aae0012ac8ee245bcaa4cddf510a801a0c 100644 (file)
--- a/TODO
+++ b/TODO
 
 ## Minor Features
 - Restore status when a recent keyword is clicked: skipped videos, sortBar and play time
-- Clear recent keywords
 - Safe search levels (in the status bar beside HD)
 - Show buffering progress (when Phonon backends will work)
-- Mark playlist items that have errors
-- Settings: number of "Recent Keywords", Phonon settings, HD or not
 - Show the toolbar when mouse hits the top of the screen in Fullscreen mode with animation
 - Show the playlist when mouse hits the left side of the screen in Fullscreen mode with animation
 - Show more thumbs on hover with animated crossfade
index 50de29b546c61756fc583f6b747cbfd4f561bcdc..f9dd824ee64dab76dbd6cb8aced908ed4cfeb0e6 100755 (executable)
@@ -8,7 +8,7 @@ MainWindow::MainWindow() :
         mediaObject(0),
         audioOutput(0),
         aboutView(0) {
-    
+
     m_fullscreen = false;
     
     // views mechanism
@@ -599,7 +599,7 @@ void MainWindow::fullscreen() {
     // workaround: prevent focus on the search bar
     // it steals the Space key needed for Play/Pause
     mainToolBar->setEnabled(m_fullscreen);
-    
+
     m_fullscreen = !m_fullscreen;
     
     setUpdatesEnabled(true);
@@ -725,93 +725,6 @@ void MainWindow::volumeMutedChanged(bool muted) {
         statusBar()->showMessage(tr("Volume is unmuted"));
 }
 
-/*
-void MainWindow::abortDownload() {
-    QProgressDialog* dlg = dynamic_cast<QProgressDialog*>(this->sender());
-    QMap<QNetworkReply*, DownloadResource>::iterator cur;
-    QMap<QNetworkReply*, DownloadResource>::iterator end;
-    // locate the DownloadResource by its dialog address and trigger abortion
-    for(cur=m_downloads.begin(), end=m_downloads.end(); cur!=end; cur++){
-        if(cur.value().dialog == dlg) cur.key()->abort();
-    }
-}
-
-void MainWindow::download() {
-    if(mediaObject == NULL || mediaObject->currentSource().url().isEmpty()){
-        // complain unless video source apperas to be valid
-        QMessageBox::critical(this, tr("No Video playing"), tr("You must first play the video you intent to download !"));
-        return;
-    }
-    QString filename = QFileDialog::getSaveFileName(this,
-                                                    tr("Save video as..."),
-                                                    tr("minitube video.mp4"),
-                                                    "Video File(*.avi *.mp4)"
-                                                    );
-    if(!filename.isNull()) {
-        // open destination file and initialize download
-        DownloadResource res;
-        res.file = new QFile(filename);
-        if(res.file->open(QFile::WriteOnly) == true) {
-            res.dialog = new QProgressDialog(tr("Downloading: ") + res.file->fileName(),
-                                             tr("Abort Download"), 0, 100, this);
-            connect(res.dialog, SIGNAL(canceled()), this, SLOT(abortDownload()));
-            download(mediaObject->currentSource().url(), res);
-        }else{
-            QMessageBox::critical(this, tr("File creation failed"), res.file->errorString());
-            delete res.file;
-        }
-    }
-}
-
-void MainWindow::download(const QUrl& url, const DownloadResource& res) {
-    // create and store request and connect the reply signals
-    QNetworkReply *r = The::networkAccessManager()->get(QNetworkRequest(url));
-    m_downloads.insert(r, res);
-    connect(r, SIGNAL(finished()), this, SLOT(replyFinished()));
-    connect(r, SIGNAL(readyRead()), this, SLOT(replyReadyRead()));
-    connect(r, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(replyError(QNetworkReply::NetworkError)));
-    connect(r, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(replyDownloadProgress(qint64,qint64)));
-    connect(r, SIGNAL(metaDataChanged()), this, SLOT(replyMetaDataChanged()));
-}
-
-void MainWindow::replyReadyRead() {
-    QNetworkReply* r = dynamic_cast<QNetworkReply*>(this->sender());
-    m_downloads[r].file->write(r->readAll());
-}
-
-void MainWindow::replyDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
-    QNetworkReply* r = dynamic_cast<QNetworkReply*>(this->sender());
-    if (bytesTotal > 0 && bytesReceived >0)
-        m_downloads[r].dialog->setValue( double(100.0/bytesTotal)*bytesReceived );  // pssst :-X
-}
-
-void MainWindow::replyError(QNetworkReply::NetworkError code) {
-    QNetworkReply* r = dynamic_cast<QNetworkReply*>(this->sender());
-    QMessageBox::critical(this, tr("Download failed"), r->errorString());
-}
-
-void MainWindow::replyFinished() {
-    QNetworkReply* r = dynamic_cast<QNetworkReply*>(this->sender());
-    m_downloads[r].dialog->close();
-    m_downloads[r].file->close();
-    delete m_downloads[r].file;
-    m_downloads.remove(r);
-}
-
-void MainWindow::replyMetaDataChanged() {
-    QNetworkReply* r = dynamic_cast<QNetworkReply*>(this->sender());
-    QUrl url = r->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
-    if(url.isValid()) {
-        // redirect - request new url, but keep the resources
-        qDebug() << "redirecting to: " << url.toString();
-        download(url, m_downloads[r]);
-        m_downloads.remove(r);
-    }
-}
-
-*/
-
-
 QPixmap MainWindow::createHDPixmap(bool enabled) {
     QPixmap pixmap = QPixmap(24,24);
     pixmap.fill(Qt::transparent);
@@ -883,3 +796,20 @@ void MainWindow::hdIndicator(bool isHd) {
         hdAct->setToolTip(tr("The current video is not in High Definition"));
     }
 }
+
+void MainWindow::showFullscreenToolbar(bool show) {
+    if (!m_fullscreen) return;
+
+    if (show) {
+        mainToolBar->show();
+    } else {
+        mainToolBar->hide();
+    }
+    mainToolBar->setEnabled(show);
+}
+
+void MainWindow::showFullscreenPlaylist(bool show) {
+    if (!m_fullscreen) return;    
+    mediaView->setPlaylistVisible(show);
+}
+
index e8d2ed592e79bf209a366ff2295053a600be7d6f..675597f756f1458048861b4f04806a06a978053d 100755 (executable)
@@ -30,13 +30,6 @@ public slots:
 protected:
     void closeEvent(QCloseEvent *);
 
-    /*
-    struct DownloadResource
-    {
-        QProgressDialog* dialog;
-        QFile* file;
-    };*/
-
 private slots:
     void fadeInWidget(QWidget *oldWidget, QWidget *newWidget);
     void goBack();
@@ -63,17 +56,9 @@ private slots:
     void volumeChanged(qreal newVolume);
     void volumeMutedChanged(bool muted);
 
-    /*
-    // download related stuff
-    void abortDownload();
-    void download();
-    void download(const QUrl& url, const DownloadResource& res);
-    void replyReadyRead();
-    void replyDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
-    void replyError(QNetworkReply::NetworkError code);
-    void replyFinished();
-    void replyMetaDataChanged();
-    */
+    // fullscreen toolbar
+    void showFullscreenToolbar(bool show);
+    void showFullscreenPlaylist(bool show);
 
 private:
     void initPhonon();
@@ -149,7 +134,6 @@ private:
     bool m_fullscreen;
     bool m_maximized;
 
-    // QMap<QNetworkReply*, DownloadResource> m_downloads;
 };
 
 #endif
index ef565b391223982b7d7198531bfafc79c293b3a5..b4f8eafcb9fdebf5cd4e4384a5ebe401e9642930 100644 (file)
@@ -46,6 +46,8 @@ LoadingWidget::LoadingWidget(QWidget *parent) : QWidget(parent) {
     layout->addWidget(progressBar);
     */
 
+    setMouseTracking(true);
+
     setLayout(layout);
 }
 
index 1d743a88f13e6a2bbec44c1ab5ad087422777ca7..a733fc1ced639f474ad3bab903eca3ecebfb8e26 100644 (file)
@@ -23,6 +23,7 @@ VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
     setLayout(vLayout);
     setAcceptDrops(true);
     
+    setMouseTracking(true);
 }
 
 void VideoAreaWidget::setVideoWidget(QWidget *videoWidget) {
@@ -92,3 +93,16 @@ void VideoAreaWidget::dropEvent(QDropEvent *event) {
         listModel->setActiveRow(row);
     event->acceptProposedAction();
 }
+
+void VideoAreaWidget::mouseMoveEvent(QMouseEvent *event) {
+    // qDebug() << "VideoAreaWidget::mouseMoveEvent" << event->pos();
+
+    QMainWindow* mainWindow = dynamic_cast<QMainWindow*>(qApp->topLevelWidgets().first());
+    bool visible = event->pos().y() <= 0;
+    bool ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenToolbar", Qt::DirectConnection, Q_ARG(bool, visible));
+    if (!ret) qDebug() << "showFullscreenToolbar invokeMethod failed";
+
+    visible = event->pos().x() <= 0;
+    ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenPlaylist", Qt::DirectConnection, Q_ARG(bool, visible));
+    if (!ret) qDebug() << "showFullscreenPlaylist invokeMethod failed";
+}
index fa37a599207b8c0580a2a3d193c6d20258c2fc76..e1f7cea3d16c5cadea95b2c7d5b29f43575c1f21 100644 (file)
@@ -31,6 +31,7 @@ protected:
     void mousePressEvent(QMouseEvent *event);
     void dragEnterEvent(QDragEnterEvent *event);
     void dropEvent(QDropEvent *event);
+    void mouseMoveEvent(QMouseEvent *event);
 
 private:
     QStackedLayout *stackedLayout;
index 71179cbe90cb5f657b1f7e4195bb1345c0dcb30e..ed6d689f964c3746adba1a1b869e575be0950789 100644 (file)
@@ -2,15 +2,17 @@
 
 VideoWidget::VideoWidget(QWidget *parent) : Phonon::VideoWidget(parent) {
     // mouse autohide
-    // setMouseTracking(true);
+    setMouseTracking(true);
     mouseTimer = new QTimer(this);
     mouseTimer->setInterval(3000);
     mouseTimer->setSingleShot(true);
     connect(mouseTimer, SIGNAL(timeout()), SLOT(hideMouse()));
 }
 
-void VideoWidget::mouseMoveEvent(QMouseEvent * /* event */) {
-    // qDebug() << "mouseMoveEvent";
+void VideoWidget::mouseMoveEvent(QMouseEvent *event) {
+    Phonon::VideoWidget::mouseMoveEvent(event);
+
+    // qDebug() << "VideoWidget::mouseMoveEvent" << event->pos();
 
     // show the normal cursor
     unsetCursor();