1 #include "MainWindow.h"
4 #include "iconloader/qticonloader.h"
6 #include "videodefinition.h"
8 #include "globalshortcuts.h"
10 #include "gnomeglobalshortcutbackend.h"
13 #include "mac_startup.h"
14 #include "macfullscreen.h"
15 #include "macsupport.h"
21 #include "downloadmanager.h"
22 #include "youtubesuggest.h"
23 #include "updatechecker.h"
25 #include "demostartupview.h"
27 #include "temporary.h"
29 #include "searchlineedit_mac.h"
31 #include "searchlineedit.h"
34 static MainWindow *singleton = 0;
36 MainWindow* MainWindow::instance() {
37 if (!singleton) singleton = new MainWindow();
41 MainWindow::MainWindow() :
52 history = new QStack<QWidget*>();
53 views = new QStackedWidget(this);
54 setCentralWidget(views);
57 searchView = new SearchView(this);
58 connect(searchView, SIGNAL(search(SearchParams*)), this, SLOT(showMedia(SearchParams*)));
59 views->addWidget(searchView);
61 mediaView = new MediaView(this);
62 mediaView->setEnabled(false);
63 views->addWidget(mediaView);
72 mediaView->setSlider(seekSlider);
73 mediaView->setMediaObject(mediaObject);
75 // remove that useless menu/toolbar context menu
76 this->setContextMenuPolicy(Qt::NoContextMenu);
78 // mediaView init stuff thats needs actions
79 mediaView->initialize();
81 // event filter to block ugly toolbar tooltips
82 qApp->installEventFilter(this);
84 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
86 // restore window position
89 // fix stacked widget minimum size
90 for (int i = 0; i < views->count(); i++) {
91 QWidget* view = views->widget(i);
92 if (view) view->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
96 // show the initial view
98 QWidget *demoStartupView = new DemoStartupView(this);
99 views->addWidget(demoStartupView);
100 showWidget(demoStartupView);
106 GlobalShortcuts &shortcuts = GlobalShortcuts::instance();
108 if (GnomeGlobalShortcutBackend::IsGsdAvailable())
109 shortcuts.setBackend(new GnomeGlobalShortcutBackend(&shortcuts));
114 connect(&shortcuts, SIGNAL(PlayPause()), pauseAct, SLOT(trigger()));
115 connect(&shortcuts, SIGNAL(Stop()), this, SLOT(stop()));
116 connect(&shortcuts, SIGNAL(Next()), skipAct, SLOT(trigger()));
117 connect(&shortcuts, SIGNAL(Previous()), skipBackwardAct, SLOT(trigger()));
118 // connect(&shortcuts, SIGNAL(StopAfter()), The::globalActions()->value("stopafterthis"), SLOT(toggle()));
120 connect(DownloadManager::instance(), SIGNAL(statusMessageChanged(QString)),
121 SLOT(updateDownloadMessage(QString)));
122 connect(DownloadManager::instance(), SIGNAL(finished()),
123 SLOT(downloadsFinished()));
125 setAcceptDrops(true);
127 QTimer::singleShot(0, this, SLOT(checkForUpdate()));
131 MainWindow::~MainWindow() {
135 void MainWindow::changeEvent(QEvent* event) {
137 if (event->type() == QEvent::WindowStateChange) {
138 The::globalActions()->value("minimize")->setEnabled(!isMinimized());
141 QMainWindow::changeEvent(event);
144 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
146 if (event->type() == QEvent::MouseMove && this->m_fullscreen) {
147 QMouseEvent *mouseEvent = static_cast<QMouseEvent*> (event);
148 int x = mouseEvent->pos().x();
149 int y = mouseEvent->pos().y();
151 if (y < 0 && (obj == this->mainToolBar || !(y <= 10-this->mainToolBar->height() && y >= 0-this->mainToolBar->height() )))
152 this->mainToolBar->setVisible(false);
154 this->mediaView->setPlaylistVisible(false);
158 if (event->type() == QEvent::ToolTip) {
162 // standard event processing
163 return QObject::eventFilter(obj, event);
166 void MainWindow::createActions() {
168 QMap<QString, QAction*> *actions = The::globalActions();
170 stopAct = new QAction(QtIconLoader::icon("media-playback-stop"), tr("&Stop"), this);
171 stopAct->setStatusTip(tr("Stop playback and go back to the search view"));
172 stopAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::Key_MediaStop));
173 stopAct->setEnabled(false);
174 actions->insert("stop", stopAct);
175 connect(stopAct, SIGNAL(triggered()), this, SLOT(stop()));
177 skipBackwardAct = new QAction(
178 QtIconLoader::icon("media-skip-backward"),
179 tr("P&revious"), this);
180 skipBackwardAct->setStatusTip(tr("Go back to the previous track"));
181 skipBackwardAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Left));
182 #if QT_VERSION >= 0x040600
183 skipBackwardAct->setPriority(QAction::LowPriority);
185 skipBackwardAct->setEnabled(false);
186 actions->insert("previous", skipBackwardAct);
187 connect(skipBackwardAct, SIGNAL(triggered()), mediaView, SLOT(skipBackward()));
189 skipAct = new QAction(QtIconLoader::icon("media-skip-forward"), tr("S&kip"), this);
190 skipAct->setStatusTip(tr("Skip to the next video"));
191 skipAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::CTRL + Qt::Key_Right) << QKeySequence(Qt::Key_MediaNext));
192 skipAct->setEnabled(false);
193 actions->insert("skip", skipAct);
194 connect(skipAct, SIGNAL(triggered()), mediaView, SLOT(skip()));
196 pauseAct = new QAction(QtIconLoader::icon("media-playback-pause"), tr("&Pause"), this);
197 pauseAct->setStatusTip(tr("Pause playback"));
198 pauseAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_Space) << QKeySequence(Qt::Key_MediaPlay));
199 pauseAct->setEnabled(false);
200 actions->insert("pause", pauseAct);
201 connect(pauseAct, SIGNAL(triggered()), mediaView, SLOT(pause()));
203 fullscreenAct = new QAction(QtIconLoader::icon("view-fullscreen"), tr("&Full Screen"), this);
204 fullscreenAct->setStatusTip(tr("Go full screen"));
205 QList<QKeySequence> fsShortcuts;
207 fsShortcuts << QKeySequence(Qt::CTRL + Qt::META + Qt::Key_F);
209 fsShortcuts << QKeySequence(Qt::Key_F11) << QKeySequence(Qt::ALT + Qt::Key_Return);
211 fullscreenAct->setShortcuts(fsShortcuts);
212 fullscreenAct->setShortcutContext(Qt::ApplicationShortcut);
213 #if QT_VERSION >= 0x040600
214 fullscreenAct->setPriority(QAction::LowPriority);
216 actions->insert("fullscreen", fullscreenAct);
217 connect(fullscreenAct, SIGNAL(triggered()), this, SLOT(fullscreen()));
219 compactViewAct = new QAction(tr("&Compact Mode"), this);
220 compactViewAct->setStatusTip(tr("Hide the playlist and the toolbar"));
222 compactViewAct->setShortcut(QKeySequence(Qt::CTRL + Qt::META + Qt::Key_C));
224 compactViewAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C));
226 compactViewAct->setCheckable(true);
227 compactViewAct->setChecked(false);
228 compactViewAct->setEnabled(false);
229 actions->insert("compactView", compactViewAct);
230 connect(compactViewAct, SIGNAL(toggled(bool)), this, SLOT(compactView(bool)));
232 webPageAct = new QAction(tr("Open the &YouTube Page"), this);
233 webPageAct->setStatusTip(tr("Go to the YouTube video page and pause playback"));
234 webPageAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Y));
235 webPageAct->setEnabled(false);
236 actions->insert("webpage", webPageAct);
237 connect(webPageAct, SIGNAL(triggered()), mediaView, SLOT(openWebPage()));
239 copyPageAct = new QAction(tr("Copy the YouTube &Link"), this);
240 copyPageAct->setStatusTip(tr("Copy the current video YouTube link to the clipboard"));
241 copyPageAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
242 copyPageAct->setEnabled(false);
243 actions->insert("pagelink", copyPageAct);
244 connect(copyPageAct, SIGNAL(triggered()), mediaView, SLOT(copyWebPage()));
246 copyLinkAct = new QAction(tr("Copy the Video Stream &URL"), this);
247 copyLinkAct->setStatusTip(tr("Copy the current video stream URL to the clipboard"));
248 copyLinkAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U));
249 copyLinkAct->setEnabled(false);
250 actions->insert("videolink", copyLinkAct);
251 connect(copyLinkAct, SIGNAL(triggered()), mediaView, SLOT(copyVideoLink()));
253 findVideoPartsAct = new QAction(tr("Find Video &Parts"), this);
254 findVideoPartsAct->setStatusTip(tr("Find other video parts hopefully in the right order"));
255 findVideoPartsAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
256 findVideoPartsAct->setEnabled(false);
257 connect(findVideoPartsAct, SIGNAL(triggered()), mediaView, SLOT(findVideoParts()));
258 actions->insert("findVideoParts", findVideoPartsAct);
260 removeAct = new QAction(tr("&Remove"), this);
261 removeAct->setStatusTip(tr("Remove the selected videos from the playlist"));
262 removeAct->setShortcuts(QList<QKeySequence>() << QKeySequence("Del") << QKeySequence("Backspace"));
263 removeAct->setEnabled(false);
264 actions->insert("remove", removeAct);
265 connect(removeAct, SIGNAL(triggered()), mediaView, SLOT(removeSelected()));
267 moveUpAct = new QAction(tr("Move &Up"), this);
268 moveUpAct->setStatusTip(tr("Move up the selected videos in the playlist"));
269 moveUpAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up));
270 moveUpAct->setEnabled(false);
271 actions->insert("moveUp", moveUpAct);
272 connect(moveUpAct, SIGNAL(triggered()), mediaView, SLOT(moveUpSelected()));
274 moveDownAct = new QAction(tr("Move &Down"), this);
275 moveDownAct->setStatusTip(tr("Move down the selected videos in the playlist"));
276 moveDownAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down));
277 moveDownAct->setEnabled(false);
278 actions->insert("moveDown", moveDownAct);
279 connect(moveDownAct, SIGNAL(triggered()), mediaView, SLOT(moveDownSelected()));
281 clearAct = new QAction(tr("&Clear Recent Searches"), this);
282 clearAct->setMenuRole(QAction::ApplicationSpecificRole);
283 clearAct->setShortcuts(QList<QKeySequence>()
284 << QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Delete)
285 << QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Backspace));
286 clearAct->setStatusTip(tr("Clear the search history. Cannot be undone."));
287 clearAct->setEnabled(true);
288 actions->insert("clearRecentKeywords", clearAct);
289 connect(clearAct, SIGNAL(triggered()), SLOT(clearRecentKeywords()));
291 quitAct = new QAction(tr("&Quit"), this);
292 quitAct->setMenuRole(QAction::QuitRole);
293 quitAct->setShortcut(QKeySequence(QKeySequence::Quit));
294 quitAct->setStatusTip(tr("Bye"));
295 actions->insert("quit", quitAct);
296 connect(quitAct, SIGNAL(triggered()), SLOT(quit()));
298 siteAct = new QAction(tr("&Website"), this);
299 siteAct->setShortcut(QKeySequence::HelpContents);
300 siteAct->setStatusTip(tr("%1 on the Web").arg(Constants::NAME));
301 actions->insert("site", siteAct);
302 connect(siteAct, SIGNAL(triggered()), this, SLOT(visitSite()));
304 #if !defined(APP_MAC) && !defined(APP_WIN)
305 donateAct = new QAction(tr("Make a &Donation"), this);
306 donateAct->setStatusTip(tr("Please support the continued development of %1").arg(Constants::NAME));
307 actions->insert("donate", donateAct);
308 connect(donateAct, SIGNAL(triggered()), this, SLOT(donate()));
311 aboutAct = new QAction(tr("&About"), this);
312 aboutAct->setMenuRole(QAction::AboutRole);
313 aboutAct->setStatusTip(tr("Info about %1").arg(Constants::NAME));
314 actions->insert("about", aboutAct);
315 connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
319 searchFocusAct = new QAction(this);
320 searchFocusAct->setShortcut(QKeySequence::Find);
321 searchFocusAct->setStatusTip(tr("Search"));
322 actions->insert("search", searchFocusAct);
323 connect(searchFocusAct, SIGNAL(triggered()), this, SLOT(searchFocus()));
324 addAction(searchFocusAct);
326 volumeUpAct = new QAction(this);
327 volumeUpAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::CTRL + Qt::Key_Plus));
328 actions->insert("volume-up", volumeUpAct);
329 connect(volumeUpAct, SIGNAL(triggered()), this, SLOT(volumeUp()));
330 addAction(volumeUpAct);
332 volumeDownAct = new QAction(this);
333 volumeDownAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::CTRL + Qt::Key_Minus));
334 actions->insert("volume-down", volumeDownAct);
335 connect(volumeDownAct, SIGNAL(triggered()), this, SLOT(volumeDown()));
336 addAction(volumeDownAct);
338 volumeMuteAct = new QAction(this);
339 volumeMuteAct->setIcon(QtIconLoader::icon("audio-volume-high"));
340 volumeMuteAct->setStatusTip(tr("Mute volume"));
341 volumeMuteAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::CTRL + Qt::Key_E));
342 actions->insert("volume-mute", volumeMuteAct);
343 connect(volumeMuteAct, SIGNAL(triggered()), SLOT(volumeMute()));
344 addAction(volumeMuteAct);
346 QAction *definitionAct = new QAction(this);
347 definitionAct->setIcon(QtIconLoader::icon("video-display"));
348 definitionAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::CTRL + Qt::Key_D));
350 QMenu *definitionMenu = new QMenu(this);
351 foreach (QString definition, VideoDefinition::getDefinitionNames()) {
352 definitionMenu->addAction(definition);
354 definitionAct->setMenu(definitionMenu);
356 actions->insert("definition", definitionAct);
357 connect(definitionAct, SIGNAL(triggered()), SLOT(toggleDefinitionMode()));
358 addAction(definitionAct);
362 action = new QAction(QtIconLoader::icon("media-playback-start"), tr("&Manually Start Playing"), this);
363 action->setStatusTip(tr("Manually start playing videos"));
364 action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B));
365 action->setCheckable(true);
366 connect(action, SIGNAL(toggled(bool)), SLOT(setManualPlay(bool)));
367 actions->insert("manualplay", action);
369 action = new QAction(tr("&Downloads"), this);
370 action->setStatusTip(tr("Show details about video downloads"));
371 action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_J));
372 action->setCheckable(true);
373 action->setIcon(QtIconLoader::icon("go-down"));
374 action->setVisible(false);
375 connect(action, SIGNAL(toggled(bool)), SLOT(toggleDownloads(bool)));
376 actions->insert("downloads", action);
378 action = new QAction(tr("&Download"), this);
379 action->setStatusTip(tr("Download the current video"));
380 #ifndef APP_NO_DOWNLOADS
381 action->setShortcut(QKeySequence::Save);
383 action->setIcon(QtIconLoader::icon("go-down"));
384 action->setEnabled(false);
385 #if QT_VERSION >= 0x040600
386 action->setPriority(QAction::LowPriority);
388 connect(action, SIGNAL(triggered()), mediaView, SLOT(downloadVideo()));
389 actions->insert("download", action);
391 QString shareTip = tr("Share the current video using %1");
393 action = new QAction("&Twitter", this);
394 action->setStatusTip(shareTip.arg("Twitter"));
395 actions->insert("twitter", action);
396 connect(action, SIGNAL(triggered()), mediaView, SLOT(shareViaTwitter()));
398 action = new QAction("&Facebook", this);
399 action->setStatusTip(shareTip.arg("Facebook"));
400 actions->insert("facebook", action);
401 connect(action, SIGNAL(triggered()), mediaView, SLOT(shareViaFacebook()));
403 action = new QAction(tr("&Email"), this);
404 action->setStatusTip(shareTip.arg(tr("Email")));
405 actions->insert("email", action);
406 connect(action, SIGNAL(triggered()), mediaView, SLOT(shareViaEmail()));
408 action = new QAction(tr("&Close"), this);
409 action->setShortcut(QKeySequence(QKeySequence::Close));
410 actions->insert("close", action);
411 connect(action, SIGNAL(triggered()), SLOT(close()));
413 action = new QAction(Constants::NAME, this);
414 action->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_1));
415 actions->insert("restore", action);
416 connect(action, SIGNAL(triggered()), SLOT(restore()));
418 action = new QAction(QtIconLoader::icon("go-top"), tr("&Float on Top"), this);
419 action->setCheckable(true);
420 actions->insert("ontop", action);
421 connect(action, SIGNAL(toggled(bool)), SLOT(floatOnTop(bool)));
423 action = new QAction(QtIconLoader::icon("media-playback-stop"), tr("&Stop After This Video"), this);
424 action->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Escape));
425 action->setCheckable(true);
426 action->setEnabled(false);
427 actions->insert("stopafterthis", action);
428 connect(action, SIGNAL(toggled(bool)), SLOT(showStopAfterThisInStatusBar(bool)));
430 // common action properties
431 foreach (QAction *action, actions->values()) {
433 // add actions to the MainWindow so that they work
434 // when the menu is hidden
438 // unexperienced users tend to keep keys pressed for a "long" time
439 action->setAutoRepeat(false);
441 // set to something more meaningful then the toolbar text
442 if (!action->statusTip().isEmpty())
443 action->setToolTip(action->statusTip());
445 // show keyboard shortcuts in the status bar
446 if (!action->shortcut().isEmpty())
447 action->setStatusTip(action->statusTip() + " (" + action->shortcut().toString(QKeySequence::NativeText) + ")");
450 action->setIconVisibleInMenu(false);
456 void MainWindow::createMenus() {
458 QMap<QString, QMenu*> *menus = The::globalMenus();
460 fileMenu = menuBar()->addMenu(tr("&Application"));
462 QAction* action = new QAction(tr("Buy %1...").arg(Constants::NAME), this);
463 action->setMenuRole(QAction::ApplicationSpecificRole);
464 connect(action, SIGNAL(triggered()), SLOT(buy()));
465 fileMenu->addAction(action);
467 fileMenu->addAction(clearAct);
469 fileMenu->addSeparator();
471 fileMenu->addAction(quitAct);
473 QMenu* playbackMenu = menuBar()->addMenu(tr("&Playback"));
474 menus->insert("playback", playbackMenu);
475 playbackMenu->addAction(pauseAct);
476 playbackMenu->addAction(stopAct);
477 playbackMenu->addAction(The::globalActions()->value("stopafterthis"));
478 playbackMenu->addSeparator();
479 playbackMenu->addAction(skipAct);
480 playbackMenu->addAction(skipBackwardAct);
481 playbackMenu->addSeparator();
482 playbackMenu->addAction(The::globalActions()->value("manualplay"));
484 MacSupport::dockMenu(playbackMenu);
487 playlistMenu = menuBar()->addMenu(tr("&Playlist"));
488 menus->insert("playlist", playlistMenu);
489 playlistMenu->addAction(removeAct);
490 playlistMenu->addSeparator();
491 playlistMenu->addAction(moveUpAct);
492 playlistMenu->addAction(moveDownAct);
494 QMenu* videoMenu = menuBar()->addMenu(tr("&Video"));
495 menus->insert("video", videoMenu);
496 videoMenu->addAction(findVideoPartsAct);
497 videoMenu->addSeparator();
498 videoMenu->addAction(webPageAct);
499 #ifndef APP_NO_DOWNLOADS
500 videoMenu->addSeparator();
501 videoMenu->addAction(The::globalActions()->value("download"));
502 videoMenu->addAction(copyLinkAct);
505 QMenu* viewMenu = menuBar()->addMenu(tr("&View"));
506 menus->insert("view", viewMenu);
507 viewMenu->addAction(fullscreenAct);
508 viewMenu->addAction(compactViewAct);
509 viewMenu->addSeparator();
510 viewMenu->addAction(The::globalActions()->value("ontop"));
512 QMenu* shareMenu = menuBar()->addMenu(tr("&Share"));
513 menus->insert("share", shareMenu);
514 shareMenu->addAction(copyPageAct);
515 shareMenu->addSeparator();
516 shareMenu->addAction(The::globalActions()->value("twitter"));
517 shareMenu->addAction(The::globalActions()->value("facebook"));
518 shareMenu->addAction(The::globalActions()->value("email"));
521 MacSupport::windowMenu(this);
524 helpMenu = menuBar()->addMenu(tr("&Help"));
525 helpMenu->addAction(siteAct);
526 #if !defined(APP_MAC) && !defined(APP_WIN)
527 helpMenu->addAction(donateAct);
529 helpMenu->addAction(aboutAct);
532 void MainWindow::createToolBars() {
534 setUnifiedTitleAndToolBarOnMac(true);
536 mainToolBar = new QToolBar(this);
537 #if QT_VERSION < 0x040600 | defined(APP_MAC)
538 mainToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
540 mainToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
542 mainToolBar->setFloatable(false);
543 mainToolBar->setMovable(false);
545 #if defined(APP_MAC) | defined(APP_WIN)
546 mainToolBar->setIconSize(QSize(32, 32));
549 mainToolBar->addAction(stopAct);
550 mainToolBar->addAction(pauseAct);
551 mainToolBar->addAction(skipAct);
553 bool addFullScreenAct = true;
555 addFullScreenAct = !mac::CanGoFullScreen(winId());
557 if (addFullScreenAct) mainToolBar->addAction(fullscreenAct);
559 #ifndef APP_NO_DOWNLOADS
560 mainToolBar->addAction(The::globalActions()->value("download"));
563 mainToolBar->addWidget(new Spacer());
565 QFont smallerFont = FontUtils::small();
566 currentTime = new QLabel(mainToolBar);
567 currentTime->setFont(smallerFont);
568 mainToolBar->addWidget(currentTime);
570 mainToolBar->addWidget(new Spacer());
572 seekSlider = new Phonon::SeekSlider(this);
573 seekSlider->setIconVisible(false);
574 seekSlider->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
575 mainToolBar->addWidget(seekSlider);
578 mainToolBar->addWidget(new Spacer());
579 slider = new QSlider(this);
580 slider->setOrientation(Qt::Horizontal);
581 slider->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
582 mainToolBar->addWidget(slider);
585 mainToolBar->addWidget(new Spacer());
587 totalTime = new QLabel(mainToolBar);
588 totalTime->setFont(smallerFont);
589 mainToolBar->addWidget(totalTime);
591 mainToolBar->addWidget(new Spacer());
593 mainToolBar->addAction(volumeMuteAct);
595 volumeSlider = new Phonon::VolumeSlider(this);
596 volumeSlider->setMuteVisible(false);
597 // qDebug() << volumeSlider->children();
598 // status tip for the volume slider
599 QSlider* volumeQSlider = volumeSlider->findChild<QSlider*>();
601 volumeQSlider->setStatusTip(tr("Press %1 to raise the volume, %2 to lower it").arg(
602 volumeUpAct->shortcut().toString(QKeySequence::NativeText), volumeDownAct->shortcut().toString(QKeySequence::NativeText)));
603 // this makes the volume slider smaller
604 volumeSlider->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
605 mainToolBar->addWidget(volumeSlider);
607 mainToolBar->addWidget(new Spacer());
610 SearchWrapper* searchWrapper = new SearchWrapper(this);
611 toolbarSearch = searchWrapper->getSearchLineEdit();
613 toolbarSearch = new SearchLineEdit(this);
615 toolbarSearch->setMinimumWidth(toolbarSearch->fontInfo().pixelSize()*15);
616 toolbarSearch->setSuggester(new YouTubeSuggest(this));
617 connect(toolbarSearch, SIGNAL(search(const QString&)), this, SLOT(startToolbarSearch(const QString&)));
618 connect(toolbarSearch, SIGNAL(suggestionAccepted(const QString&)), SLOT(startToolbarSearch(const QString&)));
619 toolbarSearch->setStatusTip(searchFocusAct->statusTip());
621 mainToolBar->addWidget(searchWrapper);
623 mainToolBar->addWidget(toolbarSearch);
624 Spacer* spacer = new Spacer();
625 // spacer->setWidth(4);
626 mainToolBar->addWidget(spacer);
629 addToolBar(mainToolBar);
632 void MainWindow::createStatusBar() {
633 QToolBar* toolBar = new QToolBar(this);
634 statusToolBar = toolBar;
635 toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
636 toolBar->setIconSize(QSize(16, 16));
637 toolBar->addAction(The::globalActions()->value("downloads"));
638 toolBar->addAction(The::globalActions()->value("definition"));
639 statusBar()->addPermanentWidget(toolBar);
643 void MainWindow::showStopAfterThisInStatusBar(bool show) {
644 QAction* action = The::globalActions()->value("stopafterthis");
645 showActionInStatusBar(action, show);
648 void MainWindow::showActionInStatusBar(QAction* action, bool show) {
650 statusToolBar->insertAction(statusToolBar->actions().first(), action);
652 statusToolBar->removeAction(action);
656 void MainWindow::readSettings() {
658 if (settings.contains("geometry")) {
659 restoreGeometry(settings.value("geometry").toByteArray());
661 MacSupport::fixGeometry(this);
664 setGeometry(100, 100, 1000, 500);
666 setDefinitionMode(settings.value("definition", VideoDefinition::getDefinitionNames().first()).toString());
667 audioOutput->setVolume(settings.value("volume", 1).toDouble());
668 audioOutput->setMuted(settings.value("volumeMute").toBool());
669 The::globalActions()->value("manualplay")->setChecked(settings.value("manualplay", false).toBool());
672 void MainWindow::writeSettings() {
675 settings.setValue("geometry", saveGeometry());
676 mediaView->saveSplitterState();
678 settings.setValue("volume", audioOutput->volume());
679 settings.setValue("volumeMute", audioOutput->isMuted());
680 settings.setValue("manualplay", The::globalActions()->value("manualplay")->isChecked());
683 void MainWindow::goBack() {
684 if ( history->size() > 1 ) {
686 QWidget *widget = history->pop();
691 void MainWindow::showWidget ( QWidget* widget ) {
693 if (compactViewAct->isChecked())
694 compactViewAct->toggle();
696 setUpdatesEnabled(false);
698 // call hide method on the current view
699 View* oldView = dynamic_cast<View *> (views->currentWidget());
701 oldView->disappear();
702 views->currentWidget()->setEnabled(false);
705 // call show method on the new view
706 View* newView = dynamic_cast<View *> (widget);
708 widget->setEnabled(true);
710 QMap<QString,QVariant> metadata = newView->metadata();
711 QString windowTitle = metadata.value("title").toString();
712 if (windowTitle.length())
713 windowTitle += " - ";
714 setWindowTitle(windowTitle + Constants::NAME);
715 statusBar()->showMessage((metadata.value("description").toString()));
718 stopAct->setEnabled(widget == mediaView);
719 compactViewAct->setEnabled(widget == mediaView);
720 webPageAct->setEnabled(widget == mediaView);
721 copyPageAct->setEnabled(widget == mediaView);
722 copyLinkAct->setEnabled(widget == mediaView);
723 findVideoPartsAct->setEnabled(widget == mediaView);
724 toolbarSearch->setEnabled(widget == searchView || widget == mediaView || widget == downloadView);
726 if (widget == searchView) {
727 skipAct->setEnabled(false);
728 The::globalActions()->value("previous")->setEnabled(false);
729 The::globalActions()->value("download")->setEnabled(false);
730 The::globalActions()->value("stopafterthis")->setEnabled(false);
733 The::globalActions()->value("twitter")->setEnabled(widget == mediaView);
734 The::globalActions()->value("facebook")->setEnabled(widget == mediaView);
735 The::globalActions()->value("email")->setEnabled(widget == mediaView);
737 aboutAct->setEnabled(widget != aboutView);
738 The::globalActions()->value("downloads")->setChecked(widget == downloadView);
740 // toolbar only for the mediaView
741 /* mainToolBar->setVisible(
742 (widget == mediaView && !compactViewAct->isChecked())
743 || widget == downloadView
746 setUpdatesEnabled(true);
748 QWidget *oldWidget = views->currentWidget();
750 oldWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
752 views->setCurrentWidget(widget);
753 widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
757 Extra::fadeInWidget(oldWidget, widget);
760 history->push(widget);
763 void MainWindow::about() {
765 aboutView = new AboutView(this);
766 views->addWidget(aboutView);
768 showWidget(aboutView);
771 void MainWindow::visitSite() {
772 QUrl url(Constants::WEBSITE);
773 statusBar()->showMessage(QString(tr("Opening %1").arg(url.toString())));
774 QDesktopServices::openUrl(url);
777 void MainWindow::donate() {
778 QUrl url(QString(Constants::WEBSITE) + "#donate");
779 statusBar()->showMessage(QString(tr("Opening %1").arg(url.toString())));
780 QDesktopServices::openUrl(url);
783 void MainWindow::quit() {
785 if (!confirmQuit()) {
789 // do not save geometry when in full screen or in compact mode
790 if (!m_fullscreen && !compactViewAct->isChecked()) {
793 Temporary::deleteAll();
797 void MainWindow::closeEvent(QCloseEvent *event) {
799 mac::closeWindow(winId());
802 if (!confirmQuit()) {
806 QWidget::closeEvent(event);
811 bool MainWindow::confirmQuit() {
812 if (DownloadManager::instance()->activeItems() > 0) {
813 QMessageBox msgBox(this);
814 msgBox.setIconPixmap(QPixmap(":/images/app.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
815 msgBox.setText(tr("Do you want to exit %1 with a download in progress?").arg(Constants::NAME));
816 msgBox.setInformativeText(tr("If you close %1 now, this download will be cancelled.").arg(Constants::NAME));
817 msgBox.setModal(true);
818 // make it a "sheet" on the Mac
819 msgBox.setWindowModality(Qt::WindowModal);
821 msgBox.addButton(tr("Close and cancel download"), QMessageBox::RejectRole);
822 QPushButton *waitButton = msgBox.addButton(tr("Wait for download to finish"), QMessageBox::ActionRole);
826 if (msgBox.clickedButton() == waitButton) {
833 void MainWindow::showSearch() {
834 showWidget(searchView);
835 currentTime->clear();
839 void MainWindow::showMedia(SearchParams *searchParams) {
840 mediaView->search(searchParams);
841 showWidget(mediaView);
844 void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState */) {
846 // qDebug() << "Phonon state: " << newState;
850 case Phonon::ErrorState:
851 if (mediaObject->errorType() == Phonon::FatalError) {
852 // Do not display because we try to play incomplete video files and sometimes trigger this
853 // We retry automatically (in MediaView) so no need to show it
854 // statusBar()->showMessage(tr("Fatal error: %1").arg(mediaObject->errorString()));
856 statusBar()->showMessage(tr("Error: %1").arg(mediaObject->errorString()));
860 case Phonon::PlayingState:
861 pauseAct->setEnabled(true);
862 pauseAct->setIcon(QtIconLoader::icon("media-playback-pause"));
863 pauseAct->setText(tr("&Pause"));
864 pauseAct->setStatusTip(tr("Pause playback") + " (" + pauseAct->shortcut().toString(QKeySequence::NativeText) + ")");
865 // stopAct->setEnabled(true);
868 case Phonon::StoppedState:
869 pauseAct->setEnabled(false);
870 // stopAct->setEnabled(false);
873 case Phonon::PausedState:
874 pauseAct->setEnabled(true);
875 pauseAct->setIcon(QtIconLoader::icon("media-playback-start"));
876 pauseAct->setText(tr("&Play"));
877 pauseAct->setStatusTip(tr("Resume playback") + " (" + pauseAct->shortcut().toString(QKeySequence::NativeText) + ")");
878 // stopAct->setEnabled(true);
881 case Phonon::BufferingState:
882 case Phonon::LoadingState:
883 pauseAct->setEnabled(false);
884 currentTime->clear();
886 // stopAct->setEnabled(true);
894 void MainWindow::stop() {
899 void MainWindow::resizeEvent(QResizeEvent*) {
901 if (mac::CanGoFullScreen(winId())) {
902 bool isFullscreen = mac::IsFullScreen(winId());
903 if (isFullscreen != m_fullscreen) {
904 if (compactViewAct->isChecked()) {
905 compactViewAct->setChecked(false);
908 m_fullscreen = isFullscreen;
909 updateUIForFullscreen();
915 void MainWindow::fullscreen() {
917 if (compactViewAct->isChecked())
918 compactViewAct->toggle();
921 WId handle = winId();
922 if (mac::CanGoFullScreen(handle)) {
923 mainToolBar->setVisible(true);
924 mac::ToggleFullScreen(handle);
929 m_fullscreen = !m_fullscreen;
934 m_maximized = isMaximized();
936 // save geometry now, if the user quits when in full screen
937 // geometry won't be saved
941 MacSupport::enterFullScreen(this, views);
951 MacSupport::exitFullScreen(this, views);
954 if (m_maximized) showMaximized();
958 // Make sure the window has focus
963 updateUIForFullscreen();
967 void MainWindow::updateUIForFullscreen() {
968 static QList<QKeySequence> fsShortcuts;
969 static QString fsText;
972 fsShortcuts = fullscreenAct->shortcuts();
973 fsText = fullscreenAct->text();
974 fullscreenAct->setShortcuts(QList<QKeySequence>(fsShortcuts)
975 << QKeySequence(Qt::Key_Escape));
976 fullscreenAct->setText(tr("Leave &Full Screen"));
978 fullscreenAct->setShortcuts(fsShortcuts);
979 fullscreenAct->setText(fsText);
982 // No compact view action when in full screen
983 compactViewAct->setVisible(!m_fullscreen);
984 compactViewAct->setChecked(false);
986 // Hide anything but the video
987 mediaView->setPlaylistVisible(!m_fullscreen);
988 statusBar()->setVisible(!m_fullscreen);
991 menuBar()->setVisible(!m_fullscreen);
995 stopAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_MediaStop));
997 stopAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::Key_MediaStop));
1001 MacSupport::fullScreenActions(The::globalActions()->values(), m_fullscreen);
1004 if (views->currentWidget() == mediaView)
1005 mediaView->setFocus();
1008 void MainWindow::compactView(bool enable) {
1010 static QList<QKeySequence> compactShortcuts;
1011 static QList<QKeySequence> stopShortcuts;
1013 const static QString key = "compactGeometry";
1017 menuBar()->setVisible(!enable);
1021 setMinimumSize(160, 120);
1023 mac::RemoveFullScreenWindow(winId());
1027 if (settings.contains(key))
1028 restoreGeometry(settings.value(key).toByteArray());
1032 mainToolBar->setVisible(!enable);
1033 mediaView->setPlaylistVisible(!enable);
1034 statusBar()->setVisible(!enable);
1036 compactShortcuts = compactViewAct->shortcuts();
1037 stopShortcuts = stopAct->shortcuts();
1039 QList<QKeySequence> newStopShortcuts(stopShortcuts);
1040 newStopShortcuts.removeAll(QKeySequence(Qt::Key_Escape));
1041 stopAct->setShortcuts(newStopShortcuts);
1042 compactViewAct->setShortcuts(QList<QKeySequence>(compactShortcuts) << QKeySequence(Qt::Key_Escape));
1044 // ensure focus does not end up to the search box
1045 // as it would steal the Space shortcut
1046 mediaView->setFocus();
1049 // unset minimum size
1050 setMinimumSize(0, 0);
1052 mac::SetupFullScreenWindow(winId());
1054 settings.setValue(key, saveGeometry());
1055 mainToolBar->setVisible(!enable);
1056 mediaView->setPlaylistVisible(!enable);
1057 statusBar()->setVisible(!enable);
1060 compactViewAct->setShortcuts(compactShortcuts);
1061 stopAct->setShortcuts(stopShortcuts);
1064 // auto float on top
1068 void MainWindow::searchFocus() {
1069 QWidget *view = views->currentWidget();
1070 toolbarSearch->selectAll();
1071 toolbarSearch->setFocus();
1074 void MainWindow::initPhonon() {
1075 // Phonon initialization
1076 if (mediaObject) delete mediaObject;
1077 if (audioOutput) delete audioOutput;
1078 mediaObject = new Phonon::MediaObject(this);
1079 mediaObject->setTickInterval(100);
1080 connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
1081 this, SLOT(stateChanged(Phonon::State, Phonon::State)));
1082 connect(mediaObject, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
1083 connect(mediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64)));
1084 seekSlider->setMediaObject(mediaObject);
1085 audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this);
1086 connect(audioOutput, SIGNAL(volumeChanged(qreal)), this, SLOT(volumeChanged(qreal)));
1087 connect(audioOutput, SIGNAL(mutedChanged(bool)), this, SLOT(volumeMutedChanged(bool)));
1088 volumeSlider->setAudioOutput(audioOutput);
1089 Phonon::createPath(mediaObject, audioOutput);
1092 void MainWindow::tick(qint64 time) {
1094 // the "if" is important because tick is continually called
1095 // and we don't want to paint the toolbar every 100ms
1096 if (!currentTime->text().isEmpty()) currentTime->clear();
1100 currentTime->setText(formatTime(time));
1103 const qint64 remainingTime = mediaObject->remainingTime();
1104 currentTime->setStatusTip(tr("Remaining time: %1").arg(formatTime(remainingTime)));
1107 slider->blockSignals(true);
1108 slider->setValue(time/1000);
1109 slider->blockSignals(false);
1113 void MainWindow::totalTimeChanged(qint64 time) {
1118 totalTime->setText(formatTime(time));
1121 slider->blockSignals(true);
1122 slider->setMaximum(time/1000);
1123 slider->blockSignals(false);
1128 QString MainWindow::formatTime(qint64 time) {
1130 displayTime = displayTime.addMSecs(time);
1132 // 60 * 60 * 1000 = 3600000
1134 timeString = displayTime.toString("h:mm:ss");
1136 timeString = displayTime.toString("m:ss");
1140 void MainWindow::volumeUp() {
1141 qreal newVolume = volumeSlider->audioOutput()->volume() + .1;
1142 if (newVolume > volumeSlider->maximumVolume())
1143 newVolume = volumeSlider->maximumVolume();
1144 volumeSlider->audioOutput()->setVolume(newVolume);
1147 void MainWindow::volumeDown() {
1148 qreal newVolume = volumeSlider->audioOutput()->volume() - .1;
1151 volumeSlider->audioOutput()->setVolume(newVolume);
1154 void MainWindow::volumeMute() {
1155 volumeSlider->audioOutput()->setMuted(!volumeSlider->audioOutput()->isMuted());
1158 void MainWindow::volumeChanged(qreal newVolume) {
1159 // automatically unmute when volume changes
1160 if (volumeSlider->audioOutput()->isMuted())
1161 volumeSlider->audioOutput()->setMuted(false);
1162 statusBar()->showMessage(tr("Volume at %1%").arg((int)(newVolume*100)));
1165 void MainWindow::volumeMutedChanged(bool muted) {
1167 volumeMuteAct->setIcon(QtIconLoader::icon("audio-volume-muted"));
1168 statusBar()->showMessage(tr("Volume is muted"));
1170 volumeMuteAct->setIcon(QtIconLoader::icon("audio-volume-high"));
1171 statusBar()->showMessage(tr("Volume is unmuted"));
1175 void MainWindow::setDefinitionMode(QString definitionName) {
1176 QAction *definitionAct = The::globalActions()->value("definition");
1177 definitionAct->setText(definitionName);
1178 definitionAct->setStatusTip(tr("Maximum video definition set to %1").arg(definitionAct->text())
1179 + " (" + definitionAct->shortcut().toString(QKeySequence::NativeText) + ")");
1180 statusBar()->showMessage(definitionAct->statusTip());
1182 settings.setValue("definition", definitionName);
1185 void MainWindow::toggleDefinitionMode() {
1187 QString currentDefinition = settings.value("definition").toString();
1188 QStringList definitionNames = VideoDefinition::getDefinitionNames();
1189 int currentIndex = definitionNames.indexOf(currentDefinition);
1191 if (currentIndex != definitionNames.size() - 1) {
1192 nextIndex = currentIndex + 1;
1194 QString nextDefinition = definitionNames.at(nextIndex);
1195 setDefinitionMode(nextDefinition);
1198 void MainWindow::showFullscreenToolbar(bool show) {
1199 if (!m_fullscreen) return;
1200 mainToolBar->setVisible(show);
1203 void MainWindow::showFullscreenPlaylist(bool show) {
1204 if (!m_fullscreen) return;
1205 mediaView->setPlaylistVisible(show);
1208 void MainWindow::clearRecentKeywords() {
1210 settings.remove("recentKeywords");
1211 settings.remove("recentChannels");
1212 searchView->updateRecentKeywords();
1213 searchView->updateRecentChannels();
1214 statusBar()->showMessage(tr("Your privacy is now safe"));
1217 void MainWindow::setManualPlay(bool enabled) {
1219 settings.setValue("manualplay", QVariant::fromValue(enabled));
1220 showActionInStatusBar(The::globalActions()->value("manualplay"), enabled);
1223 void MainWindow::updateDownloadMessage(QString message) {
1224 The::globalActions()->value("downloads")->setText(message);
1227 void MainWindow::downloadsFinished() {
1228 The::globalActions()->value("downloads")->setText(tr("&Downloads"));
1229 statusBar()->showMessage(tr("Downloads complete"));
1232 void MainWindow::toggleDownloads(bool show) {
1235 stopAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_MediaStop));
1236 The::globalActions()->value("downloads")->setShortcuts(
1237 QList<QKeySequence>() << QKeySequence(Qt::CTRL + Qt::Key_J)
1238 << QKeySequence(Qt::Key_Escape));
1240 The::globalActions()->value("downloads")->setShortcuts(
1241 QList<QKeySequence>() << QKeySequence(Qt::CTRL + Qt::Key_J));
1242 stopAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::Key_MediaStop));
1245 if (!downloadView) {
1246 downloadView = new DownloadView(this);
1247 views->addWidget(downloadView);
1249 if (show) showWidget(downloadView);
1253 void MainWindow::startToolbarSearch(QString query) {
1255 query = query.trimmed();
1257 // check for empty query
1258 if (query.length() == 0) {
1262 SearchParams *searchParams = new SearchParams();
1263 searchParams->setKeywords(query);
1266 showMedia(searchParams);
1269 void MainWindow::dragEnterEvent(QDragEnterEvent *event) {
1270 if (event->mimeData()->hasFormat("text/uri-list")) {
1271 QList<QUrl> urls = event->mimeData()->urls();
1274 QUrl url = urls.first();
1275 QString videoId = YouTubeSearch::videoIdFromUrl(url.toString());
1276 if (!videoId.isNull())
1277 event->acceptProposedAction();
1281 void MainWindow::dropEvent(QDropEvent *event) {
1282 QList<QUrl> urls = event->mimeData()->urls();
1285 QUrl url = urls.first();
1286 QString videoId = YouTubeSearch::videoIdFromUrl(url.toString());
1287 if (!videoId.isNull()) {
1288 setWindowTitle(url.toString());
1289 SearchParams *searchParams = new SearchParams();
1290 searchParams->setKeywords(videoId);
1291 showMedia(searchParams);
1295 void MainWindow::checkForUpdate() {
1296 static const QString updateCheckKey = "updateCheck";
1300 uint unixTime = QDateTime::currentDateTime().toTime_t();
1301 int lastCheck = settings.value(updateCheckKey).toInt();
1302 int secondsSinceLastCheck = unixTime - lastCheck;
1303 // qDebug() << "secondsSinceLastCheck" << unixTime << lastCheck << secondsSinceLastCheck;
1304 if (secondsSinceLastCheck < 86400) return;
1307 if (updateChecker) delete updateChecker;
1308 updateChecker = new UpdateChecker();
1309 connect(updateChecker, SIGNAL(newVersion(QString)),
1310 this, SLOT(gotNewVersion(QString)));
1311 updateChecker->checkForUpdate();
1312 settings.setValue(updateCheckKey, unixTime);
1316 void MainWindow::gotNewVersion(QString version) {
1317 if (updateChecker) {
1318 delete updateChecker;
1322 #if defined(APP_DEMO) || defined(APP_MAC_STORE) || defined(APP_USC)
1327 QString checkedVersion = settings.value("checkedVersion").toString();
1328 if (checkedVersion == version) return;
1330 QMessageBox msgBox(this);
1331 msgBox.setIconPixmap(QPixmap(":/images/app.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
1332 msgBox.setText(tr("%1 version %2 is now available.").arg(Constants::NAME, version));
1334 msgBox.setModal(true);
1335 // make it a "sheet" on the Mac
1336 msgBox.setWindowModality(Qt::WindowModal);
1338 QPushButton* laterButton = 0;
1339 QPushButton* updateButton = 0;
1341 #if defined(APP_MAC) || defined(APP_WIN)
1342 msgBox.setInformativeText(
1343 tr("To get the updated version, download %1 again from the link you received via email and reinstall.")
1344 .arg(Constants::NAME)
1346 laterButton = msgBox.addButton(tr("Remind me later"), QMessageBox::RejectRole);
1347 msgBox.addButton(QMessageBox::Ok);
1349 msgBox.addButton(QMessageBox::Close);
1350 updateButton = msgBox.addButton(tr("Update"), QMessageBox::AcceptRole);
1355 if (msgBox.clickedButton() != laterButton) {
1356 settings.setValue("checkedVersion", version);
1359 if (updateButton && msgBox.clickedButton() == updateButton) {
1360 QDesktopServices::openUrl(QUrl(QLatin1String(Constants::WEBSITE) + "#download"));
1365 void MainWindow::floatOnTop(bool onTop) {
1366 showActionInStatusBar(The::globalActions()->value("ontop"), onTop);
1368 mac::floatOnTop(winId(), onTop);
1372 setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
1375 setWindowFlags(windowFlags() ^ Qt::WindowStaysOnTopHint);
1380 void MainWindow::restore() {
1382 mac::uncloseWindow(window()->winId());
1386 void MainWindow::messageReceived(const QString &message) {
1387 if (message == "--toggle-playing") {
1388 if (pauseAct->isEnabled()) pauseAct->trigger();
1389 } else if (message == "--next") {
1390 if (skipAct->isEnabled()) skipAct->trigger();
1391 } else if (message == "--previous") {
1392 if (skipBackwardAct->isEnabled()) skipBackwardAct->trigger();
1393 } else if (!message.isEmpty()) {
1394 SearchParams *searchParams = new SearchParams();
1395 searchParams->setKeywords(message);
1396 showMedia(searchParams);