From 12ad8b3e272f6ff0045af1a64b74a0c687c91b1d Mon Sep 17 00:00:00 2001 From: Flavio Tordini Date: Thu, 25 Jun 2009 16:02:04 +0200 Subject: [PATCH] Fixed toggling of loading and video widgets Also fixed full screen mode --- minitube.pro | 29 ++++++++++++++++++---- src/MediaView.cpp | 53 +++++++++++++++-------------------------- src/MediaView.h | 4 ++-- src/videoareawidget.cpp | 46 +++++++++++++++++++++++++++++++++++ src/videoareawidget.h | 34 ++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 40 deletions(-) create mode 100644 src/videoareawidget.cpp create mode 100644 src/videoareawidget.h diff --git a/minitube.pro b/minitube.pro index ea3b061..c6a09a3 100755 --- a/minitube.pro +++ b/minitube.pro @@ -36,11 +36,11 @@ HEADERS += src/MainWindow.h \ src/videomimedata.h \ src/global.h \ src/updatechecker.h \ - src/videowidget.h \ src/playlistwidget.h \ src/searchparams.h \ src/minisplitter.h \ - src/loadingwidget.h + src/loadingwidget.h \ + src/videoareawidget.h SOURCES += src/main.cpp \ src/MainWindow.cpp \ src/SearchView.cpp \ @@ -59,12 +59,12 @@ SOURCES += src/main.cpp \ src/playlist/PrettyItemDelegate.cpp \ src/videomimedata.cpp \ src/updatechecker.cpp \ - src/videowidget.cpp \ src/networkaccess.cpp \ src/playlistwidget.cpp \ src/searchparams.cpp \ src/minisplitter.cpp \ - src/loadingwidget.cpp + src/loadingwidget.cpp \ + src/videoareawidget.cpp RESOURCES += resources.qrc DESTDIR = build/target/ OBJECTS_DIR = build/obj/ @@ -94,4 +94,25 @@ unix { PKGDATADIR = $$DATADIR/minitube DEFINES += DATADIR=\\\"$$DATADIR\\\" \ PKGDATADIR=\\\"$$PKGDATADIR\\\" + INSTALLS += translations \ + desktop \ + iconsvg \ + icon16 \ + icon32 \ + icon128 + translations.path = $$PKGDATADIR + translations.files += .qm/locale + desktop.path = $$DATADIR/applications + desktop.files += minitube.desktop + + # iconxpm.path = $$DATADIR/pixmaps + # iconxpm.files += data/minitube.xpm + iconsvg.path = $$DATADIR/icons/hicolor/scalable/apps + iconsvg.files += data/minitube.svg + icon16.path = $$DATADIR/icons/hicolor/16x16/apps + icon16.files += data/16x16/minitube.png + icon32.path = $$DATADIR/icons/hicolor/32x32/apps + icon32.files += data/32x32/minitube.png + icon128.path = $$DATADIR/icons/hicolor/128x128/apps + icon128.files += data/128x128/minitube.png } diff --git a/src/MediaView.cpp b/src/MediaView.cpp index 99641ec..381edac 100644 --- a/src/MediaView.cpp +++ b/src/MediaView.cpp @@ -59,23 +59,23 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) { 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); + videoAreaWidget = new VideoAreaWidget(this); + + videoWidget = new Phonon::VideoWidget(this); videoWidget->setMinimumSize(320,240); - // videoWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - videoWidget->hide(); - splitter->addWidget(videoWidget); - + videoAreaWidget->setVideoWidget(videoWidget); + loadingWidget = new LoadingWidget(this); loadingWidget->setMinimumSize(320,240); - // loadingWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - splitter->addWidget(loadingWidget); + videoAreaWidget->setLoadingWidget(loadingWidget); + + splitter->addWidget(videoAreaWidget); QList sizes; - sizes << 320 << 640 << 640; + sizes << 320 << 640; splitter->setSizes(sizes); layout->addWidget(splitter); @@ -87,9 +87,9 @@ MediaView::~MediaView() { } void MediaView::initialize() { - connect(videoWidget, SIGNAL(doubleClicked()), The::globalActions()->value("fullscreen"), SLOT(trigger())); - videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); - connect(videoWidget, SIGNAL(customContextMenuRequested(QPoint)), + connect(videoAreaWidget, SIGNAL(doubleClicked()), The::globalActions()->value("fullscreen"), SLOT(trigger())); + videoAreaWidget->setContextMenuPolicy(Qt::CustomContextMenu); + connect(videoAreaWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showVideoContextMenu(QPoint))); } @@ -132,8 +132,7 @@ void MediaView::stateChanged(Phonon::State newState, Phonon::State /* oldState * case Phonon::PlayingState: qDebug("playing"); - loadingWidget->hide(); - videoWidget->show(); + videoAreaWidget->showVideo(); break; case Phonon::StoppedState: @@ -172,28 +171,16 @@ void MediaView::pause() { } void MediaView::fullscreen() { - -#ifdef Q_WS_MAC splitterState = splitter->saveState(); - videoWidget->setParent(0); - videoWidget->showFullScreen(); -#else - videoWidget->setFullScreen(!videoWidget->isFullScreen()); -#endif - + videoAreaWidget->setParent(0); + videoAreaWidget->showFullScreen(); } void MediaView::exitFullscreen() { - -#ifdef Q_WS_MAC - videoWidget->setParent(this); - splitter->addWidget(videoWidget); - videoWidget->showNormal(); + videoAreaWidget->setParent(this); + splitter->addWidget(videoAreaWidget); + videoAreaWidget->showNormal(); splitter->restoreState(splitterState); -#else - videoWidget->setFullScreen(false); -#endif - } void MediaView::stop() { @@ -207,9 +194,7 @@ void MediaView::activeRowChanged(int row) { if (!video) return; // immediately show the loading widget - videoWidget->hide(); - loadingWidget->setVideo(video); - loadingWidget->show(); + videoAreaWidget->showLoading(video); mediaObject->pause(); diff --git a/src/MediaView.h b/src/MediaView.h index f39097c..3ff5e30 100644 --- a/src/MediaView.h +++ b/src/MediaView.h @@ -11,6 +11,7 @@ #include "searchparams.h" #include "playlistwidget.h" #include "loadingwidget.h" +#include "videoareawidget.h" class MediaView : public QWidget, public View { Q_OBJECT @@ -85,10 +86,9 @@ private: Phonon::VideoWidget *videoWidget; // loadingWidget + VideoAreaWidget *videoAreaWidget; LoadingWidget *loadingWidget; - QNetworkReply *networkReply; - }; #endif // __MEDIAVIEW_H__ diff --git a/src/videoareawidget.cpp b/src/videoareawidget.cpp new file mode 100644 index 0000000..00d1b6f --- /dev/null +++ b/src/videoareawidget.cpp @@ -0,0 +1,46 @@ +#include "videoareawidget.h" + +VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) { + stackedLayout = new QStackedLayout(this); + setLayout(stackedLayout); +} + +void VideoAreaWidget::setVideoWidget(QWidget *videoWidget) { + this->videoWidget = videoWidget; + stackedLayout->addWidget(videoWidget); +} + +void VideoAreaWidget::setLoadingWidget(LoadingWidget *loadingWidget) { + this->loadingWidget = loadingWidget; + stackedLayout->addWidget(loadingWidget); +} + +void VideoAreaWidget::showVideo() { + stackedLayout->setCurrentWidget(videoWidget); +} + +void VideoAreaWidget::showLoading(Video *video) { + this->loadingWidget->setVideo(video); + stackedLayout->setCurrentWidget(loadingWidget); +} + +void VideoAreaWidget::mouseDoubleClickEvent(QMouseEvent *event) { + switch(event->button()) { + case Qt::LeftButton: + emit doubleClicked(); + break; + case Qt::RightButton: + + break; + } +} + +void VideoAreaWidget::mousePressEvent(QMouseEvent *event) { + switch(event->button()) { + case Qt::LeftButton: + break; + case Qt::RightButton: + emit rightClicked(); + break; + } +} diff --git a/src/videoareawidget.h b/src/videoareawidget.h new file mode 100644 index 0000000..1af14c5 --- /dev/null +++ b/src/videoareawidget.h @@ -0,0 +1,34 @@ +#ifndef VIDEOAREAWIDGET_H +#define VIDEOAREAWIDGET_H + +#include +#include "video.h" +#include "loadingwidget.h" + +class VideoAreaWidget : public QWidget { + + Q_OBJECT + +public: + VideoAreaWidget(QWidget *parent); + void setVideoWidget(QWidget *videoWidget); + void setLoadingWidget(LoadingWidget *loadingWidget); + void showLoading(Video* video); + void showVideo(); + +signals: + void doubleClicked(); + void rightClicked(); + +protected: + void mouseDoubleClickEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); + +private: + QStackedLayout *stackedLayout; + QWidget *videoWidget; + LoadingWidget *loadingWidget; + +}; + +#endif // VIDEOAREAWIDGET_H -- 2.39.5