SimulationTimer::SimulationTimer(GUIManager& listener, hpreal minTime, hpreal maxTime, int ticksPerSimulation, hpreal tickTime): m_listener(listener), m_currentTime(minTime), m_minTime(minTime), m_maxTime(maxTime), m_deltaTick((maxTime - minTime)/(hpreal)ticksPerSimulation), m_startStopButton(new QPushButton("start")), m_tickTime(tickTime), m_timer(new QTimer(this)), m_timerIsRunning(false), m_timeSlider(new LabeledRealValuedSlider("Time", this)){ QVBoxLayout* layout = new QVBoxLayout(); layout->addWidget(m_timeSlider); layout->addWidget(m_startStopButton); setLayout(layout); connect(m_timer, SIGNAL(timeout()), this, SLOT(timerTick())); connect(m_timeSlider, SIGNAL(valueChanged(hpreal)), this, SLOT(changeTime(hpreal))); connect(m_startStopButton, SIGNAL(clicked()), this, SLOT(startStopTimer())); updateSlider(); }
void VlcSeekWidget::initSeekWidget() { _autoHide = false; _seek = new QSlider(this); _seek->setOrientation(Qt::Horizontal); _seek->setMaximum(0); _seek->setPageStep(1000); _labelElapsed = new QLabel(this); _labelElapsed->setText("00:00:00"); _labelFull = new QLabel(this); _labelFull->setText("00:00:00"); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(_labelElapsed); layout->addWidget(_seek); layout->addWidget(_labelFull); setLayout(layout); _timer = new QTimer(this); connect(_timer, SIGNAL(timeout()), this, SLOT(updateTime())); connect(_seek, SIGNAL(sliderReleased()), this, SLOT(changeTime())); _timer->start(400); }
myScene::myScene(QObject *parent) : QGraphicsScene(parent), GMT(0) { QImage clockImage("clock.png") , hourImage("hourHand.png") , minuteImage("minuteHand.png"); QGraphicsPixmapItem *clockFace = new QGraphicsPixmapItem(QPixmap::fromImage(clockImage)) , *hour = new QGraphicsPixmapItem(QPixmap::fromImage(hourImage)) , *minute = new QGraphicsPixmapItem(QPixmap::fromImage(minuteImage)); QTime time = QTime::currentTime(); hourHand = hour; minuteHand = minute; clockFace->setScale(0.3); addItem(clockFace); hourHand->setScale(0.3); hourHand->setTransformOriginPoint(53, 397); hourHand->setPos(142, -200); hourHand->setRotation(30.0 * ((time.hour() + time.minute() / 60.0)) - GMT); addItem(hourHand); minuteHand->setTransformOriginPoint(43, 521); minuteHand->setScale(0.3); minuteHand->setPos(151, -326); minuteHand->setRotation(6.0 * (time.minute() + time.second() / 60.0)); addItem(minuteHand); QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(changeTime())); timer->start(1000); }
int RTCDue::setSeconds (int second) { _changed = BIN2BCD(second) << RTC_TIMR_SEC_Pos; _current_time = (currentTime() & ~RTC_TIMR_SEC_Msk) ^ _changed; return (int)changeTime(_current_time); }
int RTCDue::setMinutes (int minute) { _changed = BIN2BCD(minute) << RTC_TIMR_MIN_Pos; _current_time = (currentTime() & ~RTC_TIMR_MIN_Msk) ^ _changed; return (int)changeTime(_current_time); }
int RTCDue::setHours (int hour) { _changed = BIN2BCD(hour) << RTC_TIMR_HOUR_Pos; _current_time = (currentTime() & ~RTC_TIMR_HOUR_Msk) ^ _changed; return (int)changeTime(_current_time); }
bool ScriptTimer::trigger() { int next = scriptTimer(scriptId); if (next > 0) { changeTime(next); return true; } return false; }
void MusicPlayer::changeTime() { if (scheduledTime >= 0) { qDebug("Changing position to %d", scheduledTime); vlcPlayer->setTime(scheduledTime); scheduledTime = -1; // reset disconnect(vlcPlayer, SIGNAL(playing()), this, SLOT(changeTime())); } else { qDebug("Error: there is no currently scheduled position!"); } }
void MusicPlayer::scheduleTimeChange(const int& pos) { if (vlcPlayer->state() == Vlc::Playing) { vlcPlayer->setTime(pos); } else { if (scheduledTime < 0) { scheduledTime = pos; connect(vlcPlayer, SIGNAL(playing()), this, SLOT(changeTime())); } else { qDebug("Error: there is currently scheduled position change!"); } } }
void DrumSet::changeTime() { Time--; TimeText->setText(QString::number(Time)); if(Time <= 0) { disconnect(textTimer, SIGNAL(timeout()), this, SLOT(changeTime())); callparent->hide(); player->stop(); delete player; player = 0; ResultWindow * rw = new ResultWindow(Score,callparent); rw->show(); } }
DrumSet::DrumSet(QWidget *parent, UserWindow *_callparent, QLabel *_RLabel, QLabel *_LLabel, QMovie *_RMovie, QMovie *_LMovie, int _Speed, QLabel *_TimeText, QLabel *_ScoreText) : QWidget(parent),callparent(_callparent),RLabel(_RLabel),LLabel(_LLabel),RMovie(_RMovie),LMovie(_LMovie),Speed(_Speed),TimeText(_TimeText),ScoreText(_ScoreText) { N = 0; Front = 0; Score = 0; Time = 62; TimeText->setText(QString::number(Time)); drum.clear(); duration.clear(); addDrum(); connect(callparent,SIGNAL(keyPressEvent(QKeyEvent*)),this,SLOT(keyPressEvent(QKeyEvent*))); textTimer = new QTimer(this); connect(textTimer, SIGNAL(timeout()), this, SLOT(changeTime())); DelayTimer = new QTimer(this); connect(DelayTimer, SIGNAL(timeout()), this, SLOT(start())); player = new QMediaPlayer(this); player->setMedia(QUrl("qrc:/img/HaWay.mp3")); player->setVolume(100); r = new Record; }
/** The main thing. * @param argc count of command-line tokens. * @param argv array of command-line tokens. * @return 0 on success, 1-255 on failure. */ int main(int argc, char* argv[]){ if(argc != 2){ printf("usage: mytimer <seconds>\n"); return EXIT_FAILURE; } if(sscanf(argv[1], "%lf",&time) != 1){ printf("\"%s\" is not a number.\n", argv[1]); return EXIT_FAILURE; } if(time <= 0){ printf("Invalid time(%lf). Must be >= 0.\n",time); return EXIT_FAILURE; } running = TRUE; char c = 'z'; set_input_mode(); //setup the signal stuff timerSetup(); while(1){ read (STDIN_FILENO, &c, 1); if(c == 'q'){ fprintf(stdout,"\n"); fflush(stdout); return EXIT_SUCCESS; } if(c == 'h' || c == 'H' || c == 'm' || c == 'M' || c == 's' || c == 'S' || c == 'c' || c == 'r'){ changeTime(c); c = 'z'; } } return EXIT_SUCCESS; }