void PlayerControls::setupTrackbar() { QHBoxLayout *hLayout = new QHBoxLayout(); QHBoxLayout *hLayoutTop = new QHBoxLayout(); QHBoxLayout *hLayoutActions = new QHBoxLayout(); QVBoxLayout *vLayout = new QVBoxLayout(); Settings *sett = Settings::instance(); m_wlTitle = new QLabel(sett->getValue("song/title").toString()); m_wlTitle->setStyleSheet("font-size: 17pt;"); m_wlTitle->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); m_wlTitle->setAlignment(Qt::AlignLeft|Qt::AlignBottom); m_wlArtist = new QLabel(sett->getValue("song/artist").toString()); m_wlArtist->setStyleSheet("font-size: 11pt;"); m_wlAlbum = new QLabel(sett->getValue("song/album").toString()); m_wlAlbum->setStyleSheet("font-size: 10pt; color: grey;"); m_wlAlbum->setAlignment(Qt::AlignLeft|Qt::AlignVCenter); // Track actions m_wbDownload = new StyledButton(QIcon(QPixmap(":icons/panel_download")), ""); m_wbDownload->setTransparent(true); m_wbDownload->setToolTip(tr("Download track")); connect(m_wbDownload, SIGNAL(clicked()), SLOT(downloadTrack())); m_wbAdd2List = new StyledButton(QIcon(QPixmap(":icons/panel_listadd")), ""); m_wbAdd2List->setTransparent(true); m_wbAdd2List->setToolTip(tr("Add to list")); m_wbAdd2List->setMenu(m_localsMenu); m_wbAdd2Library = new StyledButton(QIcon(QPixmap(":icons/panel_libraryadd")), ""); m_wbAdd2Library->setTransparent(true); m_wbAdd2Library->setToolTip(tr("Add to library")); connect(m_wbAdd2Library, SIGNAL(clicked()), SLOT(addTrack2Library())); hLayoutTop->addWidget(m_wlTitle); hLayoutTop->addLayout(hLayoutActions); hLayoutTop->setAlignment(hLayoutActions, Qt::AlignRight); hLayoutActions->addWidget(m_wbAdd2Library); hLayoutActions->addWidget(m_wbAdd2List); hLayoutActions->addWidget(m_wbDownload); hLayout->addWidget(m_wlArtist); hLayout->addWidget(m_wlAlbum); hLayout->setStretch(0, 0); hLayout->setStretch(1, 1); vLayout->addLayout(hLayoutTop); vLayout->addLayout(hLayout); m_mainLayout->addLayout(vLayout, 0, 1); }
void Playlist::createMenus() { m_localsMenu = new QMenu(tr("Add to list")); m_listMenu = new QMenu(m_listWidget); /* Popup Track actions */ // Add to Queue QAction *toQueueA = new QAction(tr("Add to queue"), this); toQueueA->setShortcut(QKeySequence("Q")); m_listMenu->addAction(toQueueA); connect(toQueueA, SIGNAL(triggered()), this, SLOT(addToQueue())); // Add to library m_toLibraryA = new QAction(tr("Add to Library"), this); m_listMenu->addAction(m_toLibraryA); connect(m_toLibraryA, SIGNAL(triggered()), this, SLOT(addToLibrary())); // Download track QAction *downloadA = new QAction(tr("Download"), this);; // downloadA->setShortcut(QKeySequence("D")); m_listMenu->addAction(downloadA); connect(downloadA, SIGNAL(triggered()), this, SLOT(downloadTrack())); // Remove track QAction *removeA = new QAction(tr("Remove"), this);; removeA->setShortcut(QKeySequence::Delete); m_listMenu->addAction(removeA); connect(removeA, SIGNAL(triggered()), this, SLOT(removeTrack())); // Set 'add to local list' menu for all lists except local list if(m_listType != PlaylistWidget::LocalList) m_listMenu->addMenu(m_localsMenu); m_listWidget->setMenu(m_listMenu); }
Playlist::Playlist(PlaylistWidget::ListTypes listType, QString title, quint64 hash, QObject *parent) : QObject(parent) { m_listType = listType; m_sTitle = title; m_bCustomTitle = false; m_Settings = Settings::instance(); connect(m_Settings, SIGNAL(changed()), SLOT(onSettingsChanged())); m_bLoadingState = false; m_bShuffleList = m_Settings->getValue("player/shuffle").toInt() > 1 ? true : false; m_LastTrack = 0; m_bLoadMeta = false; m_bUseMeta = false; m_bTitleByContent = m_Settings->getValue("playlist/tabs_by_content").toBool(); m_Auth = Auth::instance(); connect(m_Auth, SIGNAL(authComplete()), SLOT(update())); // Set hash if(hash == 0) { QDateTime *time = new QDateTime(QDateTime::currentDateTime()); m_Hash = time->toMSecsSinceEpoch(); m_bNewly = true; } else { m_Hash = hash; m_bNewly = false; } // Create playlist widget m_listWidget = new PlaylistWidget(m_listType); connect(this, SIGNAL(trackAdded()), m_listWidget, SLOT(trackAdded())); connect(m_listWidget, SIGNAL(trackActivate(Track*)), SLOT(trackActivate(Track*))); // Connect key events connect(m_listWidget, SIGNAL(skQueue()), SLOT(addToQueue())); connect(m_listWidget, SIGNAL(skRemove()), SLOT(removeTrack())); connect(m_listWidget, SIGNAL(skDownload()), SLOT(downloadTrack())); // Create object of parser m_Parser = new Parser(this); connect(m_Parser, SIGNAL(newTrack(Track*)), SLOT(addTrack(Track*))); connect(m_Parser, SIGNAL(busy()), SLOT(parserBusy())); connect(m_Parser, SIGNAL(free()), SLOT(parserFree())); connect(m_Parser, SIGNAL(savePlaylist()), SLOT(save())); connect(m_Parser, SIGNAL(busy()), m_listWidget, SLOT(showLoading())); connect(m_Parser, SIGNAL(free()), m_listWidget, SLOT(hideLoading())); // Create actions parser m_vkActions = VkActions::instance(); connect(m_vkActions, SIGNAL(message(QString,QString)), SIGNAL(message(QString,QString))); switch(m_listType) { case PlaylistWidget::Search: connect(m_listWidget, SIGNAL(searchChanged(QString)), SLOT(searchChanged(QString))); connect(m_listWidget, SIGNAL(loadMore()), m_Parser, SLOT(loadMoreResults())); break; case PlaylistWidget::AudioLib: connect(m_listWidget->friendsList(), SIGNAL(friendSelected(QString,QString,QString)), SLOT(librarySelected(QString,QString,QString))); connect(m_listWidget, SIGNAL(refresh()), SLOT(refresh())); break; case PlaylistWidget::Suggestions: connect(m_listWidget, SIGNAL(loadMore()), m_Parser, SLOT(loadMoreResults())); connect(m_listWidget, SIGNAL(refresh()), SLOT(refresh())); break; case PlaylistWidget::DbSearch: connect(m_listWidget, SIGNAL(searchChanged(QString)), SLOT(searchChanged(QString))); connect(m_listWidget, SIGNAL(newTrack(Track*)), SLOT(addTrack(Track*))); connect(m_listWidget, SIGNAL(clearList()), SLOT(clearList())); break; } m_Model = new QStandardItemModel(this); m_ProxyModel = new QSortFilterProxyModel(this); m_ProxyModel->setSourceModel(m_Model); m_ProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); m_ProxyModel->setFilterKeyColumn(2); m_listWidget->setModel(m_ProxyModel); connect(m_listWidget, SIGNAL(listSearchChanged(QString)), SLOT(setListSearch(QString))); createMenus(); load(); if(type() == PlaylistWidget::AudioLib && m_bNewly && m_Settings->getValue("playlist/autoload_library").toBool() ) librarySelected(m_Auth->vkId(), "0", tr("My Library")); // Actions on newly created plalylists if(m_bNewly) { switch(m_listType) { case PlaylistWidget::Search: m_listWidget->focusOnSearch(); break; case PlaylistWidget::AudioLib: if(m_Settings->getValue("playlist/autoload_library").toBool()) librarySelected(m_Auth->vkId(), "0", tr("My Library")); break; case PlaylistWidget::Suggestions: refresh(); break; case PlaylistWidget::DbSearch: // Unused break; } } }
void SoundCloudPlaylistWindow::loadBaseUi() { setWindowTitle(tr("Set")); setCentralWidget(new QWidget); m_view->setModel(m_model); m_view->setItemDelegate(m_delegate); m_view->setContextMenuPolicy(Qt::CustomContextMenu); m_thumbnail->setFixedSize(320, 320); m_thumbnail->setFallbackSource(QUrl::fromLocalFile("/usr/share/icons/hicolor/295x295/hildon/mediaplayer_default_album.png")); m_avatar->setFixedSize(60, 60); m_avatar->setFallbackSource(QUrl::fromLocalFile("/usr/share/icons/hicolor/64x64/hildon/general_default_avatar.png")); m_titleLabel->setWordWrap(true); m_dateLabel->setStyleSheet(QString("color: %1; font-size: 13pt").arg(palette().color(QPalette::Mid).name())); m_artistLabel->setStyleSheet("font-size: 13pt"); m_noTracksLabel->hide(); m_reloadAction->setEnabled(false); m_contextMenu->addAction(m_queueAction); m_contextMenu->addAction(m_downloadAction); m_contextMenu->addAction(m_shareAction); QWidget *scrollWidget = new QWidget(m_scrollArea); QGridLayout *grid = new QGridLayout(scrollWidget); grid->addWidget(m_thumbnail, 0, 0, 1, 2, Qt::AlignLeft); grid->addWidget(m_titleLabel, 1, 0, 1, 2); grid->addWidget(m_avatar, 2, 0, 2, 1, Qt::AlignLeft); grid->addWidget(m_artistLabel, 2, 1, Qt::AlignLeft | Qt::AlignTop); grid->addWidget(m_dateLabel, 3, 1, Qt::AlignLeft | Qt::AlignBottom); grid->addWidget(m_descriptionLabel, 4, 0, 1, 2); grid->setRowStretch(4, 1); grid->setColumnStretch(1, 1); grid->setContentsMargins(0, 0, 0, 0); m_scrollArea->setWidget(scrollWidget); m_scrollArea->setWidgetResizable(true); m_scrollArea->setFixedWidth(330); m_layout = new QHBoxLayout(centralWidget()); m_layout->addWidget(m_scrollArea); m_layout->addWidget(m_view); m_layout->addWidget(m_noTracksLabel); m_layout->setStretch(1, 1); m_layout->setStretch(2, 1); m_layout->setContentsMargins(0, 0, 0, 0); menuBar()->addAction(m_reloadAction); menuBar()->addAction(m_queuePlaylistAction); menuBar()->addAction(m_nowPlayingAction); connect(m_model, SIGNAL(statusChanged(QSoundCloud::ResourcesRequest::Status)), this, SLOT(onModelStatusChanged(QSoundCloud::ResourcesRequest::Status))); connect(m_cache, SIGNAL(imageReady()), this, SLOT(onImageReady())); connect(m_view, SIGNAL(activated(QModelIndex)), this, SLOT(showTrack(QModelIndex))); connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(m_thumbnail, SIGNAL(clicked()), this, SLOT(playPlaylist())); connect(m_delegate, SIGNAL(thumbnailClicked(QModelIndex)), this, SLOT(playTrack(QModelIndex))); connect(m_reloadAction, SIGNAL(triggered()), m_model, SLOT(reload())); connect(m_queuePlaylistAction, SIGNAL(triggered()), this, SLOT(queuePlaylist())); connect(m_avatar, SIGNAL(clicked()), this, SLOT(showArtist())); connect(m_descriptionLabel, SIGNAL(anchorClicked(QUrl)), this, SLOT(showResource(QUrl))); connect(m_queueAction, SIGNAL(triggered()), this, SLOT(queueTrack())); connect(m_downloadAction, SIGNAL(triggered()), this, SLOT(downloadTrack())); connect(m_shareAction, SIGNAL(triggered()), this, SLOT(shareTrack())); if (!SoundCloud::instance()->userId().isEmpty()) { m_favouriteAction = new QAction(this); m_contextMenu->addAction(m_favouriteAction); connect(m_favouriteAction, SIGNAL(triggered()), this, SLOT(setTrackFavourite())); } }