#include "downloadview.h"
#include "spacer.h"
#include "constants.h"
-#include "iconloader/qticonloader.h"
+#include "utils.h"
#include "global.h"
#include "videodefinition.h"
#include "fontutils.h"
QMap<QString, QAction*> *actions = The::globalActions();
- stopAct = new QAction(QtIconLoader::icon("media-playback-stop"), tr("&Stop"), this);
+ stopAct = new QAction(Utils::icon("media-playback-stop"), tr("&Stop"), this);
stopAct->setStatusTip(tr("Stop playback and go back to the search view"));
stopAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::Key_MediaStop));
stopAct->setEnabled(false);
connect(stopAct, SIGNAL(triggered()), this, SLOT(stop()));
skipBackwardAct = new QAction(
- QtIconLoader::icon("media-skip-backward"),
+ Utils::icon("media-skip-backward"),
tr("P&revious"), this);
skipBackwardAct->setStatusTip(tr("Go back to the previous track"));
skipBackwardAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Left));
actions->insert("previous", skipBackwardAct);
connect(skipBackwardAct, SIGNAL(triggered()), mediaView, SLOT(skipBackward()));
- skipAct = new QAction(QtIconLoader::icon("media-skip-forward"), tr("S&kip"), this);
+ skipAct = new QAction(Utils::icon("media-skip-forward"), tr("S&kip"), this);
skipAct->setStatusTip(tr("Skip to the next video"));
skipAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::CTRL + Qt::Key_Right) << QKeySequence(Qt::Key_MediaNext));
skipAct->setEnabled(false);
actions->insert("skip", skipAct);
connect(skipAct, SIGNAL(triggered()), mediaView, SLOT(skip()));
- pauseAct = new QAction(QtIconLoader::icon("media-playback-pause"), tr("&Pause"), this);
+ pauseAct = new QAction(Utils::icon("media-playback-pause"), tr("&Pause"), this);
pauseAct->setStatusTip(tr("Pause playback"));
pauseAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_Space) << QKeySequence(Qt::Key_MediaPlay));
pauseAct->setEnabled(false);
actions->insert("pause", pauseAct);
connect(pauseAct, SIGNAL(triggered()), mediaView, SLOT(pause()));
- fullscreenAct = new QAction(QtIconLoader::icon("view-fullscreen"), tr("&Full Screen"), this);
+ fullscreenAct = new QAction(Utils::icon("view-fullscreen"), tr("&Full Screen"), this);
fullscreenAct->setStatusTip(tr("Go full screen"));
QList<QKeySequence> fsShortcuts;
#ifdef APP_MAC
addAction(volumeDownAct);
volumeMuteAct = new QAction(this);
- volumeMuteAct->setIcon(QtIconLoader::icon("audio-volume-high"));
+ volumeMuteAct->setIcon(Utils::icon("audio-volume-high"));
volumeMuteAct->setStatusTip(tr("Mute volume"));
volumeMuteAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::CTRL + Qt::Key_E));
actions->insert("volume-mute", volumeMuteAct);
addAction(volumeMuteAct);
QAction *definitionAct = new QAction(this);
- definitionAct->setIcon(QtIconLoader::icon("video-display"));
+ definitionAct->setIcon(Utils::icon("video-display"));
definitionAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::CTRL + Qt::Key_D));
/*
QMenu *definitionMenu = new QMenu(this);
QAction *action;
- action = new QAction(QtIconLoader::icon("media-playback-start"), tr("&Manually Start Playing"), this);
+ action = new QAction(Utils::icon("media-playback-start"), tr("&Manually Start Playing"), this);
action->setStatusTip(tr("Manually start playing videos"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B));
action->setCheckable(true);
action->setStatusTip(tr("Show details about video downloads"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_J));
action->setCheckable(true);
- action->setIcon(QtIconLoader::icon("go-down"));
+ action->setIcon(Utils::icon("go-down"));
action->setVisible(false);
connect(action, SIGNAL(toggled(bool)), SLOT(toggleDownloads(bool)));
actions->insert("downloads", action);
#ifndef APP_NO_DOWNLOADS
action->setShortcut(QKeySequence::Save);
#endif
- action->setIcon(QtIconLoader::icon("go-down"));
+ action->setIcon(Utils::icon("go-down"));
action->setEnabled(false);
#if QT_VERSION >= 0x040600
action->setPriority(QAction::LowPriority);
actions->insert("restore", action);
connect(action, SIGNAL(triggered()), SLOT(restore()));
- action = new QAction(QtIconLoader::icon("go-top"), tr("&Float on Top"), this);
+ action = new QAction(Utils::icon("go-top"), tr("&Float on Top"), this);
action->setCheckable(true);
actions->insert("ontop", action);
connect(action, SIGNAL(toggled(bool)), SLOT(floatOnTop(bool)));
- action = new QAction(QtIconLoader::icon("media-playback-stop"), tr("&Stop After This Video"), this);
+ action = new QAction(Utils::icon("media-playback-stop"), tr("&Stop After This Video"), this);
action->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Escape));
action->setCheckable(true);
action->setEnabled(false);
connect(action, SIGNAL(triggered()), SLOT(reportIssue()));
action = new QAction(tr("&Refine Search..."), this);
- action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
+ action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_E));
action->setCheckable(true);
action->setEnabled(false);
actions->insert("refine-search", action);
action = new QAction(tr("More..."), this);
actions->insert("more-region", action);
+ action = new QAction(Utils::icon("related-videos"), tr("&Related Videos"), this);
+ action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
+ action->setStatusTip(tr("Watch videos related to the current one"));
+ action->setEnabled(false);
+ connect(action, SIGNAL(triggered()), mediaView, SLOT(relatedVideos()));
+ actions->insert("related-videos", action);
+
#ifdef APP_ACTIVATION
Extra::createActivationAction(tr("Buy %1...").arg(Constants::NAME));
#endif
QMenu* videoMenu = menuBar()->addMenu(tr("&Video"));
menus->insert("video", videoMenu);
+ videoMenu->addAction(The::globalActions()->value("related-videos"));
videoMenu->addAction(findVideoPartsAct);
videoMenu->addSeparator();
videoMenu->addAction(webPageAct);
mainToolBar->addAction(stopAct);
mainToolBar->addAction(pauseAct);
mainToolBar->addAction(skipAct);
+ mainToolBar->addAction(The::globalActions()->value("related-videos"));
bool addFullScreenAct = true;
#ifdef Q_WS_MAC
regionButton = new QToolButton(this);
regionButton->setStatusTip(tr("Choose your content location"));
- regionButton->setIcon(QtIconLoader::icon("go-down"));
+ regionButton->setIcon(Utils::icon("go-down"));
regionButton->setIconSize(QSize(16, 16));
regionButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
regionAction = statusToolBar->addWidget(regionButton);
copyPageAct->setEnabled(isMediaView);
copyLinkAct->setEnabled(isMediaView);
findVideoPartsAct->setEnabled(isMediaView);
+ The::globalActions()->value("related-videos")->setEnabled(isMediaView);
toolbarSearch->setEnabled(widget == homeView || isMediaView || widget == downloadView);
if (widget == homeView) {
case Phonon::PlayingState:
pauseAct->setEnabled(true);
- pauseAct->setIcon(QtIconLoader::icon("media-playback-pause"));
+ pauseAct->setIcon(Utils::icon("media-playback-pause"));
pauseAct->setText(tr("&Pause"));
pauseAct->setStatusTip(tr("Pause playback") + " (" + pauseAct->shortcut().toString(QKeySequence::NativeText) + ")");
// stopAct->setEnabled(true);
case Phonon::PausedState:
pauseAct->setEnabled(true);
- pauseAct->setIcon(QtIconLoader::icon("media-playback-start"));
+ pauseAct->setIcon(Utils::icon("media-playback-start"));
pauseAct->setText(tr("&Play"));
pauseAct->setStatusTip(tr("Resume playback") + " (" + pauseAct->shortcut().toString(QKeySequence::NativeText) + ")");
// stopAct->setEnabled(true);
void MainWindow::volumeMutedChanged(bool muted) {
if (muted) {
- volumeMuteAct->setIcon(QtIconLoader::icon("audio-volume-muted"));
+ volumeMuteAct->setIcon(Utils::icon("audio-volume-muted"));
statusBar()->showMessage(tr("Volume is muted"));
} else {
- volumeMuteAct->setIcon(QtIconLoader::icon("audio-volume-high"));
+ volumeMuteAct->setIcon(Utils::icon("audio-volume-high"));
statusBar()->showMessage(tr("Volume is unmuted"));
}
}
if (addToHistory) {
int currentIndex = getHistoryIndex();
if (currentIndex >= 0 && currentIndex < history.size() - 1) {
- for (int i = currentIndex + 1; i < history.size(); i++) {
- VideoSource *vs = history.takeAt(i);
+ while (history.size() > currentIndex + 1) {
+ VideoSource *vs = history.takeLast();
if (!vs->parent()) delete vs;
}
}
Video *video = playlistModel->videoAt(row);
if (!video) return;
- // Related videos without video interruption
- if (row == 0) {
- VideoSource *videoSource = playlistModel->getVideoSource();
- if (videoSource && !history.isEmpty() &&
- mediaObject->state() == Phonon::PlayingState &&
- videoSource->metaObject()->className() == QLatin1String("YTSingleVideoSource")) {
- if (playlistModel->videoAt(row)->title() == downloadItem->getVideo()->title())
- return;
- }
+ // Do not stop/start playing if the first video result is the current video
+ if (row == 0 && !history.isEmpty()) {
+ Video *currentVideo = 0;
+ if (downloadItem && downloadItem->getVideo()) currentVideo = downloadItem->getVideo();
+ if (currentVideo && playlistModel->videoAt(row)->webpage() == currentVideo->webpage())
+ return;
}
errorTimer->stop();
MainWindow::instance()->showMessage(video->title());
// ensure active item is visible
- // int row = listModel->activeRow();
if (row != -1) {
QModelIndex index = playlistModel->index(row, 0, QModelIndex());
playlistView->scrollTo(index, QAbstractItemView::EnsureVisible);
}
// enable/disable actions
- The::globalActions()->value("download")->setEnabled(DownloadManager::instance()->itemForVideo(video) == 0);
+ The::globalActions()->value("download")->setEnabled(
+ DownloadManager::instance()->itemForVideo(video) == 0);
The::globalActions()->value("skip")->setEnabled(true);
The::globalActions()->value("previous")->setEnabled(row > 0);
The::globalActions()->value("stopafterthis")->setEnabled(true);
delete downloadItem;
}
downloadItem = new DownloadItem(videoCopy, streamUrl, tempFile, this);
- connect(downloadItem, SIGNAL(statusChanged()), SLOT(downloadStatusChanged()), Qt::UniqueConnection);
+ connect(downloadItem, SIGNAL(statusChanged()),
+ SLOT(downloadStatusChanged()), Qt::UniqueConnection);
// connect(downloadItem, SIGNAL(progress(int)), SLOT(downloadProgress(int)));
- connect(downloadItem, SIGNAL(bufferProgress(int)), loadingWidget, SLOT(bufferStatus(int)), Qt::UniqueConnection);
+ connect(downloadItem, SIGNAL(bufferProgress(int)),
+ loadingWidget, SLOT(bufferStatus(int)), Qt::UniqueConnection);
// connect(downloadItem, SIGNAL(finished()), SLOT(itemFinished()));
- connect(video, SIGNAL(errorStreamUrl(QString)), SLOT(handleError(QString)), Qt::UniqueConnection);
- connect(downloadItem, SIGNAL(error(QString)), SLOT(handleError(QString)), Qt::UniqueConnection);
+ connect(video, SIGNAL(errorStreamUrl(QString)),
+ SLOT(handleError(QString)), Qt::UniqueConnection);
+ connect(downloadItem, SIGNAL(error(QString)),
+ SLOT(handleError(QString)), Qt::UniqueConnection);
downloadItem->start();
#ifdef Q_WS_MAC
}
+void MediaView::relatedVideos() {
+ Video* video = playlistModel->activeVideo();
+ if (!video) return;
+ YTSingleVideoSource *singleVideoSource = new YTSingleVideoSource();
+ singleVideoSource->setVideoId(video->id());
+ setVideoSource(singleVideoSource);
+}
+
void MediaView::shareViaTwitter() {
Video* video = playlistModel->activeVideo();
if (!video) return;