Example #1
0
void squeezeLiteGui::setupInterfaceConnections(void)
{
    DEBUGF("Initialize Interface Connections");

    QQuickItem *v = rootObject();
    // interface signals to application
    connect(v,SIGNAL(play(int)), this,SLOT(playState(int)));
    connect(v,SIGNAL(nextTrack()), this,SLOT(nextTrackClicked()));
    connect(v,SIGNAL(prevTrack()), this,SLOT(prevTrackClicked()));
    connect(v,SIGNAL(volUp()), this,SLOT(volUp()));
    connect(v,SIGNAL(volDown()), this,SLOT(volDown()));
    connect(v,SIGNAL(setVolume(int)), this,SLOT(setVolume(int)));
    connect(v,SIGNAL(controlClicked(QString)), this,SLOT(controlViewClicked(QString)));
    connect(v,SIGNAL(shuffle(int)), this,SLOT(shuffleState(int)));
    connect(v,SIGNAL(repeat(int)), this,SLOT(repeatState(int)));
//    connect(v,SIGNAL(playButtonClicked()),this,SLOT(playPauseToggle()));

    // application signals to interface
    connect(this,SIGNAL(playlistIndexChange(QVariant)), v, SLOT(setControlViewListIndex(QVariant)));
    connect(this,SIGNAL(updateAlbumCover(QVariant)), v,SLOT(updateAlbumCover(QVariant)));
    connect(this,SIGNAL(playStatus(QVariant)), v, SLOT(updatePlayMode(QVariant)));
    connect(this,SIGNAL(VolumeChange(QVariant)), v,SLOT(setMainVolume(QVariant)));
    connect(this,SIGNAL(songDuration(QVariant)), v,SLOT(setSongDuration(QVariant)));
    connect(this,SIGNAL(progress(QVariant)), v,SLOT(updateProgress(QVariant)));
    connect(m_playerInfo,SIGNAL(PlayingTime(QVariant,QVariant)),
            v,SLOT(setupSongTimes(QVariant,QVariant)));
    connect(m_playerInfo,SIGNAL(TimeText(QVariant)),v,SLOT(setTimeText(QVariant)));

    connect(m_playerInfo,SIGNAL(NewSong()),this,SLOT(NewSong()));
    connect(&m_tick,SIGNAL(timeout()),m_playerInfo,SLOT(tick()));

    m_tick.start(1000);

/*
 *  messages from device that need to be connected to slots
    void playlistIndexChange(QVariant newidx);
    void NewSong(int newPlayListIndex);
    void NewPlaylist(void);
    void Mute(bool);
    void VolumeChange(int);
    void ModeChange(QString);
*/
}
Example #2
0
int main() {
	boost::posix_time::ptime current_date = boost::posix_time::microsec_clock::local_time();
	boost::posix_time::time_duration current_time = current_date.time_of_day();

	std::vector <boost::posix_time::time_duration> break_times;
	break_times.push_back(boost::posix_time::time_duration(7,45,0));
	break_times.push_back(boost::posix_time::time_duration(8,30,0));
	break_times.push_back(boost::posix_time::time_duration(8,35,0));
	break_times.push_back(boost::posix_time::time_duration(9,20,0));
	break_times.push_back(boost::posix_time::time_duration(9,35,0));
	break_times.push_back(boost::posix_time::time_duration(10,20,0));
	break_times.push_back(boost::posix_time::time_duration(10,25,0));
	break_times.push_back(boost::posix_time::time_duration(11,10,0));
	break_times.push_back(boost::posix_time::time_duration(11,25,0));
	break_times.push_back(boost::posix_time::time_duration(12,10,0));
	break_times.push_back(boost::posix_time::time_duration(12,15,0));
	break_times.push_back(boost::posix_time::time_duration(13,00,0));
	break_times.push_back(boost::posix_time::time_duration(13,20,0));
	break_times.push_back(boost::posix_time::time_duration(14,05,0));
	break_times.push_back(boost::posix_time::time_duration(14,10,0));
	break_times.push_back(boost::posix_time::time_duration(14,55,0));

	float time_since_last_play = 100.f;

//	sf::RenderWindow RenderWin(sf::VideoMode::GetDesktopMode(), "MegaGong", sf::Style::Fullscreen);
	sf::RenderWindow RenderWin(sf::VideoMode::GetDesktopMode(), "MegaGong");

	sf::Font MonoFont;
	if(!MonoFont.LoadFromFile("DejaVuSansMono.ttf", 100)) {
		std::cerr << "Error while loading font, aborting..." << std::endl;
		return 1;
	}
	sf::String TimeText("time", MonoFont, 100);
	TimeText.SetCenter(TimeText.GetRect().GetWidth() / 2, TimeText.GetRect().GetHeight() / 2);
	TimeText.SetPosition(RenderWin.GetWidth() / 4, RenderWin.GetHeight() / 2);

	sf::SoundBuffer Ring;
	if(!Ring.LoadFromFile("train.wav")) {
		std::cerr << "Error while loading sound, aborting..." << std::endl;
		return 1;
	}
	sf::Sound RingSound(Ring);

	// Main loop.
	while(RenderWin.IsOpened()) {
		sf::Event Event;
		while(RenderWin.GetEvent(Event)) {
			if(Event.Type == sf::Event::Closed)
				RenderWin.Close();
			if(Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Escape)
				RenderWin.Close();
		}

		time_since_last_play += RenderWin.GetFrameTime();

		current_time = boost::posix_time::microsec_clock::local_time().time_of_day();
		TimeText.SetText(boost::posix_time::to_simple_string(current_time));

		if(time_since_last_play <= 5.f) {
			TimeText.SetColor(sf::Color(255, time_since_last_play * 50, time_since_last_play * 50));
			RenderWin.Clear(sf::Color(sf::Randomizer::Random(0, 255), sf::Randomizer::Random(0, 255), sf::Randomizer::Random(0, 255)));
		}
		else {
			TimeText.SetColor(sf::Color(255, 255, 255));
			RenderWin.Clear();
		}

		BOOST_FOREACH(auto break_time, break_times) {
			if (break_time.hours() == current_time.hours() && break_time.minutes() == current_time.minutes() && time_since_last_play > 60.f) {
				RingSound.Play();
				std::cout << "GONG! at " << current_time << std::endl;
				TimeText.SetColor(sf::Color::Red);
				time_since_last_play = 0.f;
			}
		}
		
		RenderWin.Draw(TimeText);

		RenderWin.Display();
	}
}