Exemple #1
0
ControlPanel::ControlPanel(QWidget *parent) : QWidget(parent), 	m_coverArt(new CoverArtDialog(this)), 	m_lyricsDialog(new LyricsDialog(this)), m_lastFm(new LastFmSubmitter(this)) {
	Q_ASSERT(m_coverArt);
	Q_ASSERT(m_lyricsDialog);
	Q_ASSERT(m_lastFm);
	setupUi(this);
	coverArtButton->setVisible(false);

	connect(prevButton, SIGNAL(clicked()), MPD::instance(), SLOT(prev()));
	connect(playButton, SIGNAL(clicked()), MPD::instance(), SLOT(play()));
	connect(pauseButton, SIGNAL(clicked()), MPD::instance(), SLOT(pause()));
	connect(stopButton, SIGNAL(clicked()), MPD::instance(), SLOT(stop()));
	connect(nextButton, SIGNAL(clicked()), MPD::instance(), SLOT(next()));
	connect(volumeSlider, SIGNAL(valueChanged(int)), MPD::instance(), SLOT(setVolume(int)));
	connect(timeSlider, SIGNAL(timeChanged(int)), MPD::instance(), SLOT(seek(int)));
	connect(timeSlider, SIGNAL(valueChanged(int)), elapsedLabel, SLOT(setTime(int)));
	connect(MPD::instance(), SIGNAL(volumeUpdated(int)), volumeSlider, SLOT(setValue(int)));
	connect(MPD::instance(), SIGNAL(timeUpdated(int, int)), elapsedLabel, SLOT(setTime(int, int)));
	connect(MPD::instance(), SIGNAL(timeUpdated(int, int)), totalLabel, SLOT(setTime(int, int)));
	connect(MPD::instance(), SIGNAL(timeUpdated(int, int)), timeSlider, SLOT(setTime(int, int)));
	connect(MPD::instance(), SIGNAL(playingSongUpdated(const MPDSong &)), this, SLOT(setSong(const MPDSong &)));
	connect(Config::instance(), SIGNAL(showCoverArtChanged(bool)), this, SLOT(showCoverArtChanged(bool)));
	connect(coverArtButton, SIGNAL(clicked()), m_coverArt, SLOT(show()));
	connect(lyricsButton, SIGNAL(clicked()), m_lyricsDialog, SLOT(show()));
	connect(m_lastFm, SIGNAL(infoMsg(QString)), this, SIGNAL(infoMsg(QString)));
	connect(scrobbleCheckBox, SIGNAL(toggled(bool)), Config::instance(), SLOT(setSubmitSongsToLastFm(bool)));
	connect(Config::instance(), SIGNAL(submitSongsToLastFmChanged(bool)), scrobbleCheckBox, SLOT(setChecked(bool)));
	
	scrobbleCheckBox->setChecked(Config::instance()->submitSongsToLastFm());
	
	// Short cuts
	m_fwdKey = new QShortcut(Qt::CTRL | Qt::Key_Right, this);
	m_rwdKey = new QShortcut(Qt::CTRL | Qt::Key_Left, this);
	m_volUpKey = new QShortcut(Qt::CTRL | Qt::Key_Up, this);
	m_volDnKey = new QShortcut(Qt::CTRL | Qt::Key_Down, this);
	m_stopMultKey = new QShortcut(Qt::Key_MediaStop, this);
	m_togglePlayMultKey = new QShortcut(Qt::Key_MediaPlay, this);
	m_fwdMultKey = new QShortcut(Qt::Key_MediaNext, this);
	m_rwdMultKey = new QShortcut(Qt::Key_MediaPrevious, this);
	m_fwdKey->setObjectName("nextSongKey");
	m_rwdKey->setObjectName("prevSongKey");
	m_volUpKey->setObjectName("volumeUpKey");
	m_volDnKey->setObjectName("volumeDownKey");
	m_stopMultKey->setObjectName("stopKey");
	m_togglePlayMultKey->setObjectName("togglePlayKey");
	m_fwdMultKey->setObjectName("nextSongMultimediaKey");
	m_rwdMultKey->setObjectName("prevSongMultimediaKey");
	connect(m_fwdKey, SIGNAL(activated()), MPD::instance(), SLOT(seekForward()));
	connect(m_rwdKey, SIGNAL(activated()), MPD::instance(), SLOT(seekBackward()));
	connect(m_volUpKey, SIGNAL(activated()), MPD::instance(), SLOT(volumeUp()));
	connect(m_volDnKey, SIGNAL(activated()), MPD::instance(), SLOT(volumeDown()));
	connect(m_stopMultKey, SIGNAL(activated()), MPD::instance(), SLOT(stop()));
	connect(m_togglePlayMultKey, SIGNAL(activated()), MPD::instance(), SLOT(togglePlay()));
	connect(m_fwdMultKey, SIGNAL(activated()), MPD::instance(), SLOT(next()));
	connect(m_rwdMultKey, SIGNAL(activated()), MPD::instance(), SLOT(prev()));
	setSong(MPDSong());
}
MPDEntities MPDConnection::entities() const {
	ASSERT;
	MPDEntities ret;

	for (mpd_InfoEntity *entity; (entity = mpd_getNextInfoEntity(d->connection)) != NULL; ) {
		if (entity->type == MPD_INFO_ENTITY_TYPE_SONG) {
			ret.appendSong(MPDSong(entity));
		} else if (entity->type == MPD_INFO_ENTITY_TYPE_DIRECTORY) {
			ret.appendDirectory(QString::fromUtf8(entity->info.directory->path));
		} else if (entity->type == MPD_INFO_ENTITY_TYPE_PLAYLISTFILE) {
			ret.appendPlaylist(MPDSong(entity));
		} else {
			qWarning("MPDConnection::availableEntities() Unknown entity type: %d", entity->type);
		}
		mpd_freeInfoEntity(entity);
	}

	return ret;
}
Exemple #3
0
MPDSong MPDSongModel::song(const QModelIndex &index) const {
	if (!index.isValid() || index.row() < 0 || m_visible.count() <= index.row())
		return MPDSong();
	return m_visible.at(index.row());
}