Esempio n. 1
0
QString Notifications::makeTitle(const MPDSong &s) {
	int desktopWidth = QApplication::desktop()->width();
	QString title = elideRichText("", s.title().isEmpty() ? s.filename() : s.title()  , "", desktopWidth / 2) + "\n";
	QString artist = elideRichText("", s.artist(), "", desktopWidth / 4);
	QString album = elideRichText("", s.album(), "", desktopWidth / 4);
	
	if (!artist.isEmpty())
		title += artist + "\n";
	if (!album.isEmpty())
		title += album;
	return title;
}
Esempio n. 2
0
void ControlPanel::setSong(const MPDSong &s) {
	if (s.isNull()) {
		titleLabel->setText(MPDConnection::instance()->isConnected() ? "" : QString("<h3>%1</h3>").arg(tr("Not connected", "qmpdclient is not connected to MPD")));
		artistLabel->setText("");
		timeSlider->setEnabled(true);
		return;
	}

	// Disable time counting for streams
	timeSlider->setEnabled(s.type() != MPDSong::PLAYLISTSTREAM);

	// Ensure labels are not too small if window is hidden
	const int titleWidth = isVisible() ? titleLabel->width() : width() - 200;
//	const int artistWidth = isVisible() ? artistLabel->width() : width() - 200;

	QString title = elideRichText("<h3>", s.title() , "</h3>", titleWidth);
	QString artist = s.artist();
	QString album = s.album();

	if (!artist.isEmpty() && !album.isEmpty())
		artist = QString("<b>%1</b> - <b>%2</b>").arg(artist, album);
	else if (!artist.isEmpty())
		artist += QString("<b>%1</b>").arg(artist);
	else if (!album.isEmpty())
		artist += QString("<b>%1</b>").arg(album);

	titleLabel->setText(title);
	artistLabel->setText(artist);

	if (Config::instance()->submitSongsToLastFm()) m_lastFm->setSong(s);
	m_lyricsDialog->setSong(s);

	if (!m_lyricsDialog->isHidden()) m_lyricsDialog->updateLyrics();

	if (Config::instance()->showCoverArt()) {
		m_coverArt->setSong(s);
		if (m_coverArt->hasCoverArt()) {
			coverArtButton->setIcon(m_coverArt->coverArt());
			coverArtButton->setIconSize(QSize(50, 50));
			coverArtButton->setVisible(true);
		}
		else coverArtButton->setVisible(false);
	}
}