void TimeWidget::startState() { // Save selected values saveValues(); // Get max value const auto time_to_wait = timeToWait(); // Protection against wrong value if( time_to_wait <= 0 ) { QMessageBox::warning(this, tr("Wrong values"), tr("You need to specify a time superior to 0")); return; } // Set active and update button text m_active = true; m_widget_button->setText(tr("Cancel")); // Update the progresss bar m_widget_progress->setMaximum(time_to_wait); m_widget_progress->setValue(time_to_wait); updateProgressText(timesFromSeconds( remainingSeconds() )); m_widget_progress->setTextVisible(true); // Start the timer m_timer->start(1000); // In milliseconds emit started(); }
/*! \reimp */ bool QXtEventLoop::processEvents( ProcessEventsFlags flags ) { // Qt uses posted events to do lots of delayed operations, like repaints... these // need to be delivered before we go to sleep TQApplication::sendPostedEvents(); // make sure we fire off Qt's timers int ttw = timeToWait(); if ( d->timerid != 0 ) { XtRemoveTimeOut( d->timerid ); } d->timerid = 0; if ( ttw != -1 ) { d->timerid = XtAppAddTimeOut( d->appContext, ttw, qmotif_timeout_handler, 0 ); } // get the pending event mask from Xt and process the next event XtInputMask pendingmask = XtAppPending( d->appContext ); XtInputMask mask = pendingmask; if ( pendingmask & XtIMTimer ) { mask &= ~XtIMTimer; // zero timers will starve the Xt X event dispatcher... so process // something *instead* of a timer first... if ( mask != 0 ) XtAppProcessEvent( d->appContext, mask ); // and process a timer afterwards mask = pendingmask & XtIMTimer; } if ( ( flags & WaitForMore ) ) XtAppProcessEvent( d->appContext, XtIMAll ); else XtAppProcessEvent( d->appContext, mask ); int nevents = 0; if ( ! ( flags & ExcludeSocketNotifiers ) ) nevents += activateSocketNotifiers(); if ( d->activate_timers ) { nevents += activateTimers(); } d->activate_timers = FALSE; return ( (flags & WaitForMore) || ( pendingmask != 0 ) || nevents > 0 ); }
// --------------------------------------------------------------------------- // ?implementation_description // --------------------------------------------------------------------------- // EXPORT_C void CXIMPTestGeneralWaiter::WaitForL( TInt aSeconds ) { TTimeIntervalMicroSeconds32 timeToWait( aSeconds * 1000000 ); iTimer.After( iStatus, timeToWait ); SetActive(); }