setupShuffleList();
setupActions();
setupMenus();
- setupUi();
+ /* if (settings.value("uiflipped", false).toBool())
+ setupUiFlipped();
+ else*/
+ setupUi ();
show ();
timeLcd->display("00:00:00");
plman.addStringList(settings.value("lastPlaylist").toStringList());
void MainWindow::about()
{
- QMessageBox::information(this, tr("About TomAmp v0.1"),
+ QMessageBox::information(this, tr("About TomAmp v0.2"),
tr("TomAmp is a simple playlist-based music player.\n\n"
"(c) 2010 Tamas Marki <tmarki@gmail.com>\n\n"
"Please send comments and bug reports to the above e-mail address.\n\n"
- "Icons by http://itweek.deviantart.com/"));
+ "Icons by http://itweek.deviantart.com/\n\n"
+ "Special thanks to Attila Csipa"));
}
void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState */)
playAction->setEnabled(false);
pauseAction->setEnabled(true);
stopAction->setEnabled(true);
- //lastPlayed = plman.indexOf(mediaObject->currentSource());
+ unhighlightRow(lastPlayed);
+ lastPlayed = plman.indexOf(mediaObject->currentSource());
+ highlightRow(plman.indexOf(mediaObject->currentSource()));
+ musicTable->selectRow(plman.indexOf(mediaObject->currentSource()));
break;
case Phonon::StoppedState:
setWindowTitle("TomAmp");
{
if (i < plman.size() && i >= 0)
{
- if (lastPlayed >= 0)
- unhighlightRow(lastPlayed);
+ /* if (lastPlayed >= 0)
+ unhighlightRow(lastPlayed);*/
if (shuffle)
{
mediaObject->setCurrentSource(plman.at (shuffleList[i]));
shuffleAction->setCheckable(true);
shuffleAction->setChecked(shuffle);
shuffleAction->setShortcut(tr("Ctrl+H"));
+ enqueueActionButton = new QAction (tr ("E"), this);
volumeAction = new QAction(QIcon (QPixmap (":images/volume")), "", this);
volumeAction->setCheckable(true);
volumeAction->setShortcut(tr("Ctrl+V"));
connect(repeatAction, SIGNAL(triggered()), this, SLOT(repeatToggle()));
connect(shuffleAction, SIGNAL(triggered()), this, SLOT(shuffleToggle()));
connect(volumeAction, SIGNAL(triggered()), this, SLOT(volumeToggle()));
+ connect(enqueueActionButton, SIGNAL(triggered()), this, SLOT(enqueueSelected()));
connect(addFilesAction, SIGNAL(triggered()), this, SLOT(addFiles()));
connect(addFoldersAction, SIGNAL(triggered()), this, SLOT(addFolder()));
void MainWindow::play()
{
mediaObject->play();
- lastPlayed = plman.indexOf(mediaObject->currentSource());
+ // lastPlayed = plman.indexOf(mediaObject->currentSource());
highlightRow(lastPlayed);
isPlaying = true;
}
void MainWindow::setupUi()
{
QToolBar *bar = new QToolBar;
+ bool flip = settings.value("uiflipped", false).toBool();
- bar->setOrientation(Qt::Vertical);
+ if(!flip) bar->setOrientation(Qt::Vertical);
bar->setStyleSheet("padding:7px");
seekSlider = new Phonon::SeekSlider(this);
seekSlider->setMediaObject(mediaObject);
+ if (flip) seekSlider->setOrientation(Qt::Vertical);
volumeSlider = new Phonon::VolumeSlider(this);
volumeSlider->setAudioOutput(audioOutput);
volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
- volumeSlider->setOrientation(Qt::Horizontal);
+ if (flip) volumeSlider->setOrientation(Qt::Vertical);
volumeSlider->setMuteVisible(false);
- // volumeAddedAction = bar->addWidget(volumeSlider);
- // volumeAddedAction->setVisible(false);
bar->addAction(playAction);
bar->addAction(pauseAction);
bar->addAction(stopAction);
bar->addAction(upAction);
bar->addAction(downAction);
bar->addAction(delAction);
+ bar->addAction(enqueueActionButton);
contextMenu = new QMenu (this);
enqueueAction = contextMenu->addAction(tr ("Enqueue"));
}
- QHBoxLayout *seekerLayout = new QHBoxLayout;
+ QLayout *seekerLayout;
+ QLayout *playbackLayout;
+ if (flip)
+ {
+ seekerLayout = new QVBoxLayout;
+ playbackLayout = new QHBoxLayout;
+ bar->addWidget(timeLcd);
+ }
+ else
+ {
+ seekerLayout = new QHBoxLayout;
+ playbackLayout = new QVBoxLayout;
+ }
QToolBar* bar2 = new QToolBar;
bar2->addAction(volumeAction);
seekerLayout->addWidget(bar2);
seekerLayout->addWidget(volumeSlider);
seekerLayout->addWidget(seekSlider);
- seekerLayout->addWidget(timeLcd);
-
- QVBoxLayout *playbackLayout = new QVBoxLayout;
+ if (!flip)
+ seekerLayout->addWidget(timeLcd);
volumeSlider->hide ();
playbackLayout->addWidget(bar);
QVBoxLayout *seekAndTableLayout = new QVBoxLayout;
seekAndTableLayout->addWidget(musicTable);
- seekAndTableLayout->addLayout(seekerLayout);
-
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout(seekAndTableLayout);
- mainLayout->addLayout(playbackLayout);
+ if (flip)
+ {
+ seekAndTableLayout->addLayout(playbackLayout);
+ mainLayout->addLayout(seekerLayout);
+ }
+ else
+ {
+ seekAndTableLayout->addLayout(seekerLayout);
+ mainLayout->addLayout(playbackLayout);
+ }
+
QWidget *widget = new QWidget;
widget->setLayout(mainLayout);
mediaObject->queue().clear();
mediaObject->enqueue(plman.at(sel));
#ifdef Q_WS_MAEMO_5
- QMaemo5InformationBox::information(this, tr ("Song enqueued as next song"),
+ QMaemo5InformationBox::information(this, tr ("Enqueued as next song"),
QMaemo5InformationBox::DefaultTimeout);
#endif
QString filename = QFileDialog::getSaveFileName(this, tr("Please select file name"), "", "Playlist Files (*.m3u *.pls)");
if (filename.isEmpty())
return;
- plman.savePlaylist(filename);
+ if (!plman.savePlaylist(filename))
+ {
+#ifdef Q_WS_MAEMO_5
+ QMaemo5InformationBox::information(this, tr ("Error writing playlist file"),
+ QMaemo5InformationBox::DefaultTimeout);
+#else
+ QMessageBox::critical(this, "Write error", "Error writing playlist file", QMessageBox::Ok);
+#endif
+ }
+
}
void MainWindow::loadPlaylist ()
{
QTableWidgetItem *item3 = new QTableWidgetItem(item.album);
item3->setFlags(item3->flags() ^ Qt::ItemIsEditable);
+
musicTable->setItem(row, col, item3);
}
}
void MainWindow::showOptions ()
{
+ bool flip = settings.value("uiflipped", false).toBool();
OptionDialog* dlg = new OptionDialog (this, settings);
dlg->exec();
delete dlg;
+ if (flip != settings.value("uiflipped", false).toBool())
+ {
+ delete centralWidget();
+ setupUi ();
+ }
setOrientation ();
if (headers != settings.value("headers", QStringList ()).toStringList())
{
PlaylistManager::PlaylistManager(QWidget* parent)
: parentWidget (parent), lastMetaRead (-1)
{
- allowedExtensions << "mp3" << "ogg" << "wav" << "wmv" << "wma";
+ allowedExtensions << "mp3" << "ogg" << "wav" << "wmv" << "wma" << "flac";
// qDebug () << Phonon::BackendCapabilities::availableMimeTypes();
metaInformationResolver = new Phonon::MediaObject(parent);
connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
void PlaylistManager::parseAndAddFolder(const QString &dir, bool recursive)
{
QStringList filters;
- // filters << "*.mp3";
QStringList files = QDir (dir).entryList(filters);
qDebug () << "Parsing folder " << dir;
- //settings.setValue("LastFolder", dir);
int index = items.size();
foreach (QString string, files)
{
items.append(PlaylistItem (PlaylistItem (fname)));
}
}
- // if (!items.isEmpty())
if (items.size () > index)
{
metaInformationResolver->setCurrentSource(items.at(index).source);
items.append(PlaylistItem (string));
}
}
- // if (!items.isEmpty())
if (items.size () > index)
{
metaInformationResolver->setCurrentSource(items.at(index).source);
void PlaylistManager::metaStateChanged(Phonon::State newState, Phonon::State oldState)
{
qDebug () << "Meta state now " << newState << " old state " << oldState;
- // This is an ugly hack, since the metaInformationResolver doesn't properly load the assigned source when it's in the error state
+ // 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;
if (wasError && newState == Phonon::StoppedState)
}
int index = lastMetaRead;
- qDebug () << "Reading meta info of " << metaInformationResolver->currentSource().fileName() << " => " << index;
QMap<QString, QString> metaData = metaInformationResolver->metaData();
items[index].genre = metaData.value("GENRE");
qDebug () << "Meta " << metaData;
qDebug () << "Info is: " << items[index].year << " - " << items[index].genre;*/
- if (metaData.isEmpty())
- qDebug () << "Detected to be empty: " << items[index].uri;
- else
+ if (!metaData.isEmpty())
items[index].playable = true;
emit itemUpdated (index);
}
}
}
-void PlaylistManager::savePlaylist(const QString& filenam)
+bool PlaylistManager::savePlaylist(const QString& filenam)
{
QString filename = filenam;
if (filename.isEmpty())
- return;
+ return false;
bool writepls = false;
if (filename.length() < 4 || (filename.right(4).toLower() != ".m3u" && filename.right(4).toLower() != ".pls"))
{
if (writepls)
f.write ("Version=2\n");
f.close ();
+ return true;
}
catch (...)
{
-// QMessageBox::critical(this, "Write error", "Could not write playlist file", QMessageBox::Ok);
}
+ return false;
}
void PlaylistManager::loadPlaylist(const QString& filename)
{
items.clear();
emit playlistChanged(0);
- /* while (musicTable->rowCount())
- musicTable->removeRow(0);
- mediaObject->clear();*/
}
QStringList PlaylistManager::playlistStrings() const
bool PlaylistManager::fileSupported (const QString& fname) const
{
- QString ext = fname.right(3).toLower();
+ if (fname.lastIndexOf('.') < 0)
+ return false;
+ QString ext = fname.right(fname.size() - fname.lastIndexOf('.') - 1).toLower();
foreach (QString e, allowedExtensions)
{
if (ext == e)
items[i - 1] = items[i];
items[i] = tmp;
return true;
- // emit playlistChanged(i - 1);
}
return false;
}
items[i + 1] = items[i];
items[i] = tmp;
return true;
- // emit playlistChanged(i - 1);
}
return false;
}