if (curind >= 0)
setItem (curind, false);
audioOutput->setVolume(settings.value("volume", .5).toReal());
+ QApplication::setWindowIcon(QIcon (QPixmap (":images/tomamp")));
}
MainWindow::~MainWindow()
if (folder.isEmpty())
folder = QDesktopServices::storageLocation(QDesktopServices::MusicLocation);
QStringList files = QFileDialog::getOpenFileNames(this, tr("Select Files To Add"),
- folder);
+ folder, "Music files (*.mp3 *.ogg *.wav *.flac);;Playlists (*.m3u *.pls)");
if (files.isEmpty())
return;
QStringList toadd;
foreach (QString string, files)
{
- toadd.append (string);
+ if (string.toLower().endsWith(".pls") || string.toLower().endsWith(".m3u"))
+ plman.addPlaylist(string);
+ else
+ toadd.append (string);
}
plman.addStringList(toadd);
}
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 deleket (http://www.deleket.com)"));
+ "Icons by http://itweek.deviantart.com/"));
}
void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState */)
lastPlayed = plman.indexOf(mediaObject->currentSource());
break;
case Phonon::StoppedState:
+ setWindowTitle("TomAmp");
stopAction->setEnabled(false);
playAction->setEnabled(true);
pauseAction->setVisible(false);
nextAction->setShortcut(tr("Ctrl+N"));
previousAction = new QAction(QIcon (QPixmap (":images/previous")), tr("Previous"), this);
previousAction->setShortcut(tr("Ctrl+R"));
- repeatAction = new QAction(QIcon (QPixmap (":images/repeat")), tr("Repeat"), this);
+ if (repeat)
+ repeatAction = new QAction(QIcon (QPixmap (":images/repeatActive")), tr("Repeat"), this);
+ else
+ repeatAction = new QAction(QIcon (QPixmap (":images/repeat")), tr("Repeat"), this);
repeatAction->setCheckable(true);
repeatAction->setChecked(repeat);
repeatAction->setShortcut(tr("Ctrl+I"));
- shuffleAction = new QAction(QIcon (QPixmap (":images/shuffle")), tr("Shuffle"), this);
+ if (shuffle)
+ shuffleAction = new QAction(QIcon (QPixmap (":images/shuffleActive")), tr("Shuffle"), this);
+ else
+ shuffleAction = new QAction(QIcon (QPixmap (":images/shuffle")), tr("Shuffle"), this);
shuffleAction->setCheckable(true);
shuffleAction->setChecked(shuffle);
shuffleAction->setShortcut(tr("Ctrl+H"));
repeat = !repeat;
qDebug() << "Repeat toggled to " << repeat;
settings.setValue("repeat", QVariant (repeat));
+ if (repeat)
+ repeatAction->setIcon(QIcon (QPixmap (":images/repeatActive")));
+ else
+ repeatAction->setIcon(QIcon (QPixmap (":images/repeat")));
}
void MainWindow::shuffleToggle ()
{
shuffle = !shuffle;
settings.setValue("shuffle", QVariant (shuffle));
+ if (shuffle)
+ shuffleAction->setIcon(QIcon (QPixmap (":images/shuffleActive")));
+ else
+ shuffleAction->setIcon(QIcon (QPixmap (":images/shuffle")));
}
void MainWindow::volumeToggle ()
void MainWindow::contextMenuEvent (QContextMenuEvent*e)
{
qDebug () << "Context menu event!";
+ if (childAt (e->pos())->parentWidget() != musicTable)
+ return;
contextMenu->popup(e->globalPos());
}
void MainWindow::savePlaylist ()
{
- QString filename = QFileDialog::getSaveFileName(this, tr("Please select file name"), "", "Playlist Files (*.m3u)");
- plman.loadPlaylist(filename);
+ QString filename = QFileDialog::getSaveFileName(this, tr("Please select file name"), "", "Playlist Files (*.m3u *.pls)");
+ if (filename.isEmpty())
+ return;
+ plman.savePlaylist(filename);
}
void MainWindow::loadPlaylist ()
{
- QString filename = QFileDialog::getOpenFileName(this, tr("Select playlist file to load"), "", "*.m3u");
+ QString filename = QFileDialog::getOpenFileName(this, tr("Select playlist file to load"), "", "*.m3u *.pls");
+ if (filename.isEmpty())
+ return;
plman.loadPlaylist (filename);
}