+
+void MainWindow::_save_playlist() {
+ QString name = QInputDialog::getText(this, "Playlist name", "Name:");
+ 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);
+}