Exemplo n.º 1
0
Controller* PlayField::createController()
{
    // The client or server will overwrite this default configuration when 
    // the network messages are interchanged
    m_battle_ships_configuration = Settings::severalShips() ? 
    BattleShipsConfiguration::defaultMultipleShipsConfiguration(Settings::adjacentShips()):
    BattleShipsConfiguration::defaultSingleShipsConfiguration(Settings::adjacentShips());
    Controller* controller = new Controller(this, m_player, m_battle_ships_configuration);
    connect(controller, SIGNAL(gameOver(Sea::Player)),
            this, SLOT(gameOver(Sea::Player)));
    connect(controller, SIGNAL(restartRequested()),
            this, SLOT(restartRequested()));
    connect(controller, SIGNAL(compatibility(int)),
            this, SLOT(setCompatibility(int)));
    connect(controller, SIGNAL(nickChanged(int,QString)),
            this, SLOT(updateNick(int,QString)));
    connect(controller, SIGNAL(turnChanged(int)),
            this, SLOT(changeTurn(int)));
    connect(controller, SIGNAL(playerReady(int)),
            this, SLOT(playerReady(int)));
    connect(controller, SIGNAL(restartPlacingShips(Sea::Player)),
            this, SLOT(restartPlacingShips(Sea::Player)));
    connect(controller, SIGNAL(startPlacingShips(int)),
            this, SLOT(startPlacingShips()));

    return controller;
}
bool workflowControls::runCurrentStep(const word& stepName)
{
    if
    (
        completedStepsBeforeRestart_.size() &&
        completedStepsBeforeRestart_.contains(currentStep_) &&
        restartRequested() &&
        !isRestarted_
    )
    {
        Info << "Step " << currentStep_ << " has already been executed" << endl;

        const bool retVal = runAfterCurrentStep();

        //- this step has already been executed
        setStepCompleted();
        currentStep_ = stepName;

        return retVal;
    }
    else if( stopAfterCurrentStep() )
    {
        //- the process shall exit within the stopAfterCurrentStep function
        return false;
    }

    //- check if the requested step exists in the database of steps
    std::map<word, label>::const_iterator it = workflowSteps_.find(stepName);
    if( it == workflowSteps_.end() )
    {
        DynList<word> toc;
        for(it=workflowSteps_.begin();it!=workflowSteps_.end();++it)
            toc.append(it->first);

        FatalErrorIn
        (
            "void workflowControls::setCurrentStep(const word&)"
        ) << "Step " << stepName << " is not a valid name."
          << " Valid step names are " << toc << exit(FatalError);
    }

    setStepCompleted();
    currentStep_ = stepName;

    return true;
}
workflowControls::workflowControls(polyMeshGen& mesh)
:
    mesh_(mesh),
    currentStep_("start"),
    restartAfterStep_(),
    completedStepsBeforeRestart_(),
    isRestarted_(false)
{
    if( restartRequested() )
    {
        restartAfterStep_ = lastCompletedStep();
        completedStepsBeforeRestart_ = completedSteps();
    }
    else
    {
        clearCompletedSteps();

    }
}
Exemplo n.º 4
0
void PDFViewerWindow::keyPressEvent(QKeyEvent* e)
{
    QWidget::keyPressEvent(e);
    
    switch( e->key() )
    {
      case Qt::Key_G:
	changePageNumberDialog();
	break;
      case Qt::Key_F12:
      case Qt::Key_S: //Swap
	emit screenSwapRequested();
	break;
      case Qt::Key_Escape:
      case Qt::Key_Q: //quit
	emit quitRequested();
	break;
      case Qt::Key_Space:
      case Qt::Key_Enter:
      case Qt::Key_Return:
      case Qt::Key_PageDown:
      case Qt::Key_Down:
      case Qt::Key_Right:
      case Qt::Key_F: // Forward
      case Qt::Key_N: // Next
	emit nextPageRequested();
	break;
      case Qt::Key_PageUp:
      case Qt::Key_Up:
      case Qt::Key_Left:
      case Qt::Key_Backspace:
      case Qt::Key_B: // Back
      case Qt::Key_P: //Previous
	emit previousPageRequested();
	break;
      case Qt::Key_Home:
      case Qt::Key_H: //Home
	emit restartRequested();
	break;
    }
}
Exemplo n.º 5
0
DSPDFViewer::DSPDFViewer(const RuntimeConfiguration& r): 
	runtimeConfiguration(r),
	pdfDocument(Poppler::Document::load(r.filePathQString()))
	,
 renderFactory(r.filePathQString()),
 m_pagenumber(0),
 audienceWindow(0,  r.useFullPage()? PagePart::FullPage : PagePart::LeftHalf , false, r),
 secondaryWindow(1, r.useFullPage()? PagePart::FullPage : PagePart::RightHalf, true, r, r.useSecondScreen() )
{
  qDebug() << "Starting constructor" ;
  
  if ( ! r.useSecondScreen() ) {
    secondaryWindow.hide();
  }
  
  audienceWindow.showLoadingScreen(0);
  secondaryWindow.showLoadingScreen(0);
  
  if ( ! pdfDocument  || pdfDocument->isLocked() )
  {
    /// FIXME: Error message
    throw std::runtime_error("I was not able to open the PDF document. Sorry.");
  }
  setHighQuality(true);
  
  qDebug() << "Connecting audience window";
  
  audienceWindow.setPageNumberLimits(0, numberOfPages()-1);
  
  connect( &renderFactory, SIGNAL(pageRendered(QSharedPointer<RenderedPage>)), &audienceWindow, SLOT(renderedPageIncoming(QSharedPointer<RenderedPage>)));
  connect( &renderFactory, SIGNAL(thumbnailRendered(QSharedPointer<RenderedPage>)), &audienceWindow, SLOT(renderedThumbnailIncoming(QSharedPointer<RenderedPage>)));
  
  connect( &audienceWindow, SIGNAL(nextPageRequested()), this, SLOT(goForward()));
  connect( &audienceWindow, SIGNAL(previousPageRequested()), this, SLOT(goBackward()));
  connect( &audienceWindow, SIGNAL(pageRequested(uint)), this, SLOT(gotoPage(uint)));
  
  connect( &audienceWindow, SIGNAL(quitRequested()), this, SLOT(exit()));
  connect( &audienceWindow, SIGNAL(rerenderRequested()), this, SLOT(renderPage()));
  connect( &audienceWindow, SIGNAL(restartRequested()), this, SLOT(goToStartAndResetClocks()));
  
  connect( &audienceWindow, SIGNAL(screenSwapRequested()), this, SLOT(swapScreens()) );
  
  if ( r.useSecondScreen() )
  {
    qDebug() << "Connecting secondary window";
    
    secondaryWindow.setPageNumberLimits(0, numberOfPages()-1);
    
    connect( &renderFactory, SIGNAL(pageRendered(QSharedPointer<RenderedPage>)), &secondaryWindow, SLOT(renderedPageIncoming(QSharedPointer<RenderedPage>)));
    connect( &renderFactory, SIGNAL(thumbnailRendered(QSharedPointer<RenderedPage>)), &secondaryWindow, SLOT(renderedThumbnailIncoming(QSharedPointer<RenderedPage>)));

    connect( &secondaryWindow, SIGNAL(nextPageRequested()), this, SLOT(goForward()));
    connect( &secondaryWindow, SIGNAL(previousPageRequested()), this, SLOT(goBackward()));
    connect( &secondaryWindow, SIGNAL(pageRequested(uint)), this, SLOT(gotoPage(uint)));
    
    connect( &secondaryWindow, SIGNAL(quitRequested()), this, SLOT(exit()));
    connect( &secondaryWindow, SIGNAL(rerenderRequested()), this, SLOT(renderPage()));
    connect( &secondaryWindow, SIGNAL(restartRequested()), this, SLOT(goToStartAndResetClocks()));
    
    connect( &secondaryWindow, SIGNAL(screenSwapRequested()), this, SLOT(swapScreens()) );
    
    connect( this, SIGNAL(presentationClockUpdate(QTime)), &secondaryWindow, SLOT(updatePresentationClock(QTime)));
    connect( this, SIGNAL(slideClockUpdate(QTime)), &secondaryWindow, SLOT(updateSlideClock(QTime)));
    connect( this, SIGNAL(wallClockUpdate(QTime)), &secondaryWindow, SLOT(updateWallClock(QTime)));
  

  }
  
  renderPage();
  
  clockDisplayTimer.setInterval(TIMER_UPDATE_INTERVAL);
  clockDisplayTimer.start();
  connect( &clockDisplayTimer, SIGNAL(timeout()), this, SLOT(sendAllClockSignals()));
  sendAllClockSignals();
}