src/loadingwidget.h \
src/videoareawidget.h \
src/autocomplete.h \
- src/videowidget.h \
src/videodefinition.h \
src/fontutils.h \
src/globalshortcuts.h \
src/loadingwidget.cpp \
src/videoareawidget.cpp \
src/autocomplete.cpp \
- src/videowidget.cpp \
src/videodefinition.cpp \
src/constants.cpp \
src/fontutils.cpp \
#else
#include "searchlineedit.h"
#endif
+#include <iostream>
static MainWindow *singleton = 0;
}
MainWindow::MainWindow() :
+ updateChecker(0),
aboutView(0),
downloadView(0),
mediaObject(0),
audioOutput(0),
- m_fullscreen(false),
- updateChecker(0) {
+ m_fullscreen(false) {
singleton = this;
setAcceptDrops(true);
mouseTimer = new QTimer(this);
- mouseTimer->setInterval(3000);
+ mouseTimer->setInterval(5000);
mouseTimer->setSingleShot(true);
connect(mouseTimer, SIGNAL(timeout()), SLOT(hideMouse()));
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
-#ifdef Q_WS_X11
- if (event->type() == QEvent::MouseMove && this->m_fullscreen) {
- QMouseEvent *mouseEvent = static_cast<QMouseEvent*> (event);
- int x = mouseEvent->pos().x();
- int y = mouseEvent->pos().y();
-
- if (y < 0 && (obj == this->mainToolBar || !(y <= 10-this->mainToolBar->height() && y >= 0-this->mainToolBar->height() )))
- this->mainToolBar->setVisible(false);
- if (x < 0)
- this->mediaView->setPlaylistVisible(false);
- }
-#endif
-#ifndef Q_WS_X11
- // mac::IsFullScreen(winId())
- if (event->type() == QEvent::MouseMove && m_fullscreen) {
-
- // show the normal cursor
- unsetCursor();
- // then hide it again after a few seconds
- mouseTimer->start();
+ if (m_fullscreen && event->type() == QEvent::MouseMove) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*> (event);
const int x = mouseEvent->pos().x();
const QString className = QString(obj->metaObject()->className());
- const bool isHoveringVideo = className == "QGLWidget";
- // qDebug() << obj << x << isHoveringVideo << mediaView->isPlaylistVisible();
+ const bool isHoveringVideo = (className == "QGLWidget") || (className == "VideoAreaWidget");
+
+ // qDebug() << obj << mouseEvent->pos() << isHoveringVideo << mediaView->isPlaylistVisible();
+
if (mediaView->isPlaylistVisible()) {
if (isHoveringVideo && x > 5) mediaView->setPlaylistVisible(false);
} else {
- bool visible = (isHoveringVideo && x >= 0 && x < 5);
- mediaView->setPlaylistVisible(visible);
+ if (isHoveringVideo && x >= 0 && x < 5) mediaView->setPlaylistVisible(true);
+ }
+
+#ifndef APP_MAC
+ const int y = mouseEvent->pos().y();
+ if (mainToolBar->isVisible()) {
+ if (isHoveringVideo && y > 5) mainToolBar->setVisible(false);
+ } else {
+ if (isHoveringVideo && y >= 0 && y < 5) mainToolBar->setVisible(true);
}
- }
#endif
+ // show the normal cursor
+ unsetCursor();
+ // then hide it again after a few seconds
+ mouseTimer->start();
+
+ }
+
if (event->type() == QEvent::ToolTip) {
// kill tooltips
return true;
}
void MainWindow::searchFocus() {
- QWidget *view = views->currentWidget();
toolbarSearch->selectAll();
toolbarSearch->setFocus();
}
if (skipAct->isEnabled()) skipAct->trigger();
} else if (message == "--previous") {
if (skipBackwardAct->isEnabled()) skipBackwardAct->trigger();
+ } else if (message.startsWith("--")) {
+ MainWindow::printHelp();
} else if (!message.isEmpty()) {
SearchParams *searchParams = new SearchParams();
searchParams->setKeywords(message);
void MainWindow::hideMouse() {
setCursor(Qt::BlankCursor);
mediaView->setPlaylistVisible(false);
+#ifndef APP_MAC
+ mainToolBar->setVisible(false);
+#endif
+}
+
+void MainWindow::printHelp() {
+ QString msg = QString("%1 %2\n\n").arg(Constants::NAME, Constants::VERSION);
+ msg += "Usage: minitube [options]\n";
+ msg += "Options:\n";
+ msg += " --toggle-playing\t";
+ msg += "Start or pause playback.\n";
+ msg += " --next\t\t";
+ msg += "Skip to the next video.\n";
+ msg += " --previous\t\t";
+ msg += "Go back to the previous video.\n";
+ std::cout << msg.toLocal8Bit().data();
}
Phonon::SeekSlider* getSeekSlider() { return seekSlider; }
void readSettings();
void writeSettings();
+ static void printHelp();
public slots:
void showMedia(SearchParams *params);
videoAreaWidget = new VideoAreaWidget(this);
// videoAreaWidget->setMinimumSize(320,240);
-
-#ifdef APP_MAC
- // mouse autohide does not work on the Mac (no mouseMoveEvent)
videoWidget = new Phonon::VideoWidget(this);
-#else
- videoWidget = new VideoWidget(this);
-#endif
-
videoAreaWidget->setVideoWidget(videoWidget);
videoAreaWidget->setListModel(listModel);
QtSingleApplication app(argc, argv);
QString message = app.arguments().size() > 1 ? app.arguments().at(1) : "";
+ if (message == "--help") {
+ MainWindow::printHelp();
+ return 0;
+ }
+
if (app.sendMessage(message))
return 0;
if (app.arguments().size() > 1) {
QString query = app.arguments().at(1);
- SearchParams *searchParams = new SearchParams();
- searchParams->setKeywords(query);
- mainWin.showMedia(searchParams);
+ if (query.startsWith("--")) {
+ mainWin.messageReceived(query);
+ return 0;
+ } else {
+ SearchParams *searchParams = new SearchParams();
+ searchParams->setKeywords(query);
+ mainWin.showMedia(searchParams);
+ }
}
// Seed random number generator
listModel->setActiveRow(row);
event->acceptProposedAction();
}
-
-void VideoAreaWidget::mouseMoveEvent(QMouseEvent *event) {
- QWidget::mouseMoveEvent(event);
-
-#ifdef Q_WS_X11
- 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 <= 10;
- bool ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenToolbar", Qt::DirectConnection, Q_ARG(bool, visible));
- if (!ret) qDebug() << "showFullscreenToolbar invokeMethod failed";
-
- visible = x <= 10;
- ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenPlaylist", Qt::DirectConnection, Q_ARG(bool, visible));
- if (!ret) qDebug() << "showFullscreenPlaylist invokeMethod failed";
-#endif
-}
-
-void VideoAreaWidget::leaveEvent(QMouseEvent *event) {
- QWidget::leaveEvent(event);
-
-#ifdef Q_WS_X11
- QWidget* mainWindow = window();
- if (!mainWindow->isFullScreen()) return;
-
- bool visible = false;
- bool ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenToolbar", Qt::DirectConnection, Q_ARG(bool, visible));
- if (!ret) qDebug() << "showFullscreenToolbar invokeMethod failed";
-
- ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenPlaylist", Qt::DirectConnection, Q_ARG(bool, visible));
- if (!ret) qDebug() << "showFullscreenPlaylist invokeMethod failed";
-#endif
-}
void mousePressEvent(QMouseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void leaveEvent(QMouseEvent *event);
private slots:
void hideSnapshotPreview();
+++ /dev/null
-#include "videowidget.h"
-
-VideoWidget::VideoWidget(QWidget *parent) : Phonon::VideoWidget(parent) {
- // mouse autohide
- setMouseTracking(true);
- mouseTimer = new QTimer(this);
- mouseTimer->setInterval(3000);
- mouseTimer->setSingleShot(true);
- connect(mouseTimer, SIGNAL(timeout()), SLOT(hideMouse()));
-}
-
-void VideoWidget::mouseMoveEvent(QMouseEvent *event) {
- QWidget::mouseMoveEvent(event);
-
- // qDebug() << "VideoWidget::mouseMoveEvent" << event->pos();
-
- // show the normal cursor
- unsetCursor();
-
- // then hide it again after a few seconds
- mouseTimer->start();
-}
-
-void VideoWidget::hideMouse() {
- // qDebug() << "hideMouse()";
- setCursor(Qt::BlankCursor);
-}
+++ /dev/null
-#ifndef VIDEOWIDGET_H
-#define VIDEOWIDGET_H
-
-#include <QtGui>
-#include <phonon/videowidget.h>
-#include <QTimer>
-
-class VideoWidget : public Phonon::VideoWidget {
-
- Q_OBJECT
-
-public:
- VideoWidget(QWidget *parent);
-
-protected:
- void mouseMoveEvent (QMouseEvent *event);
-
-private slots:
- void hideMouse();
-
-private:
- QTimer *mouseTimer;
-
-};
-
-#endif // VIDEOWIDGET_H