MainWindow::MainWindow()
: plman (this), settings (tr ("TomAmp"), "TomAmp"), isPlaying (false)
{
- setOrientation();
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mediaObject = new Phonon::MediaObject(this);
setItem (curind, false);
audioOutput->setVolume(settings.value("volume", .5).toReal());
QApplication::setWindowIcon(QIcon (QPixmap (":images/tomamp")));
+ setOrientation();
}
MainWindow::~MainWindow()
#ifdef Q_WS_MAEMO_5
QString orient = settings.value("orientation", "Automatic").toString();
if (orient == "Portrait")
+ {
setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+ }
else if (orient == "Landscape")
+ {
setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
+ }
else
+ {
setAttribute(Qt::WA_Maemo5AutoOrientation, true);
+ }
#endif
}
if (mediaObject->queue().size())
{
setItem (plman.indexOf(mediaObject->queue()[0]), wasPlaying);
+ mediaObject->queue().clear();
return;
}
int index = plman.indexOf(mediaObject->currentSource());
volumeSlider = new Phonon::VolumeSlider(this);
volumeSlider->setAudioOutput(audioOutput);
- volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
- if (flip) volumeSlider->setOrientation(Qt::Vertical);
+ if (flip)
+ {
+ volumeSlider->setOrientation(Qt::Vertical);
+ }
+ volumeSlider->setMinimumWidth(150);
volumeSlider->setMuteVisible(false);
bar->addAction(playAction);
bar->addAction(pauseAction);
musicTable->setHorizontalHeaderLabels(headers);
musicTable->setSelectionMode(QAbstractItemView::SingleSelection);
musicTable->setSelectionBehavior(QAbstractItemView::SelectRows);
+// musicTable->setAlternatingRowColors(true);
+ musicTable->verticalHeader ()->hide();
connect(musicTable, SIGNAL(cellDoubleClicked(int,int)),
this, SLOT(tableClicked(int,int)));
connect(musicTable, SIGNAL(cellClicked(int,int)),
void MainWindow::enqueueSelected()
{
int sel = musicTable->currentRow();
+ qDebug () << "Enqueue on " << sel;
if (sel >= 0)
{
mediaObject->queue().clear();
mediaObject->enqueue(plman.at(sel));
#ifdef Q_WS_MAEMO_5
- QMaemo5InformationBox::information(this, tr ("Enqueued as next song"),
+ QMaemo5InformationBox::information(this, plman.getItem(sel).title + tr (" enqueued as next song"),
QMaemo5InformationBox::DefaultTimeout);
#endif
if (controlCol >= 0 && !musicTable->cellWidget(row, controlCol))
{
QLabel* label = new QLabel;
- label->setText(QString::fromUtf8("<b><a style='text-decoration:none' href='up'>▲</a> <a style='text-decoration:none' href='down'>▼</a> <a style='text-decoration:none' href='del'>╳</a> <a style='text-decoration:none' href='info'>i</a></b>"));
+ label->setText(QString::fromUtf8("<b><a style='text-decoration:none' href='up'>▲</a> <a style='text-decoration:none' href='down'>▼</a> <a style='text-decoration:none' href='del'>╳</a> <a style='text-decoration:none' href='enq'>E</a></b>"));
label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
label->setProperty("row", row);
musicTable->setCellWidget(row, controlCol, label);
void MainWindow::playlistControl (const QString& con)
{
int i = sender ()->property("row").toInt();
- qDebug () << "Playlist control: " << con << " on " << i;
if (con == "up")
buttonUp(i);
else if (con == "down")
buttonDown(i);
else if (con == "del")
buttonDel (i);
+ else if (con == "enq")
+ {
+ musicTable->selectRow(i);
+ enqueueSelected();
+ }
else
QMessageBox::information(this, tr ("Coming up..."), tr ("This feature is not implemented yet."));
}
void MainWindow::buttonUp(int i)
{
- qDebug () << "Presses up on " << i;
if (i)
{
plman.moveItemUp(i);
void MainWindow::buttonDown(int i)
{
- qDebug () << "Presses down on " << i;
if (i < plman.size() - 1)
{
plman.moveItemDown(i);
void MainWindow::buttonDel(int i)
{
- qDebug () << "Presses del on " << i;
if (QMessageBox::question(this, "Confirm remove", "Are you sure you want to remove this item?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
return;
if (i < plman.size())
musicTable->setHorizontalHeaderLabels(headers);
playlistChanged(0);
}
+ int curitem = plman.indexOf(mediaObject->currentSource());
+ if (curitem >= 0 && isPlaying)
+ highlightRow(curitem);
}
: parentWidget (parent), lastMetaRead (-1)
{
allowedExtensions << "mp3" << "ogg" << "wav" << "wmv" << "wma" << "flac";
-// qDebug () << Phonon::BackendCapabilities::availableMimeTypes();
metaInformationResolver = new Phonon::MediaObject(parent);
connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
this, SLOT(metaStateChanged(Phonon::State,Phonon::State)));
if (files.isEmpty())
return;
- qDebug () << "Parsing folder " << dir;
int index = items.size();
foreach (QString string, files)
metaInformationResolver->setCurrentSource(items.at(index).source);
lastMetaRead = index;
}
- qDebug () << " SIZE: " << items.size ();
emit playlistChanged (index);
}
{
if (fileSupported(string) || string.toLower().startsWith("http"))
{
- qDebug () << "Adding " << string;
items.append(PlaylistItem (string));
}
}
void PlaylistManager::metaStateChanged(Phonon::State newState, Phonon::State oldState)
{
- qDebug () << "Meta state now " << newState << " old state " << oldState;
// NOTE: This is an ugly hack, since the metaInformationResolver doesn't properly load the assigned source when it's in the error state
// In order to properly read the next file we have to set it as current source again when the resolver entered the stopped state after the error
static bool wasError = false;
void PlaylistManager::appendPlaylist(const QString& filename)
{
- qDebug () << "Attempting to load playlist: " << filename;
QFile f(filename);
if (!f.open (QFile::ReadOnly))
return;
{
continue;
}
- qDebug () << "Load " << l;
items.append(PlaylistItem (l));
}
}
void PlaylistManager::appendPlaylistPLS(const QString& filename)
{
- qDebug () << "Attempting to load playlist: " << filename;
QFile f(filename);
if (!f.open (QFile::ReadOnly))
return;
{
continue;
}
- qDebug () << "PLS " << l;
if (l.trimmed().toLower().left(4) == "file")
{
QStringList tokens = l.split('=');
continue;
tokens[0] = tokens[0].mid (4);
filemap.insert(tokens[0].toInt (), items.size ());
- qDebug () << tokens;
items.append(PlaylistItem (tokens[1]));
}
else if (l.trimmed().toLower().left(5) == "title")
continue;
tokens[0] = tokens[0].mid (5);
int toupdate = filemap[tokens[0].toInt()];
- qDebug () << "Need to update " << toupdate << " for " << l;
QStringList metatok = tokens[1].split (" - ");
- qDebug () << metatok;
if (metatok.size() > 2 && toupdate >= 0 && toupdate < items.size ())
{
items[toupdate].artist = metatok[0];
QStringList ret;
for (int i = 0; i < items.size (); ++i)
ret << items[i].uri;
- qDebug () << "Returning playlist " << ret << " SIZE: " << items.size ();
return ret;
}