void MyCCDialog::onDtmf(int event, int duration) { DBG("MyCCDialog::onDtmf, got event %d, duration %d.\n", event, duration); switch (state) { case CC_Collecting_PIN: { // flush the playlist (stop playing) // if a key is entered playlist.flush(); if(event <10) { pin +=int2str(event); DBG("pin is now '%s'\n", pin.c_str()); } else { AmArg di_args,ret; di_args.push(pin.c_str()); cc_acc->invoke("getCredit", di_args, ret); credit = ret.get(0).asInt(); if (credit < 0) { addToPlaylist(MyCCFactory::IncorrectPIN); pin = ""; } else if (credit == 0) { addToPlaylist(MyCCFactory::OutOfCredit); pin = ""; } else { number = ""; state = CC_Collecting_Number; addToPlaylist(MyCCFactory::EnterNumber); } } } break; case CC_Collecting_Number: { // flush the playlist (stop playing) // if a key is entered playlist.flush(); if(event <10) { number +=int2str(event); DBG("number is now '%s'\n", number.c_str()); } else { if (getCalleeStatus() == None) { state = CC_Dialing; connectCallee(number + " <sip:" + number+ MyCCFactory::ConnectSuffix + ">", "sip:"+number+MyCCFactory::ConnectSuffix); addToPlaylist(MyCCFactory::Dialing); } } } break; case CC_Dialing: case CC_Connected: default: break; }; }
MediaPlayer::MediaPlayer( QObject * parent ) : QObject ( parent ) { playlist = new MediaPlaylist; player = new QMediaPlayer; tracker = new trackerinterface; player->setPlaylist(playlist); iPlaybackStatus = 0; iPosition = 0; iDuration = 0; iCurrentIndex = 0; sCurrentResultsQuery = ""; mediaArtist = ""; mediaTitle = ""; plModel = new PlaylistModel(); plModel->setPlaylist(playlist); shuffle = false; loop = false; if(_settings.value("playMode") == 1) toggleLoop(); QObject::connect(player, &QMediaPlayer::stateChanged, this, &MediaPlayer::setPlaybackStatus); QObject::connect(player, &QMediaPlayer::positionChanged, this, &MediaPlayer::setPosition); QObject::connect(player, &QMediaPlayer::durationChanged, this, &MediaPlayer::setDuration); //Old connection syntax due to overloaded metaDataChanged() QObject::connect(player, SIGNAL(metaDataChanged()), this, SLOT(metaDataCallback())); QObject::connect(playlist, &QMediaPlaylist::currentIndexChanged, this, &MediaPlayer::checkPlaylist); //QObject::connect(tracker, &trackerinterface::randomItemComplete, this, &MediaPlayer::addToPlaylist); //old connection syntax due to overloaded slot method QObject::connect(tracker, SIGNAL(randomItemComplete(QString)), this, SLOT(addToPlaylist(QString))); }
bool MyCCDialog::onOtherReply(const AmSipReply& reply) { DBG("OnOtherReply \n"); if (state == CC_Dialing) { if (reply.code < 200) { DBG("Callee is trying... code %d\n", reply.code); } else if(reply.code < 300){ if (getCalleeStatus() == Connected) { state = CC_Connected; startAccounting(); // clear audio input and output setInOut(NULL, NULL); // detach from media processor (not in RTP path any more) AmMediaProcessor::instance()->removeSession(this); // set the call timer setTimer(TIMERID_CREDIT_TIMEOUT, credit); } } else { DBG("Callee final error with code %d\n",reply.code); addToPlaylist(MyCCFactory::DialFailed); number = ""; state = CC_Collecting_Number; } } // we dont call // AmB2BCallerSession::onOtherReply(reply); // as it tears down the call if callee could // not be reached return false; }
void MusicPlayer::playSong(char *songName) { Flag_toPlay = 1; if(addToPlaylist(songName)) { playList(); } }
void Player::showTracksContextMenu(const QPoint &point) { if (_ui->tracks->currentRow() >= 0 && _tracksMenu->exec(_ui->tracks->mapToGlobal(point)) == _trackToPlaylistAction) { addToPlaylist(_libTracks[_ui->tracks->currentRow()]); } }
void Player::showArtistsContextMenu(const QPoint &point) { if (_ui->artists->itemAt(point) && _artistsMenu->exec(_ui->artists->mapToGlobal(point)) == _artistToPlaylistAction) { addToPlaylist(DataBase::instance()->tracks(_ui->artists->itemAt(point)->text(), ALL)); } }
void ControlWidget::dropEvent( QDropEvent *event ) { const QMimeData *mimeData = event->mimeData(); if( mimeData->hasUrls() ) { int player = -1; PlayerFSM::eState state[2]; state[0] = mpPlayer[0]->getState(); state[1] = mpPlayer[1]->getState(); QString fileName; QStringList fileNames; foreach( const QUrl &url, mimeData->urls() ) { fileName = url.toLocalFile(); if( !fileName.isEmpty() ) { fileNames.append( fileName ); } } if( (state[0] == PlayerFSM::ready) ) { player = 0; } else if( (state[1] == PlayerFSM::ready) ) { player = 1; } if( player >= 0 ) { fileNames << mpPlayer[player]->getCurrentTrack(); addToPlaylist( fileNames ); mpPlayer[player]->unload( true ); } else { addToPlaylist( fileNames ); } if( (state[0] == PlayerFSM::disconnected) && (state[1] == PlayerFSM::disconnected) ) { QMetaObject::invokeMethod( mpStartButton, "click", Qt::QueuedConnection ); } event->acceptProposedAction(); return; }
void Player::showAlbumsContextMenu(const QPoint &point) { if (_ui->albums->itemAt(point) && _albumsMenu->exec(_ui->albums->mapToGlobal(point)) == _albumToPlaylistAction) { addToPlaylist(DataBase::instance()->tracks(_ui->artists->currentItem()->text(), _ui->albums->itemAt(point)->text())); } }
boolean MusicPlayer::addToPlaylist(char *songName)//add a song to current playlist { unsigned int songindex; if(newsd.findIndex(songName,songindex)) { addToPlaylist(songindex); return true; } else return false; }
void MyCCDialog::onSessionStart(const AmSipRequest& req) { DBG("MyCCDialog::onSessionStart"); AmB2BCallerSession::onSessionStart(req); setInOut(&playlist, &playlist); addToPlaylist(MyCCFactory::InitialAnnouncement); setDtmfDetectionEnabled(true); }
void MainWindow::open() //POST: Clears our playlist, and starts playing the file returned by our file dialog { cleanUp(); //delete wav files made by last playlist playlistWidget->clear(); //clear our playlist curTrack = -1; //allow for our curTrack to be incremented to zero numTracks = 0; //reset the number of tracks we have addToPlaylist(); //open a file dialog and add new songs to our now empty playlist }
void Player::open() { #ifdef Q_WS_MAEMO_5 QStringList fileNames; QString fileName = QFileDialog::getOpenFileName(this, tr("Open Files"), "/"); if (!fileName.isEmpty()) fileNames << fileName; #else QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Files")); #endif addToPlaylist(fileNames); }
VimeoPlaylistDialog::VimeoPlaylistDialog(VimeoVideo *video, QWidget *parent) : Dialog(parent), m_video(video), m_playlist(0), m_model(new VimeoPlaylistModel(this)), m_cache(new ImageCache), m_view(new ListView(this)), m_tabBar(new QTabBar(this)), m_stack(new QStackedWidget(this)), m_scrollArea(0), m_titleEdit(0), m_descriptionEdit(0), m_passwordEdit(0), m_label(new QLabel(QString("<p align='center'; style='font-size: 40px; color: %1'>%2</p>") .arg(palette().color(QPalette::Mid).name()).arg(tr("No albums found")), this)), m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Vertical, this)), m_layout(new QGridLayout(this)) { setWindowTitle(tr("Add to album")); setMinimumHeight(340); m_view->setModel(m_model); m_view->setItemDelegate(new PlaylistDelegate(m_cache, VimeoPlaylistModel::DateRole, VimeoPlaylistModel::ThumbnailUrlRole, VimeoPlaylistModel::TitleRole, VimeoPlaylistModel::UsernameRole, VimeoPlaylistModel::VideoCountRole, m_view)); m_tabBar->addTab(tr("Albums")); m_tabBar->addTab(tr("New album")); m_tabBar->setExpanding(false); m_tabBar->setDrawBase(false); m_tabBar->setStyleSheet("QTabBar::tab { height: 40px; }"); m_stack->addWidget(m_view); m_stack->addWidget(m_label); m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); m_layout->addWidget(m_tabBar, 0, 0); m_layout->addWidget(m_stack, 1, 0); m_layout->addWidget(m_buttonBox, 1, 1, 2, 1); m_layout->setRowStretch(1, 1); connect(m_cache, SIGNAL(imageReady()), this, SLOT(onImageReady())); connect(m_model, SIGNAL(statusChanged(QVimeo::ResourcesRequest::Status)), this, SLOT(onModelStatusChanged(QVimeo::ResourcesRequest::Status))); connect(m_view, SIGNAL(activated(QModelIndex)), this, SLOT(addToPlaylist(QModelIndex))); connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(onTabIndexChanged(int))); connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(createNewPlaylist())); }
void Player::open() { QSettings s; QString foldername = s.value("last_folder",QDir::currentPath()).toString(); QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Files"), foldername); if(fileNames.size() > 0) { QFileInfo info(fileNames.first()); s.setValue("last_folder", info.absolutePath()); } addToPlaylist(fileNames); }
void loadPlaylistFromStateFile(FILE * fp, char * buffer, int state, int current, unsigned time) { char * ptrptr; char * temp; int song; if(!myFgets(buffer,PLAYLIST_BUFFER_SIZE,fp)) { ERROR("error parsing state file \"%s\"\n",playlist_stateFile); exit(EXIT_FAILURE); } while(strcmp(buffer,PLAYLIST_STATE_FILE_PLAYLIST_END)) { song = atoi(strtok_r(buffer,":",&ptrptr)); if(!(temp = strtok_r(NULL,"",&ptrptr))) { ERROR("error parsing state file \"%s\"\n", playlist_stateFile); exit(EXIT_FAILURE); } if(addToPlaylist(stderr,temp)==0 && current==song) { if(state!=PLAYER_STATE_STOP) { playPlaylist(stderr,playlist.length-1,0); } if(state==PLAYER_STATE_PAUSE) { playerPause(stderr); } if(state!=PLAYER_STATE_STOP) { seekSongInPlaylist(stderr,playlist.length-1, time); } } if(!myFgets(buffer,PLAYLIST_BUFFER_SIZE,fp)) { ERROR("error parsing state file \"%s\"\n", playlist_stateFile); exit(EXIT_FAILURE); } } }
bool Player::loadPlaylist(const QString &fileName) { QFile file(fileName); if (!file.open(QFile::ReadOnly)) return false; QTextStream stream(&file); stream.setCodec("UTF-8"); Track *track = 0; while (!stream.atEnd()) { QString trackFileName = stream.readLine(); if (!trackFileName.isEmpty()) { track = DataBase::instance()->track(trackFileName); if (!track) track = new Track(trackFileName); addToPlaylist(track); } } file.close(); _ui->playlist->setCurrentCell(0, 0); return true; }
Player::Player(QWidget *parent) : QWidget(parent) , videoWidget(0) , coverLabel(0) , slider(0) #ifndef PLAYER_NO_COLOROPTIONS , colorDialog(0) #endif { //! [create-objs] player = new QMediaPlayer(this); // owned by PlaylistModel playlist = new QMediaPlaylist(); player->setPlaylist(playlist); //! [create-objs] connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64))); connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64))); connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged())); connect(playlist, SIGNAL(currentIndexChanged(int)), SLOT(playlistPositionChanged(int))); connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(statusChanged(QMediaPlayer::MediaStatus))); connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int))); connect(player, SIGNAL(videoAvailableChanged(bool)), this, SLOT(videoAvailableChanged(bool))); connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage())); //! [2] videoWidget = new VideoWidget(this); player->setVideoOutput(videoWidget); playlistModel = new PlaylistModel(this); playlistModel->setPlaylist(playlist); //! [2] playlistView = new QListView(this); playlistView->setModel(playlistModel); playlistView->setCurrentIndex(playlistModel->index(playlist->currentIndex(), 0)); connect(playlistView, SIGNAL(activated(QModelIndex)), this, SLOT(jump(QModelIndex))); slider = new QSlider(Qt::Horizontal, this); slider->setRange(0, player->duration() / SLIDER_DIVISOR); labelDuration = new QLabel(this); connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(seek(int))); labelHistogram = new QLabel(this); labelHistogram->setText("Histogram:"); histogram = new HistogramWidget(this); QHBoxLayout *histogramLayout = new QHBoxLayout; histogramLayout->addWidget(labelHistogram); histogramLayout->addWidget(histogram, 1); probe = new QVideoProbe(this); connect(probe, SIGNAL(videoFrameProbed(QVideoFrame)), histogram, SLOT(processFrame(QVideoFrame))); probe->setSource(player); QPushButton *openButton = new QPushButton(tr("Open"), this); connect(openButton, SIGNAL(clicked()), this, SLOT(open())); PlayerControls *controls = new PlayerControls(this); controls->setState(player->state()); controls->setVolume(player->volume()); controls->setMuted(controls->isMuted()); connect(controls, SIGNAL(play()), player, SLOT(play())); connect(controls, SIGNAL(pause()), player, SLOT(pause())); connect(controls, SIGNAL(stop()), player, SLOT(stop())); connect(controls, SIGNAL(next()), playlist, SLOT(next())); connect(controls, SIGNAL(previous()), this, SLOT(previousClicked())); connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int))); connect(controls, SIGNAL(changeMuting(bool)), player, SLOT(setMuted(bool))); connect(controls, SIGNAL(changeRate(qreal)), player, SLOT(setPlaybackRate(qreal))); connect(controls, SIGNAL(stop()), videoWidget, SLOT(update())); connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), controls, SLOT(setState(QMediaPlayer::State))); connect(player, SIGNAL(volumeChanged(int)), controls, SLOT(setVolume(int))); connect(player, SIGNAL(mutedChanged(bool)), controls, SLOT(setMuted(bool))); fullScreenButton = new QPushButton(tr("FullScreen"), this); fullScreenButton->setCheckable(true); #ifndef PLAYER_NO_COLOROPTIONS colorButton = new QPushButton(tr("Color Options..."), this); colorButton->setEnabled(false); connect(colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog())); #endif QBoxLayout *displayLayout = new QHBoxLayout; displayLayout->addWidget(videoWidget, 2); displayLayout->addWidget(playlistView); QBoxLayout *controlLayout = new QHBoxLayout; controlLayout->setMargin(0); controlLayout->addWidget(openButton); controlLayout->addStretch(1); controlLayout->addWidget(controls); controlLayout->addStretch(1); controlLayout->addWidget(fullScreenButton); #ifndef PLAYER_NO_COLOROPTIONS controlLayout->addWidget(colorButton); #endif QBoxLayout *layout = new QVBoxLayout; layout->addLayout(displayLayout); QHBoxLayout *hLayout = new QHBoxLayout; hLayout->addWidget(slider); hLayout->addWidget(labelDuration); layout->addLayout(hLayout); layout->addLayout(controlLayout); layout->addLayout(histogramLayout); setLayout(layout); if (!player->isAvailable()) { QMessageBox::warning(this, tr("Service not available"), tr("The QMediaPlayer object does not have a valid service.\n"\ "Please check the media service plugins are installed.")); controls->setEnabled(false); playlistView->setEnabled(false); openButton->setEnabled(false); #ifndef PLAYER_NO_COLOROPTIONS colorButton->setEnabled(false); #endif fullScreenButton->setEnabled(false); } metaDataChanged(); QStringList arguments = qApp->arguments(); arguments.removeAt(0); addToPlaylist(arguments); }
void Player::open() { QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Files")); addToPlaylist(fileNames); }
void MainWindow::createActions() //POST: Actions are initialized and connected to the appropriate slots for handling { //This is very repetitive. Format for creating an action: /* actionPointer = new QAction("n&ame", parent); //Initiliaze action of name // "name" with alt-shortcut indicated // by character following '&' actionPointer->setShorcut(tr("keyboard shortcut")); //Sets the action's shortcut // ex. "Ctrl+Alt+K" connect(actionPointer, SIGNAL(triggered), //When the action is triggered (via menu someWidgetPointer, SLOT(someSlot())); // click et al.), handle this via a slot */ //method of someWidget //If the action just switches some property on or off (true or false), one can use // actionPointer->setCheckable() to indicate this. To check if the property is on or off // use actionPointer->isChecked() // File menu actions openAct = new QAction("&Open", this); openAct->setShortcut(tr("Ctrl+O")); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); enqueueAct = new QAction("&Add to Playlist", this); enqueueAct->setShortcut(tr("Ctrl+A")); connect(enqueueAct, SIGNAL(triggered()), this, SLOT(addToPlaylist())); quitAct = new QAction("&Quit", this); quitAct->setShortcut(tr("Ctrl+Q")); connect(quitAct, SIGNAL(triggered()), this, SLOT(quit())); // Controls toolbar actions pauseAct = new QAction(style()->standardIcon(QStyle::SP_MediaPause), tr("P&ause"), this); connect(pauseAct, SIGNAL(triggered()), myPlayer, SLOT(pause())); connect(pauseAct, SIGNAL(triggered()), glWindow, SLOT(pauseSong())); playAct = new QAction(style()->standardIcon(QStyle::SP_MediaPlay), "P&lay", this); connect(playAct, SIGNAL(triggered()), this, SLOT(resumeTest())); prevAct = new QAction(style()->standardIcon(QStyle::SP_MediaSkipBackward), "&Prev", this); connect(prevAct, SIGNAL(triggered()), this, SLOT(gotoPrevSong())); nextAct = new QAction(style()->standardIcon(QStyle::SP_MediaSkipForward), "&Next", this); connect(nextAct, SIGNAL(triggered()), this, SLOT(gotoNextSong())); stopAct = new QAction(style()->standardIcon(QStyle::SP_MediaStop), "&Stop", this); connect(stopAct, SIGNAL(triggered()), myPlayer, SLOT(stop())); connect(stopAct, SIGNAL(triggered()), glWindow, SLOT(stopSong())); // Visualization menu actions redAct = new QAction("Increase &Red", this); redAct->setShortcut(tr("Ctrl+R")); connect(redAct, SIGNAL(triggered()), glWindow, SLOT(IncreaseRed())); greenAct = new QAction("Increase &Green", this); greenAct->setShortcut(tr("Ctrl+G")); connect(greenAct, SIGNAL(triggered()), glWindow, SLOT(IncreaseGreen())); blueAct = new QAction("Increase &Blue", this); blueAct->setShortcut(tr("Ctrl+B")); connect(blueAct, SIGNAL(triggered()), glWindow, SLOT(IncreaseBlue())); prevVisAct = new QAction("&Previous Visualization", this); prevVisAct->setShortcut(tr("Ctrl+Z")); connect(prevVisAct, SIGNAL(triggered()), glWindow, SLOT(LastVisualization())); nextVisAct = new QAction("&Next Visualization", this); nextVisAct->setShortcut(tr("Ctrl+X")); connect(nextVisAct, SIGNAL(triggered()), glWindow, SLOT(NextVisualization())); fullScreenAct = new QAction("&Fullscreen", this); fullScreenAct->setShortcut(tr("Ctrl+F")); fullScreenAct->setCheckable(true); connect(fullScreenAct, SIGNAL(triggered()), this, SLOT(fullScreen())); //Playlist actions repeatOneAct = new QAction("Repeat &One", this); repeatOneAct->setShortcut(tr("Ctrl+T")); repeatOneAct->setCheckable(true); repeatAllAct = new QAction("Repeat &All", this); repeatAllAct->setShortcut(tr("Ctrl+Alt+T")); repeatAllAct->setCheckable(true); // About action aboutAct = new QAction("&About", this); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); }
void MusicListView::showContextMenu(const QPoint &pos, PlaylistPtr selectedPlaylist, PlaylistPtr favPlaylist, QList<PlaylistPtr> newPlaylists) { Q_D(MusicListView); QItemSelectionModel *selection = this->selectionModel(); if (selection->selectedRows().length() <= 0) { return; } QPoint globalPos = this->mapToGlobal(pos); QMenu playlistMenu; playlistMenu.setStyle(QStyleFactory::create("dlight")); auto newvar = QVariant::fromValue(PlaylistPtr()); auto createPlaylist = playlistMenu.addAction(tr("New playlist")); createPlaylist->setData(newvar); createPlaylist->setIcon(QIcon(":/light/image/plus.svg")); playlistMenu.addSeparator(); if (selectedPlaylist != favPlaylist) { auto act = playlistMenu.addAction(favPlaylist->displayName()); act->setData(QVariant::fromValue(favPlaylist)); } for (auto playlist : newPlaylists) { QFont font(playlistMenu.font()); QFontMetrics fm(font); auto text = fm.elidedText(QString(playlist->displayName().replace("&", "&&")), Qt::ElideMiddle, 160); auto act = playlistMenu.addAction(text); act->setData(QVariant::fromValue(playlist)); } connect(&playlistMenu, &QMenu::triggered, this, [ = ](QAction * action) { auto playlist = action->data().value<PlaylistPtr >(); qDebug() << playlist; MetaPtrList metalist; for (auto &index : selection->selectedRows()) { auto meta = d->model->meta(index); if (!meta.isNull()) { metalist << meta; } } Q_EMIT addToPlaylist(playlist, metalist); }); bool singleSelect = (1 == selection->selectedRows().length()); QMenu myMenu; myMenu.setStyle(QStyleFactory::create("dlight")); QAction *playAction = nullptr; if (singleSelect) { playAction = myMenu.addAction(tr("Play")); } myMenu.addAction(tr("Add to playlist"))->setMenu(&playlistMenu); myMenu.addSeparator(); QAction *displayAction = nullptr; if (singleSelect) { displayAction = myMenu.addAction(tr("Display in file manager")); } auto removeAction = myMenu.addAction(tr("Remove from playlist")); auto deleteAction = myMenu.addAction(tr("Delete from local disk")); QAction *songAction = nullptr; QMenu textCodecMenu; textCodecMenu.setStyle(QStyleFactory::create("dlight")); if (singleSelect) { auto index = selection->selectedRows().first(); auto meta = d->model->meta(index); QList<QByteArray> codecList = DMusic::detectMetaEncodings(meta); // codecList << "utf-8" ; for (auto codec : codecList) { auto act = textCodecMenu.addAction(codec); act->setData(QVariant::fromValue(codec)); } if (codecList.length() > 1) { myMenu.addSeparator(); myMenu.addAction(tr("Encoding"))->setMenu(&textCodecMenu); } myMenu.addSeparator(); songAction = myMenu.addAction(tr("Song info")); connect(&textCodecMenu, &QMenu::triggered, this, [ = ](QAction * action) { auto codec = action->data().toByteArray(); meta->updateCodec(codec); Q_EMIT updateMetaCodec(meta); }); } if (playAction) { connect(playAction, &QAction::triggered, this, [ = ](bool) { auto index = selection->selectedRows().first(); Q_EMIT playMedia(d->model->meta(index)); }); } if (displayAction) { connect(displayAction, &QAction::triggered, this, [ = ](bool) { auto index = selection->selectedRows().first(); auto meta = d->model->meta(index); auto dirUrl = QUrl::fromLocalFile(meta->localPath); Dtk::Widget::DDesktopServices::showFileItem(dirUrl); }); } if (removeAction) { connect(removeAction, &QAction::triggered, this, [ = ](bool) { d->removeSelection(selection); }); } if (deleteAction) { connect(deleteAction, &QAction::triggered, this, [ = ](bool) { bool containsCue = false; MetaPtrList metalist; for (auto index : selection->selectedRows()) { auto meta = d->model->meta(index); if (!meta->cuePath.isEmpty()) { containsCue = true; } metalist << meta; } Dtk::Widget::DDialog warnDlg(this); warnDlg.setStyle(QStyleFactory::create("dlight")); warnDlg.setTextFormat(Qt::RichText); warnDlg.addButton(tr("Cancel"), true, Dtk::Widget::DDialog::ButtonWarning); warnDlg.addButton(tr("Delete"), false, Dtk::Widget::DDialog::ButtonNormal); auto cover = QImage(QString(":/common/image/del_notify.svg")); if (1 == metalist.length()) { auto meta = metalist.first(); auto coverData = MetaSearchService::coverData(meta); if (coverData.length() > 0) { cover = QImage::fromData(coverData); } warnDlg.setMessage(QString(tr("Are you sure you want to delete %1?")).arg(meta->title)); } else { warnDlg.setMessage(QString(tr("Are you sure you want to delete the selected %1 songs?")).arg(metalist.length())); } if (containsCue) { warnDlg.setTitle(tr("Are you sure you want to delete the selected %1 songs?").arg(metalist.length())); warnDlg.setMessage(tr("Deleting the current song will also delete the song files contained")); } auto coverPixmap = QPixmap::fromImage(WidgetHelper::cropRect(cover, QSize(64, 64))); warnDlg.setIcon(QIcon(coverPixmap)); if (0 == warnDlg.exec()) { return; } Q_EMIT deleteMusicList(metalist); }); } if (songAction) { connect(songAction, &QAction::triggered, this, [ = ](bool) { auto index = selection->selectedRows().first(); auto meta = d->model->meta(index); Q_EMIT showInfoDialog(meta); }); } myMenu.exec(globalPos); }
void Player::addToPlaylist(const QList<Track *> &tracks) { for (int i = 0; i < tracks.size(); ++i) addToPlaylist(tracks[i]); }
void MusicPlayer::addToNewPlaylist() { playlistInit();//clear the current playlist addToPlaylist(); }
void AnimationListWidget::addSelectedItemsToPlaylist() { Q_EMIT addToPlaylist(selectedItems()); }
int loadPlaylist(FILE * fp, char * utf8file) { FILE * fileP; char s[MAXPATHLEN+1]; int slength = 0; char * temp = strdup(utf8ToFsCharset(utf8file)); char * rfile = malloc(strlen(temp)+strlen(".")+ strlen(PLAYLIST_FILE_SUFFIX)+1); char * actualFile; char * parent = parentPath(temp); int parentlen = strlen(parent); char * erroredFile = NULL; int tempInt; int commentCharFound = 0; strcpy(rfile,temp); strcat(rfile,"."); strcat(rfile,PLAYLIST_FILE_SUFFIX); free(temp); if((actualFile = rpp2app(rfile)) && isPlaylist(actualFile)) free(rfile); else { free(rfile); commandError(fp, ACK_ERROR_NO_EXIST, "playlist \"%s\" not found", utf8file); return -1; } while(!(fileP = fopen(actualFile,"r")) && errno==EINTR); if(fileP==NULL) { commandError(fp, ACK_ERROR_SYSTEM, "problems opening file \"%s\"", utf8file); return -1; } while((tempInt = fgetc(fileP))!=EOF) { s[slength] = tempInt; if(s[slength]=='\n' || s[slength]=='\0') { commentCharFound = 0; s[slength] = '\0'; if(s[0]==PLAYLIST_COMMENT) { commentCharFound = 1; } if(strncmp(s,musicDir,strlen(musicDir))==0) { strcpy(s,&(s[strlen(musicDir)])); } else if(parentlen) { temp = strdup(s); memset(s,0,MAXPATHLEN+1); strcpy(s,parent); strncat(s,"/",MAXPATHLEN-parentlen); strncat(s,temp,MAXPATHLEN-parentlen-1); if(strlen(s)>=MAXPATHLEN) { commandError(fp, ACK_ERROR_PLAYLIST_LOAD, "\"%s\" too long", temp); free(temp); while(fclose(fileP) && errno==EINTR); if(erroredFile) free(erroredFile); return -1; } free(temp); } slength = 0; temp = fsCharsetToUtf8(s); if(!temp) continue; temp = strdup(temp); if(commentCharFound && !getSongFromDB(temp) && !isRemoteUrl(temp)) { free(temp); continue; } if((addToPlaylist(stderr,temp))<0) { if(!erroredFile) erroredFile = strdup(temp); } free(temp); } else if(slength==MAXPATHLEN) { s[slength] = '\0'; commandError(fp, ACK_ERROR_PLAYLIST_LOAD, "line in \"%s\" is too long", utf8file); ERROR("line \"%s\" in playlist \"%s\" is too long\n", s, utf8file); while(fclose(fileP) && errno==EINTR); if(erroredFile) free(erroredFile); return -1; } else if(s[slength]!='\r') slength++; } while(fclose(fileP) && errno==EINTR); if(erroredFile) { commandError(fp, ACK_ERROR_PLAYLIST_LOAD, "can't add file \"%s\"", erroredFile); free(erroredFile); return -1; } return 0; }