void playlistWindow::on_saveplaylist_clicked(void){ static Glib::ustring working_dir = Glib::get_home_dir(); Gtk::FileChooserDialog chooser(*this, "Save your playlist", Gtk::FILE_CHOOSER_ACTION_SAVE); chooser.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); chooser.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); chooser.set_current_folder(working_dir); const int response = chooser.run(); if(response == Gtk::RESPONSE_OK) { std::string filename = (isM3U(chooser.get_filename())) ? chooser.get_filename() : chooser.get_filename()+".m3u"; if (fileExists(filename)) { Gtk::MessageDialog dialog(*this, "File already exists", false /* use_markup */, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK_CANCEL); dialog.set_secondary_text("A file named \""+Glib::filename_display_basename(chooser.get_filename())+"\"alreay exists." ); dialog.run(); int result = dialog.run(); //Handle the response: if (result == Gtk::RESPONSE_OK) { writeM3U(filename); } } else { writeM3U(filename); } } }
/*! \brief \param songsOut \param log \param QHash<QString \param tags \return bool */ bool PlayList::generate(QList<M3uEntry> *songsOut, QString* log, QHash<QString, Tag*> *tags) { QTime timer; timer.start(); bool canceled = false; QList<M3uEntry> songs = findFiles(&canceled, log, tags); songsOut->append(songs); if (canceled) { return canceled; } int milliSecs = timer.elapsed(); QString timeUsed = Global::timeString(milliSecs); QString tmp = "Found " + QString::number(songs.size()) + " songs for " + name(); qDebug()<<tmp; log->append("\n"+tmp); tmp = "Time used: " + timeUsed; log->append("\n"+tmp); if (songs.isEmpty()) { QMessageBox::information(0, "", "No songs matching your criteria were found for playlist " + name(), QMessageBox::Ok, QMessageBox::Ok); return true; } QString outPutPath = guiSettings->value("outPutPath").toString(); QString file = name() + ".m3u"; writeM3U(outPutPath, file, songs, log); return canceled; }