]> git.sur5r.net Git - minitube/commitdiff
Fixed toggling of loading and video widgets
authorFlavio Tordini <flavio.tordini@gmail.com>
Thu, 25 Jun 2009 14:02:04 +0000 (16:02 +0200)
committerFlavio Tordini <flavio.tordini@gmail.com>
Thu, 25 Jun 2009 14:02:04 +0000 (16:02 +0200)
Also fixed full screen mode

minitube.pro
src/MediaView.cpp
src/MediaView.h
src/videoareawidget.cpp [new file with mode: 0644]
src/videoareawidget.h [new file with mode: 0644]

index ea3b061502d83582e2500992f8b4953808952f7a..c6a09a3263cc672ef5b796fcec33cb55061e65b7 100755 (executable)
@@ -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
 }
index 99641ecd5e12a4a67413abf1123cb89a45195bdd..381edac6c50094b2298352c181b757a4e97ed7df 100644 (file)
@@ -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<int> 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();
 
index f39097cbf13078a91a522641aa9bfb7342609840..3ff5e30022e88c46b4bf2f1183526088dc9db97b 100644 (file)
@@ -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 (file)
index 0000000..00d1b6f
--- /dev/null
@@ -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 (file)
index 0000000..1af14c5
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef VIDEOAREAWIDGET_H
+#define VIDEOAREAWIDGET_H
+
+#include <QWidget>
+#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