#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(5000);
+ mouseTimer->setSingleShot(true);
+ connect(mouseTimer, SIGNAL(timeout()), SLOT(hideMouse()));
+
QTimer::singleShot(0, this, SLOT(checkForUpdate()));
}
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
-#ifdef Q_WS_X11
- if (event->type() == QEvent::MouseMove && this->m_fullscreen) {
+
+ if (m_fullscreen && event->type() == QEvent::MouseMove) {
+
QMouseEvent *mouseEvent = static_cast<QMouseEvent*> (event);
- int x = mouseEvent->pos().x();
- int y = mouseEvent->pos().y();
+ const int x = mouseEvent->pos().x();
+ const QString className = QString(obj->metaObject()->className());
+ const bool isHoveringVideo = (className == "QGLWidget") || (className == "VideoAreaWidget");
- 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);
- }
+ // qDebug() << obj << mouseEvent->pos() << isHoveringVideo << mediaView->isPlaylistVisible();
+
+ if (mediaView->isPlaylistVisible()) {
+ if (isHoveringVideo && x > 5) mediaView->setPlaylistVisible(false);
+ } else {
+ 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;
}
// standard event processing
- return QObject::eventFilter(obj, event);
+ return QMainWindow::eventFilter(obj, event);
}
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);
actions->insert("facebook", action);
connect(action, SIGNAL(triggered()), mediaView, SLOT(shareViaFacebook()));
+ action = new QAction("&Buffer", this);
+ action->setStatusTip(shareTip.arg("Buffer"));
+ actions->insert("buffer", action);
+ connect(action, SIGNAL(triggered()), mediaView, SLOT(shareViaBuffer()));
+
action = new QAction(tr("&Email"), this);
action->setStatusTip(shareTip.arg(tr("Email")));
actions->insert("email", action);
actions->insert("stopafterthis", action);
connect(action, SIGNAL(toggled(bool)), SLOT(showStopAfterThisInStatusBar(bool)));
+ action = new QAction(tr("&Report an Issue..."), this);
+ actions->insert("report-issue", action);
+ connect(action, SIGNAL(triggered()), SLOT(reportIssue()));
+
+ action = new QAction(tr("&Refine Search..."), this);
+ action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
+ action->setCheckable(true);
+ actions->insert("refine-search", action);
+
// common action properties
foreach (QAction *action, actions->values()) {
playlistMenu->addSeparator();
playlistMenu->addAction(moveUpAct);
playlistMenu->addAction(moveDownAct);
+ playlistMenu->addSeparator();
+ playlistMenu->addAction(The::globalActions()->value("refine-search"));
QMenu* videoMenu = menuBar()->addMenu(tr("&Video"));
menus->insert("video", videoMenu);
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);
shareMenu->addSeparator();
shareMenu->addAction(The::globalActions()->value("twitter"));
shareMenu->addAction(The::globalActions()->value("facebook"));
+ shareMenu->addAction(The::globalActions()->value("buffer"));
+ shareMenu->addSeparator();
shareMenu->addAction(The::globalActions()->value("email"));
#ifdef APP_MAC
#if !defined(APP_MAC) && !defined(APP_WIN)
helpMenu->addAction(donateAct);
#endif
+ helpMenu->addAction(The::globalActions()->value("report-issue"));
helpMenu->addAction(aboutAct);
}
The::globalActions()->value("twitter")->setEnabled(widget == mediaView);
The::globalActions()->value("facebook")->setEnabled(widget == mediaView);
+ The::globalActions()->value("buffer")->setEnabled(widget == mediaView);
The::globalActions()->value("email")->setEnabled(widget == mediaView);
aboutAct->setEnabled(widget != aboutView);
QDesktopServices::openUrl(url);
}
+void MainWindow::reportIssue() {
+ QUrl url("http://flavio.tordini.org/forums/forum/minitube-forums/minitube-troubleshooting");
+ QDesktopServices::openUrl(url);
+}
+
void MainWindow::quit() {
#ifdef APP_MAC
if (!confirmQuit()) {
if (views->currentWidget() == mediaView)
mediaView->setFocus();
+
+ if (m_fullscreen) {
+ hideMouse();
+ } else {
+ mouseTimer->stop();
+ unsetCursor();
+ }
}
void MainWindow::compactView(bool enable) {
}
void MainWindow::searchFocus() {
- QWidget *view = views->currentWidget();
toolbarSearch->selectAll();
toolbarSearch->setFocus();
}
}
void MainWindow::startToolbarSearch(QString query) {
-
query = query.trimmed();
// check for empty query
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);
showMedia(searchParams);
}
}
+
+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();
+}