X-Git-Url: https://git.sur5r.net/?p=minitube;a=blobdiff_plain;f=src%2FMainWindow.cpp;h=23cb1a60054c15e4f5b0e3cb4666e43e29c26306;hp=1ef752bd424d60008f45786f3d787c00b85f73af;hb=d1f0fac328bdf71b840ac6ac9f6fed8f324d02bb;hpb=e536746e91459fb3a7735f36caee77f299c765e2 diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp old mode 100755 new mode 100644 index 1ef752b..23cb1a6 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -9,10 +9,11 @@ #ifdef Q_WS_X11 #include "gnomeglobalshortcutbackend.h" #endif -#ifdef APP_MAC -// #include "local/mac/mac_startup.h" +#ifdef APP_MAC_STORE +#include "local/mac/mac_startup.h" #endif #include "downloadmanager.h" +#include "youtubesuggest.h" MainWindow::MainWindow() : aboutView(0), @@ -28,7 +29,7 @@ MainWindow::MainWindow() : // views searchView = new SearchView(this); - connect(searchView, SIGNAL(search(QString)), this, SLOT(showMedia(QString))); + connect(searchView, SIGNAL(search(SearchParams*)), this, SLOT(showMedia(SearchParams*))); views->addWidget(searchView); mediaView = new MediaView(this); @@ -36,7 +37,8 @@ MainWindow::MainWindow() : toolbarSearch = new SearchLineEdit(this); toolbarSearch->setMinimumWidth(toolbarSearch->fontInfo().pixelSize()*15); - connect(toolbarSearch, SIGNAL(search(const QString&)), searchView, SLOT(watch(const QString&))); + toolbarSearch->setSuggester(new YouTubeSuggest(this)); + connect(toolbarSearch, SIGNAL(search(const QString&)), this, SLOT(startToolbarSearch(const QString&))); // build ui createActions(); @@ -87,13 +89,23 @@ MainWindow::~MainWindow() { } bool MainWindow::eventFilter(QObject *obj, QEvent *event) { + if (event->type() == QEvent::MouseMove && this->m_fullscreen) { + QMouseEvent *mouseEvent = static_cast (event); + int x = mouseEvent->pos().x(); + int y = mouseEvent->pos().y(); + + 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); + } + if (event->type() == QEvent::ToolTip) { // kill tooltips return true; - } else { - // standard event processing - return QObject::eventFilter(obj, event); } + // standard event processing + return QObject::eventFilter(obj, event); } void MainWindow::createActions() { @@ -182,7 +194,7 @@ void MainWindow::createActions() { actions->insert("moveDown", moveDownAct); connect(moveDownAct, SIGNAL(triggered()), mediaView, SLOT(moveDownSelected())); - clearAct = new QAction(tr("&Clear recent keywords"), this); + clearAct = new QAction(tr("&Clear recent searches"), this); clearAct->setMenuRole(QAction::ApplicationSpecificRole); clearAct->setShortcuts(QList() << QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Delete) @@ -359,7 +371,9 @@ void MainWindow::createMenus() { helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(siteAct); +#if !defined(APP_MAC) && !defined(APP_WIN) helpMenu->addAction(donateAct); +#endif helpMenu->addAction(aboutAct); } @@ -370,13 +384,21 @@ void MainWindow::createToolBars() { mainToolBar = new QToolBar(this); #if QT_VERSION < 0x040600 | defined(APP_MAC) mainToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); +#elif defined(APP_WIN) + mainToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + mainToolBar->setStyleSheet( + "QToolBar {" + "background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #fafcfd, stop:.5 #e6f0fa, stop:.51 #dde9f7, stop:1 #dde9f7);" + "border: 0;" + "border-bottom: 1px solid #a0afc3;" + "}"); #else mainToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle); #endif mainToolBar->setFloatable(false); mainToolBar->setMovable(false); -#ifdef APP_MAC +#if defined(APP_MAC) | defined(APP_WIN) mainToolBar->setIconSize(QSize(32, 32)); #endif @@ -396,16 +418,12 @@ void MainWindow::createToolBars() { mainToolBar->addWidget(new Spacer()); seekSlider = new Phonon::SeekSlider(this); -#ifdef Q_WS_X11 - seekSlider->setDisabled(true); -#endif seekSlider->setIconVisible(false); seekSlider->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); mainToolBar->addWidget(seekSlider); - mainToolBar->addWidget(new Spacer()); - /* + mainToolBar->addWidget(new Spacer()); slider = new QSlider(this); slider->setOrientation(Qt::Horizontal); slider->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); @@ -448,7 +466,7 @@ void MainWindow::createStatusBar() { // remove ugly borders on OSX // also remove excessive spacing - statusBar()->setStyleSheet("::item{border:0 solid} QToolBar {padding:0;spacing:0;margin:0}"); + statusBar()->setStyleSheet("::item{border:0 solid} QToolBar {padding:0;spacing:0;margin:0;border:0}"); QToolBar *toolBar = new QToolBar(this); toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); @@ -466,7 +484,11 @@ void MainWindow::readSettings() { restoreGeometry(settings.value("geometry").toByteArray()); #ifdef APP_MAC if (!isMaximized()) +#ifdef QT_MAC_USE_COCOA move(x(), y() + 10); +#else + move(x(), y() + mainToolBar->height() + 8); +#endif #endif setDefinitionMode(settings.value("definition", VideoDefinition::getDefinitionNames().first()).toString()); audioOutput->setVolume(settings.value("volume", 1).toDouble()); @@ -538,7 +560,7 @@ void MainWindow::showWidget ( QWidget* widget ) { QWidget *oldWidget = views->currentWidget(); views->setCurrentWidget(widget); -#ifdef APP_MAC +#if defined(APP_MAC) || defined(APP_WIN) // crossfade only on OSX // where we can be sure of video performance fadeInWidget(oldWidget, widget); @@ -611,9 +633,7 @@ void MainWindow::showSearch() { totalTime->clear(); } -void MainWindow::showMedia(QString query) { - SearchParams *searchParams = new SearchParams(); - searchParams->setKeywords(query); +void MainWindow::showMedia(SearchParams *searchParams) { mediaView->search(searchParams); showWidget(mediaView); } @@ -932,7 +952,9 @@ void MainWindow::showFullscreenPlaylist(bool show) { void MainWindow::clearRecentKeywords() { QSettings settings; settings.remove("recentKeywords"); + settings.remove("recentChannels"); searchView->updateRecentKeywords(); + searchView->updateRecentChannels(); statusBar()->showMessage(tr("Your privacy is now safe")); } @@ -972,3 +994,19 @@ void MainWindow::toggleDownloads(bool show) { if (show) showWidget(downloadView); else goBack(); } + +void MainWindow::startToolbarSearch(QString query) { + + query = query.trimmed(); + + // check for empty query + if (query.length() == 0) { + return; + } + + SearchParams *searchParams = new SearchParams(); + searchParams->setKeywords(query); + + // go! + showMedia(searchParams); +}