X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=groove.cpp;h=50accaec8447636678bcd645c3ea78cbda950414;hb=b0d38c63f46e940c41f87ad71fa36c5321b141a8;hp=f8c30c04849c69dc14dca95403ef5f1aa4eecc72;hpb=761d03eb0416a4ce1b43fb9c3d84342458c1c54f;p=groove diff --git a/groove.cpp b/groove.cpp index f8c30c0..50accae 100644 --- a/groove.cpp +++ b/groove.cpp @@ -1,12 +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,12 +17,13 @@ groove::groove(QWidget *parent) : player = new sPlayer(); QHBoxLayout *layout = new QHBoxLayout(); QVBoxLayout *vlayout = new QVBoxLayout(); - QHBoxLayout *bottomLayout = new QHBoxLayout(); + //QHBoxLayout *bottomLayout = new QHBoxLayout(); button = new QPushButton("Search"); 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(); @@ -28,12 +32,10 @@ groove::groove(QWidget *parent) : pushMenu->addAction("Song:"); //pushMenu->addAction("Artist:"); //pushMenu->addAction("Album:"); - pd = new grooveProgressBar(this); - pd->hide(); QMenu *moreAction = new QMenu(); //moreAction->addAction("Playlist"); connect(moreAction->addAction("Play Now"),SIGNAL(triggered()),this,SLOT(play())); - connect(moreAction->addAction("Show download Progress"),SIGNAL(triggered()),pd,SLOT(show())); + //connect(moreAction->addAction("Show download Progress"),SIGNAL(triggered()),pd,SLOT(show())); moreButton->setMenu(moreAction); //sMethod->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Maximum); @@ -52,6 +54,7 @@ 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);*/ @@ -63,16 +66,26 @@ groove::groove(QWidget *parent) : //this->setAttribute(Qt::WA_Maemo5AutoOrientation); layout->addWidget(lineEdit); layout->addWidget(button); - vlayout->addLayout(layout); - vlayout->addWidget(resultView); - vlayout->addLayout(bottomLayout); - bottomLayout->addWidget(dButton); + vlayout->setContentsMargins(QMargins(0,0,0,0)); + //vlayout->setMargin(0); + vlayout->setSpacing(0); + vlayout->addWidget(ok); + //vlayout->addLayout(layout); + stack = new QStackedWidget(); + stack->addWidget(resultView); + + vlayout->addWidget(stack); + //vlayout->addLayout(bottomLayout); + bBar = new bottomBar(); + vlayout->addWidget(bBar); + + /*bottomLayout->addWidget(dButton); bottomLayout->addWidget(stopButton); bottomLayout->addWidget(nextB); - bottomLayout->addWidget(moreButton); + bottomLayout->addWidget(moreButton);*/ vlayout->setMenuBar(mBar); setLayout(vlayout); - setWindowTitle("GrooveShark"); + setWindowTitle("Groove"); //Create New Grooveshark connection gs = new gscom(); //Connections @@ -84,16 +97,53 @@ groove::groove(QWidget *parent) : connect(stopButton,SIGNAL(clicked()),this,SLOT(stop())); connect(moreButton,SIGNAL(clicked()),this,SLOT(moreB())); //connect(rotator,SIGNAL(orientationChanged(Orientation)),this,SLOT(orientationChanged())); - pl = new playlist(); + 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(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())); + connect(bBar,SIGNAL(settings()),this,SLOT(showSettings())); + bBar->setPlaybackProgress(100,100); + pwindow = new pWin(); + stack->addWidget(pwindow); + stack->setCurrentWidget(resultView); + connect(bBar,SIGNAL(list()),this,SLOT(togglePlaylist())); + pwindow->setModel(pl); + } +void groove::showSettings(){ +#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON) + rot->test(); +#endif +} + +void groove::togglePlaylist() +{ + if(stack->currentWidget()==pwindow) + stack->setCurrentWidget(resultView); + else + stack->setCurrentWidget(pwindow); +} + +void groove::performSearch(QString s) +{ + qDebug() << s; + resultView->setModel(gs->getSongModel(s)); + this->stack->setCurrentWidget(this->resultView); +} + void groove::search() { if(!lineEdit->text().isEmpty()) @@ -129,8 +179,8 @@ void groove::finishedS() model = gs->getModel(); resultView->setModel(model); button->setText("Search"); - resultView->setColumnWidth(0,resultView->viewport()->width()/2); - resultView->setColumnWidth(1,resultView->viewport()->width()/2); + resultView->setColumnWidth(0,resultView->maximumViewportSize().width()/2); + resultView->setColumnWidth(1,resultView->maximumViewportSize().width()/2); lineEdit->setDisabled(false); resultView->setColumnHidden(2,true); } @@ -139,6 +189,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); @@ -148,10 +209,7 @@ void groove::play() if(item == 0) return; //gs->getSong(); - player->play(pl->addSong(item)); - pd->setMaximum(100); - pd->setValue(0); - pd->show(); + player->play(pl->addSong(item,model->item(selected.first().row(),0)->text())); } //selected. //if @@ -167,20 +225,20 @@ void groove::addSongPlaylist() //gs->getSong(); if(pl->currentplaying() == -1) { - player->play(pl->addSong(item)); + player->play(pl->addSong(item,model->item(selected.first().row(),0)->text())); } else - pl->addSong(item); - pd->setMaximum(100); - pd->setValue(0); - pd->show(); + pl->addSong(item,model->item(selected.first().row(),0)->text()); model->item(selected.first().row(),1)->setText("Added to Playlist");; + //pwindow->addSong(model->item(selected.first().row(),0)->text()); } + } void groove::stop() { player->pause(); + //mpg->pause(); } void groove::moreB() { @@ -190,12 +248,19 @@ void groove::progressUpdate(int p, qint64 d, qint64 t) { //if(!pd->isHidden()) //{ - - - pd->setMaximum(t); - pd->setValue(d); + bBar->setPlaybackProgress(d,t); //} } +void groove::resizeEvent(QResizeEvent *) +{ + if(resultView->isColumnHidden(2)) + { + resultView->setColumnWidth(0,resultView->maximumViewportSize().width()/2); + resultView->setColumnWidth(1,resultView->maximumViewportSize().width()/2); + } + else + resultView->setColumnWidth(0,resultView->maximumViewportSize().width()); +} void groove::orientationChanged() {