+void MainWindow::aboutQt() {
+ QMessageBox::aboutQt(this, "About Qt");
+}
+
+void MainWindow::about() {
+ QMessageBox::about(this, QString("About SomePlayer v")+_SOMEPLAYER_VERSION_, "Alternate music player for Maemo 5 "
+ "written in C++ with Qt4\n\n"
+ "Author: Nikolay Tischenko aka \"somebody\" <niktischenko@gmail.com>");
+}
+
+void MainWindow::player() {
+ ui->stackedWidget->setCurrentIndex(0);
+ _player_form->reload();
+ setWindowTitle("SomePlayer");
+}
+
+void MainWindow::library() {
+ ui->menuBar->setEnabled(true);
+ ui->stackedWidget->setCurrentIndex(1);
+ showSearchPanel();
+ setWindowTitle("SomePlayer Library");
+}
+
+void MainWindow::_add_directory() {
+ QString directory = QFileDialog::getExistingDirectory (this, "Select directory", "/home/user/MyDocs", QFileDialog::ShowDirsOnly );
+ if (!directory.isEmpty()) {
+ showBusyWidget("<H1>Scanning... Please wait</H1>");
+ _library->addDirectory(directory);
+ }
+}
+
+void MainWindow::_save_playlist() {
+ QString name = QInputDialog::getText(this, "Playlist name", "Name:");
+ QList<QString> playlists = _library->getPlaylistsNames();
+ bool append = false;
+ if (playlists.contains(name)) {
+ if (QMessageBox::question(this, "Append to playlist?", "Playlist with name \""+name+"\" already exists.\n"
+ "Dow you want to append current playlist to it?",
+ QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) {
+ append = true;
+ } else {
+ append = false;
+ }
+ }
+ if (append) {
+ Playlist cur = _library->getCurrentPlaylist();
+ Playlist target = _library->getPlaylist(name);
+ QList<Track> tracks = cur.tracks();
+ foreach (Track track, tracks) {
+ target.addTrack(track);
+ }
+ _library->savePlaylist(target);
+ } else {
+ Playlist playlist = _library->getCurrentPlaylist();
+ playlist.setName(name);
+ _library->savePlaylist(playlist);
+ }
+}
+
+void MainWindow::_clear_current_playlist() {
+ Playlist playlist = _library->getCurrentPlaylist();
+ playlist.clear();
+ _library->saveCurrentPlaylist(playlist);
+ _player_form->reload();
+}
+
+void MainWindow::showBusyWidget(QString caption) {
+ _busy_widget->setText(caption);
+ ui->menuBar->setEnabled(false);
+ hideSearchPanel();
+ ui->stackedWidget->setCurrentIndex(2);
+}
+
+void MainWindow::_toggle_search_line() {
+ if (ui->searchLine->isVisible()) {
+ ui->searchLine->setText("");
+ ui->searchLine->hide();
+ ui->nextButton->hide();
+ ui->prevButton->hide();
+ _cancelSearch();
+ } else {
+ ui->searchLine->show();
+ ui->nextButton->show();
+ ui->prevButton->show();
+ }
+}
+
+void MainWindow::showSearchPanel() {
+ ui->searchButton->show();
+ ui->searchLine->setFocus();
+}
+
+void MainWindow::hideSearchPanel() {
+ ui->searchLine->setText("");
+ ui->searchLine->hide();
+ ui->nextButton->hide();
+ ui->prevButton->hide();
+ ui->searchButton->hide();
+ _cancelSearch();
+}
+
+void MainWindow::_search(QString pattern) {
+ if (ui->stackedWidget->currentIndex() == 0) { // player
+ _player_form->search(pattern);
+ } else if (ui->stackedWidget->currentIndex() == 1) { // library
+ _library_form->search(pattern);
+ }
+}
+
+void MainWindow::_nextItem() {
+ if (ui->stackedWidget->currentIndex() == 0) { // player
+ _player_form->nextItem();
+ } else if (ui->stackedWidget->currentIndex() == 1) { // library
+ _library_form->nextItem();
+ }
+}
+
+void MainWindow::_prevItem() {
+ if (ui->stackedWidget->currentIndex() == 0) { // player
+ _player_form->prevItem();
+ } else if (ui->stackedWidget->currentIndex() == 1) { // library
+ _library_form->prevItem();
+ }
+}
+
+void MainWindow::_cancelSearch() {
+ if (ui->stackedWidget->currentIndex() == 0) { // player
+ _player_form->cancelSearch();
+ } else if (ui->stackedWidget->currentIndex() == 1) { // library
+ _library_form->cancelSearch();
+ }
+}
+
+void MainWindow::_toggle_full_screen() {
+ if (isFullScreen()) {
+ ui->fscreenButton->setIcon(QIcon(":/icons/fullscreen.png"));
+ showNormal();
+ } else {
+ ui->fscreenButton->setIcon(QIcon(":/icons/window.png"));
+ showFullScreen();
+ }
+}
+
+void MainWindow::_add_files() {
+ QStringList files = QFileDialog::getOpenFileNames(this, "Add file");
+ if (!files.isEmpty()) _player_form->addFiles(files);
+}
+
+void MainWindow::_set_timer() {
+ TimerDialog dialog(this);
+ dialog.init();
+ if (_timer->isActive()) {
+ dialog.showDisable();
+ int msec = _timer->interval();
+ int h = msec/3600000;
+ int m = msec/60000 - h * 60;
+ int s = msec/1000 - h * 3600 - m * 60;
+ dialog.setTime(h, m, s);
+ }
+ if (QDialog::Accepted == dialog.exec()) {
+ if (!dialog.timerDisabled()) {
+ int h, m, s;
+ dialog.getTime(&h, &m, &s);
+ _timer->setInterval(h*3600000+m*60000+s*1000);
+ _timer->start();
+ } else if (_timer->isActive()) {
+ _timer->stop();
+ }
+ }
+}
+
+void MainWindow::_timeout() {
+ _player_form->stop();
+ _timer->stop();