#include "downloaditem.h"
#include "MainWindow.h"
#include "temporary.h"
+#include "sidebarwidget.h"
+#include "playlistwidget.h"
+#include "refinesearchwidget.h"
+#include "sidebarwidget.h"
+#ifdef APP_MAC
+#include "macfullscreen.h"
+#endif
namespace The {
NetworkAccess* http();
splitter = new MiniSplitter(this);
splitter->setChildrenCollapsible(false);
- sortBar = new SegmentedControl(this);
- mostRelevantAction = new QAction(tr("Most relevant"), this);
- QKeySequence keySequence(Qt::CTRL + Qt::Key_1);
- mostRelevantAction->setShortcut(keySequence);
- mostRelevantAction->setStatusTip(mostRelevantAction->text() + " (" + keySequence.toString(QKeySequence::NativeText) + ")");
- addAction(mostRelevantAction);
- connect(mostRelevantAction, SIGNAL(triggered()), this, SLOT(searchMostRelevant()), Qt::QueuedConnection);
- sortBar->addAction(mostRelevantAction);
- mostRecentAction = new QAction(tr("Most recent"), this);
- keySequence = QKeySequence(Qt::CTRL + Qt::Key_2);
- mostRecentAction->setShortcut(keySequence);
- mostRecentAction->setStatusTip(mostRecentAction->text() + " (" + keySequence.toString(QKeySequence::NativeText) + ")");
- addAction(mostRecentAction);
- connect(mostRecentAction, SIGNAL(triggered()), this, SLOT(searchMostRecent()), Qt::QueuedConnection);
- sortBar->addAction(mostRecentAction);
- mostViewedAction = new QAction(tr("Most viewed"), this);
- keySequence = QKeySequence(Qt::CTRL + Qt::Key_3);
- mostViewedAction->setShortcut(keySequence);
- mostViewedAction->setStatusTip(mostViewedAction->text() + " (" + keySequence.toString(QKeySequence::NativeText) + ")");
- addAction(mostViewedAction);
- connect(mostViewedAction, SIGNAL(triggered()), this, SLOT(searchMostViewed()), Qt::QueuedConnection);
- sortBar->addAction(mostViewedAction);
-
listView = new PlaylistView(this);
listView->setItemDelegate(new PrettyItemDelegate(this));
listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(listView, SIGNAL(authorPushed(QModelIndex)), SLOT(authorPushed(QModelIndex)));
- playlistWidget = new PlaylistWidget(this, sortBar, listView);
-
- splitter->addWidget(playlistWidget);
+ sidebar = new SidebarWidget(this);
+ sidebar->setPlaylist(listView);
+ connect(sidebar->getRefineSearchWidget(), SIGNAL(searchRefined()),
+ SLOT(searchAgain()));
+ connect(listModel, SIGNAL(haveSuggestions(const QStringList &)),
+ sidebar, SLOT(showSuggestions(const QStringList &)));
+ connect(sidebar, SIGNAL(suggestionAccepted(QString)),
+ MainWindow::instance(), SLOT(startToolbarSearch(QString)));
+ splitter->addWidget(sidebar);
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);
connect(videoAreaWidget, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(showVideoContextMenu(QPoint)));
*/
+
+ QAction* refineSearchAction = The::globalActions()->value("refine-search");
+ connect(refineSearchAction, SIGNAL(toggled(bool)),
+ sidebar, SLOT(toggleRefineSearch(bool)));
}
void MediaView::setMediaObject(Phonon::MediaObject *mediaObject) {
// start serching for videos
listModel->search(searchParams);
- // this implies that the enum and the bar action order is the same
- sortBar->setCheckedAction(searchParams->sortBy()-1);
-
+ sidebar->showPlaylist();
listView->setFocus();
QString keyword = searchParams->keywords();
}
}
+ sidebar->getRefineSearchWidget()->setSearchParams(searchParams);
+ sidebar->hideSuggestions();
+
+}
+
+void MediaView::searchAgain() {
+ search(searchParams);
}
void MediaView::appear() {
delete downloadItem;
downloadItem = 0;
}
+ The::globalActions()->value("refine-search")->setChecked(false);
}
void MediaView::activeRowChanged(int row) {
}
void MediaView::setPlaylistVisible(bool visible) {
- playlistWidget->setVisible(visible);
+ if (splitter->widget(0)->isVisible() == visible) return;
+ splitter->widget(0)->setVisible(visible);
+ listView->setFocus();
+}
+
+bool MediaView::isPlaylistVisible() {
+ return splitter->widget(0)->isVisible();
}
void MediaView::timerPlay() {
if (mainWindow) mainWindow->statusBar()->showMessage(message);
}
+void MediaView::snapshot() {
+ QImage image = videoWidget->snapshot();
+ qDebug() << image.size();
+
+ const QPixmap& pixmap = QPixmap::grabWindow(videoWidget->winId());
+ // qDebug() << pixmap.size();
+ videoAreaWidget->showSnapshotPreview(pixmap);
+}
+
void MediaView::fullscreen() {
videoAreaWidget->setParent(0);
videoAreaWidget->showFullScreen();
QDesktopServices::openUrl(url);
}
+void MediaView::shareViaBuffer() {
+ Video* video = listModel->activeVideo();
+ if (!video) return;
+ QUrl url("http://bufferapp.com/add");
+ url.addQueryItem("via", "minitubeapp");
+ url.addQueryItem("text", video->title());
+ url.addQueryItem("url", video->webpage().toString());
+ if (!video->thumbnailUrls().isEmpty())
+ url.addQueryItem("picture", video->thumbnailUrls().first().toString());
+ QDesktopServices::openUrl(url);
+}
+
void MediaView::shareViaEmail() {
Video* video = listModel->activeVideo();
if (!video) return;