]> git.sur5r.net Git - minitube/blobdiff - src/videoareawidget.cpp
Imported Upstream version 2.1.3
[minitube] / src / videoareawidget.cpp
index 695070f7141c2eb195ee42d5d0e9a07ce9b527a8..14a57187b09d2af07c2fe810d8523cfe33063304 100644 (file)
@@ -1,8 +1,32 @@
+/* $BEGIN_LICENSE
+
+This file is part of Minitube.
+Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
+
+Minitube is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Minitube is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
+
+$END_LICENSE */
+
 #include "videoareawidget.h"
 #include "videomimedata.h"
-#ifndef Q_WS_X11
+#include "mainwindow.h"
+#ifdef APP_EXTRA
 #include "extra.h"
 #endif
+#ifdef Q_WS_MAC
+#include "macutils.h"
+#endif
 
 VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
     QBoxLayout *vLayout = new QVBoxLayout(this);
@@ -28,11 +52,12 @@ VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
     stackedLayout = new QStackedLayout();
     vLayout->addLayout(stackedLayout);
 
-    snapshotPreview = new QLabel(this);
-    stackedLayout->addWidget(snapshotPreview);
+    // snapshotPreview = new QLabel(this);
+    // stackedLayout->addWidget(snapshotPreview);
     
-    setAcceptDrops(true);    
+    setAcceptDrops(true);
     setMouseTracking(true);
+    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 }
 
 void VideoAreaWidget::setVideoWidget(QWidget *videoWidget) {
@@ -44,10 +69,12 @@ void VideoAreaWidget::setVideoWidget(QWidget *videoWidget) {
 void VideoAreaWidget::setLoadingWidget(LoadingWidget *loadingWidget) {
     this->loadingWidget = loadingWidget;
     stackedLayout->addWidget(loadingWidget);
+    stackedLayout->setCurrentWidget(loadingWidget);
 }
 
 void VideoAreaWidget::showVideo() {
     stackedLayout->setCurrentWidget(videoWidget);
+    loadingWidget->clear();
 }
 
 void VideoAreaWidget::showError(QString message) {
@@ -58,16 +85,17 @@ void VideoAreaWidget::showError(QString message) {
 }
 
 void VideoAreaWidget::showLoading(Video *video) {
-    stackedLayout->setCurrentWidget(loadingWidget);
-    this->loadingWidget->setVideo(video);
     messageLabel->hide();
     messageLabel->clear();
+    stackedLayout->setCurrentWidget(loadingWidget);
+    loadingWidget->setVideo(video);
 }
 
+/*
 void VideoAreaWidget::showSnapshotPreview(QPixmap pixmap) {
     snapshotPreview->setPixmap(pixmap);
     stackedLayout->setCurrentWidget(snapshotPreview);
-#ifndef Q_WS_X11
+#ifdef APP_EXTRA
     Extra::flashInWidget(snapshotPreview);
 #endif
     QTimer::singleShot(1500, this, SLOT(hideSnapshotPreview()));
@@ -76,13 +104,14 @@ void VideoAreaWidget::showSnapshotPreview(QPixmap pixmap) {
 void VideoAreaWidget::hideSnapshotPreview() {
     stackedLayout->setCurrentWidget(videoWidget);
 }
+*/
 
 void VideoAreaWidget::clear() {
-    stackedLayout->setCurrentWidget(loadingWidget);
     loadingWidget->clear();
     messageLabel->hide();
     messageLabel->clear();
-    snapshotPreview->clear();
+    // snapshotPreview->clear();
+    stackedLayout->setCurrentWidget(loadingWidget);
 }
 
 void VideoAreaWidget::mouseDoubleClickEvent(QMouseEvent *event) {
@@ -95,6 +124,29 @@ void VideoAreaWidget::mousePressEvent(QMouseEvent *event) {
 
     if(event->button() == Qt::RightButton)
         emit rightClicked();
+
+    else if (event->button() == Qt::LeftButton) {
+        bool isNormalWindow = !window()->isMaximized() &&
+                !MainWindow::instance()->isReallyFullScreen();
+        if (isNormalWindow) {
+            dragPosition = event->globalPos() - window()->frameGeometry().topLeft();
+            event->accept();
+        }
+    }
+}
+
+void VideoAreaWidget::mouseMoveEvent(QMouseEvent *event) {
+    bool isNormalWindow = !window()->isMaximized() &&
+            !MainWindow::instance()->isReallyFullScreen();
+    if (event->buttons() & Qt::LeftButton && isNormalWindow) {
+        QPoint p = event->globalPos() - dragPosition;
+#ifdef Q_WS_MAC
+        mac::moveWindowTo(window()->winId(), p.x(), p.y());
+#else
+        window()->move(p);
+#endif
+        event->accept();
+    }
 }
 
 void VideoAreaWidget::dragEnterEvent(QDragEnterEvent *event) {