2 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)
3 #include "qmaemo5rotator.h"
7 groove::groove(QWidget *parent) :
10 mBar = new QMenuBar();
11 //mBar->addAction("test");
12 sMethod = new QPushButton("Song:");
13 lineEdit = new QLineEdit("");
14 player = new sPlayer();
15 QHBoxLayout *layout = new QHBoxLayout();
16 QVBoxLayout *vlayout = new QVBoxLayout();
17 QHBoxLayout *bottomLayout = new QHBoxLayout();
18 button = new QPushButton("Search");
19 QPushButton *dButton = new QPushButton("Queue");
20 QPushButton *stopButton = new QPushButton("Pause");
21 QPushButton *moreButton = new QPushButton("...");
22 QPushButton *nextB = new QPushButton("->");
23 resultView = new QTableView();
24 QMenu *pushMenu = new QMenu();
27 lineEdit->setDisabled(true);
28 pushMenu->addAction("Song:");
29 //pushMenu->addAction("Artist:");
30 //pushMenu->addAction("Album:");
31 pd = new grooveProgressBar(this);
33 QMenu *moreAction = new QMenu();
34 //moreAction->addAction("Playlist");
35 connect(moreAction->addAction("Play Now"),SIGNAL(triggered()),this,SLOT(play()));
36 connect(moreAction->addAction("Show download Progress"),SIGNAL(triggered()),pd,SLOT(show()));
37 moreButton->setMenu(moreAction);
39 //sMethod->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Maximum);
40 sMethod->setMaximumWidth(sMethod->sizeHint().rwidth());
41 sMethod->setMenu(pushMenu);
42 model = new QStandardItemModel();
43 model->setHorizontalHeaderLabels(
44 QStringList() << "Please wait for initialization"
46 resultView->setModel(model);
47 resultView->verticalHeader()->hide();
48 resultView->horizontalHeader()->setStretchLastSection(true);
49 resultView->setSelectionBehavior(QAbstractItemView::SelectRows);
50 resultView->setSelectionMode(QAbstractItemView::SingleSelection);
51 resultView->setEditTriggers(QAbstractItemView::NoEditTriggers);
52 resultView->setColumnHidden(2,true);
53 resultView->setColumnHidden(3,true);
54 resultView->setAutoScroll(false);
55 /*QPalette pal = resultView->palette();
56 pal.setBrush(QPalette::Highlight,QBrush(Qt::transparent,Qt::NoBrush));
57 resultView->setPalette(pal);*/
59 layout->addWidget(sMethod);
60 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)
61 rot = new QMaemo5Rotator(QMaemo5Rotator::AutomaticBehavior,this);
63 //this->setAttribute(Qt::WA_Maemo5AutoOrientation);
64 layout->addWidget(lineEdit);
65 layout->addWidget(button);
66 vlayout->addLayout(layout);
67 vlayout->addWidget(resultView);
68 vlayout->addLayout(bottomLayout);
69 bottomLayout->addWidget(dButton);
70 bottomLayout->addWidget(stopButton);
71 bottomLayout->addWidget(nextB);
72 bottomLayout->addWidget(moreButton);
73 vlayout->setMenuBar(mBar);
75 setWindowTitle("GrooveShark");
76 //Create New Grooveshark connection
79 connect(button, SIGNAL(clicked()), this, SLOT(search()));
80 connect(gs, SIGNAL(finishedSearch()), this, SLOT(finishedS()));
81 connect(lineEdit,SIGNAL(returnPressed()),this, SLOT(search()));
82 connect(pushMenu,SIGNAL(triggered(QAction*)),this,SLOT(changeS(QAction*)));
83 connect(dButton,SIGNAL(clicked()),this, SLOT(addSongPlaylist()));
84 connect(stopButton,SIGNAL(clicked()),this,SLOT(stop()));
85 connect(moreButton,SIGNAL(clicked()),this,SLOT(moreB()));
86 //connect(rotator,SIGNAL(orientationChanged(Orientation)),this,SLOT(orientationChanged()));
89 player->setPlaylist(pl);
90 connect(pl,SIGNAL(downloadProgress(int,qint64,qint64)),this,SLOT(progressUpdate(int,qint64,qint64)));
91 connect(pl,SIGNAL(bufferReady(int)),pd,SLOT(close()));
92 connect(pl,SIGNAL(freeze(bool)),resultView,SLOT(setDisabled(bool)));
93 connect(pl,SIGNAL(freeze(bool)),pushMenu,SLOT(setDisabled(bool)));
94 connect(pl,SIGNAL(freeze(bool)),dButton,SLOT(setDisabled(bool)));
95 connect(nextB,SIGNAL(clicked()),player,SLOT(playNext()));
99 if(!lineEdit->text().isEmpty())
101 if(lineEdit->isEnabled())
104 if(sMethod->text().compare("Song:")==0)
105 resultView->setModel(gs->getSongModel(lineEdit->text()));
106 else if(sMethod->text().compare("Artist:")==0)
107 resultView->setModel(gs->getArtistModel(lineEdit->text()));
108 else if(sMethod->text().compare("Album")==0)
109 resultView->setModel(gs->getAlbumModel(lineEdit->text()));
114 button->setText("Stop");
115 lineEdit->setDisabled(true);
119 resultView->setModel(model);
120 button->setText("Search");
121 resultView->setColumnWidth(0,resultView->viewport()->width()/2);
122 resultView->setColumnWidth(1,resultView->viewport()->width()/2);
123 lineEdit->setDisabled(false);
127 void groove::finishedS()
129 model = gs->getModel();
130 resultView->setModel(model);
131 button->setText("Search");
132 resultView->setColumnWidth(0,resultView->viewport()->width()/2);
133 resultView->setColumnWidth(1,resultView->viewport()->width()/2);
134 lineEdit->setDisabled(false);
135 resultView->setColumnHidden(2,true);
137 void groove::changeS( QAction * action)
139 sMethod->setText(action->text());
140 sMethod->setMaximumWidth(sMethod->sizeHint().rwidth());
144 QModelIndexList selected = resultView->selectionModel()->selectedRows(0);
145 if(!selected.isEmpty())
147 QStandardItem *item = model->item(selected.first().row(),2);
151 player->play(pl->addSong(item));
159 void groove::addSongPlaylist()
161 QModelIndexList selected = resultView->selectionModel()->selectedRows(0);
162 if(!selected.isEmpty())
164 QStandardItem *item = model->item(selected.first().row(),2);
168 if(pl->currentplaying() == -1)
170 player->play(pl->addSong(item));
177 model->item(selected.first().row(),1)->setText("Added to Playlist");;
187 qDebug() << "He pressed the button";
189 void groove::progressUpdate(int p, qint64 d, qint64 t)
191 //if(!pd->isHidden())
200 void groove::orientationChanged()
203 QRect screenGeometry = QApplication::desktop()->screenGeometry();
204 if (screenGeometry.width() > screenGeometry.height())