]> git.sur5r.net Git - minitube/commitdiff
* Fixed dualscreen behaviour
authorGeorg Grabler <georg@grabler.net>
Sun, 30 Jan 2011 18:14:01 +0000 (18:14 +0000)
committerGeorg Grabler <georg@grabler.net>
Sun, 30 Jan 2011 18:14:01 +0000 (18:14 +0000)
src/MainWindow.cpp
src/MainWindow.h
src/MediaView.cpp
src/MediaView.h
src/videoareawidget.cpp
src/videoareawidget.h

index 2064ce929de21cfa2b3f0c3dafefea528533539c..6fdb6c4dcf7d54a0a01a933565be5f92f9512d48 100644 (file)
@@ -82,6 +82,8 @@ MainWindow::MainWindow() :
             SLOT(updateDownloadMessage(QString)));
     connect(DownloadManager::instance(), SIGNAL(finished()),
             SLOT(downloadsFinished()));
+
+    this->setMouseTracking(true);
 }
 
 MainWindow::~MainWindow() {
@@ -89,13 +91,41 @@ MainWindow::~MainWindow() {
 }
 
 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
+    if (this->mediaView->isVisible()) {
+        if (event->type() == QEvent::MouseMove) {
+            QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
+
+            const int x = mouseEvent->pos().x();
+            const int y = mouseEvent->pos().y();
+
+            if (x >= 0 && x <= 10 && this->m_fullscreen) {
+                this->mediaView->setPlaylistVisible(true);
+            } else if ((x > this->mediaView->getPlaylistSize().width() || x < 0) && this->m_fullscreen) {
+                this->mediaView->setPlaylistVisible(false);
+            } else if (!this->m_fullscreen){
+                this->mediaView->setPlaylistVisible(true);
+            }
+
+            if (y >= 0 && y <= 10 && this->m_fullscreen) {
+                this->mainToolBar->setVisible(true);
+            } else if ((y > this->mainToolBar->size().height() || y < 0) && this->m_fullscreen) {
+                this->mainToolBar->setVisible(false);
+            } else if (!this->m_fullscreen) {
+                this->mainToolBar->setVisible(true);
+            }
+        }
+        if (event->type() == QEvent::FocusOut) {
+            this->mediaView->setPlaylistVisible(false);
+            this->mainToolBar->setVisible(false);
+        }
+    }
+
     if (event->type() == QEvent::ToolTip) {
         // kill tooltips
         return true;
-    } else {
-        // standard event processing
-        return QObject::eventFilter(obj, event);
     }
+    // standard event processing
+    return QObject::eventFilter(obj, event);
 }
 
 void MainWindow::createActions() {
@@ -925,16 +955,6 @@ void MainWindow::toggleDefinitionMode() {
     setDefinitionMode(nextDefinition);
 }
 
-void MainWindow::showFullscreenToolbar(bool show) {
-    if (!m_fullscreen) return;
-    mainToolBar->setVisible(show);
-}
-
-void MainWindow::showFullscreenPlaylist(bool show) {
-    if (!m_fullscreen) return;
-    mediaView->setPlaylistVisible(show);
-}
-
 void MainWindow::clearRecentKeywords() {
     QSettings settings;
     settings.remove("recentKeywords");
index 5034df8afb8dc1c18e249ddece89e6b26f054ccd..34da611b0d4dd6dc9b7c4420c41df22ec57e6599 100644 (file)
@@ -54,10 +54,6 @@ private slots:
     void volumeChanged(qreal newVolume);
     void volumeMutedChanged(bool muted);
 
-    // fullscreen toolbar
-    void showFullscreenToolbar(bool show);
-    void showFullscreenPlaylist(bool show);
-
     // void setAutoplay(bool enabled);
     void updateDownloadMessage(QString);
     void downloadsFinished();
index 0fd49b27ca97eebfd944133661b8357fe9a9ed6f..48bb22dd0a601ce0d5326a10df64230efb99ae1c 100644 (file)
@@ -626,6 +626,10 @@ void MediaView::fullscreen() {
     videoAreaWidget->showFullScreen();
 }
 
+QSize MediaView::getPlaylistSize() {
+    return this->playlistWidget->size();
+}
+
 /*
 void MediaView::setSlider(QSlider *slider) {
     this->slider = slider;
index a4016bee1b60775b7535e081e1df22089095ff5b..d4784796c4f7c18d3b377b0f525fd2e3cd76af73 100644 (file)
@@ -42,6 +42,7 @@ public:
 
     void setMediaObject(Phonon::MediaObject *mediaObject);
     void setSlider(QSlider *slider);
+    QSize getPlaylistSize();
 
 public slots:
     void search(SearchParams *searchParams);
index f4b48e6ecae75303d638cf5dafd44646abfe2a98..e33450cf1e60b48aff6637bcb09ace5d0ae1c785 100644 (file)
@@ -95,23 +95,3 @@ void VideoAreaWidget::dropEvent(QDropEvent *event) {
         listModel->setActiveRow(row);
     event->acceptProposedAction();
 }
-
-void VideoAreaWidget::mouseMoveEvent(QMouseEvent *event) {
-    QWidget::mouseMoveEvent(event);
-
-    QWidget* mainWindow = window();
-    if (!mainWindow->isFullScreen()) return;
-
-    // qDebug() << "VideoAreaWidget::mouseMoveEvent" << event->pos();
-
-    const int x = event->pos().x();
-    const int y = event->pos().y();
-
-    bool visible = y <= 0;
-    bool ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenToolbar", Qt::DirectConnection, Q_ARG(bool, visible));
-    if (!ret) qDebug() << "showFullscreenToolbar invokeMethod failed";
-
-    visible = x <= 0;
-    ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenPlaylist", Qt::DirectConnection, Q_ARG(bool, visible));
-    if (!ret) qDebug() << "showFullscreenPlaylist invokeMethod failed";
-}
index e1f7cea3d16c5cadea95b2c7d5b29f43575c1f21..fa37a599207b8c0580a2a3d193c6d20258c2fc76 100644 (file)
@@ -31,7 +31,6 @@ protected:
     void mousePressEvent(QMouseEvent *event);
     void dragEnterEvent(QDragEnterEvent *event);
     void dropEvent(QDropEvent *event);
-    void mouseMoveEvent(QMouseEvent *event);
 
 private:
     QStackedLayout *stackedLayout;