]> git.sur5r.net Git - minitube/commitdiff
Tentative snapshot impl. Phonon is broken so feature stays disabled.
authorFlavio <flavio@odisseo.local>
Tue, 24 Jul 2012 16:16:33 +0000 (18:16 +0200)
committerFlavio <flavio@odisseo.local>
Tue, 24 Jul 2012 16:16:33 +0000 (18:16 +0200)
src/MainWindow.cpp
src/MediaView.cpp
src/MediaView.h
src/videoareawidget.cpp
src/videoareawidget.h
src/videowidget.cpp

index 5f3ee91cd63a62fa22810a140662efd8462750bb..e9b6a0bf05042062e5a9f6043cb82c5023c40950 100644 (file)
@@ -388,6 +388,13 @@ void MainWindow::createActions() {
     connect(action, SIGNAL(triggered()), mediaView, SLOT(downloadVideo()));
     actions->insert("download", action);
 
+    /*
+    action = new QAction(tr("&Snapshot"), this);
+    action->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_S));
+    actions->insert("snapshot", action);
+    connect(action, SIGNAL(triggered()), mediaView, SLOT(snapshot()));
+    */
+
     QString shareTip = tr("Share the current video using %1");
 
     action = new QAction("&Twitter", this);
@@ -507,11 +514,12 @@ void MainWindow::createMenus() {
     videoMenu->addAction(findVideoPartsAct);
     videoMenu->addSeparator();
     videoMenu->addAction(webPageAct);
-#ifndef APP_NO_DOWNLOADS
     videoMenu->addSeparator();
+#ifndef APP_NO_DOWNLOADS
     videoMenu->addAction(The::globalActions()->value("download"));
-    videoMenu->addAction(copyLinkAct);
+    // videoMenu->addAction(copyLinkAct);
 #endif
+    // videoMenu->addAction(The::globalActions()->value("snapshot"));
 
     QMenu* viewMenu = menuBar()->addMenu(tr("&View"));
     menus->insert("view", viewMenu);
index dcfd0549f1472ce42f0b82b5b8f2d8eecce81854..f4ef7275375b97d3f2e1a00d5b7127ecb464620c 100644 (file)
@@ -76,7 +76,7 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) {
     videoAreaWidget = new VideoAreaWidget(this);
     // videoAreaWidget->setMinimumSize(320,240);
 
-#ifdef APP_MAC
+#ifdef APP_MAC_NO
     // mouse autohide does not work on the Mac (no mouseMoveEvent)
     videoWidget = new Phonon::VideoWidget(this);
 #else
@@ -703,6 +703,15 @@ void MediaView::downloadVideo() {
     if (mainWindow) mainWindow->statusBar()->showMessage(message);
 }
 
+void MediaView::snapshot() {
+    QImage image = videoWidget->snapshot();
+    qDebug() << image.size();
+
+    const QPixmap& pixmap = QPixmap::grabWindow(videoWidget->winId());
+    // qDebug() << pixmap.size();
+    videoAreaWidget->showSnapshotPreview(pixmap);
+}
+
 void MediaView::fullscreen() {
     videoAreaWidget->setParent(0);
     videoAreaWidget->showFullScreen();
index 9a56597dfcc9aa7acb522a096ce69bd9cb217f52..a69bef3467954867a1ef377ac54b37c2b257bd29 100644 (file)
@@ -62,6 +62,7 @@ public slots:
     void setPlaylistVisible(bool visible=true);
     void saveSplitterState();
     void downloadVideo();
+    void snapshot();
     void fullscreen();
     void findVideoParts();
 
index bf2ae03312302b58f33557e840aa6249196bbea0..0efdbb4ec96cc5c0159bf013abc74e0e889fd768 100644 (file)
@@ -1,5 +1,8 @@
 #include "videoareawidget.h"
 #include "videomimedata.h"
+#ifndef Q_WS_X11
+#include "extra.h"
+#endif
 
 VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
     QBoxLayout *vLayout = new QVBoxLayout(this);
@@ -26,6 +29,9 @@ VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
     
     stackedLayout = new QStackedLayout();
     vLayout->addLayout(stackedLayout);
+
+    snapshotPreview = new QLabel(this);
+    stackedLayout->addWidget(snapshotPreview);
     
     setLayout(vLayout);
     setAcceptDrops(true);
@@ -62,11 +68,25 @@ void VideoAreaWidget::showLoading(Video *video) {
     messageLabel->clear();
 }
 
+void VideoAreaWidget::showSnapshotPreview(QPixmap pixmap) {
+    snapshotPreview->setPixmap(pixmap);
+    stackedLayout->setCurrentWidget(snapshotPreview);
+#ifndef Q_WS_X11
+    Extra::flashInWidget(snapshotPreview);
+#endif
+    QTimer::singleShot(1500, this, SLOT(hideSnapshotPreview()));
+}
+
+void VideoAreaWidget::hideSnapshotPreview() {
+    stackedLayout->setCurrentWidget(videoWidget);
+}
+
 void VideoAreaWidget::clear() {
     stackedLayout->setCurrentWidget(loadingWidget);
     loadingWidget->clear();
     messageLabel->hide();
     messageLabel->clear();
+    snapshotPreview->clear();
 }
 
 void VideoAreaWidget::mouseDoubleClickEvent(QMouseEvent *event) {
index 60112f56fdddbf6b67f967be0c3778f589f18bb2..7d318c1d66ab0e0c0266f0a410283952faadc5a7 100644 (file)
@@ -21,6 +21,7 @@ public:
     void setListModel(ListModel *listModel) {
         this->listModel = listModel;
     }
+    void showSnapshotPreview(QPixmap pixmap);
 
 signals:
     void doubleClicked();
@@ -34,12 +35,16 @@ protected:
     void mouseMoveEvent(QMouseEvent *event);
     void leaveEvent(QMouseEvent *event);
 
+private slots:
+    void hideSnapshotPreview();
+
 private:
     QStackedLayout *stackedLayout;
     QWidget *videoWidget;
     LoadingWidget *loadingWidget;
     ListModel *listModel;
     QLabel *messageLabel;
+    QLabel *snapshotPreview;
 
 };
 
index ed6d689f964c3746adba1a1b869e575be0950789..df59365a59c827512b126fa602b8747fb8a149ee 100644 (file)
@@ -10,7 +10,7 @@ VideoWidget::VideoWidget(QWidget *parent) : Phonon::VideoWidget(parent) {
 }
 
 void VideoWidget::mouseMoveEvent(QMouseEvent *event) {
-    Phonon::VideoWidget::mouseMoveEvent(event);
+    QWidget::mouseMoveEvent(event);
 
     // qDebug() << "VideoWidget::mouseMoveEvent" << event->pos();