PlayMusicWindow::PlayMusicWindow(QWidget *parent, PlaylistHandler *plh, API *api, CoverHelper *coverHelper, QMainWindow* mainWindow, Player *player) : QMainWindow(parent), ui(new Ui::PlayMusicWindow) { timer = new QTimer(this); timer->setInterval(1000); timer->setSingleShot(true); currCurrentCover = ""; nextCurrentCover = ""; prevCurrentCover = ""; connect(timer, SIGNAL(timeout()), this, SLOT(timerDone())); posSliderMoving = false; this->realMainWindow = mainWindow; this->plh = plh; this->api = api; this->player = player; this->apb = new AudioPlayerBridge(realMainWindow); this->coverHelper = coverHelper; int volume = player->getVolume(); ui->setupUi(this); this->setWindowFlags(this->windowFlags() & ~(Qt::WindowFullscreenButtonHint)); messageHandler = new MessageHandler(this); QRect geometry = QApplication::desktop()->screenGeometry(); this->setGeometry((geometry.width() - this->width()) / 2, (geometry.height() - this->height()) / 2, this->width(), this->height()); ui->sldVolume->setStyle(new MyVolumeStyle); ui->sldVolume->setValue(volume); ui->sldPosition->setStyle(new MyVolumeStyle); this->setAttribute(Qt::WA_QuitOnClose, false); this->setAttribute(Qt::WA_DeleteOnClose); this->setFixedSize(this->size()); playlistsRefreshing = false; QWidget* shadowArray[] = {ui->lblPlayMusic, ui->lblPlayedPlaylist}; int count = sizeof(shadowArray) / sizeof(QWidget*); for (int i = 0; i < count; i++) { QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(shadowArray[i]); effect->setBlurRadius(1); effect->setColor(QColor("#bb6008")); effect->setOffset(0, 1); shadowArray[i]->setGraphicsEffect(effect); } QWidget* clickthruArray[] = {}; count = sizeof(clickthruArray) / sizeof(QWidget*); for (int i = 0; i < count; i++) { clickthruArray[i]->setAttribute(Qt::WA_TransparentForMouseEvents); } connect(player, SIGNAL(playlistsChanged(std::vector<std::string>)), this, SLOT(playlistsChanged(std::vector<std::string>))); connect(player, SIGNAL(currentSongChanged()), this, SLOT(songsChanged())); connect(player, SIGNAL(songPositionChanged()), this, SLOT(onPositionChanged())); connect(player, SIGNAL(stateChanged()), this, SLOT(refreshPlayPause())); connect(coverHelper, SIGNAL(coverGotten(std::string)), this, SLOT(gotCover(std::string)), Qt::DirectConnection); connect(messageHandler, SIGNAL(addedMessage(Message*)), this, SLOT(addedMessage(Message*))); connect(messageHandler, SIGNAL(removedMessage(Message*)), this, SLOT(deletedMessage(Message*))); connect(player, SIGNAL(songFailed()), this, SLOT(songFailed())); playlistsChanged(plh->getPlaylists()); songsChanged(); refreshPlayPause(); wasPlaying = player->isPlaying() || player->isPaused(); }
SearchMusicListItem::SearchMusicListItem(QWidget *parent, Song* song, API *api, AudioPlayerBridge *apb, PlaylistHandler *plh, MessageHandler* messageHandler, Player *player) : QWidget(parent), ui(new Ui::SearchMusicListItem) { ui->setupUi(this); playerWasPlaying = false; this->song = song; this->player = player; ui->lblTitle->setText(QString::fromStdString(song->getSongName())); ui->lblArtist->setText(QString::fromStdString(song->getArtistName())); ui->lblAlbum->setText(QString::fromStdString(song->getAlbumName())); ui->lblArtist->setAttribute(Qt::WA_TransparentForMouseEvents); ui->lblArtistCaption->setAttribute(Qt::WA_TransparentForMouseEvents); ui->lblAlbum->setAttribute(Qt::WA_TransparentForMouseEvents); ui->lblAlbumCaption->setAttribute(Qt::WA_TransparentForMouseEvents); ui->lblTitle->setAttribute(Qt::WA_TransparentForMouseEvents); ui->lblTitleCaption->setAttribute(Qt::WA_TransparentForMouseEvents); ui->cmbAddTo->setCurrentIndex(0); MouseWheelDisabler* mwd = new MouseWheelDisabler(ui->cmbAddTo); ui->cmbAddTo->installEventFilter(mwd); connect(mwd, SIGNAL(playlistAddEvent()), this, SLOT(createNewPlaylist())); this->apb = apb; this->api = api; this->plh = plh; this->messageHandler = messageHandler; onPlaylistChange(plh->getPlaylists()); connect(plh, SIGNAL(playlistsChanged(std::vector<std::string>)), this, SLOT(onPlaylistChange(std::vector<std::string>))); this->setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&))); }
bool PlaylistHandler::createPlaylist(std::string name) { checkInit(); QDomNode node = root.firstChild(); while (!node.isNull()) { QDomElement element = node.toElement(); if (!element.isNull()) { if (element.tagName() == "Playlist") { if (element.attribute("name").toStdString() == name) { return false; } } } node = node.nextSibling(); } QDomElement thisPlaylist = doc.createElement("Playlist"); thisPlaylist.setAttribute("name", QString::fromStdString(name)); boost::uuids::uuid uuidobj = boost::uuids::random_generator()(); std::stringstream ss; ss << uuidobj; QString uuid = QString::fromStdString(ss.str()); thisPlaylist.setAttribute("id", uuid); root.appendChild(thisPlaylist); save(); emit playlistsChanged(getPlaylists()); return true; }
void PlaylistHandler::renamePlaylist(std::string oldName, std::string newName) { checkInit(); QDomNode node = root.firstChild(); QDomElement renameElement; while (!node.isNull()) { QDomElement element = node.toElement(); if (!element.isNull() && element.tagName() == "Playlist" && element.attribute("name").toStdString() == oldName) { renameElement = element; } node = node.nextSibling(); } renameElement.setAttribute("name", QString::fromStdString(newName)); save(); emit playlistsChanged(getPlaylists()); }
void PlaylistHandler::removePlaylist(std::string playlistName) { checkInit(); QDomNode node = root.firstChild(); QDomNode removalNode; while (!node.isNull()) { QDomElement element = node.toElement(); if (!element.isNull() && element.tagName() == "Playlist" && element.attribute("name").toStdString() == playlistName) { removalNode = node; } node = node.nextSibling(); } root.removeChild(removalNode); save(); emit playlistsChanged(getPlaylists()); }
SearchMusicListItem::~SearchMusicListItem() { delete ui; disconnect(api, SIGNAL(streamKeyReady(StreamInformation*)), this, SLOT(gotStreamKey(StreamInformation*))); disconnect(plh, SIGNAL(playlistsChanged(std::vector<std::string>)), this, SLOT(onPlaylistChange(std::vector<std::string>))); }
QSpotifyPlaylistContainer *QSpotifyUser::playlistContainer() const { if (!m_playlistContainer) { sp_playlistcontainer *pc; if (QSpotifySession::instance()->user() == this) { pc = sp_session_playlistcontainer(QSpotifySession::instance()->m_sp_session); sp_playlistcontainer_add_ref(pc); } else { pc = sp_session_publishedcontainer_for_user_create(QSpotifySession::instance()->m_sp_session, m_canonicalName.toUtf8().constData()); } m_playlistContainer = new QSpotifyPlaylistContainer(pc); m_playlistContainer->init(); connect(m_playlistContainer, SIGNAL(playlistContainerDataChanged()), this, SIGNAL(playlistsChanged())); connect(m_playlistContainer, SIGNAL(playlistsNameChanged()), this, SIGNAL(playlistsNameChanged())); } return m_playlistContainer; }