From 69e1e6a3327b7066da7c065529e1e176131e9b65 Mon Sep 17 00:00:00 2001 From: Georg Grabler Date: Sun, 30 Jan 2011 18:14:01 +0000 Subject: [PATCH] * Fixed dualscreen behaviour --- src/MainWindow.cpp | 46 +++++++++++++++++++++++++++++------------ src/MainWindow.h | 4 ---- src/MediaView.cpp | 4 ++++ src/MediaView.h | 1 + src/videoareawidget.cpp | 20 ------------------ src/videoareawidget.h | 1 - 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 2064ce9..6fdb6c4 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -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(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"); diff --git a/src/MainWindow.h b/src/MainWindow.h index 5034df8..34da611 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -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(); diff --git a/src/MediaView.cpp b/src/MediaView.cpp index 0fd49b2..48bb22d 100644 --- a/src/MediaView.cpp +++ b/src/MediaView.cpp @@ -626,6 +626,10 @@ void MediaView::fullscreen() { videoAreaWidget->showFullScreen(); } +QSize MediaView::getPlaylistSize() { + return this->playlistWidget->size(); +} + /* void MediaView::setSlider(QSlider *slider) { this->slider = slider; diff --git a/src/MediaView.h b/src/MediaView.h index a4016be..d478479 100644 --- a/src/MediaView.h +++ b/src/MediaView.h @@ -42,6 +42,7 @@ public: void setMediaObject(Phonon::MediaObject *mediaObject); void setSlider(QSlider *slider); + QSize getPlaylistSize(); public slots: void search(SearchParams *searchParams); diff --git a/src/videoareawidget.cpp b/src/videoareawidget.cpp index f4b48e6..e33450c 100644 --- a/src/videoareawidget.cpp +++ b/src/videoareawidget.cpp @@ -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"; -} diff --git a/src/videoareawidget.h b/src/videoareawidget.h index e1f7cea..fa37a59 100644 --- a/src/videoareawidget.h +++ b/src/videoareawidget.h @@ -31,7 +31,6 @@ protected: void mousePressEvent(QMouseEvent *event); void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); - void mouseMoveEvent(QMouseEvent *event); private: QStackedLayout *stackedLayout; -- 2.39.5