X-Git-Url: http://git.maemo.org/git/?p=groove;a=blobdiff_plain;f=groove.cpp;h=c996e4b6458c06d126ef62243205aaa75ea06014;hp=102c3693e0753cfc55da8824f9f3b143e484918d;hb=0b3634745b89622ed8779575c5367bfe43a2bc0b;hpb=6413ec62dde3e49705db1a14deaa1890163dd8f1 diff --git a/groove.cpp b/groove.cpp index 102c369..c996e4b 100644 --- a/groove.cpp +++ b/groove.cpp @@ -1,10 +1,15 @@ #include "groove.h" - +#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON) +#include "qmaemo5rotator.h" +#include +#endif groove::groove(QWidget *parent) : QWidget(parent) { + //mpg = new mpgplayer(); + //mpg->start(); mBar = new QMenuBar(); //mBar->addAction("test"); sMethod = new QPushButton("Song:"); @@ -14,9 +19,11 @@ groove::groove(QWidget *parent) : QVBoxLayout *vlayout = new QVBoxLayout(); QHBoxLayout *bottomLayout = new QHBoxLayout(); button = new QPushButton("Search"); - QPushButton *dButton = new QPushButton("Play"); - QPushButton *stopButton = new QPushButton("Stop"); + QPushButton *dButton = new QPushButton("Queue"); + QPushButton *stopButton = new QPushButton("Pause"); QPushButton *moreButton = new QPushButton("..."); + QPushButton *nextB = new QPushButton("->"); + topBar *ok = new topBar(this); resultView = new QTableView(); QMenu *pushMenu = new QMenu(); //showFullScreen(); @@ -25,11 +32,10 @@ groove::groove(QWidget *parent) : pushMenu->addAction("Song:"); //pushMenu->addAction("Artist:"); //pushMenu->addAction("Album:"); - QMenu *moreAction = new QMenu(); - moreAction->addAction("Playlist"); - moreAction->addAction("Add current song to playlist"); - moreAction->addAction("Show download Progress"); + //moreAction->addAction("Playlist"); + connect(moreAction->addAction("Play Now"),SIGNAL(triggered()),this,SLOT(play())); + //connect(moreAction->addAction("Show download Progress"),SIGNAL(triggered()),pd,SLOT(show())); moreButton->setMenu(moreAction); //sMethod->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Maximum); @@ -48,25 +54,33 @@ groove::groove(QWidget *parent) : resultView->setColumnHidden(2,true); resultView->setColumnHidden(3,true); resultView->setAutoScroll(false); + resultView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); /*QPalette pal = resultView->palette(); pal.setBrush(QPalette::Highlight,QBrush(Qt::transparent,Qt::NoBrush)); resultView->setPalette(pal);*/ - + portrait = false; layout->addWidget(sMethod); -#ifdef Q_WS_MAEMO_5 - setAttribute(Qt::WA_Maemo5AutoOrientation,true); +#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON) + rot = new QMaemo5Rotator(QMaemo5Rotator::AutomaticBehavior,this); #endif + //this->setAttribute(Qt::WA_Maemo5AutoOrientation); layout->addWidget(lineEdit); layout->addWidget(button); - vlayout->addLayout(layout); + vlayout->addWidget(ok); + //vlayout->addLayout(layout); vlayout->addWidget(resultView); - vlayout->addLayout(bottomLayout); + //vlayout->addLayout(bottomLayout); + bBar = new bottomBar(); + vlayout->addWidget(bBar); + vlayout->setSpacing(0); bottomLayout->addWidget(dButton); bottomLayout->addWidget(stopButton); + bottomLayout->addWidget(nextB); bottomLayout->addWidget(moreButton); vlayout->setMenuBar(mBar); + vlayout->setContentsMargins(QMargins()); setLayout(vlayout); - setWindowTitle("GrooveShark"); + setWindowTitle("Groove"); //Create New Grooveshark connection gs = new gscom(); //Connections @@ -74,11 +88,38 @@ groove::groove(QWidget *parent) : connect(gs, SIGNAL(finishedSearch()), this, SLOT(finishedS())); connect(lineEdit,SIGNAL(returnPressed()),this, SLOT(search())); connect(pushMenu,SIGNAL(triggered(QAction*)),this,SLOT(changeS(QAction*))); - connect(dButton,SIGNAL(clicked()),this, SLOT(play())); + connect(dButton,SIGNAL(clicked()),this, SLOT(addSongPlaylist())); connect(stopButton,SIGNAL(clicked()),this,SLOT(stop())); - connect(gs,SIGNAL(sKeyFound()),this,SLOT(startP())); connect(moreButton,SIGNAL(clicked()),this,SLOT(moreB())); + //connect(rotator,SIGNAL(orientationChanged(Orientation)),this,SLOT(orientationChanged())); + pl = new playlist(this); + pl->setGscom(gs); + player->setPlaylist(pl); + connect(pl,SIGNAL(downloadProgress(int,qint64,qint64)),this,SLOT(progressUpdate(int,qint64,qint64))); + //connect(pl,SIGNAL(bufferReady(int)),pd,SLOT(close())); + connect(pl,SIGNAL(freeze(bool)),resultView,SLOT(setDisabled(bool))); + connect(pl,SIGNAL(freeze(bool)),pushMenu,SLOT(setDisabled(bool))); + connect(pl,SIGNAL(freeze(bool)),dButton,SLOT(setDisabled(bool))); + connect(nextB,SIGNAL(clicked()),player,SLOT(playNext())); + connect(ok,SIGNAL(changeTask()),this,SLOT(showOthers())); + connect(ok,SIGNAL(searchRequest(QString)),this,SLOT(performSearch(QString))); + connect(ok,SIGNAL(closeApp()),this,SLOT(close())); + connect(bBar,SIGNAL(addB()),this,SLOT(addSongPlaylist())); + connect(bBar,SIGNAL(nextB()),player,SLOT(playNext())); + connect(bBar,SIGNAL(pause()),this,SLOT(stop())); + + connect(bBar,SIGNAL(back()),player,SLOT(back())); + bBar->setPlaybackProgress(100,100); + //pwindow = new pListWin(0); + //pwindow->show(); + +} +void groove::performSearch(QString s) +{ + qDebug() << s; + resultView->setModel(gs->getSongModel(s)); } + void groove::search() { if(!lineEdit->text().isEmpty()) @@ -124,6 +165,17 @@ void groove::changeS( QAction * action) sMethod->setText(action->text()); sMethod->setMaximumWidth(sMethod->sizeHint().rwidth()); } + +void groove::showOthers() +{ +#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON) + QDBusConnection c = QDBusConnection::sessionBus(); + QDBusMessage m = QDBusMessage::createSignal("/", "com.nokia.hildon_desktop", "exit_app_view"); + + c.send(m); +#endif +} + void groove::play() { QModelIndexList selected = resultView->selectionModel()->selectedRows(0); @@ -133,25 +185,55 @@ void groove::play() if(item == 0) return; //gs->getSong(); - gs->getSong(item->text()); + player->play(pl->addSong(item)); } //selected. //if } -void groove::startP() +void groove::addSongPlaylist() { - if(!gs->sku.isValid()) - return; - player->~sPlayer(); - player = new sPlayer(); - player->play(gs->streamID,gs->sku); - + QModelIndexList selected = resultView->selectionModel()->selectedRows(0); + if(!selected.isEmpty()) + { + QStandardItem *item = model->item(selected.first().row(),2); + if(item == 0) + return; + //gs->getSong(); + if(pl->currentplaying() == -1) + { + player->play(pl->addSong(item)); + } + else + pl->addSong(item); + model->item(selected.first().row(),1)->setText("Added to Playlist");; + } + //pwindow->updateList(); } + void groove::stop() { - player->stop(); + player->pause(); + //mpg->pause(); } void groove::moreB() { qDebug() << "He pressed the button"; } +void groove::progressUpdate(int p, qint64 d, qint64 t) +{ + //if(!pd->isHidden()) + //{ + bBar->setPlaybackProgress(d,t); + //} +} + +void groove::orientationChanged() +{ +#ifdef Q_WS_MAEMO_5 + QRect screenGeometry = QApplication::desktop()->screenGeometry(); + if (screenGeometry.width() > screenGeometry.height()) + portrait = false; + else + portrait = true; +#endif +}