Ejemplo n.º 1
0
void GridButton::enterEvent(QEvent *event)
{
    emit entered();
}
Ejemplo n.º 2
0
Archivo: main5.cpp Proyecto: RSATom/Qt
int main(int argv, char **args)
{
    QApplication app(argv, args);
    QWidget *button;

  {
//![0]
    QStateMachine machine;
    machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);

    QState *s1 = new QState();
    s1->assignProperty(object, "fooBar", 1.0);
    machine.addState(s1);
    machine.setInitialState(s1);

    QState *s2 = new QState();
    machine.addState(s2);
//![0]
  }

  {

//![2]
    QStateMachine machine;
    machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);

    QState *s1 = new QState();
    s1->assignProperty(object, "fooBar", 1.0);
    machine.addState(s1);
    machine.setInitialState(s1);

    QState *s2 = new QState(s1);
    s2->assignProperty(object, "fooBar", 2.0);
    s1->setInitialState(s2);

    QState *s3 = new QState(s1);
//![2]

  }

  {
//![3]
    QState *s1 = new QState();
    QState *s2 = new QState();

    s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
    s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100));

    s1->addTransition(button, SIGNAL(clicked()), s2);
//![3]

  }

  {
//![4]
    QState *s1 = new QState();
    QState *s2 = new QState();

    s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
    s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100));

    QSignalTransition *transition = s1->addTransition(button, SIGNAL(clicked()), s2);
    transition->addAnimation(new QPropertyAnimation(button, "geometry"));
//![4]

  }

  {
    QMainWindow *mainWindow = 0;

//![5]
    QMessageBox *messageBox = new QMessageBox(mainWindow);
    messageBox->addButton(QMessageBox::Ok);
    messageBox->setText("Button geometry has been set!");
    messageBox->setIcon(QMessageBox::Information);

    QState *s1 = new QState();

    QState *s2 = new QState();
    s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
    connect(s2, SIGNAL(entered()), messageBox, SLOT(exec()));

    s1->addTransition(button, SIGNAL(clicked()), s2);
//![5]
  }

  {
    QMainWindow *mainWindow = 0;

//![6]
    QMessageBox *messageBox = new QMessageBox(mainWindow);
    messageBox->addButton(QMessageBox::Ok);
    messageBox->setText("Button geometry has been set!");
    messageBox->setIcon(QMessageBox::Information);

    QState *s1 = new QState();

    QState *s2 = new QState();
    s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));

    QState *s3 = new QState();
    connect(s3, SIGNAL(entered()), messageBox, SLOT(exec()));

    s1->addTransition(button, SIGNAL(clicked()), s2);
    s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
//![6]

  }

  {

//![7]
    QState *s1 = new QState();
    QState *s2 = new QState();

    s2->assignProperty(object, "fooBar", 2.0);
    s1->addTransition(s2);

    QStateMachine machine;
    machine.setInitialState(s1);
    machine.addDefaultAnimation(new QPropertyAnimation(object, "fooBar"));
//![7]

  }



    return app.exec();
}
MTapStateMachine::MTapStateMachine(QObject *parent)
    :   QObject(parent),
        d_ptr(new MTapStateMachinePrivate)
{
    Q_D(MTapStateMachine);

    d->style = static_cast<const MTapStateMachineStyle *>(MTheme::style("MTapStateMachineStyle", ""));

    d->highlightMachine = new QStateMachine(this);

    d->unhighlightedState = new QState(d->highlightMachine);
    d->initialWaitState = new QState(d->highlightMachine);
    d->pressHighlightedState = new QState(d->highlightMachine);
    d->timedHighlightedState = new QState(d->highlightMachine);

    d->initialWaitTimer = new QTimer(this);
    d->initialWaitTimer->setSingleShot(true);
    d->initialWaitTimer->setInterval(d->style->initialWaitTime());

    d->minimumHighlightTimer = new QTimer(this);
    d->minimumHighlightTimer->setSingleShot(true);
    d->minimumHighlightTimer->setInterval(d->style->blinkDuration());

    d->highlightMachine->setInitialState(d->unhighlightedState);

    //Unhighlighted -> initialWaitState (on mouse press)
    d->initialMousePressTransition = new QEventTransition(parent, QEvent::GraphicsSceneMousePress);
    d->initialMousePressTransition->setTargetState(d->initialWaitState);
    d->unhighlightedState->addTransition(d->initialMousePressTransition);

    //InitialWaitState -> unhighlightedState (on Cancel Event)
    d->initCancelEventTransition = new MCancelEventTransition(parent);
    d->initCancelEventTransition->setTargetState(d->unhighlightedState);
    d->initialWaitState->addTransition(d->initCancelEventTransition);

    //InitialWaitState -> unhighlightedState (on visible changed)
    d->initVisibleChangedTransition = new QSignalTransition(parent, SIGNAL(visibleChanged()));
    d->initVisibleChangedTransition->setTargetState(d->unhighlightedState);
    d->initialWaitState->addTransition(d->initVisibleChangedTransition);

    //InitialWaitState -> timedHighlight (on mouse release)
    d->releaseTimedHighlightTransition = new QEventTransition(parent, QEvent::GraphicsSceneMouseRelease);
    d->releaseTimedHighlightTransition->setTargetState(d->timedHighlightedState);
    d->initialWaitState->addTransition(d->releaseTimedHighlightTransition);

    //InitialWaitState -> pressHighlightedState (on timer)
    d->timerHighlightTransition = new QSignalTransition(d->initialWaitTimer, SIGNAL(timeout()));
    d->timerHighlightTransition->setTargetState(d->pressHighlightedState);
    d->initialWaitState->addTransition(d->timerHighlightTransition);

    //PressHighlightedState -> unhighlightedState (on mouse release)
    d->releaseUnhighlightTransition = new QEventTransition(parent, QEvent::GraphicsSceneMouseRelease);
    d->releaseUnhighlightTransition->setTargetState(d->unhighlightedState);
    d->pressHighlightedState->addTransition(d->releaseUnhighlightTransition);

    //pressHighlightedState -> unhighlightedState (on Cancel Event)
    d->pressedCancelEventTransition = new MCancelEventTransition(parent);
    d->pressedCancelEventTransition->setTargetState(d->unhighlightedState);
    d->pressHighlightedState->addTransition(d->pressedCancelEventTransition);

    //pressHighlightedState -> unhighlightedState (on visible changed)
    d->pressedVisibleChangedTransition = new QSignalTransition(parent, SIGNAL(visibleChanged()));
    d->pressedVisibleChangedTransition->setTargetState(d->unhighlightedState);
    d->pressHighlightedState->addTransition(d->pressedVisibleChangedTransition);

    //TimedHighlightState -> UnhighlightedState (on timer)
    d->timerUnhighlightTransition = new QSignalTransition(d->minimumHighlightTimer, SIGNAL(timeout()));
    d->timerUnhighlightTransition->setTargetState(d->unhighlightedState);
    d->timedHighlightedState->addTransition(d->timerUnhighlightTransition);

    d->highlightMachine->start();

    connect(d->initialWaitState, SIGNAL(entered()), d->initialWaitTimer, SLOT(start()));
    connect(d->timedHighlightedState, SIGNAL(entered()), d->minimumHighlightTimer, SLOT(start()));
    connect(d->initialWaitState, SIGNAL(exited()), d->initialWaitTimer, SLOT(stop()));
    connect(d->timedHighlightedState, SIGNAL(exited()), d->minimumHighlightTimer, SLOT(stop()));

    connect(d->initCancelEventTransition, SIGNAL(triggered()), this, SIGNAL(release()));
    connect(d->initVisibleChangedTransition, SIGNAL(triggered()), this, SIGNAL(release()));
    connect(d->releaseUnhighlightTransition, SIGNAL(triggered()), this, SIGNAL(release()));
    connect(d->pressedCancelEventTransition, SIGNAL(triggered()), this, SIGNAL(release()));
    connect(d->pressedVisibleChangedTransition, SIGNAL(triggered()), this, SIGNAL(release()));
    connect(d->timerUnhighlightTransition, SIGNAL(triggered()), this, SIGNAL(release()));

    connect(d->pressHighlightedState, SIGNAL(entered()), this, SIGNAL(delayedPress()));
    connect(d->timedHighlightedState, SIGNAL(entered()), this, SIGNAL(delayedPress()));
}
Ejemplo n.º 4
0
KPrAnimationSelectorWidget::KPrAnimationSelectorWidget(KPrShapeAnimationDocker *docker, KPrPredefinedAnimationsLoader *animationsData,
        QWidget *parent)
    : QWidget(parent)
    , m_docker(docker)
    , m_previewAnimation(0)
    , m_showAutomaticPreview(false)
    , m_animationsData(animationsData)
    , m_collectionContextBar(0)
    , m_collectionPreviewButton(0)
    , m_subTypeContextBar(0)
    , m_subTypePreviewButton(0)
{
    QGridLayout *containerLayout = new QGridLayout;

    m_previewCheckBox = new QCheckBox(i18n("Automatic animation preview"), this);
    m_previewCheckBox->setChecked(loadPreviewConfig());
    m_showAutomaticPreview = m_previewCheckBox->isChecked();

    QFont viewWidgetFont  = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
    qreal pointSize = QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont).pointSizeF();
    viewWidgetFont.setPointSizeF(pointSize);

    m_collectionChooser = new QListWidget;
    m_collectionChooser->setViewMode(QListView::IconMode);
    m_collectionChooser->setIconSize(QSize(KIconLoader::SizeLarge, KIconLoader::SizeLarge));
    m_collectionChooser->setSelectionMode(QListView::SingleSelection);
    m_collectionChooser->setResizeMode(QListView::Adjust);
    m_collectionChooser->setGridSize(QSize(75, 64));
    m_collectionChooser->setFixedWidth(90);
    m_collectionChooser->setMovement(QListView::Static);
    m_collectionChooser->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_collectionChooser->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_collectionChooser->setFont(viewWidgetFont);
    connect(m_collectionChooser, SIGNAL(itemClicked(QListWidgetItem*)),
            this, SLOT(activateShapeCollection(QListWidgetItem*)));

    m_collectionView = new QListView;
    m_collectionView->setViewMode(QListView::IconMode);
    m_collectionView->setIconSize(QSize(KIconLoader::SizeLarge, KIconLoader::SizeLarge));
    m_collectionView->setDragDropMode(QListView::DragOnly);
    m_collectionView->setSelectionMode(QListView::SingleSelection);
    m_collectionView->setResizeMode(QListView::Adjust);
    m_collectionView->setGridSize(QSize(75, 64));
    m_collectionView->setWordWrap(true);
    m_collectionView->viewport()->setMouseTracking(true);
    m_collectionView->setFont(viewWidgetFont);
    connect(m_collectionView, SIGNAL(clicked(QModelIndex)),
            this, SLOT(setAnimation(QModelIndex)));

    m_subTypeView = new QListView;
    m_subTypeView->setViewMode(QListView::IconMode);
    m_subTypeView->setIconSize(QSize(KIconLoader::SizeLarge, KIconLoader::SizeLarge));
    m_subTypeView->setDragDropMode(QListView::DragOnly);
    m_subTypeView->setSelectionMode(QListView::SingleSelection);
    m_subTypeView->setResizeMode(QListView::Adjust);
    m_subTypeView->setGridSize(QSize(75, 64));
    m_subTypeView->setFixedHeight(79);
    m_subTypeView->setWordWrap(true);
    m_subTypeView->viewport()->setMouseTracking(true);
    m_subTypeView->hide();
    m_subTypeView->setFont(viewWidgetFont);
    connect(m_subTypeView, SIGNAL(clicked(QModelIndex)),
            this, SLOT(setAnimation(QModelIndex)));

    containerLayout->addWidget(m_collectionChooser, 0, 0,2,1);
    containerLayout->addWidget(m_collectionView, 0, 1, 1, 1);
    containerLayout->addWidget(m_subTypeView, 1, 1, 1, 1);
    containerLayout->addWidget(m_previewCheckBox, 2, 0, 1, 2);


    // set signals
    connect(m_collectionView, SIGNAL(entered(QModelIndex)), this, SLOT(automaticPreviewRequested(QModelIndex)));
    connect(m_subTypeView, SIGNAL(entered(QModelIndex)), this, SLOT(automaticPreviewRequested(QModelIndex)));
    connect(m_previewCheckBox, SIGNAL(toggled(bool)), this, SLOT(setPreviewState(bool)));
    connect(docker, SIGNAL(previousStateChanged(bool)), this, SLOT(setPreviewState(bool)));
    setLayout(containerLayout);
}
Ejemplo n.º 5
0
	void entered_(const QModelIndex& index)         { entered(index); }
Ejemplo n.º 6
0
//------------------------------------------------------------------------------
// Initialize - Initialize the states and transitions of a Card.
//------------------------------------------------------------------------------
void Card::Initialize(void)
{
    // Set the Point value of the card.
    SetValue();

    // Initialize the renderer and start the card facing down.
    renderer = new QSvgRenderer(backImage);
    this->setSharedRenderer(renderer);
    facedown = true;

    // Initialize the transition animation associated with a Card
    // moving from one place to another.
    transitionAnimation = new QPropertyAnimation(this, "pos");

    // Setup the internal state machine of the Card.
    stateMachine        = new QStateMachine();

    // Initialize the various states that a Card can be in.
    inDeckState           = new InDeckState();
    inTalonState          = new InTalonState();
    inPlayerHandState     = new InPlayerHandState();
    inCpuHandState        = new InCpuHandState();
    inPlayerDiscardsState = new InPlayerDiscardsState();
    inCpuDiscardsState    = new InCpuDiscardsState();
    inPlayerTrickState    = new InPlayerTrickState();
    inCpuTrickState       = new InCpuTrickState();
    inPreviousTricksState = new InPreviousTricksState();

    // Add the states to the state machine.
    stateMachine->addState(inDeckState);
    stateMachine->addState(inTalonState);
    stateMachine->addState(inPlayerHandState);
    stateMachine->addState(inCpuHandState);
    stateMachine->addState(inPlayerDiscardsState);
    stateMachine->addState(inCpuDiscardsState);
    stateMachine->addState(inPlayerTrickState);
    stateMachine->addState(inCpuTrickState);
    stateMachine->addState(inPreviousTricksState);

    // Set the initial state.
    stateMachine->setInitialState(inDeckState);

    // Setup the transitions from the InDeck state.
    inDeckState->addTransition(this, SIGNAL(InPlayerHand()), inPlayerHandState);
    inDeckState->addTransition(this, SIGNAL(InCpuHand()),    inCpuHandState);
    inDeckState->addTransition(this, SIGNAL(InTalon()),      inTalonState);

    // Setup the transitions from the InTalon state.
    inTalonState->addTransition(this, SIGNAL(InPlayerHand()),
                                inPlayerHandState);
    inTalonState->addTransition(this, SIGNAL(InCpuHand()), inCpuHandState);
    inTalonState->addTransition(this, SIGNAL(InDeck()),    inDeckState);


    // Setup the transitions from the InPlayerHand state.
    inPlayerHandState->addTransition(this, SIGNAL(InPlayerDiscards()),
                                     inPlayerDiscardsState);
    inPlayerHandState->addTransition(this, SIGNAL(InPlayerTrick()),
                                     inPlayerTrickState);
    inPlayerHandState->addTransition(this, SIGNAL(InDeck()), inDeckState);

    // Setup the transitions from the InCpuHand state.
    inCpuHandState->addTransition(this, SIGNAL(InCpuDiscards()),
                                  inCpuDiscardsState);
    inCpuHandState->addTransition(this, SIGNAL(InCpuTrick()),
                                  inCpuTrickState);
    inCpuHandState->addTransition(this, SIGNAL(InDeck()), inDeckState);

    // Setup the transitions from the InPlayerDiscards state.
    inPlayerDiscardsState->addTransition(this, SIGNAL(InDeck()), inDeckState);

    // Setup the transitions from the InCpuDiscards state.
    inCpuDiscardsState->addTransition(this, SIGNAL(InDeck()), inDeckState);

    // Setup the transitions from the InPlayerTrick state.
    inPlayerTrickState->addTransition(this, SIGNAL(InPlayerHand()),
                                       inPlayerHandState);
    inPlayerTrickState->addTransition(this, SIGNAL(InPreviousTricks()),
                                      inPreviousTricksState);
    inPlayerTrickState->addTransition(this, SIGNAL(InDeck()), inDeckState);

    // Setup the transitions from the InCpuTrick state.
    inCpuTrickState->addTransition(this, SIGNAL(InCpuHand()),
                                   inCpuHandState);
    inCpuTrickState->addTransition(this, SIGNAL(InPreviousTricks()),
                                   inPreviousTricksState);
    inCpuTrickState->addTransition(this, SIGNAL(InDeck()), inDeckState);

    // Setup the transitions from the InPreviousTricks state.
    inPreviousTricksState->addTransition(this, SIGNAL(InDeck()), inDeckState);

    // Link the card to the signals from CardStates.
    connect(inPlayerHandState,     SIGNAL(entered()), this, SLOT(FlipCard()));
    connect(inPlayerHandState,     SIGNAL(exited()),  this, SLOT(FlipCard()));
    connect(inPlayerTrickState,    SIGNAL(entered()), this, SLOT(FlipCard()));
    connect(inPlayerTrickState,    SIGNAL(exited()),  this, SLOT(FlipCard()));
    connect(inCpuTrickState,       SIGNAL(entered()), this, SLOT(FlipCard()));
    connect(inCpuTrickState,       SIGNAL(exited()),  this, SLOT(FlipCard()));
    connect(inPreviousTricksState, SIGNAL(entered()), this, SLOT(Display()));
    connect(inPreviousTricksState, SIGNAL(exited()),  this, SLOT(Display()));
    connect(inPlayerDiscardsState, SIGNAL(entered()), this, SLOT(FlipCard()));
    connect(inPlayerDiscardsState, SIGNAL(exited()),  this, SLOT(FlipCard()));

    // Run the state machine.
    stateMachine->start();
}
Ejemplo n.º 7
0
GameStateMachine::GameStateMachine(QObject *parent) :
    QObject(parent)
{
    // ****************************************************
    // initialize all states and substates
    theFailedState             = new GameState(&theGameStateMachine, "FailedState");

    theProblemState            = new GameState(&theGameStateMachine, "ProblemState");

    theRunningState            = new GameState(&theGameStateMachine, "RunningState");
    theRunningForwardSubState  = new GameState( theRunningState,      "RunningForwardSubState");
    theRunningNormalSubState   = new GameState( theRunningState,      "RunningNormalSubState");
    theRunningPausedSubState   = new GameState( theRunningState,      "RunningPausedSubState");
    theRunningRealFastSubState = new GameState( theRunningState,      "RunningRealFastSubState");
    theRunningSlowSubState     = new GameState( theRunningState,      "RunningSlowSubState");
    theRunningState->setInitialState(theRunningNormalSubState);

    theStoppedState            = new GameState(&theGameStateMachine, "StoppedState");

    theWonState                = new GameState(&theGameStateMachine, "WonState");
    theWonPausedSubState       = new GameState( theWonState,          "WonPausedSubState");
    theWonRunningSubState      = new GameState( theWonState,          "WonRunningSubState");
    theWonState->setInitialState(theWonRunningSubState);

    theGameStateMachine.setInitialState(theStoppedState);

    // ****************************************************
    // setup all state transitions

    theFailedState->addTransition(this, SIGNAL(signal_Reset_triggered()), theStoppedState);
    connect(theFailedState, SIGNAL(entered()), this, SIGNAL(signal_Stop_Gameplay()));
    connect(theFailedState, SIGNAL(entered()), this, SIGNAL(signal_Game_Failed()));
    connect(theFailedState, SIGNAL(activated(GameState *)), this,
            SLOT(slot_State_Activated(GameState *)));

    theProblemState->addTransition(this, SIGNAL(signal_Problems_solved()), theStoppedState);
    connect(theProblemState, SIGNAL(activated(GameState *)), this,
            SLOT(slot_State_Activated(GameState *)));
    connect(theProblemState, SIGNAL(entered()), this, SLOT(slot_AllowEntered()));
    connect(theProblemState, SIGNAL(exited()), this, SLOT(slot_AllowExited()));

    theRunningState->addTransition(this, SIGNAL(signal_Fail_happened()), theFailedState);
    theRunningState->addTransition(this, SIGNAL(signal_Won_happened()), theWonState);
    theRunningState->addTransition(this, SIGNAL(signal_Reset_triggered()), theStoppedState);

    //theRunningForwardSubState->addTransition(this, SIGNAL(signal_Forward_triggered()), theRunningForwardSubState);
    theRunningForwardSubState->addTransition(this, SIGNAL(signal_Pause_triggered()),
                                             theRunningPausedSubState);
    theRunningForwardSubState->addTransition(this, SIGNAL(signal_Play_triggered()),
                                             theRunningNormalSubState);
    theRunningForwardSubState->addTransition(this, SIGNAL(signal_RealFast_triggered()),
                                             theRunningRealFastSubState);
    theRunningForwardSubState->addTransition(this, SIGNAL(signal_Slow_triggered()),
                                             theRunningSlowSubState);
    connect(theRunningForwardSubState, SIGNAL(activated(GameState *)), this,
            SLOT(slot_State_Activated(GameState *)));

    theRunningNormalSubState->addTransition(this, SIGNAL(signal_Forward_triggered()),
                                            theRunningForwardSubState);
    theRunningNormalSubState->addTransition(this, SIGNAL(signal_Pause_triggered()),
                                            theRunningPausedSubState);
    //theRunningNormalSubState->addTransition(this, SIGNAL(signal_Play_triggered()), theRunningNormalSubState);
    theRunningNormalSubState->addTransition(this, SIGNAL(signal_RealFast_triggered()),
                                            theRunningRealFastSubState);
    theRunningNormalSubState->addTransition(this, SIGNAL(signal_Slow_triggered()),
                                            theRunningSlowSubState);
    connect(theRunningNormalSubState, SIGNAL(activated(GameState *)), this,
            SLOT(slot_State_Activated(GameState *)));

    theRunningPausedSubState->addTransition(this, SIGNAL(signal_Forward_triggered()),
                                            theRunningForwardSubState);
    //theRunningPausedSubState->addTransition(this, SIGNAL(signal_Pause_triggered()), theRunningPausedSubState);
    theRunningPausedSubState->addTransition(this, SIGNAL(signal_Play_triggered()),
                                            theRunningNormalSubState);
    theRunningPausedSubState->addTransition(this, SIGNAL(signal_RealFast_triggered()),
                                            theRunningRealFastSubState);
    theRunningPausedSubState->addTransition(this, SIGNAL(signal_Slow_triggered()),
                                            theRunningSlowSubState);
    connect(theRunningPausedSubState, SIGNAL(activated(GameState *)), this,
            SLOT(slot_State_Activated(GameState *)));

    theRunningRealFastSubState->addTransition(this, SIGNAL(signal_Forward_triggered()),
                                              theRunningForwardSubState);
    theRunningRealFastSubState->addTransition(this, SIGNAL(signal_Pause_triggered()),
                                              theRunningPausedSubState);
    theRunningRealFastSubState->addTransition(this, SIGNAL(signal_Play_triggered()),
                                              theRunningNormalSubState);
    //theRunningRealFastSubState->addTransition(this, SIGNAL(signal_RealFast_triggered()), theRunningRealFastSubState);
    theRunningRealFastSubState->addTransition(this, SIGNAL(signal_Slow_triggered()),
                                              theRunningSlowSubState);
    connect(theRunningRealFastSubState, SIGNAL(activated(GameState *)), this,
            SLOT(slot_State_Activated(GameState *)));

    theRunningSlowSubState->addTransition(this, SIGNAL(signal_Forward_triggered()),
                                          theRunningForwardSubState);
    theRunningSlowSubState->addTransition(this, SIGNAL(signal_Pause_triggered()),
                                          theRunningPausedSubState);
    theRunningSlowSubState->addTransition(this, SIGNAL(signal_Play_triggered()),
                                          theRunningNormalSubState);
    theRunningSlowSubState->addTransition(this, SIGNAL(signal_RealFast_triggered()),
                                          theRunningRealFastSubState);
    //theRunningSlowSubState->addTransition(this, SIGNAL(signal_Slow_triggered()), theRunningSlowSubState);
    connect(theRunningSlowSubState, SIGNAL(activated(GameState *)), this,
            SLOT(slot_State_Activated(GameState *)));

    theStoppedState->addTransition(this, SIGNAL(signal_Problems_arised()), theProblemState);
    // TODO: figure out if immediately jump to substate or to master & retransmit
    theStoppedState->addTransition(this, SIGNAL(signal_Forward_triggered()), theRunningForwardSubState);
    theStoppedState->addTransition(this, SIGNAL(signal_Pause_triggered()), theRunningPausedSubState);
    theStoppedState->addTransition(this, SIGNAL(signal_Play_triggered()), theRunningNormalSubState);
    theStoppedState->addTransition(this, SIGNAL(signal_RealFast_triggered()),
                                   theRunningRealFastSubState);
    theStoppedState->addTransition(this, SIGNAL(signal_Slow_triggered()), theRunningSlowSubState);
    connect(theStoppedState, SIGNAL(entered()), this, SIGNAL(signal_Stop_Gameplay()));
    connect(theStoppedState, SIGNAL(entered()), this, SIGNAL(signal_makeAllDialogsDisappear()));
    connect(theStoppedState, &GameState::activated, this, &GameStateMachine::slot_State_Activated);
    connect(theStoppedState, SIGNAL(entered()), this, SLOT(slot_AllowEntered()));
    connect(theStoppedState, SIGNAL(exited()), this, SLOT(slot_AllowExited()));

    theWonState->addTransition(this, SIGNAL(signal_Reset_triggered()), theStoppedState);
    connect(theWonState, SIGNAL(activated(GameState *)), this, SLOT(slot_State_Activated(GameState *)));
    theWonRunningSubState->addTransition(&theWonRunningTimer, SIGNAL(timeout()), theWonPausedSubState);
    connect(theWonState, SIGNAL(entered()), this, SLOT(slot_SetWonRunningTimeout()));
    connect(theWonRunningSubState, SIGNAL(entered()), this, SIGNAL(signal_Game_Is_Won()));
    theWonPausedSubState->addTransition(this, SIGNAL(signal_Reset_triggered()), theStoppedState);
    connect(theWonPausedSubState, SIGNAL(entered()), this, SIGNAL(signal_Stop_Gameplay()));

    emit theGameStateMachine.start();
}
KinotifyWidget::KinotifyWidget (int timeout, QWidget *widget, int animationTimout)
: QWebView (widget)
, Timeout_ (timeout)
, AnimationTime_ (animationTimout)
{
    setWindowOpacity (0.0);
    this->setContextMenuPolicy(Qt::NoContextMenu);

    CloseTimer_ = new QTimer (this);
    CheckTimer_ = new QTimer (this);
    CloseTimer_->setSingleShot (true);
    CheckTimer_->setSingleShot (true);

    showStartState = new QState;
    showFinishState = new QState;
    closeStartState = new QState;
    closeFinishState = new QState;
    finalState = new QFinalState;

    QPropertyAnimation *opacityAmination = new QPropertyAnimation (this, "opacity");
    opacityAmination->setDuration (AnimationTime_);

    showStartState->assignProperty (this, "opacity", 0.0);
    showFinishState->assignProperty (this, "opacity", 0.8);
    closeStartState->assignProperty (this, "opacity", 0.8);
    closeFinishState->assignProperty (this, "opacity", 0.0);

    showStartState->addTransition (showFinishState);
    showFinishState->addTransition (this,
    SIGNAL (initiateCloseNotification ()), closeStartState);

    closeStartState->addTransition (closeFinishState);
    closeFinishState->addTransition (closeFinishState,
    SIGNAL (propertiesAssigned ()), finalState);


    Machine_.addState (showStartState);
    Machine_.addState (showFinishState);
    Machine_.addState (closeStartState);
    Machine_.addState (closeFinishState);
    Machine_.addState (finalState);

    Machine_.addDefaultAnimation (opacityAmination);
    Machine_.setInitialState (showStartState);

    connect (&Machine_,
    SIGNAL (finished ()),
    this,
    SLOT (closeNotification ()));

    connect (showFinishState,
    SIGNAL (entered ()),
    this,
    SLOT (stateMachinePause ()));

    connect (CloseTimer_,
    SIGNAL (timeout ()),
    this,
    SIGNAL (initiateCloseNotification ()));

    connect (CheckTimer_,
    SIGNAL (timeout ()),
    this,
    SIGNAL (checkNotificationQueue ()));
}
Ejemplo n.º 9
0
FormulaDialog::FormulaDialog(QWidget* parent, Selection* selection, CellEditorBase* editor, const QString& formulaName)
        : KDialog(parent)
{
    setCaption(i18n("Function"));
    setButtons(Ok | Cancel);
    //setWFlags( Qt::WDestructiveClose );

    m_selection = selection;
    m_editor = editor;
    m_focus = 0;
    m_desc = 0;

    KCCell cell(m_selection->activeSheet(), m_selection->marker());
    m_oldText = cell.userInput();
    // Make sure that there is a cell editor running.
    if (cell.userInput().isEmpty())
        m_editor->setText("=");
    else if (cell.userInput().at(0) != '=')
        m_editor->setText('=' + cell.userInput());
    else
        m_editor->setText(cell.userInput());

    QWidget *page = new QWidget(this);
    setMainWidget(page);

    QGridLayout *grid1 = new QGridLayout(page);
    grid1->setMargin(KDialog::marginHint());
    grid1->setSpacing(KDialog::spacingHint());

    searchFunct = new KLineEdit(page);
    searchFunct->setClearButtonShown(true);
    searchFunct->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));

    grid1->addWidget(searchFunct, 0, 0);

    typeFunction = new KComboBox(page);
    QStringList cats = KCFunctionRepository::self()->groups();
    cats.prepend(i18n("All"));
    typeFunction->setMaxVisibleItems(15);
    typeFunction->insertItems(0, cats);
    grid1->addWidget(typeFunction, 1, 0);

    functions = new QListView(page);
    functions->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));
    functions->setSelectionMode(QAbstractItemView::SingleSelection);
    functions->setEditTriggers(QAbstractItemView::NoEditTriggers);
    grid1->addWidget(functions, 2, 0);

    functionsModel = new QStringListModel(this);
    proxyModel = new QSortFilterProxyModel(functions);
    proxyModel->setSourceModel(functionsModel);
    proxyModel->setFilterKeyColumn(0);
    proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
    functions->setModel(proxyModel);

    QItemSelectionModel* selectionmodel = new QItemSelectionModel(proxyModel, this);
    functions->setSelectionModel(selectionmodel);
    connect(selectionmodel, SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
            this, SLOT(slotSelected()));
    // When items are activated on single click, also change the help page on mouse-over, otherwise there is no (easy) way to get
    // the help without inserting the function
    if (functions->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, functions)) {
        connect(functions, SIGNAL(entered(QModelIndex)), this, SLOT(slotIndexSelected(QModelIndex)));
        functions->setMouseTracking(true);
    }
    //connect(proxyModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(slotDataChanged(QModelIndex,QModelIndex)));

    selectFunction = new QPushButton(page);
    selectFunction->setToolTip(i18n("Insert function"));
    selectFunction->setIcon(BarIcon("go-down", KIconLoader::SizeSmall));
    grid1->addWidget(selectFunction, 3, 0);

    result = new KLineEdit(page);
    grid1->addWidget(result, 4, 0, 1, -1);

    m_tabwidget = new KTabWidget(page);
    m_tabwidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
    grid1->addWidget(m_tabwidget, 0, 1, 4, 1);

    m_browser = new KTextBrowser(m_tabwidget, true);
    m_browser->document()->setDefaultStyleSheet("h1 { font-size:x-large; } h2 { font-size:large; } h3 { font-size:medium; }");
    m_browser->setMinimumWidth(300);

    m_tabwidget->addTab(m_browser, i18n("Help"));
    int index = m_tabwidget->currentIndex();

    m_input = new QWidget(m_tabwidget);
    QVBoxLayout *grid2 = new QVBoxLayout(m_input);
    grid2->setMargin(KDialog::marginHint());
    grid2->setSpacing(KDialog::spacingHint());

    // grid2->setResizeMode (QLayout::Minimum);

    label1 = new QLabel(m_input);
    grid2->addWidget(label1);

    firstElement = new KLineEdit(m_input);
    grid2->addWidget(firstElement);

    label2 = new QLabel(m_input);
    grid2->addWidget(label2);

    secondElement = new KLineEdit(m_input);
    grid2->addWidget(secondElement);

    label3 = new QLabel(m_input);
    grid2->addWidget(label3);

    thirdElement = new KLineEdit(m_input);
    grid2->addWidget(thirdElement);

    label4 = new QLabel(m_input);
    grid2->addWidget(label4);

    fourElement = new KLineEdit(m_input);
    grid2->addWidget(fourElement);

    label5 = new QLabel(m_input);
    grid2->addWidget(label5);

    fiveElement = new KLineEdit(m_input);
    grid2->addWidget(fiveElement);

    grid2->addStretch(10);

    m_tabwidget->addTab(m_input, i18n("Parameters"));
    m_tabwidget->setTabEnabled(m_tabwidget->indexOf(m_input), false);

    m_tabwidget->setCurrentIndex(index);

    refresh_result = true;

    connect(this, SIGNAL(cancelClicked()), this, SLOT(slotClose()));
    connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
    connect(typeFunction, SIGNAL(activated(const QString &)),
            this, SLOT(slotActivated(const QString &)));
    /*
        connect( functions, SIGNAL( highlighted(const QString &) ),
                 this, SLOT( slotSelected(const QString &) ) );
        connect( functions, SIGNAL( selected(const QString &) ),
                 this, SLOT( slotSelected(const QString &) ) );
    */
    connect(functions, SIGNAL(activated(QModelIndex)),
            this , SLOT(slotDoubleClicked(QModelIndex)));

    slotActivated(i18n("All"));

    connect(selectFunction, SIGNAL(clicked()),
            this, SLOT(slotSelectButton()));

    connect(firstElement, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotChangeText(const QString &)));
    connect(secondElement, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotChangeText(const QString &)));
    connect(thirdElement, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotChangeText(const QString &)));
    connect(fourElement, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotChangeText(const QString &)));
    connect(fiveElement, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotChangeText(const QString &)));

    connect(m_selection, SIGNAL(changed(const KCRegion&)),
            this, SLOT(slotSelectionChanged()));

    connect(m_browser, SIGNAL(urlClick(const QString&)),
            this, SLOT(slotShowFunction(const QString&)));

    // Save the name of the active sheet.
    m_sheetName = m_selection->activeSheet()->sheetName();
    // Save the cells current text.
    QString tmp_oldText = m_editor->toPlainText();
    // Position of the cell.
    m_column = m_selection->marker().x();
    m_row = m_selection->marker().y();

    if (tmp_oldText.isEmpty())
        result->setText("=");
    else {
        if (tmp_oldText.at(0) != '=')
            result->setText('=' + tmp_oldText);
        else
            result->setText(tmp_oldText);
    }

    // Allow the user to select cells on the spreadsheet.
    m_selection->startReferenceSelection();

    qApp->installEventFilter(this);

    // Was a function name passed along with the constructor ? Then activate it.
    if (!formulaName.isEmpty()) {
        kDebug() << "formulaName=" << formulaName;
#if 0
        QList<QListWidgetItem *> items = functions->findItems(formulaName, Qt::MatchFixedString);
        if (items.count() > 0) {
            functions->setCurrentItem(items[0]);
            slotDoubleClicked(items[0]);
        }
#else
        int row = functionsModel->stringList().indexOf(formulaName);
        const QModelIndex sourcemodelindex = functionsModel->index(row, 0);
        const QModelIndex proxymodelindex = proxyModel->mapFromSource(sourcemodelindex);
        if (proxymodelindex.isValid()) {
            functions->setCurrentIndex(proxymodelindex);
            slotDoubleClicked(proxymodelindex);
        }
#endif
    } else {
        // Set keyboard focus to allow selection of a formula.
        searchFunct->setFocus();
    }

    // Add auto completion.
    searchFunct->setCompletionMode(KGlobalSettings::CompletionAuto);
    searchFunct->setCompletionObject(&listFunct, true);

    if (functions->currentIndex().isValid())
        selectFunction->setEnabled(false);

    connect(searchFunct, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotSearchText(const QString &)));
    connect(searchFunct, SIGNAL(returnPressed()),
            this, SLOT(slotPressReturn()));

    resize(QSize(660, 520).expandedTo(minimumSizeHint()));
}
SmoozikSimplestClientWindow::SmoozikSimplestClientWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::SmoozikSimplestClientWindow)
{
    ui->setupUi(this);

    // Initialize SmoozikManager
    smoozikManager = new SmoozikManager(APIKEY, SECRET, SmoozikManager::XML, false, this);
    smoozikPlaylist = new SmoozikPlaylist;
    connect(smoozikManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(processNetworkReply(QNetworkReply*)));

    // Initialize music directory
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    _dirName = QDesktopServices::storageLocation(QDesktopServices::MusicLocation);
#else
    _dirName = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
#endif

    // Initialize playlist filler
    ui->setupUi(this);
    smoozikPlaylistFillerThread = new QThread();
    smoozikPlaylistFiller = new SmoozikPlaylistFiller(smoozikPlaylist);
    smoozikPlaylistFiller->moveToThread(smoozikPlaylistFillerThread);
    connect(smoozikPlaylistFiller, SIGNAL(trackFound(QString,QString,QString,QString,uint)), this, SLOT(addTrackToPlaylist(QString,QString,QString,QString,uint)));
    connect(smoozikPlaylistFiller, SIGNAL(tracksRetrieved()), this, SIGNAL(tracksRetrieved()));
    connect(smoozikPlaylistFiller, SIGNAL(noTrackRetrieved()), this, SLOT(noTrackRetrievedMessage()));
    connect(smoozikPlaylistFiller, SIGNAL(maxPlaylistSizeReached()), this, SLOT(maxPlaylistSizeReachedMessage()));
    connect(smoozikPlaylistFillerThread, SIGNAL(started()), smoozikPlaylistFiller, SLOT(fillPlaylist()));
    connect(smoozikPlaylistFiller, SIGNAL(finished()), smoozikPlaylistFillerThread, SLOT(quit()), Qt::DirectConnection);

    // Initialize player
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    player = new Phonon::MediaObject(this);
    Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    Phonon::createPath(player, audioOutput);
    connect(player, SIGNAL(currentSourceChanged(Phonon::MediaSource)), this, SLOT(updateTrackLabels()));
    connect(player, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(playerStateChanged()));
#else
    player = new QMediaPlayer(this);
    player->setPlaylist(new QMediaPlaylist(player));
    player->playlist()->setPlaybackMode(QMediaPlaylist::Sequential);
    connect(player, SIGNAL(currentMediaChanged(QMediaContent)), this, SLOT(updateTrackLabels()));
    connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playerStateChanged()));
#endif
    connect(ui->playButton, SIGNAL(clicked()), player, SLOT(play()));
    connect(ui->pauseButton, SIGNAL(clicked()), player, SLOT(pause()));
    connect(this, SIGNAL(currentTrackSet()), this, SLOT(updateTrackLabels()));
    connect(this, SIGNAL(nextTrackSet()), this, SLOT(updateTrackLabels()));

    // Initialize main state machine which controls what is displayed
    QStateMachine *mainStateMachine = new QStateMachine(this);
    QState *mainState = new QState(mainStateMachine);
    QState *loginState = new QState(mainState);
    QState *startPartyState = new QState(mainState);
    QState *connectedState = new QState(mainState);
    QState *retrieveTracksState = new QState(connectedState);
    QState *sendPlaylistState = new QState(connectedState);
    QState *getTopTracksState = new QState(connectedState);
    QState *partyState = new QState(connectedState);
    QState *waitingState = new QState(partyState);
    QState *sendCurrentTrackState = new QState(partyState);
    QState *sendNextTrackState = new QState(partyState);

    QStateMachine *playerStateMachine = new QStateMachine(this);
    QState *playerState = new QState(playerStateMachine);
    QState *playingState = new QState(playerState);
    QState *pausedState = new QState(playerState);

    // Define state initial states and transitions
    mainStateMachine->setInitialState(mainState);
    mainState->setInitialState(loginState);
    connectedState->setInitialState(retrieveTracksState);
    partyState->setInitialState(waitingState);
    playerStateMachine->setInitialState(playerState);
    playerState->setInitialState(pausedState);

    mainState->addTransition(this, SIGNAL(disconnected()), loginState);
    loginState->addTransition(this, SIGNAL(loggedIn()), startPartyState);
    startPartyState->addTransition(this, SIGNAL(partyStarted()), connectedState);
    connectedState->addTransition(ui->changePlaylistButton, SIGNAL(clicked()), retrieveTracksState);
    retrieveTracksState->addTransition(this, SIGNAL(tracksRetrieved()), sendPlaylistState);
    sendPlaylistState->addTransition(this, SIGNAL(playlistSent()), getTopTracksState);
    getTopTracksState->addTransition(this, SIGNAL(currentTrackSet()), sendCurrentTrackState);
    sendCurrentTrackState->addTransition(this, SIGNAL(currentTrackSent()), getTopTracksState);
    getTopTracksState->addTransition(this, SIGNAL(nextTrackSet()), sendNextTrackState);
    sendNextTrackState->addTransition(this, SIGNAL(nextTrackSent()), waitingState);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    waitingState->addTransition(player, SIGNAL(currentSourceChanged(Phonon::MediaSource)), sendCurrentTrackState);
#else
    waitingState->addTransition(player, SIGNAL(currentMediaChanged(QMediaContent)), sendCurrentTrackState);
#endif

    playerState->addTransition(this, SIGNAL(playing()), playingState);
    playerState->addTransition(this, SIGNAL(paused()), pausedState);

    // Define state properties
    loginState->assignProperty(this, "state", Login);
    loginState->assignProperty(ui->stackedWidget, "currentIndex", ui->stackedWidget->indexOf(ui->loginPage));
    loginState->assignProperty(ui->loginButton, "enabled", true);
    loginState->assignProperty(ui->disconnectButton, "visible", false);
    loginState->assignProperty(ui->changePlaylistButton, "visible", false);
    loginState->assignProperty(ui->usernameLineEdit, "enabled", true);
    loginState->assignProperty(ui->passwordLineEdit, "enabled", true);
    loginState->assignProperty(ui->loginStateLabel, "text", QString());

    startPartyState->assignProperty(this, "state", StartParty);
    startPartyState->assignProperty(ui->loginStateLabel, "text", tr("Starting party..."));
    startPartyState->assignProperty(ui->disconnectButton, "visible", false);
    startPartyState->assignProperty(ui->changePlaylistButton, "visible", false);

    connectedState->assignProperty(ui->disconnectButton, "visible", true);

    retrieveTracksState->assignProperty(ui->stackedWidget, "currentIndex", ui->stackedWidget->indexOf(ui->loadingPage));
    retrieveTracksState->assignProperty(ui->loginStateLabel, "text", tr("Connected"));
    retrieveTracksState->assignProperty(ui->loadingLabel, "text", tr("Retrieving tracks..."));
    retrieveTracksState->assignProperty(ui->changePlaylistButton, "visible", false);

    sendPlaylistState->assignProperty(this, "state", SendPlaylist);
    sendPlaylistState->assignProperty(ui->loadingLabel, "text", tr("Sending playlist..."));
    sendPlaylistState->assignProperty(ui->changePlaylistButton, "visible", true);

    getTopTracksState->assignProperty(this, "state", GetTopTracks);
    getTopTracksState->assignProperty(ui->loadingLabel, "text", tr("Get top tracks..."));
    getTopTracksState->assignProperty(ui->nextButton, "enabled", false);
    getTopTracksState->assignProperty(ui->changePlaylistButton, "visible", true);

    partyState->assignProperty(ui->stackedWidget, "currentIndex", ui->stackedWidget->indexOf(ui->playerPage));
    partyState->assignProperty(ui->changePlaylistButton, "visible", true);

    sendCurrentTrackState->assignProperty(this, "state", SendCurrentTrack);
    sendCurrentTrackState->assignProperty(ui->nextButton, "enabled", false);

    sendNextTrackState->assignProperty(this, "state", SendNextTrack);
    sendNextTrackState->assignProperty(ui->nextButton, "enabled", false);

    waitingState->assignProperty(ui->nextButton, "enabled", true);

    playingState->assignProperty(ui->playButton, "visible", false);
    playingState->assignProperty(ui->pauseButton, "visible", true);

    pausedState->assignProperty(ui->playButton, "visible", true);
    pausedState->assignProperty(ui->pauseButton, "visible", false);

    // Connect states and actions
    connect(startPartyState, SIGNAL(entered()), this, SLOT(startParty()));
    connect(retrieveTracksState, SIGNAL(entered()), this, SLOT(retrieveTracksDialog()));
    connect(sendPlaylistState, SIGNAL(entered()), this, SLOT(sendPlaylist()));
    connect(getTopTracksState, SIGNAL(entered()), this, SLOT(getTopTracks()));
    connect(sendCurrentTrackState, SIGNAL(entered()), this, SLOT(sendCurrentTrack()));
    connect(sendNextTrackState, SIGNAL(entered()), this, SLOT(sendNextTrack()));

    // Connect gui and actions
    connect(ui->usernameLineEdit, SIGNAL(returnPressed()), this, SLOT(submitLogin()));
    connect(ui->passwordLineEdit, SIGNAL(returnPressed()), this, SLOT(submitLogin()));
    connect(ui->loginButton, SIGNAL(clicked()), this, SLOT(submitLogin()));
    connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(nextTrack()));
    connect(ui->disconnectButton, SIGNAL(clicked()), this, SLOT(disconnect()));

    // Start state machine
    mainStateMachine->start();
    playerStateMachine->start();
}
Ejemplo n.º 11
0
void StateMachineMgr::buildStateMachine(QLayout* layout,bool bIsEntryLane)
{
    if(bIsEntryLane)
    {
        buildEntryWindows(layout);
    }
    else
    {
        buildExitWindows(layout);
    }
    //设备查看状态
    QState * devShowState = new MtcLaneState(&m_machine, m_devTable);
    //初始化状态
    QState * initState = new MtcLaneState(&m_machine, m_pFormLoadParam);
    //参数加载成功状态
    QState * loadSuccess = new MtcLaneState(&m_machine,m_pFormMsg);
    //加载参数成功时页面显示设置
    loadSuccess->assignProperty(m_pFormMsg, "message", tr("请放置身份卡\n按『上/下班』键登录"));
    loadSuccess->assignProperty(m_pFormMsg, "title", tr(""));
    //选择程序操作:退出程序、重启程序、关闭计算机、重启计算机
    QState *exitState = new MtcLaneState(&m_machine,m_pTableWidget);
    //工班选择状态
    QState * shiftState = new MtcLaneState(&m_machine, m_pTableWidget);
    //选择票号修改状态
    QState *IdTKstate=new MtcLaneState(&m_machine,m_pTableWidget);
    //修改票号页面状态
    QState *IdInform=new MtcLaneState(&m_machine,getInformWidget());
    //确认票号状态
    QState *confirmInvState = new MtcLaneState(&m_machine, m_pFormMsg);
    //正常上班状态
    QState* ordState = new MtcLaneState(&m_machine, m_pOrdWidget);
    //提示切换雨棚灯状态
    QState * turnOnLightState = new MtcLaneState(&m_machine, m_pFormMsg);

    turnOnLightState->assignProperty(m_pFormMsg, "message", tr("请按【雨棚开关】键\n将雨棚灯切换至绿灯"));
    //设备状态确认->初始化状态
    devShowState->addTransition(new TranConfirmDev(initState));
    //初始化状态->参数加载成功状态
    LoadParamTransition *tLoadParam = new LoadParamTransition(initState,SIGNAL(entered()));
    tLoadParam->setTargetState(loadSuccess);
    initState->addTransition(tLoadParam);
    //加载成功状态->选择程序退出状态
    TranExitApp *exitTrans = new TranExitApp(exitState);
    loadSuccess->addTransition(exitTrans);
    //加载成功状态->闯关tran->加载成功状态
    addRushTranLogOut(loadSuccess);
    //选择程序退出状态->执行退出操作
    TranSelectExitApp *exitAppTrans = new TranSelectExitApp(loadSuccess);
    exitState->addTransition(exitAppTrans);
    //退出程序操作,返回初始化界面
    TranQuitSelect *quitselTrans = new TranQuitSelect(loadSuccess);
    exitState->addTransition(quitselTrans);
    //选择工班时出现闯关
    addRushTranLogOut(shiftState);


    //上班后出现闯关
    QHistoryState* rushState = new QHistoryState(ordState);
    TranRushLogin* tranLogin = new TranRushLogin(getDeviceFactory()->getIOBoard(), SIGNAL(InputChanged(quint32,quint8)));
    tranLogin->setTargetState(rushState);
    ordState->addTransition(tranLogin);
    //上班后收费员按F12键,切换菜单
    QHistoryState* showLogState = new QHistoryState(ordState);
    TranChangeVpr* tranVpr = new TranChangeVpr(showLogState);
    ordState->addTransition(tranVpr);

    //建立上班后子状态机
    m_pOrdWidget->initStateMachine(ordState, loadSuccess);
    //加载参数成功->用户验证身份
    TranShift *tShowPassword = new TranShift(shiftState);
    loadSuccess->addTransition(tShowPassword);

    //打开雨棚灯状态闯关
    addRushTranLogOut(turnOnLightState);
    //打开雨棚灯状态->正常上班状态
    TranTurnOnCanLight* tOrd = new TranTurnOnCanLight(ordState);
    turnOnLightState->addTransition(tOrd);

    //确认卡盒卡ID操作,模拟实现
    TranCardBox *tGotoLight = new TranCardBox(turnOnLightState);

    //入口没有票号处理
    if(getLaneInfo()->isEntryLane())
    {
        shiftState->addTransition(new TranEntryConfirmShift(turnOnLightState));
    }
    else
    {
        //下班时票号操作
        QState *logOutIdState=new MtcLaneState(&m_machine,m_pTableWidget);
        QState *logOutInform=new MtcLaneState(&m_machine,getInformWidget());
        loadSuccess->addTransition(new TranShowInvoiceMenu(logOutIdState));
        logOutIdState->addTransition(new TranModifyInvoice(logOutInform));
        logOutIdState->addTransition(new TranChangeUpInvoice(logOutInform));
        logOutInform->addTransition(new TranFinInvoice(loadSuccess));
        logOutIdState->addTransition(new TranRtInvConfirm(loadSuccess));
        logOutInform->addTransition(new TranRtInvConfirm(loadSuccess));

        //确认班次,用户从班次中选择一个班次上班,班次记录到LaneInfo
        TranConfirmShift *tConfirm = new TranConfirmShift(confirmInvState);
        shiftState->addTransition(tConfirm);
        //修改票号时出现闯关
        addRushTranLogOut(IdTKstate);
        //修改票号时出现闯关
        addRushTranLogOut(IdInform);
        //确认票号状态闯关
        addRushTranLogOut(confirmInvState);
        //选择票号处理菜单,包括票据换上、修改票号
        TranShowInvoiceMenu * tMessIDTick = new TranShowInvoiceMenu(IdTKstate);
        confirmInvState->addTransition(tMessIDTick);
        //显示插入票号页面
        TranChangeUpInvoice *tInsertTK=new TranChangeUpInvoice(IdInform);//跳转到票号输入页面
        IdTKstate->addTransition(tInsertTK);
        //显示修改票号页面
        TranModifyInvoice *tInformTK=new TranModifyInvoice(IdInform);
        IdTKstate->addTransition(tInformTK);
        //完成票号操作,跳转票号确认状态
        TranFinInvoice *tShowInform=new TranFinInvoice(confirmInvState); //从页面输入和修改跳转到票号页面
        IdInform->addTransition(tShowInform);
        //输入修改票号跳转
        TranRtInvConfirm *treturntable=new TranRtInvConfirm(confirmInvState);
        IdInform->addTransition(treturntable);
        IdTKstate->addTransition(new TranRtInvConfirm(confirmInvState));
        //显示确认卡盒卡界面
        confirmInvState->addTransition(tGotoLight);
    }
    //返回等待上班状态
    shiftState->addTransition(new SpecialKeySignalTransition(loadSuccess, KeyEsc, KC_Func));
    confirmInvState->addTransition(new SpecialKeySignalTransition(loadSuccess, KeyEsc, KC_Func));
    //跳转到功能页面
    m_machine.setInitialState(devShowState);
    m_machine.start();
    //上班前功能界面
    loadSuccess->addTransition(new TranLogOutFunc(loadSuccess));
    QTimer::singleShot(1000, this, SLOT(beginInitState()));
}
Ejemplo n.º 12
0
void SketchToolButton::enterEvent(QEvent *event) {
    QToolButton::enterEvent(event);
    emit entered();
}
void DWidget::enterEvent( QEvent* e ) {
    emit entered();
    QWidget::enterEvent(e);
}
Ejemplo n.º 14
0
Menu::Menu(QWidget *parent):
	QWidget(parent)
{
	setObjectName("Menu");
	isStay=isPoped=false;
	Utils::setGround(this,Qt::white);
	fileL=new QLineEdit(this);
	danmL=new QLineEdit(this);
	sechL=new QLineEdit(this);
	fileL->installEventFilter(this);
	danmL->installEventFilter(this);
	sechL->installEventFilter(this);
	fileL->setReadOnly(true);
	fileL->setPlaceholderText(tr("choose a local media"));
	danmL->setPlaceholderText(tr("input av/ac number"));
	sechL->setPlaceholderText(tr("search danmaku online"));
	fileL->setGeometry(QRect(10,25, 120,25));
	danmL->setGeometry(QRect(10,65, 120,25));
	sechL->setGeometry(QRect(10,105,120,25));
	connect(danmL,&QLineEdit::textEdited,[this](QString text){
		QRegularExpression regexp("(av|ac|dd)((\\d+)([#_])?(\\d+)?)?|[ad]");
		regexp.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
		auto iter=regexp.globalMatch(text);
		QString match;
		while(iter.hasNext()){
			match=iter.next().captured();
		}
		danmL->setText(match.toLower().replace('_','#'));
	});
	danmC=new QCompleter(new LoadModelWapper(Load::instance()->getModel(),tr("Load All")),this);
	danmC->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
	danmC->setCaseSensitivity(Qt::CaseInsensitive);
	danmC->setWidget(danmL);
	QAbstractItemView *popup=danmC->popup();
	popup->setMouseTracking(true);
	connect(popup,SIGNAL(entered(QModelIndex)),popup,SLOT(setCurrentIndex(QModelIndex)));
	connect<void (QCompleter::*)(const QModelIndex &)>(danmC,&QCompleter::activated,[this](const QModelIndex &index){
		QVariant v=index.data(Load::UrlRole);
		if(!v.isNull()&&!v.toUrl().isValid()){
			Load::instance()->loadDanmaku();
		}
		else{
			Load::instance()->loadDanmaku(index);
		}
	});
	fileB=new QPushButton(this);
	sechB=new QPushButton(this);
	danmB=new QPushButton(this);
	fileB->setGeometry(QRect(135,25, 55,25));
	danmB->setGeometry(QRect(135,65, 55,25));
	sechB->setGeometry(QRect(135,105,55,25));
	fileB->setText(tr("Open"));
	danmB->setText(tr("Load"));
	sechB->setText(tr("Search"));
	fileA=new QAction(tr("Open File"),this);
	fileA->setObjectName("File");
	fileA->setShortcut(Config::getValue("/Shortcut/File",QString()));
	danmA=new QAction(tr("Load Danmaku"),this);
	danmA->setObjectName("Danm");
	danmA->setShortcut(Config::getValue("/Shortcut/Danm",QString()));
	sechA=new QAction(tr("Search Danmaku"),this);
	sechA->setObjectName("Sech");
	sechA->setShortcut(Config::getValue("/Shortcut/Sech",QString()));
	connect(fileA,&QAction::triggered,[this](){
		QString _file=QFileDialog::getOpenFileName(Local::mainWidget(),
												   tr("Open File"),
												   Utils::defaultPath(),
												   tr("Media files (%1);;All files (*.*)").arg(Utils::getSuffix(Utils::Video|Utils::Audio,"*.%1").join(' ')));
		if(!_file.isEmpty()){
			APlayer::instance()->setMedia(_file);
		}
	});
	connect(danmA,&QAction::triggered,[this](){
		if(Config::getValue("/Danmaku/Local",false)){
			QString _file=QFileDialog::getOpenFileName(Local::mainWidget(),
													   tr("Open File"),
													   Utils::defaultPath(),
													   tr("Danmaku files (%1);;All files (*.*)").arg(Utils::getSuffix(Utils::Danmaku,"*.%1").join(' ')));
			if(!_file.isEmpty()){
				Load::instance()->loadDanmaku(_file);
			}
		}
		else{
			if(danmL->text().isEmpty()){
				pop();
				isStay=true;
				danmL->setFocus();
			}
			else{
				Load::instance()->loadDanmaku(danmL->text());
			}
		}
	});
	connect(sechA,&QAction::triggered,[this](){
		Search searchBox(Local::mainWidget());
		sechL->setText(sechL->text().simplified());
		if(!sechL->text().isEmpty()){
			searchBox.setKey(sechL->text());
		}
		if(searchBox.exec()) {
			Load::instance()->loadDanmaku(searchBox.getAid());
		}
		sechL->setText(searchBox.getKey());
	});
	addAction(fileA);
	addAction(danmA);
	addAction(sechA);
	connect(fileB,&QPushButton::clicked,fileA,&QAction::trigger);
	connect(danmB,&QPushButton::clicked,danmA,&QAction::trigger);
	connect(sechB,&QPushButton::clicked,sechA,&QAction::trigger);
	connect(danmL,&QLineEdit::returnPressed,danmA,&QAction::trigger);
	connect(sechL,&QLineEdit::returnPressed,sechA,&QAction::trigger);
	alphaT=new QLabel(this);
	alphaT->setGeometry(QRect(10,145,100,25));
	alphaT->setText(tr("Danmaku Alpha"));
	alphaS=new QSlider(this);
	alphaS->setOrientation(Qt::Horizontal);
	alphaS->setGeometry(QRect(10,170,180,15));
	alphaS->setRange(0,100);
	alphaS->setValue(Config::getValue("/Danmaku/Alpha",100));
	connect(alphaS,&QSlider::valueChanged,[this](int _alpha){
		Config::setValue("/Danmaku/Alpha",_alpha);
		QPoint p;
		p.setX(QCursor::pos().x());
		p.setY(alphaS->mapToGlobal(alphaS->rect().center()).y());
		QToolTip::showText(p,QString::number(_alpha));
	});
	powerT=new QLabel(this);
	powerT->setGeometry(QRect(10,205,100,20));
	powerT->setText(tr("Danmaku Power"));
	powerL=new QLineEdit(this);
	powerL->setGeometry(QRect(160,205,30,20));
	powerL->setValidator(new QRegularExpressionValidator(QRegularExpression("^\\w*$"),powerL));
	connect(powerL,&QLineEdit::editingFinished,[this](){
		Render::instance()->setRefreshRate(powerL->text().toInt());
	});
	connect(Render::instance(),&Render::refreshRateChanged,[this](int fps){
		if(fps==0){
			powerL->clear();
		}
		else{
			powerL->setText(QString::number(fps));
		}
	});
	localT=new QLabel(this);
	localT->setGeometry(QRect(10,240,100,25));
	localT->setText(tr("Local Danmaku"));
	localC=new QCheckBox(this);
	localC->setGeometry(QRect(168,240,25,25));
	connect(localC,&QCheckBox::stateChanged,[this](int state){
		bool local=state==Qt::Checked;
		danmL->setText("");
		sechL->setText("");
		danmL->setReadOnly(local);
		sechL->setEnabled(!local);
		sechB->setEnabled(!local);
		sechA->setEnabled(!local);
		danmB->setText(local?tr("Open"):tr("Load"));
		danmL->setPlaceholderText(local?tr("choose a local danmaku"):tr("input av/ac number"));
		for(const Record &r:Danmaku::instance()->getPool()){
			if(QUrl(r.source).isLocalFile()==local){
				danmL->setText(r.string);
			}
		}
		danmL->setCursorPosition(0);
		Config::setValue("/Danmaku/Local",local);
	});
	localC->setChecked(Config::getValue("/Danmaku/Local",false));
	subT=new QLabel(this);
	subT->setGeometry(QRect(10,275,100,25));
	subT->setText(tr("Protect Sub"));
	subC=new QCheckBox(this);
	subC->setGeometry(QRect(168,275,25,25));
	subC->setChecked(Config::getValue("/Danmaku/Protect",false));
	connect(subC,&QCheckBox::stateChanged,[this](int state){
		Config::setValue("/Danmaku/Protect",state==Qt::Checked);
	});
	loopT=new QLabel(this);
	loopT->setGeometry(QRect(10,310,100,25));
	loopT->setText(tr("Loop Playback"));
	loopC=new QCheckBox(this);
	loopC->setGeometry(QRect(168,310,25,25));
	loopC->setChecked(Config::getValue("/Playing/Loop",false));
	connect(loopC,&QCheckBox::stateChanged,[this](int state){
		Config::setValue("/Playing/Loop",state==Qt::Checked);
	});

	animation=new QPropertyAnimation(this,"pos",this);
	animation->setDuration(200);
	animation->setEasingCurve(QEasingCurve::OutCubic);
	connect(animation,&QPropertyAnimation::finished,[this](){
		if(!isPoped){
			hide();
		}
	});
	connect(Load::instance(),&Load::stateChanged,[this](int state){
		switch(state){
		case Load::Page:
			isStay=1;
			break;
		case Load::Part:
			if(isPoped&&animation->state()==QAbstractAnimation::Stopped){
				danmC->complete();
				danmC->popup()->setCurrentIndex(Load::instance()->getModel()->index(0,0));
			}
		case Load::File:
			localC->setChecked(QUrl(Load::instance()->getUrl()).isLocalFile());
			danmL->setText(Load::instance()->getStr());
			danmL->setCursorPosition(0);
		case Load::Code:
		case Load::None:
			isStay=0;
			break;
		default:
			QMessageBox::warning(Local::mainWidget(),tr("Network Error"),tr("Network error occurred, error code: %1").arg(state));
			isStay=0;
			break;
		}
	});
	connect(APlayer::instance(),&APlayer::mediaChanged,[this](QString _file){
		fileL->setText(QFileInfo(_file).fileName());
		fileL->setCursorPosition(0);
	});
	hide();
}
Ejemplo n.º 15
0
Animator::Animator(AbstractItemView *view)
    : QObject(view)
{
    connect(view, SIGNAL(entered(QModelIndex)), SLOT(entered(QModelIndex)));
    connect(view, SIGNAL(left(QModelIndex)), SLOT(left(QModelIndex)));
}
Ejemplo n.º 16
0
    void BfVM::initializeStateMachine() {
        // see the state chart for a clearer picture of what's going on with the states
        /////////////////////////////////////////////////////////////////////////////////////
        //// STATE NAME INITIALIZATIONS
        ///////////////////////////////
        //: Please don't translate the state names in case I forget to remove the tr()s
        m_stateGroup->setProperty("statename", QVariant::fromValue(tr("main state group")));
        m_runGroup->setProperty("statename", QVariant::fromValue(tr("run state group")));
        m_emptySt->setProperty("statename", QVariant::fromValue(tr("empty VM")));
        m_steppingSt->setProperty("statename", QVariant::fromValue(tr("stepping")));
        m_runningSt->setProperty("statename", QVariant::fromValue(tr("running")));
        m_clearSt->setProperty("statename", QVariant::fromValue(tr("clearing")));
        m_initializedSt->setProperty("statename", QVariant::fromValue(tr("initialized")));
        m_finishedSt->setProperty("statename", QVariant::fromValue(tr("finished")));
        m_waitingForInpSt->setProperty("statename", QVariant::fromValue(
                tr("waiting for input")));
        m_breakpointSt->setProperty("statename", QVariant::fromValue(tr("breakpoint")));
        m_runHistorySt->setProperty("statename", QVariant::fromValue(
                tr("run history state")));


        /////////////////////////////////////////////////////////////////////////////////////
        //// EMPTY STATE
        ////////////////
        /*
         Only transition away from the empty state when the VM is initialized, ie. a
         Brainfuck program is loaded succesfully
          */
        InitedEventTransition *iet = new InitedEventTransition();
        iet->setTargetState(m_initializedSt);
        m_emptySt->addTransition(iet);


        /////////////////////////////////////////////////////////////////////////////////////
        //// INITIALIZED STATE
        //////////////////////
        // reset the VM when the initialized state is entered
        connect(m_initializedSt, SIGNAL(entered()), this, SLOT(reset()));

        // emit inited() when entering the initialized state so the GUI knows we're ready
        connect(m_initializedSt, SIGNAL(entered()), this, SIGNAL(inited()));

        m_initializedSt->addTransition(this, SIGNAL(toggleRunSig()), m_runningSt);
        m_initializedSt->addTransition(this, SIGNAL(stepSig()), m_steppingSt);


        /////////////////////////////////////////////////////////////////////////////////////
        //// STEPPING STATE
        ///////////////////
        // run step() whenever this state is entered
        connect(m_steppingSt, SIGNAL(entered()), this, SLOT(step()));
        // just loops back to itself when receiving additional stepSig()s
        m_steppingSt->addTransition(this, SIGNAL(stepSig()), m_steppingSt);
        // Transition to running if toggleRunSig() received
        m_steppingSt->addTransition(this, SIGNAL(toggleRunSig()), m_runningSt);


        /////////////////////////////////////////////////////////////////////////////////////
        //// RUNNING STATE
        //////////////////
        /* Entering or exiting this state controls whether the run timer is running. */
        connect(m_runningSt, SIGNAL(entered()), this, SLOT(go()));
        connect(m_runningSt, SIGNAL(exited()), this, SLOT(stop()));
        m_runningSt->addTransition(this, SIGNAL(stepSig()), m_steppingSt);
        m_runningSt->addTransition(this, SIGNAL(toggleRunSig()), m_steppingSt);


        /////////////////////////////////////////////////////////////////////////////////////
        //// FINISHED STATE
        ///////////////////
        /* the only way to get out of the finished state is to reset or clear the VM.
           finish() is emitted when this state is entered so that the GUI can disable
           actions and whatnot */

        connect(m_finishedSt, SIGNAL(entered()), this, SIGNAL(finish()));
        m_finishedSt->addTransition(this, SIGNAL(resetSig()), m_initializedSt);

        /////////////////////////////////////////////////////////////////////////////////////
        //// WAITING FOR INPUT STATE
        ////////////////////////////

        // signal the GUI that the VM needs input
        connect(m_waitingForInpSt, SIGNAL(entered()), this, SIGNAL(needInput()));

        /* send the same signal when exiting the state, so the GUI can toggle its
           input notification */
        connect(m_waitingForInpSt, SIGNAL(exited()), this, SIGNAL(needInput()));

        /* To get out of the wait state we need either input or a reset/clear.
           Clears are handled by the top state group, but we need to catch the reset
           signal ourselves.
           Transitions back to the correct state of the running state group by using
           m_runGroup's history state */
        InpBufFilledTransition *ibft = new InpBufFilledTransition();
        ibft->setTargetState(m_runHistorySt);
        m_waitingForInpSt->addTransition(ibft);
        m_waitingForInpSt->addTransition(this, SIGNAL(resetted()), m_initializedSt);


        /////////////////////////////////////////////////////////////////////////////////////
        //// BREAKPOINT STATE
        /////////////////////
        connect(m_breakpointSt, SIGNAL(entered()), this, SLOT(breakPtTest()));
        m_breakpointSt->addTransition(this, SIGNAL(stepSig()), m_steppingSt);
        m_breakpointSt->addTransition(this, SIGNAL(toggleRunSig()), m_runningSt);


        /////////////////////////////////////////////////////////////////////////////////////
        //// CLEARING STATE
        ///////////////////
        connect(m_clearSt, SIGNAL(entered()), this, SLOT(clear()));
        m_clearSt->addTransition(m_emptySt);

        /////////////////////////////////////////////////////////////////////////////////////
        //// TOP STATE GROUP
        ////////////////////
        m_stateGroup->setInitialState(m_emptySt);  // start in the empty state
        // if the clearSig() signal is sent when in any state, go to the clear state
        m_stateGroup->addTransition(this, SIGNAL(clearSig()), m_clearSt);


        /////////////////////////////////////////////////////////////////////////////////////
        //// RUN STATE GROUP
        ////////////////////
        m_runGroup->setInitialState(m_steppingSt); /* the run group always starts in the
                                                      stepping state*/

        /* If the VM is reset while running, go back to the initialized state */
        m_runGroup->addTransition(this, SIGNAL(resetSig()), m_initializedSt);

        // Stop the VM when exiting the run group
        connect(m_runGroup, SIGNAL(exited()), this, SLOT(stop()));

        /* handle an EndEvent in any run state by transitioning to the finished state */
        EndEventTransition *eet = new EndEventTransition();
        eet->setTargetState(m_finishedSt);
        m_runGroup->addTransition(eet);

        /* if the input buffer is empty and the VM needs input, go into the waiting
           for input state */
        InpBufEmptyTransition *ibet = new InpBufEmptyTransition();
        ibet->setTargetState(m_waitingForInpSt);
        m_runGroup->addTransition(ibet);

        // go to the breakpoint state if a breakpoint was reached
        BreakpointTransition *bpt = new BreakpointTransition();
        bpt->setTargetState(m_breakpointSt);
        m_runGroup->addTransition(bpt);



        /////////////////////////////////////////////////////////////////////////////////////
        //// STATE MACHINE INITIALIZATION
        /////////////////////////////////

        m_stateMachine->addState(m_stateGroup);
        m_stateMachine->setInitialState(m_stateGroup);
    }
Ejemplo n.º 17
0
FctnDialog::FctnDialog(stringFactory *fac, QWidget *parent) :
    QDialog(parent)
{
    setWindowTitle("Mace");
    setWindowIcon(QIcon("icons/MaceLogo.png"));

    vbox = new QVBoxLayout;
    funcVars = new QVBoxLayout;
    hbox = new QHBoxLayout;
    grid = new QGridLayout;
    radioGrid = new QGridLayout;

    radioBox = new QVBoxLayout;
    mlay = new QHBoxLayout;

    pBox = new QSpinBox;
    pBox2 = new QSpinBox;

    pdf = new QRadioButton("pdf (probability density function)");
    cdf = new QRadioButton("cdf (cumulative distribution function)");
    hazard = new QRadioButton("haz (hazard function)");
    quantile = new QRadioButton("qua (quantile)");
    pdf->setChecked(true);

    kurt = new QRadioButton("kurtosis");
    kurtex = new QRadioButton("kurtosis excess");
    mean = new QRadioButton("mean");
    median = new QRadioButton("median");
    mode = new QRadioButton("mode");
    skewness = new QRadioButton("skewness");
    standdev = new QRadioButton("standard deviation");
    variance = new QRadioButton("variance");
    mean->setChecked(true);

    tab = new QTabWidget;

    statFunc = new QGroupBox("");
    statVars = new QGroupBox("");

    help = new QPushButton("Help");
    but = new QPushButton("Ok");
    but2 = new QPushButton("No");

    line1 = new MaceLineEdit;
    line2 = new MaceLineEdit;
    line3 = new MaceLineEdit;
    line4 = new MaceLineEdit;

    label1 = new QLabel;
    label2 = new QLabel;
    label3 = new QLabel;
    label4 = new QLabel;

    pLabel = new QLabel;
    pLabel2 = new QLabel;

    grid->addWidget(label1,0,0,1,1);
    grid->addWidget(line1,0,1,1,1);
    grid->addWidget(label2,1,0,1,1);
    grid->addWidget(line2,1,1,1,1);
    grid->addWidget(label3,2,0,1,1);
    grid->addWidget(line3,2,1,1,1);
    grid->addWidget(label4,3,0,1,1);
    grid->addWidget(line4,3,1,1,1);
    grid->addWidget(pLabel,4,0,1,1);
    grid->addWidget(pBox,4,1,1,1);
    grid->addWidget(pLabel2,5,0,1,1);
    grid->addWidget(pBox2,5,1,1,1);

    info = new QTextEdit;
    vertic = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);

    factory = fac;

    label = new QLabel(labelStr);

    vbox->addWidget(label);

    vbox->addLayout(grid);

    info->setMaximumSize(237,120);
    info->setReadOnly(true);
    info->setHidden(true);

    vbox->addWidget(info);
    vbox->addItem(vertic);

    hbox->addWidget(but);
    hbox->addWidget(but2);
    hbox->addWidget(help);
    vbox->addLayout(hbox);

    radioBox->addWidget(pdf);
    radioBox->addWidget(cdf);
    radioBox->addWidget(hazard);
    radioBox->addWidget(quantile);
    statFunc->setLayout(radioBox);

    radioGrid->addWidget(mean,0,0,1,1);
    radioGrid->addWidget(skewness,0,1,1,1);
    radioGrid->addWidget(median,1,0,1,1);
    radioGrid->addWidget(standdev,1,1,1,1);
    radioGrid->addWidget(mode,2,0,1,1);
    radioGrid->addWidget(variance,2,1,1,1);
    radioGrid->addWidget(kurt,3,0,1,1);
    radioGrid->addWidget(kurtex,3,1,1,1);
    statVars->setLayout(radioGrid);

    mlay->addLayout(vbox);

    statFunc->setFlat(true);
    statVars->setFlat(true);

    tab->addTab(statFunc,"Functions");
    tab->addTab(statVars,"Properties");

    mlay->addWidget(tab);
    setLayout(mlay);

    quantile->setHidden(true);
    kurt->setHidden(true);
    kurtex->setHidden(true);

    this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);

    QWidget::connect(but2,SIGNAL(clicked()),this,SLOT(close()));
    QWidget::connect(but,SIGNAL(clicked()),this,SLOT(agree()));
    QWidget::connect(help,SIGNAL(clicked()),this,SLOT(show_info()));
    QWidget::connect(tab,SIGNAL(currentChanged(int)),this,SLOT(statSwitch(int)));

    QObject::connect(line2,SIGNAL(entered()),this,SLOT(agree()));
    QObject::connect(line1,SIGNAL(entered()),this,SLOT(nextLine()));
}
Ejemplo n.º 18
0
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),contactModel(parent)
{

  QWidget *centralWidget = new QWidget(this);
  setCentralWidget(centralWidget);
  createActions();

  createMenus();
  const QString mainQmlApp = QLatin1String("qrc:///qml/main.qml");
  view =new QDeclarativeView(this);
  view->rootContext()->setContextProperty("Main", this);
  view->rootContext()->setContextProperty("contactModel", &contactModel);

  view->setSource(QUrl(mainQmlApp));
  // view->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
  view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
  view->engine()->addImportPath(QString("/opt/qtm12/imports"));
  view->engine()->addPluginPath(QString("/opt/qtm12/plugins"));

  /*test*/

  //  QSharedPointer<Contact> co = QSharedPointer<Contact>(new Contact("piter88", "Petja"));
  //  co->setLastDataMark(QSharedPointer<DataMark>(new DataMark(0, 59.938994,30.315857, "QString label",
  //                                                                 "QString description", "QString url", QDateTime::currentDateTime())));
  //  contactModel.addContact(co);

  //  QSharedPointer<Contact> con = QSharedPointer<Contact>(new Contact("marja", "Mother"));
  //  con->setLastDataMark(QSharedPointer<DataMark>(new DataMark(0,59.925657,30.296165, "QString label",
  //                                                                 "QString description", "QString url", QDateTime::currentDateTime().addSecs(-3800))));
  //  contactModel.addContact(con);

  //  QSharedPointer<Contact> contact = QSharedPointer<Contact>(new Contact("vred", "Vasja"));
  //  contact->setLastDataMark(QSharedPointer<DataMark>(new DataMark(0,59.945152,31.371842, "QString label",
  //                                                                 "QString description", "QString url", QDateTime::currentDateTime().addSecs(-9600))));
  //  contactModel.addContact(contact);
  //  QSharedPointer<Contact> cont= QSharedPointer<Contact>(new Contact("quen", "daughter"));
  //  cont->setLastDataMark(QSharedPointer<DataMark>(new DataMark(0,59.94376,30.368825, "QString label",
  //                                                                 "QString description", "QString url", QDateTime::currentDateTime())));
  //  contactModel.addContact(cont);

  /*test*/

  client =new Client(&contactModel, this);
  //   view->rootContext()->setContextProperty("Client", client);

  //qmlRegisterType<ContactModel>();

  QObject* rootObject = dynamic_cast<QObject*>(view->rootObject());
  QObject::connect(authAction, SIGNAL(triggered()), rootObject, SLOT(showLoginView()));
  QObject::connect(client, SIGNAL(error(QVariant)), rootObject, SLOT(incorrect(QVariant)));
  QObject::connect(client, SIGNAL(authentificated(QVariant)), rootObject, SLOT(entered(QVariant)));

  QObject::connect(trackingAction, SIGNAL(triggered()), rootObject, SLOT(showTrackSettings()));
  connect(client, SIGNAL(registrationRequestConfirm()),rootObject,SLOT(showNotify()));

  #if defined(Q_WS_MAEMO_5)
  view->setGeometry(QRect(0,0,800,480));
  view->showFullScreen();
  #elif defined(Q_WS_S60)
  view->setGeometry(QRect(0,0,640,360));
  view->showFullScreen();
  #else
  view->setGeometry(QRect(100,100,800, 480));
  view->show();
  #endif
  QVBoxLayout *mainLayout = new QVBoxLayout();
  mainLayout->addWidget(view);
  centralWidget->setLayout(mainLayout);

}
Ejemplo n.º 19
0
TimeWidget::TimeWidget(JointModel *model, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TimeWidget),
    m_model(model),
    m_delegate(new JointDelegate(this)),
    m_leftProxy(new JointProxyModel(model, this)),
    m_rightProxy(new JointProxyModel(model, this))
{
    ui->setupUi(this);

    QTreeView *namesView = ui->namesView;
    QTreeView *timeLineView = ui->timeLineView;

    // Sync views
    connect(namesView->verticalScrollBar(), SIGNAL(valueChanged(int)), timeLineView->verticalScrollBar(), SLOT(setValue(int)));
    connect(timeLineView->verticalScrollBar(), SIGNAL(valueChanged(int)), namesView->verticalScrollBar(), SLOT(setValue(int)));
    connect(namesView, SIGNAL(expanded(QModelIndex)), SLOT(onExpanded(QModelIndex)));
    connect(namesView, SIGNAL(collapsed(QModelIndex)), SLOT(onCollapsed(QModelIndex)));

    // Configure names view
    m_leftProxy->showAnims(false);

    namesView->setModel(m_leftProxy);
//    namesView->setModel(model);
    namesView->setItemDelegate(m_delegate);
    namesView->setHeader(new JointHeaderView(false));
    namesView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    namesView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

    // Configure time line view
    JointHeaderView *header = new JointHeaderView(true);

    m_rightProxy->showVisibleColumn(false);
    m_rightProxy->showAnim(0);

    timeLineView->setModel(m_rightProxy);
    timeLineView->setItemDelegate(m_delegate);
    timeLineView->setHeader(header);
    timeLineView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    timeLineView->hideColumn(JointModel::NameColumn);
    timeLineView->setAutoScroll(false);
    timeLineView->setMouseTracking(true);
    timeLineView->setItemsExpandable(false);

    connect(timeLineView, SIGNAL(entered(QModelIndex)), SLOT(openEditor(QModelIndex)));
    connect(model->animModel(), SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(resetEditor()));
    connect(model->animModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), SLOT(resetEditor()));
    connect(model->animModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(resetEditor()));

    connect(m_delegate, SIGNAL(currentFrameChanged(int)), header, SLOT(setCurrentFrame(int)));
    connect(header, SIGNAL(currentFrameChanged(int)), m_delegate, SLOT(setCurrentFrame(int)));
    connect(header, SIGNAL(currentFrameChanged(int)), timeLineView->viewport(), SLOT(update()));
    connect(header, SIGNAL(currentFrameChanged(int)), SIGNAL(currentFrameChanged(int)));

    // Configure push buttons
    connect(ui->frameCount, SIGNAL(pressed()), SLOT(showFrameCountDialog()));
    connect(ui->fps, SIGNAL(pressed()), SLOT(showFpsDialog()));

    // Initialize
    setCurrentAnim(-1);
}