From: Flavio Tordini Date: Sat, 18 Sep 2010 08:38:33 +0000 (+0200) Subject: Video downloads! X-Git-Tag: 1.2~16 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2684a39f839b383957a544b03a354f3fe9b110c0;p=minitube Video downloads! --- diff --git a/CHANGES b/CHANGES index 8892267..6355232 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ -1.2 -- Support for media keys on OS X and GNOME +1.2 - Sep ??, 2010 +- Ability to download videos +- Support for media keys on GNOME +- More style, especially on the Mac +- Fixed crash when trying delete or move the the las playlist item 1.1 - Jul 27, 2010 - Minitube now correctly plays cat and mouse with YouTube diff --git a/TODO b/TODO index 954bd98..62c8c00 100644 --- a/TODO +++ b/TODO @@ -2,11 +2,6 @@ ## Killer features -- Video download - Download status on the status bar. When clicked, a download manager view appears. - Videos should be downloaded in the current format - directly on the Desktop or Downloads dir without asking for a location. - - YouTube related videos List of related videos identical to the playlist. When a related video is clicked Minitube will keep playing the next related videos. @@ -21,7 +16,8 @@ - Windows build Stefan Brueck has compiled on Windows but there are problems with Phonon's directX backend - Marco di Antonio tried with the Mplayer backend, but it is very unstable + Marco di Antonio tried with the Mplayer backend, but it is very unstable. + Waiting for the VLC backend to work. - Subtitles, see http://google2srt.sourceforge.net/ diff --git a/minitube.pro b/minitube.pro index 94fa98b..bea0df2 100755 --- a/minitube.pro +++ b/minitube.pro @@ -1,6 +1,6 @@ CONFIG += release TEMPLATE = app -VERSION = 1.1 +VERSION = 1.2 DEFINES += APP_VERSION="$$VERSION" INCLUDEPATH += /usr/include/phonon @@ -10,9 +10,7 @@ TARGET = minitube QT += network \ xml \ phonon - include(src/qtsingleapplication/qtsingleapplication.pri) - HEADERS += src/MainWindow.h \ src/SearchView.h \ src/MediaView.h \ @@ -40,12 +38,17 @@ HEADERS += src/MainWindow.h \ src/videoareawidget.h \ src/googlesuggest.h \ src/videowidget.h \ - src/flickcharm.h \ src/videodefinition.h \ src/fontutils.h \ src/thlibrary/thblackbar.h \ src/globalshortcuts.h \ - src/globalshortcutbackend.h + src/globalshortcutbackend.h \ + src/downloadmanager.h \ + src/downloaditem.h \ + src/downloadview.h \ + src/downloadmodel.h \ + src/downloadlistview.h \ + src/downloadsettings.h SOURCES += src/main.cpp \ src/MainWindow.cpp \ src/SearchView.cpp \ @@ -71,13 +74,18 @@ SOURCES += src/main.cpp \ src/videoareawidget.cpp \ src/googlesuggest.cpp \ src/videowidget.cpp \ - src/flickcharm.cpp \ src/videodefinition.cpp \ src/constants.cpp \ src/fontutils.cpp \ src/thlibrary/thblackbar.cpp \ src/globalshortcuts.cpp \ - src/globalshortcutbackend.cpp + src/globalshortcutbackend.cpp \ + src/downloadmanager.cpp \ + src/downloaditem.cpp \ + src/downloadview.cpp \ + src/downloadmodel.cpp \ + src/downloadlistview.cpp \ + src/downloadsettings.cpp RESOURCES += resources.qrc DESTDIR = build/target/ OBJECTS_DIR = build/obj/ @@ -92,13 +100,10 @@ include(locale/locale.pri) # deploy DISTFILES += CHANGES \ COPYING - -unix:!mac { +unix:!mac { QT += dbus - HEADERS += src/gnomeglobalshortcutbackend.h SOURCES += src/gnomeglobalshortcutbackend.cpp - isEmpty(PREFIX):PREFIX = /usr BINDIR = $$PREFIX/bin INSTALLS += target diff --git a/src/AboutView.cpp b/src/AboutView.cpp index 42477be..961c867 100644 --- a/src/AboutView.cpp +++ b/src/AboutView.cpp @@ -17,7 +17,7 @@ AboutView::AboutView(QWidget *parent) : QWidget(parent) { layout->setSpacing(30); aboutlayout->addLayout(layout); - QString info = "

" + QString(Constants::APP_NAME) + "

" + QString info = "

" + QString(Constants::APP_NAME) + "

" "

" + tr("There's life outside the browser!") + "

" "

" + tr("Version %1").arg(Constants::VERSION) + "

" + QString("

%1

").arg(Constants::WEBSITE) + @@ -65,7 +65,8 @@ AboutView::AboutView(QWidget *parent) : QWidget(parent) { "

" + tr("Released under the GNU General Public License") .arg("http://www.gnu.org/licenses/gpl.html") + "

" #endif - "

© 2009-2010 " + Constants::ORG_NAME + "

"; + "

© 2009-2010 " + Constants::ORG_NAME + "

" + "";; QLabel *infoLabel = new QLabel(info, this); infoLabel->setOpenExternalLinks(true); infoLabel->setWordWrap(true); diff --git a/src/ListModel.cpp b/src/ListModel.cpp index 2b0d12f..761e5a4 100755 --- a/src/ListModel.cpp +++ b/src/ListModel.cpp @@ -78,29 +78,7 @@ QVariant ListModel::data(const QModelIndex &index, int role) const { case ActiveTrackRole: return video == m_activeVideo; case Qt::DisplayRole: - case Qt::StatusTipRole: return video->title(); - /* - case Qt::ToolTipRole: - - QString tooltip; - if (!element.firstChildElement().text().isEmpty()) { - tooltip.append(QString("").append(element.firstChildElement().text()).append("
")); - } - if (!fromDate.isEmpty()) { - tooltip.append("Pubblicato il ").append(fromDate); - } - if (!toDate.isEmpty()) { - tooltip.append("
Scadenza: ").append(toDate); - } - tooltip.append("
Tipo: ").append(typeName) - .append("
Id: ").appen QFont boldFont; - boldFont.setBold(true);d(id); - return tooltip; - */ - - // case StreamUrlRole: - // return video->streamUrl(); } return QVariant(); @@ -112,8 +90,6 @@ void ListModel::setActiveRow( int row) { m_activeRow = row; m_activeVideo = videoAt(row); - // setStateOfRow( row, Item::Played ); - int oldactiverow = m_activeRow; if ( rowExists( oldactiverow ) ) @@ -268,6 +244,7 @@ void ListModel::removeIndexes(QModelIndexList &indexes) { QList originalList(videos); QList delitems; foreach (QModelIndex index, indexes) { + if (index.row() >= originalList.size()) continue; Video* video = originalList.at(index.row()); int idx = videos.indexOf(video); if (idx != -1) { @@ -381,6 +358,7 @@ void ListModel::move(QModelIndexList &indexes, bool up) { foreach (QModelIndex index, indexes) { int row = index.row(); + if (row >= videos.size()) continue; // qDebug() << "index row" << row; Video *video = videoAt(row); movedVideos << video; diff --git a/src/ListModel.h b/src/ListModel.h index c4c078f..c84b605 100755 --- a/src/ListModel.h +++ b/src/ListModel.h @@ -8,7 +8,11 @@ enum DataRoles { ItemTypeRole = Qt::UserRole, VideoRole, - ActiveTrackRole + ActiveTrackRole, + DownloadItemRole, + HoveredItemRole, + DownloadButtonHoveredRole, + DownloadButtonPressedRole }; enum ItemTypes { diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 33a8a2f..e240745 100755 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -10,11 +10,13 @@ #include "gnomeglobalshortcutbackend.h" #endif #ifdef APP_MAC -#include "local/mac/mac_startup.h" +// #include "local/mac/mac_startup.h" #endif +#include "downloadmanager.h" MainWindow::MainWindow() : aboutView(0), + downloadView(0), mediaObject(0), audioOutput(0), m_fullscreen(false) { @@ -22,6 +24,7 @@ MainWindow::MainWindow() : // views mechanism history = new QStack(); views = new QStackedWidget(this); + setCentralWidget(views); // views searchView = new SearchView(this); @@ -32,7 +35,6 @@ MainWindow::MainWindow() : views->addWidget(mediaView); toolbarSearch = new SearchLineEdit(this); - toolbarSearch->setFont(qApp->font()); toolbarSearch->setMinimumWidth(toolbarSearch->fontInfo().pixelSize()*15); connect(toolbarSearch, SIGNAL(search(const QString&)), searchView, SLOT(watch(const QString&))); @@ -51,21 +53,15 @@ MainWindow::MainWindow() : // mediaView init stuff thats needs actions mediaView->initialize(); - // cool toolbar on the Mac - // this is too buggy to be enabled - // setUnifiedTitleAndToolBarOnMac(true); - // event filter to block ugly toolbar tooltips qApp->installEventFilter(this); - // show the initial view - showWidget(searchView); - - setCentralWidget(views); - // restore window position readSettings(); + // show the initial view + showWidget(searchView); + // Global shortcuts GlobalShortcuts &shortcuts = GlobalShortcuts::instance(); #ifdef Q_WS_X11 @@ -73,11 +69,16 @@ MainWindow::MainWindow() : shortcuts.setBackend(new GnomeGlobalShortcutBackend(&shortcuts)); #endif #ifdef APP_MAC - mac::MacSetup(); + // mac::MacSetup(); #endif connect(&shortcuts, SIGNAL(PlayPause()), pauseAct, SLOT(trigger())); connect(&shortcuts, SIGNAL(Stop()), this, SLOT(stop())); connect(&shortcuts, SIGNAL(Next()), skipAct, SLOT(trigger())); + + connect(DownloadManager::instance(), SIGNAL(statusMessageChanged(QString)), + SLOT(updateDownloadMessage(QString))); + connect(DownloadManager::instance(), SIGNAL(finished()), + SLOT(downloadsFinished())); } MainWindow::~MainWindow() { @@ -101,6 +102,7 @@ void MainWindow::createActions() { stopAct = new QAction(QtIconLoader::icon("media-playback-stop"), tr("&Stop"), this); stopAct->setStatusTip(tr("Stop playback and go back to the search view")); stopAct->setShortcuts(QList() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::Key_MediaStop)); + stopAct->setEnabled(false); actions->insert("stop", stopAct); connect(stopAct, SIGNAL(triggered()), this, SLOT(stop())); @@ -122,6 +124,9 @@ void MainWindow::createActions() { fullscreenAct->setStatusTip(tr("Go full screen")); fullscreenAct->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Return)); fullscreenAct->setShortcutContext(Qt::ApplicationShortcut); +#if QT_VERSION >= 0x040600 + fullscreenAct->setPriority(QAction::LowPriority); +#endif actions->insert("fullscreen", fullscreenAct); connect(fullscreenAct, SIGNAL(triggered()), this, SLOT(fullscreen())); @@ -191,7 +196,7 @@ void MainWindow::createActions() { quitAct->setShortcuts(QList() << QKeySequence(tr("Ctrl+Q")) << QKeySequence(Qt::CTRL + Qt::Key_W)); quitAct->setStatusTip(tr("Bye")); actions->insert("quit", quitAct); - connect(quitAct, SIGNAL(triggered()), this, SLOT(quit())); + connect(quitAct, SIGNAL(triggered()), this, SLOT(close())); siteAct = new QAction(tr("&Website"), this); siteAct->setShortcut(QKeySequence::HelpContents); @@ -255,6 +260,37 @@ void MainWindow::createActions() { connect(definitionAct, SIGNAL(triggered()), SLOT(toggleDefinitionMode())); addAction(definitionAct); + QAction *action; + + /* + action = new QAction(tr("&Autoplay"), this); + action->setStatusTip(tr("Automatically start playing videos")); + action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P)); + action->setCheckable(true); + connect(action, SIGNAL(toggled(bool)), SLOT(setAutoplay(bool))); + actions->insert("autoplay", action); + */ + + action = new QAction(tr("&Downloads"), this); + 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->setVisible(false); + connect(action, SIGNAL(toggled(bool)), SLOT(toggleDownloads(bool))); + actions->insert("downloads", action); + + action = new QAction(tr("&Download"), this); + action->setStatusTip(tr("Download the current video")); + action->setShortcut(QKeySequence::Save); + action->setIcon(QtIconLoader::icon("go-down")); + action->setEnabled(false); +#if QT_VERSION >= 0x040600 + action->setPriority(QAction::LowPriority); +#endif + connect(action, SIGNAL(triggered()), mediaView, SLOT(downloadVideo())); + actions->insert("download", action); + // common action properties foreach (QAction *action, actions->values()) { @@ -307,12 +343,18 @@ void MainWindow::createMenus() { viewMenu->addAction(pauseAct); viewMenu->addAction(skipAct); viewMenu->addSeparator(); + viewMenu->addAction(The::globalActions()->value("download")); + viewMenu->addSeparator(); viewMenu->addAction(webPageAct); viewMenu->addAction(copyPageAct); viewMenu->addAction(copyLinkAct); viewMenu->addSeparator(); viewMenu->addAction(compactViewAct); viewMenu->addAction(fullscreenAct); +#ifdef APP_MAC + extern void qt_mac_set_dock_menu(QMenu *); + qt_mac_set_dock_menu(viewMenu); +#endif helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(siteAct); @@ -341,6 +383,7 @@ void MainWindow::createToolBars() { mainToolBar->addAction(pauseAct); mainToolBar->addAction(skipAct); mainToolBar->addAction(fullscreenAct); + mainToolBar->addAction(The::globalActions()->value("download")); mainToolBar->addWidget(new Spacer()); @@ -353,7 +396,7 @@ void MainWindow::createToolBars() { seekSlider = new Phonon::SeekSlider(this); seekSlider->setIconVisible(false); - seekSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + seekSlider->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); mainToolBar->addWidget(seekSlider); mainToolBar->addWidget(new Spacer()); @@ -397,6 +440,8 @@ void MainWindow::createStatusBar() { QToolBar *toolBar = new QToolBar(this); toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); toolBar->setIconSize(QSize(16, 16)); + toolBar->addAction(The::globalActions()->value("downloads")); + // toolBar->addAction(The::globalActions()->value("autoplay")); toolBar->addAction(The::globalActions()->value("definition")); statusBar()->addPermanentWidget(toolBar); @@ -406,17 +451,24 @@ void MainWindow::createStatusBar() { void MainWindow::readSettings() { QSettings settings; restoreGeometry(settings.value("geometry").toByteArray()); +#ifdef APP_MAC + if (!isMaximized()) + move(x(), y() + mainToolBar->height() + 8); +#endif setDefinitionMode(settings.value("definition", VideoDefinition::getDefinitionNames().first()).toString()); audioOutput->setVolume(settings.value("volume", 1).toDouble()); audioOutput->setMuted(settings.value("volumeMute").toBool()); } void MainWindow::writeSettings() { - // do not save geometry when in full screen - if (m_fullscreen) - return; + QSettings settings; - settings.setValue("geometry", saveGeometry()); + + // do not save geometry when in full screen + if (!m_fullscreen) { + settings.setValue("geometry", saveGeometry()); + } + settings.setValue("volume", audioOutput->volume()); settings.setValue("volumeMute", audioOutput->isMuted()); mediaView->saveSplitterState(); @@ -459,9 +511,14 @@ void MainWindow::showWidget ( QWidget* widget ) { copyPageAct->setEnabled(widget == mediaView); copyLinkAct->setEnabled(widget == mediaView); aboutAct->setEnabled(widget != aboutView); + The::globalActions()->value("download")->setEnabled(widget == mediaView); + The::globalActions()->value("downloads")->setChecked(widget == downloadView); // toolbar only for the mediaView - mainToolBar->setVisible(widget == mediaView && !compactViewAct->isChecked()); + /* mainToolBar->setVisible( + (widget == mediaView && !compactViewAct->isChecked()) + || widget == downloadView + ); */ setUpdatesEnabled(true); @@ -513,19 +570,28 @@ void MainWindow::quit() { } void MainWindow::closeEvent(QCloseEvent *event) { + if (DownloadManager::instance()->activeItems() > 0) { + QMessageBox msgBox; + msgBox.setIconPixmap(QPixmap(":/images/app.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + msgBox.setText(tr("Do you want to exit %1 with a download in progress?").arg(Constants::APP_NAME)); + msgBox.setInformativeText(tr("If you close %1 now, this download will be cancelled.").arg(Constants::APP_NAME)); + msgBox.setModal(true); + + msgBox.addButton(tr("Close and cancel download"), QMessageBox::RejectRole); + QPushButton *waitButton = msgBox.addButton(tr("Wait for download to finish"), QMessageBox::ActionRole); + + msgBox.exec(); + + if (msgBox.clickedButton() == waitButton) { + event->ignore(); + return; + } + + } quit(); QWidget::closeEvent(event); } -/* -void MainWindow::showSettings() { - if (!settingsView) { - settingsView = new SettingsView(this); - views->addWidget(settingsView); - } - showWidget(settingsView); -}*/ - void MainWindow::showSearch() { showWidget(searchView); currentTime->clear(); @@ -559,11 +625,13 @@ void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState pauseAct->setText(tr("&Pause")); pauseAct->setStatusTip(tr("Pause playback") + " (" + pauseAct->shortcut().toString(QKeySequence::NativeText) + ")"); skipAct->setEnabled(true); + // stopAct->setEnabled(true); break; case Phonon::StoppedState: pauseAct->setEnabled(false); skipAct->setEnabled(false); + // stopAct->setEnabled(false); break; case Phonon::PausedState: @@ -572,6 +640,7 @@ void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState pauseAct->setIcon(QtIconLoader::icon("media-playback-start")); pauseAct->setText(tr("&Play")); pauseAct->setStatusTip(tr("Resume playback") + " (" + pauseAct->shortcut().toString(QKeySequence::NativeText) + ")"); + // stopAct->setEnabled(true); break; case Phonon::BufferingState: @@ -580,6 +649,7 @@ void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState pauseAct->setEnabled(false); currentTime->clear(); totalTime->clear(); + // stopAct->setEnabled(true); break; default: @@ -594,8 +664,6 @@ void MainWindow::stop() { void MainWindow::fullscreen() { - setUpdatesEnabled(false); - // No compact view action when in full screen compactViewAct->setVisible(m_fullscreen); compactViewAct->setChecked(false); @@ -609,7 +677,7 @@ void MainWindow::fullscreen() { // workaround: prevent focus on the search bar // it steals the Space key needed for Play/Pause - mainToolBar->setEnabled(m_fullscreen); + toolbarSearch->setEnabled(m_fullscreen); // Hide anything but the video mediaView->setPlaylistVisible(m_fullscreen); @@ -632,20 +700,33 @@ void MainWindow::fullscreen() { #endif if (m_fullscreen) { - // use setShortucs instead of setShortcut + + // Exit full screen + + // use setShortcuts instead of setShortcut // the latter seems not to work fullscreenAct->setShortcuts(QList() << QKeySequence(Qt::ALT + Qt::Key_Return)); fullscreenAct->setText(tr("&Full Screen")); stopAct->setShortcuts(QList() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::Key_MediaStop)); +#ifdef APP_MAC + setCentralWidget(views); + views->showNormal(); + show(); + mediaView->setFocus(); +#else mainToolBar->show(); if (m_maximized) showMaximized(); else showNormal(); +#endif - // Make sure the window has focus (Mac) + // Make sure the window has focus activateWindow(); } else { + + // Enter full screen + stopAct->setShortcuts(QList() << QKeySequence(Qt::Key_MediaStop)); fullscreenAct->setShortcuts(QList() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::ALT + Qt::Key_Return)); fullscreenAct->setText(tr("Exit &Full Screen")); @@ -655,21 +736,23 @@ void MainWindow::fullscreen() { // geometry won't be saved writeSettings(); +#ifdef APP_MAC + hide(); + views->setParent(0); + QTimer::singleShot(0, views, SLOT(showFullScreen())); +#else mainToolBar->hide(); showFullScreen(); +#endif + } m_fullscreen = !m_fullscreen; - setUpdatesEnabled(true); } void MainWindow::compactView(bool enable) { - setUpdatesEnabled(false); - - mainToolBar->setVisible(!enable); - mainToolBar->setEnabled(!enable); mediaView->setPlaylistVisible(!enable); statusBar()->setVisible(!enable); @@ -677,22 +760,20 @@ void MainWindow::compactView(bool enable) { menuBar()->setVisible(!enable); #endif - // ensure focus does not end up to the search box - // as it would steal the Space shortcut - // toolbarSearch->setEnabled(!enable); - if (enable) { - stopAct->setShortcut(QString("")); - QList shortcuts; - // for some reason it is important that ESC comes first - shortcuts << QKeySequence(Qt::CTRL + Qt::Key_Return) << QKeySequence(Qt::Key_Escape); - compactViewAct->setShortcuts(shortcuts); + stopAct->setShortcuts(QList() << QKeySequence(Qt::Key_MediaStop)); + compactViewAct->setShortcuts( + QList() << QKeySequence(Qt::CTRL + Qt::Key_Return) + << QKeySequence(Qt::Key_Escape)); + + // ensure focus does not end up to the search box + // as it would steal the Space shortcut + mediaView->setFocus(); } else { - compactViewAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return)); - stopAct->setShortcut(QKeySequence(Qt::Key_Escape)); + compactViewAct->setShortcuts(QList() << QKeySequence(Qt::CTRL + Qt::Key_Return)); + stopAct->setShortcuts(QList() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::Key_MediaStop)); } - setUpdatesEnabled(true); } void MainWindow::searchFocus() { @@ -835,3 +916,40 @@ void MainWindow::clearRecentKeywords() { searchView->updateRecentKeywords(); statusBar()->showMessage(tr("Your privacy is now safe")); } + +/* + void MainWindow::setAutoplay(bool enabled) { + QSettings settings; + settings.setValue("autoplay", QVariant::fromValue(enabled)); + } + */ + +void MainWindow::updateDownloadMessage(QString message) { + The::globalActions()->value("downloads")->setText(message); +} + +void MainWindow::downloadsFinished() { + The::globalActions()->value("downloads")->setText(tr("&Downloads")); + statusBar()->showMessage(tr("Downloads complete")); +} + +void MainWindow::toggleDownloads(bool show) { + + if (show) { + stopAct->setShortcuts(QList() << QKeySequence(Qt::Key_MediaStop)); + The::globalActions()->value("downloads")->setShortcuts( + QList() << QKeySequence(Qt::CTRL + Qt::Key_J) + << QKeySequence(Qt::Key_Escape)); + } else { + The::globalActions()->value("downloads")->setShortcuts( + QList() << QKeySequence(Qt::CTRL + Qt::Key_J)); + stopAct->setShortcuts(QList() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::Key_MediaStop)); + } + + if (!downloadView) { + downloadView = new DownloadView(this); + views->addWidget(downloadView); + } + if (show) showWidget(downloadView); + else goBack(); +} diff --git a/src/MainWindow.h b/src/MainWindow.h index 1eb0251..e90dbf8 100755 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -12,6 +12,7 @@ #include "SearchView.h" #include "MediaView.h" #include "AboutView.h" +#include "downloadview.h" class MainWindow : public QMainWindow { @@ -56,6 +57,11 @@ private slots: void showFullscreenToolbar(bool show); void showFullscreenPlaylist(bool show); + // void setAutoplay(bool enabled); + void updateDownloadMessage(QString); + void downloadsFinished(); + void toggleDownloads(bool show); + private: void initPhonon(); void createActions(); @@ -76,6 +82,7 @@ private: SearchView *searchView; MediaView *mediaView; QWidget *aboutView; + QWidget *downloadView; // actions QAction *addGadgetAct; @@ -95,7 +102,6 @@ private: QAction *webPageAct; QAction *copyPageAct; QAction *copyLinkAct; - QAction *downloadAct; QAction *volumeUpAct; QAction *volumeDownAct; QAction *volumeMuteAct; diff --git a/src/MediaView.cpp b/src/MediaView.cpp index 855e275..7cda1cb 100644 --- a/src/MediaView.cpp +++ b/src/MediaView.cpp @@ -3,8 +3,8 @@ #include "networkaccess.h" #include "videowidget.h" #include "minisplitter.h" -#include "flickcharm.h" #include "constants.h" +#include "downloadmanager.h" namespace The { QMap* globalActions(); @@ -118,14 +118,6 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) { workaroundTimer->setInterval(3000); connect(workaroundTimer, SIGNAL(timeout()), SLOT(timerPlay())); - // TODO Enable this on touch devices - // FlickCharm *flickCharm = new FlickCharm(this); - // flickCharm->activateOn(listView); - -} - -MediaView::~MediaView() { - } void MediaView::initialize() { @@ -278,6 +270,8 @@ void MediaView::activeRowChanged(int row) { QMainWindow* mainWindow = dynamic_cast(window()); if (mainWindow) mainWindow->statusBar()->showMessage(video->title()); + The::globalActions()->value("download")->setEnabled(DownloadManager::instance()->itemForVideo(video) == 0); + // see you in gotStreamUrl... } @@ -285,6 +279,13 @@ void MediaView::activeRowChanged(int row) { void MediaView::gotStreamUrl(QUrl streamUrl) { if (reallyStopped) return; + Video *video = static_cast