void UserInfoTask::requestInfoFor( const QString& contact, unsigned int types )
{
	Oscar::DWORD seq = client()->snacSequence();
	kDebug(OSCAR_RAW_DEBUG) << "setting sequence " << seq << " for contact " << contact;
	m_contactSequenceMap[seq] = contact;
	m_typesSequenceMap[seq] = types;
	m_seq = seq;
	onGo();
}
importerWindow::importerWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::importerWindow),
    impa(false, "it", "ru", this)
{
    ui->setupUi(this);

    connect (ui->pushButton, SIGNAL(clicked()), this,  SLOT(onGo()));
    connect (&impa, SIGNAL(wordTranslated(QString)), this, SLOT(weVeGotTranslation(QString)), Qt::QueuedConnection);
}
/** Base on the network timer set current world count up ticks to tick_now.
 */
void WorldStatus::endLiveJoinWorld(int ticks_now)
{
    m_live_join_ticks = ticks_now;
    m_live_join_world = false;
    m_auxiliary_ticks = 0;
    m_phase = MUSIC_PHASE;
    m_race_ticks = m_live_join_ticks + stk_config->time2Ticks(
        stk_config->m_music_credit_time);
    onGo();
    startEngines();
    music_manager->startMusic();
    setTicksForRewind(m_live_join_ticks);
}   // endLiveJoinWorld
Beispiel #4
0
void ChessWidget::onMoveFound()
{
  enableActions(true);
  update();

  if ( autoPlay_ )
  {
    if ( goingToClose_ )
      return;

    onGo();
  }
}
Beispiel #5
0
void ChessWidget::mouseReleaseEvent(QMouseEvent * e)
{
  curPt_ = e->pos();

  if ( e->button() == Qt::LeftButton )
  {
    if ( cpos_.makeMovement(curPt_) )
    {
      changed_ = true;
      movesCount_ = cpos_.movesCount();
      onGo();
    }
  }

  update();
}
void	MainWindowImpl::setSlots(void) {
	connect( actionNew,		SIGNAL( triggered() ),	this, SLOT( onActionNew() ) );
	connect( actionOpen,		SIGNAL( triggered() ),	this, SLOT( onActionOpen() ) );
	connect( actionSaveAs,		SIGNAL( triggered() ),	this, SLOT( onActionSaveAs() ) );
	connect( actionProperties,	SIGNAL( triggered() ),	this, SLOT( onActionProperties() ) );
	connect( actionExit,		SIGNAL( triggered() ),	this, SLOT( onActionExit() ) );
	connect( actionCut,		SIGNAL( triggered() ),	this, SLOT( onActionCut() ) );
	connect( actionCopy,		SIGNAL( triggered() ),	this, SLOT( onActionCopy() ) );
	connect( actionPaste,		SIGNAL( triggered() ),	this, SLOT( onActionPaste() ) );
	connect( actionSelectAll,	SIGNAL( triggered() ),	this, SLOT( onActionSelectAll() ) );
	connect( actionDeselect,	SIGNAL( triggered() ),	this, SLOT( onActionDeselect() ) );
	connect( actionAddFile,		SIGNAL( triggered() ),	this, SLOT( onActionAddFile() ) );
	connect( actionAddDirectory,	SIGNAL( triggered() ),	this, SLOT( onActionAddDirectory() ) );
	connect( actionDelete,		SIGNAL( triggered() ),	this, SLOT( onActionDelete() ) );
	connect( actionAbout,		SIGNAL( triggered() ),	this, SLOT( onActionAbout() ) );
	connect( actionAboutQt,		SIGNAL( triggered() ),	this, SLOT( onActionAboutQt() ) );
	connect( treeView->selectionModel(),	SIGNAL( currentChanged(const QModelIndex &, const QModelIndex &) ),	this, SLOT( onItemSelected(const QModelIndex &, const QModelIndex &) ) );
	connect( pbGo,			SIGNAL( clicked() ),	this, SLOT( onGo() ) );
}
Beispiel #7
0
/** Updates all status information, called once per frame.
 *  \param dt Duration of time step.
 */
void WorldStatus::update(const float dt)
{
    switch(m_phase)
    {
        // Note: setup phase must be a separate phase, since the race_manager
        // checks the phase when updating the camera: in the very first time
        // step dt is large (it includes loading time), so the camera might
        // tilt way too much. A separate setup phase for the first frame
        // simplifies this handling
        case SETUP_PHASE:
            m_auxiliary_timer = 0.0f;  
            m_phase = TRACK_INTRO_PHASE;
            if (UserConfigParams::m_music && m_play_racestart_sounds)
            {
                m_track_intro_sound->play();
            }
            return;
        case TRACK_INTRO_PHASE:
            m_auxiliary_timer += dt;
            // Work around a bug that occurred on linux once:
            // the sfx_manager kept on reporting that it is playing,
            // while it was not - so STK would never reach the ready
            // ... phase. Since the sound effect is about 3 seconds
            // long, we use the aux timer to force the next phase
            // after 3.5 seconds.
            if(m_track_intro_sound->getStatus()==SFXManager::SFX_PLAYING
	            && m_auxiliary_timer<3.5f)
                return;
            m_auxiliary_timer = 0.0f;
            if (m_play_racestart_sounds) m_prestart_sound->play();
            m_phase = READY_PHASE;
            for(unsigned int i=0; i<World::getWorld()->getNumKarts(); i++)
                World::getWorld()->getKart(i)->startEngineSFX();

            break;
        case READY_PHASE:
            if(m_auxiliary_timer>1.0)
            {
                if (m_play_racestart_sounds) m_prestart_sound->play();
                m_phase=SET_PHASE;   
            }
            m_auxiliary_timer += dt;
            
            // In artist debug mode, when without opponents, skip the ready/set/go counter faster
            if (UserConfigParams::m_artist_debug_mode && race_manager->getNumberOfKarts() == 1)
                m_auxiliary_timer += dt*6;
            return;
        case SET_PHASE  :
            if(m_auxiliary_timer>2.0) 
            {
                // set phase is over, go to the next one
                m_phase=GO_PHASE;  
                if (m_play_racestart_sounds) m_start_sound->play();
                
                World::getWorld()->getTrack()->startMusic();
                
                // event
                onGo();
            }
            m_auxiliary_timer += dt;
            
            // In artist debug mode, when without opponents, skip the ready/set/go counter faster
            if (UserConfigParams::m_artist_debug_mode && race_manager->getNumberOfKarts() == 1)
                m_auxiliary_timer += dt*6;
            return;
        case GO_PHASE  :
            
            if (m_auxiliary_timer>2.5f && music_manager->getCurrentMusic())
                music_manager->startMusic(music_manager->getCurrentMusic());
            
            if(m_auxiliary_timer>3.0f)    // how long to display the 'go' message  
            {
                m_phase=MUSIC_PHASE;
            }
            
            m_auxiliary_timer += dt;
            
            // In artist debug mode, when without opponents, skip the ready/set/go counter faster
            if (UserConfigParams::m_artist_debug_mode && race_manager->getNumberOfKarts() == 1)
                m_auxiliary_timer += dt*6;
            break;
        case MUSIC_PHASE:
            // how long to display the 'music' message
            if(m_auxiliary_timer>stk_config->m_music_credit_time)
                m_phase=RACE_PHASE;  
            m_auxiliary_timer += dt;
            break;
        case RACE_PHASE:
            // Nothing to do for race phase, switch to delay finish phase
            // happens when 
            break;
        case DELAY_FINISH_PHASE :
        {
            m_auxiliary_timer += dt;
            
            // Change to next phase if delay is over
            if(m_auxiliary_timer > stk_config->m_delay_finish_time)
            {
                m_phase = RESULT_DISPLAY_PHASE;
                terminateRace();
            }
            break;
        }
        case RESULT_DISPLAY_PHASE : 
            {
                // Wait for the race over GUI/modal dialog to appear
                // Previously the in race race over results are shown,
                // and getCurrent() returns NULL.
                RaceOverDialog *m = 
                    dynamic_cast<RaceOverDialog*>(GUIEngine::ModalDialog
                                                          ::getCurrent());
                if( m && m->menuIsFinished() )
                {
                    m_phase = FINISH_PHASE;
                }
            break;
            }
        case FINISH_PHASE:
            // Nothing to do here.
            break;
        default: break;
    }
    
    switch(m_clock_mode)
    {
        case CLOCK_CHRONO:
            m_time += dt;
            break;
        case CLOCK_COUNTDOWN:
            // stop countdown when race is over
            if (m_phase == RESULT_DISPLAY_PHASE || m_phase == FINISH_PHASE)
            {
                m_time = 0.0f;
                break;
            }
            
            m_time -= dt;
            
            if(m_time <= 0.0)
            {
                // event
                countdownReachedZero();
            }
                
            break;
        default: break;
    }
}   // update
Beispiel #8
0
void Task::go(bool autoDelete)
{
	d->autoDelete = autoDelete;

	onGo();
}
Beispiel #9
0
void Task::go(AutoDeleteSetting autoDelete)
{
	d->autoDelete = autoDelete;
	onGo();
}
/** Updates the world time and clock (which might be running backwards), and
 *  all status information, called once per frame at the end of the main
 *  loop.
 *  \param ticks Number of ticks (physics time steps) - should be 1.
 */
void WorldStatus::updateTime(int ticks)
{
    switch (m_phase.load())
    {
        // Note: setup phase must be a separate phase, since the race_manager
        // checks the phase when updating the camera: in the very first time
        // step dt is large (it includes loading time), so the camera might
        // tilt way too much. A separate setup phase for the first frame
        // simplifies this handling
        case SETUP_PHASE:
            m_auxiliary_ticks= 0;
            m_phase = TRACK_INTRO_PHASE;
            
            if (m_play_track_intro_sound)
            {
                m_track_intro_sound->play();
            }

            if (Weather::getInstance())
            {
                Weather::getInstance()->playSound();
            }

            return;   // Do not increase time
        case TRACK_INTRO_PHASE:
            m_auxiliary_ticks++;

            if (UserConfigParams::m_artist_debug_mode &&
                !NetworkConfig::get()->isNetworking() &&
                race_manager->getNumberOfKarts() -
                race_manager->getNumSpareTireKarts() == 1 &&
                race_manager->getTrackName() != "tutorial")
            {
                m_auxiliary_ticks += 6;
            }

            if (!m_play_track_intro_sound)
            {
                startEngines();
            }

            // Wait before ready phase
            if (m_auxiliary_ticks < stk_config->time2Ticks(3.0f))
                return;

            m_auxiliary_ticks = 0;

            // In a networked game the client needs to wait for a notification
            // from the server that all clients and the server are ready to 
            // start the game. The server will actually wait for all clients
            // to confirm that they have started the race before starting
            // itself. In a normal race, this phase is skipped and the race
            // starts immediately.
            if (NetworkConfig::get()->isNetworking())
            {
                m_phase = WAIT_FOR_SERVER_PHASE;
                // In networked races, inform the start game protocol that
                // the world has been setup
                if (!m_live_join_world)
                {
                    auto lobby = LobbyProtocol::get<LobbyProtocol>();
                    assert(lobby);
                    lobby->finishedLoadingWorld();
                }
            }
            else
            {
                if (m_play_ready_set_go_sounds)
                    m_prestart_sound->play();
                m_phase = READY_PHASE;
            }
            return;   // Don't increase time
        case WAIT_FOR_SERVER_PHASE:
        {
            if (m_live_join_world)
            {
                m_auxiliary_ticks++;
                // Add 3 seconds delay before telling server finish loading
                // world, so previous (if any) disconnected player has left
                // fully
                if (m_auxiliary_ticks == stk_config->time2Ticks(3.0f))
                {
                    auto cl = LobbyProtocol::get<ClientLobby>();
                    assert(cl);
                    cl->finishedLoadingWorld();
#ifndef ANDROID
                    static bool helper_msg_shown = false;
                    if (!helper_msg_shown && cl->isSpectator())
                    {
                        helper_msg_shown = true;
                        cl->addSpectateHelperMessage();
                    }
#endif
                }
                return;
            }
            return;   // Don't increase time
        }
        case SERVER_READY_PHASE:
        {
            auto lobby = LobbyProtocol::get<LobbyProtocol>();
            if (lobby && lobby->isRacing())
            {
                if (m_play_ready_set_go_sounds)
                    m_prestart_sound->play();
                m_phase = READY_PHASE;
            }
            return;   // Don't increase time
        }
        case READY_PHASE:
            startEngines();
            // One second
            if (m_auxiliary_ticks > stk_config->getPhysicsFPS())
            {
                if (m_play_ready_set_go_sounds)
                {
                    m_prestart_sound->play();
                }

                m_phase = SET_PHASE;
            }

            m_auxiliary_ticks++;

            // In artist debug mode, when without opponents, skip the
            // ready/set/go counter faster
            if (UserConfigParams::m_artist_debug_mode     &&
                !NetworkConfig::get()->isNetworking()     &&
                race_manager->getNumberOfKarts() -
                race_manager->getNumSpareTireKarts() == 1 &&
                race_manager->getTrackName() != "tutorial")
            {
                m_auxiliary_ticks += 6;
            }

            return;   // Do not increase time
        case SET_PHASE:
            if (m_auxiliary_ticks > 2*stk_config->getPhysicsFPS())
            {
                // set phase is over, go to the next one
                m_phase = GO_PHASE;
                if (m_play_ready_set_go_sounds)
                {
                    m_start_sound->play();
                }

                // event
                onGo();
                // In artist debug mode, when without opponents,
                // skip the ready/set/go counter faster
                m_start_music_ticks =
                    UserConfigParams::m_artist_debug_mode &&
                    !NetworkConfig::get()->isNetworking()     &&
                    race_manager->getNumberOfKarts() -
                    race_manager->getNumSpareTireKarts() == 1 &&
                    race_manager->getTrackName() != "tutorial" ?
                    stk_config->time2Ticks(0.2f) :
                    stk_config->time2Ticks(1.0f);
                // how long to display the 'music' message
                // no graphics mode goes race phase at 3 seconds;
                m_race_ticks = ProfileWorld::isNoGraphics() ?
                    stk_config->time2Ticks(3.0f) :
                    stk_config->time2Ticks(stk_config->m_music_credit_time);
            }

            m_auxiliary_ticks++;

            // In artist debug mode, when without opponents, 
            // skip the ready/set/go counter faster
            if (UserConfigParams::m_artist_debug_mode &&
                !NetworkConfig::get()->isNetworking() &&
                race_manager->getNumberOfKarts() -
                race_manager->getNumSpareTireKarts() == 1 &&
                race_manager->getTrackName() != "tutorial")
            {
                m_auxiliary_ticks += 6;
            }

            return;   // Do not increase time
        case GO_PHASE:
        {
            if (m_start_music_ticks != -1 &&
                m_count_up_ticks >= m_start_music_ticks)
            {
                m_start_music_ticks = -1;
                if (music_manager->getCurrentMusic() &&
                    !music_manager->getCurrentMusic()->isPlaying())
                {
                    music_manager->startMusic();
                }
                m_phase = MUSIC_PHASE;
            }
            break;   // Now the world time starts
        }
        case MUSIC_PHASE:
        {
            // Start the music here when starting fast
            if (UserConfigParams::m_race_now)
            {
                music_manager->startMusic();
                UserConfigParams::m_race_now = false;
            }
            if (m_race_ticks != -1 && m_count_up_ticks >= m_race_ticks)
            {
                m_race_ticks = -1;
                m_phase = RACE_PHASE;
            }
            break;
        }
        case RACE_PHASE:
            // Nothing to do for race phase, switch to delay finish phase
            // happens when
            break;
        case DELAY_FINISH_PHASE:
        {
            m_auxiliary_ticks++;

            // Change to next phase if delay is over
            if (m_auxiliary_ticks >
                stk_config->time2Ticks(stk_config->m_delay_finish_time))
            {
                m_phase = RESULT_DISPLAY_PHASE;
                terminateRace();
            }

            break;
        }
        case RESULT_DISPLAY_PHASE:
        {
            break;
        }
        case FINISH_PHASE:
        case IN_GAME_MENU_PHASE:
            // Nothing to do here.
            break;
        case GOAL_PHASE:
            // Nothing to do here as well.
            break;

        default: break;
    }

    IrrlichtDevice *device = irr_driver->getDevice();
    
    switch (m_clock_mode)
    {
        case CLOCK_CHRONO:
            if (!device->getTimer()->isStopped())
            {
                m_time_ticks++;
                m_time  = stk_config->ticks2Time(m_time_ticks);
                m_count_up_ticks++;
            }
            break;
        case CLOCK_COUNTDOWN:
            // stop countdown when race is over
            if (m_phase == RESULT_DISPLAY_PHASE || m_phase == FINISH_PHASE)
            {
                m_time_ticks = 0;
                m_time = 0.0f;
                m_count_up_ticks = 0;
                break;
            }

            if (!device->getTimer()->isStopped())
            {
                m_time_ticks--;
                m_time = stk_config->ticks2Time(m_time_ticks);
                m_count_up_ticks++;
            }

            if (m_time_ticks <= 0)
            {
                // event
                countdownReachedZero();
            }

            break;
        default: break;
    }   // switch m_phase

}   // update
Beispiel #11
0
void MathTest::initDisplay()
{
    int index;

    // Set the starting coordinates in pixels for the objects that will be
    // laid out.
    //
    const int tests_x = 20;     // x coord of left side of groups
    const int tests_y = 50;     // y coord of top of groups
    const int text_w = 80;      // Width of all text
    const int text_h = 14;      // Height of all text
    const int box_w = 60;       // Width of Edit Boxes and Labels
    const int box_h = 30;       // Height of all controls
    const int vs = 36;          // Vertical Span
    const int hs = 36;          // Horizontal span

    // Instantiate the Layout parameters.
    // See layout.h
    //
    LAYOUT_INIT()

    // Layout the Tests Checkboxes
    //
    LAYOUT(tests_x, tests_y, 0, vs)
    Twidget *tw = new Twidget;
    tw->objName = "Tests";
    tw->objText << "Add" << "Subtract" << "Multiply" << "Divide";
    tw->sizes   << QSize(text_w+10, box_h);
    tw->layout  << CELL(0,0) << CELL(0,1) << CELL(0,2) << CELL(0,3);
    tw->connect = false;
    //
    // Layout the Labels for number of Problems, time in Seconds, and Grade
    // Level.
    // These labels will "belong" to the pTests control group.
    //
    int label_x  = tests_x + text_w + hs;
    int label_y  = 14;
    int label_hs = box_w + hs;
    LAYOUT(label_x, label_y, label_hs, text_h)
    tw->labelText   << "Number of" << "Problems"
                    << "Time in" << "Seconds"
                    << "Grade" << "Level";
    tw->labelSizes  << QSize(text_w, text_h);
    tw->labelLayout << CELL(0,0) << CELL(0,1)
                    << CELL(1,0) << CELL(1,1)
                    << CELL(2,0) << CELL(2,1);
    pTests = new TButtonGroup <QCheckBox>(tw, this);

    // Layout the "Problems" QLineEdit boxes
    //
    tw = new Twidget;
    int prob_x = label_x;
    int prob_y = tests_y;
    LAYOUT(prob_x, prob_y, 0, vs)
    tw->objName = "Problems";
    tw->objText << "5" << "5" << "5" << "5";
    tw->sizes   << QSize(box_w, box_h);
    tw->layout  << CELL(0,0) << CELL(0,1) << CELL(0,2) << CELL (0,3);
    tw->connect = true;
    pProblems   = new TEditGroup <QLineEdit>(tw, this);
    for(index = 0; index < pProblems->widgetList.size(); index++)
        pProblems->widgetList[index]->setInputMask("00");

    // Layout the "Seconds" QLineEdit boxes
    //
    tw = new Twidget;
    int time_x = label_x + box_w + hs;
    int time_y = prob_y;
    LAYOUT(time_x, time_y, 0, vs);
    tw->layout  << CELL(0,0) << CELL(0,1) << CELL(0,2) << CELL(0,3);
    tw->objName = "Seconds";
    tw->objText << "10" << "10" << "25" << "30";
    tw->sizes   << QSize(box_w, box_h);
    tw->connect = false;
    pTimes      = new TEditGroup <QLineEdit>(tw, this);
    for(index = 0; index < pTimes->widgetList.size(); index++)
        pTimes->widgetList[index]->setInputMask("00");

    // Layout the Grade Level radiobuttons.
    //
    tw = new Twidget;
    int gl_x = time_x + box_w + hs - 10;
    int gl_y = time_y;
    LAYOUT(gl_x, gl_y, 0, vs);
    tw->layout << CELL(0,0) << CELL(0,1) << CELL(0,2) << CELL(0,3);
    tw->sizes << QSize(box_w - 10, box_h);
    tw->objText << "1" << "2" << "3" <<"4";
    tw->connect = true;
    tw->grouped = true;
    pGradeLevel = new TButtonGroup <QRadioButton>(tw, this);
    pGradeLevel->widgetList[gl_3]->setChecked(true);
    connect(pGradeLevel->buttonGroup, SIGNAL(buttonClicked(int)),
            this, SLOT(onGradeLevel(int)));

    // Layout the UserName box and its label
    //
    int userName_x = tests_x;
    int userName_y = tests_y + text_h + (4 * vs);
    int userNameEd_x = userName_x + text_w;
    int userNameEd_w = 250;
    userNameLabel = new QLabel(this);
    userNameLabel->setGeometry(userName_x, userName_y, text_w, text_h);
    userNameLabel->setText("Your Name:");
    userNameEdit = new QLineEdit(this);
    userNameEdit->setGeometry(userNameEd_x, userName_y, userNameEd_w, box_h);
    userNameEdit->setText("");
    userNameEdit->setCursorPosition(0);
    connect(userNameEdit, SIGNAL(returnPressed()), this, SLOT(onUserName()));

    // Create and connect the Start button.
    // Because this pushbutton's parent is QDialog, it will have its
    // autoDefault property set when instantiated. This can cause some very
    // confusing behavior if you don't know this. See "autoDefault" in the
    // QPushButton class reference. We will explicitly set this property
    // to FALSE for this button, and also set its "default" property to
    // FALSE.
    //
    const int pbw = 100;
    const int pbhs = 110;
    int goButton_x = tests_x+10;
    int goButton_y = userName_y + vs + 6;
    goButton = new QPushButton("Start", this);
    goButton->setGeometry(goButton_x, goButton_y, pbw, box_h);
    goButton->setAutoDefault(false);
    goButton->setDefault(false);
    connect(goButton, SIGNAL(clicked()), this, SLOT(onGo()));

    // Create and connect the stop button.
    //
    int stopButton_x = goButton_x + pbhs;
    int stopButton_y = goButton_y;
    stopButton = new QPushButton("Stop", this);
    stopButton->setGeometry(stopButton_x, stopButton_y, pbw, box_h);
    stopButton->setAutoDefault(false);
    stopButton->setDefault(false);
    connect(stopButton, SIGNAL(clicked()), this, SLOT(onStop()));

    // Create and connect the Default button.
    //
    int defaultButton_x = stopButton_x + pbhs;
    int defaultButton_y = goButton_y;
    defaultButton = new QPushButton("Defaults", this);
    defaultButton->setGeometry(defaultButton_x, defaultButton_y, pbw, box_h);
    defaultButton->setAutoDefault(false);
    defaultButton->setDefault(false);
    connect(defaultButton, SIGNAL(clicked()), this, SLOT(onDefault()));

    // Layout the Quiz and Answer Boxes and their labels
    //
    tw = new Twidget;
    int quiz_x = tests_x + 20;
    int quiz_y = goButton_y + vs;
    LAYOUT(quiz_x, quiz_y, hs + box_w+10, text_h)
    tw->labelLayout << CELL(0,0) << CELL(1,0) << CELL(2,0)
                    << CELL(0,1) << CELL(1,1) << CELL(2,1);
    tw->labelText   << "Problem" << "The" << "Your"
                    << "Number" << "Problem" << "Answer";
    tw->labelSizes  << QSize(text_w, text_h);
    LAYOUT(quiz_x, quiz_y+(2*text_h)+2, hs + box_w+10, 0)
    tw->objName = "Quiz";
    tw->objText << "";
    tw->sizes   << QSize(box_w, box_h)
                << QSize(box_w+30, box_h)
                << QSize(box_w+10, box_h);
    tw->hOffset << 20 << -5 << 0 << 20 << -5 << 0;
    tw->layout  << CELL(0,0) << CELL(1,0) << CELL(2,0);
    pQuiz = new TEditGroup <QLineEdit>(tw, this);
    //
    // Set the Quiz Box to ReadOnly and connect the returnPressed
    // signal from the Answer Box.
    //
    pQuiz->widgetList[qz_number]->setReadOnly(true);
    pQuiz->widgetList[qz_number]->setAlignment(Qt::AlignRight);
    pQuiz->widgetList[qz_quiz]->setReadOnly(true);
    pQuiz->widgetList[qz_answer]->setEnabled(true);
    pQuiz->widgetList[qz_answer]->setInputMask("0000");
    pQuiz->widgetList[qz_answer]->setCursor(Qt::IBeamCursor);
    pQuiz->widgetList[qz_answer]->setCursorPosition(0);
    QLineEdit *tempLineEdit = pQuiz->widgetList[qz_answer];
    connect (tempLineEdit, SIGNAL(returnPressed()),
        this, SLOT(onAnswer()));

    // Create the Message Box
    //
    int msg_x = tests_x;
    int msg_y = quiz_y + vs + (3 * text_h);
    int msg_w = 340;
    int msg_h = 180;
    QTextEdit* messages = new QTextEdit(this);
    messages->setGeometry(msg_x, msg_y, msg_w, msg_h);
    messages->setReadOnly(true);
    messages->setFocusPolicy(Qt::ClickFocus);
    messages->setUpdatesEnabled(true);
    pMsg = new Msg(messages);
}
Beispiel #12
0
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
{
  CPlugin * pPlugin = (CPlugin *)GetWindowLong(hWnd, DWL_USER);
  if (!pPlugin)
    return;

  switch (id)
  {
    case IDC_COMBO_API_CALL:
      if(codeNotify != CBN_SELCHANGE)
        break;
      updateUI(hWnd);
      break;
    case IDC_BUTTON_GO:
      pLogger->blockDumpToFile(FALSE);
      onGo(hWnd);
      break;
    case IDC_EDIT_ARG1:
    case IDC_EDIT_ARG2:
    case IDC_EDIT_ARG3:
    case IDC_EDIT_ARG4:
    case IDC_EDIT_ARG5:
    case IDC_EDIT_ARG6:
    case IDC_EDIT_ARG7:
    {
      if(codeNotify == EN_SETFOCUS)
        pPlugin->m_hWndLastEditFocus = hWndCtl;

      char szString[80];
      char szEdit[128];
      int iIndex = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_COMBO_API_CALL));
      ComboBox_GetLBText(GetDlgItem(hWnd, IDC_COMBO_API_CALL), iIndex, szString);
      if(   ((strcmp(szString, STRING_NPN_POSTURL) == 0) || (strcmp(szString, STRING_NPN_POSTURLNOTIFY) == 0))
         && (id == IDC_EDIT_ARG5)
         && (codeNotify == EN_CHANGE))
      {
        Edit_GetText(hWndCtl, szEdit, sizeof(szEdit));
        int iLength = strlen(szEdit);
        SetDlgItemInt(hWnd, IDC_EDIT_ARG4, iLength, FALSE);
      }
      if(   ((strcmp(szString, STRING_NPN_WRITE) == 0))
         && (id == IDC_EDIT_ARG4)
         && (codeNotify == EN_CHANGE))
      {
        Edit_GetText(hWndCtl, szEdit, sizeof(szEdit));
        int iLength = strlen(szEdit);
        SetDlgItemInt(hWnd, IDC_EDIT_ARG3, iLength, FALSE);
      }

      // save values of window size on the fly as we type it
      if(    (strcmp(szString, STRING_NPN_SETVALUE) == 0)
          && ((id == IDC_EDIT_ARG3) || (id == IDC_EDIT_ARG4)) 
          && (codeNotify == EN_CHANGE)
          && (hWndCtl == GetFocus()))
      {
        iIndex = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_COMBO_ARG2));
        ComboBox_GetLBText(GetDlgItem(hWnd, IDC_COMBO_ARG2), iIndex, szString);
        if(strcmp(szString, "NPPVpluginWindowSize") == 0)
        {
          BOOL bTranslated = FALSE;
          int iWidth = GetDlgItemInt(hWnd, IDC_EDIT_ARG3, &bTranslated, TRUE);
          int iHeight = GetDlgItemInt(hWnd, IDC_EDIT_ARG4, &bTranslated, TRUE);

          if(pPlugin->m_iWidth != iWidth)
            pPlugin->m_iWidth = iWidth;
          if(pPlugin->m_iHeight != iHeight)
            pPlugin->m_iHeight = iHeight;
        }
      }
      break;
    }
    case IDC_COMBO_ARG2:
    {
      if(codeNotify != CBN_SELCHANGE)
        break;

      ShowWindow(GetDlgItem(hWnd, IDC_STATIC_ARG4), SW_HIDE);
      ShowWindow(GetDlgItem(hWnd, IDC_EDIT_ARG4), SW_HIDE);
      Static_SetText(GetDlgItem(hWnd, IDC_STATIC_ARG3), "*value:");
      Edit_SetText(GetDlgItem(hWnd, IDC_EDIT_ARG3), "");

      char szString[80];
      int iIndex = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_COMBO_API_CALL));
      ComboBox_GetLBText(GetDlgItem(hWnd, IDC_COMBO_API_CALL), iIndex, szString);
      if(strcmp(szString, STRING_NPN_SETVALUE) == 0)
      {
        iIndex = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_COMBO_ARG2));
        ComboBox_GetLBText(GetDlgItem(hWnd, IDC_COMBO_ARG2), iIndex, szString);
        if((strcmp(szString, "NPPVpluginWindowBool") == 0) ||
           (strcmp(szString, "NPPVpluginTransparentBool") == 0) ||
           (strcmp(szString, "NPPVpluginKeepLibraryInMemory") == 0))
        {
          HWND hWndCombo = GetDlgItem(hWnd, IDC_COMBO_ARG3);
          ComboBox_ResetContent(hWndCombo);
          ComboBox_AddString(hWndCombo, "TRUE");
          ComboBox_AddString(hWndCombo, "FALSE");
          ComboBox_SetCurSel(hWndCombo, 0);
          ShowWindow(GetDlgItem(hWnd, IDC_EDIT_ARG3), SW_HIDE);
          ShowWindow(hWndCombo, SW_SHOW);
        }
        else
        {
          ShowWindow(GetDlgItem(hWnd, IDC_EDIT_ARG3), SW_SHOW);
          ShowWindow(GetDlgItem(hWnd, IDC_COMBO_ARG3), SW_HIDE);
          if(strcmp(szString, "NPPVpluginWindowSize") == 0)
          {
            EnableWindow(GetDlgItem(hWnd, IDC_EDIT_ARG4), TRUE);
            ShowWindow(GetDlgItem(hWnd, IDC_EDIT_ARG4), SW_SHOW);
            ShowWindow(GetDlgItem(hWnd, IDC_STATIC_ARG4), SW_SHOW);
            Static_SetText(GetDlgItem(hWnd, IDC_STATIC_ARG3), "width:");
            Static_SetText(GetDlgItem(hWnd, IDC_STATIC_ARG4), "height:");
            SetDlgItemInt(hWnd, IDC_EDIT_ARG3, pPlugin->m_iWidth, TRUE);
            SetDlgItemInt(hWnd, IDC_EDIT_ARG4, pPlugin->m_iHeight, TRUE);
          }
        }
      }
      break;
    }
    case IDC_BUTTON_PASTE:
      onPaste(pPlugin->m_hWndLastEditFocus);
      break;
    default:
      break;
  }
}
Beispiel #13
0
void ChessWidget::createMenu()
{
  QMenu * gameMenu = menuBar()->addMenu(tr("&Game"));

  onNewAction_ = new QAction(tr("&New"), this);
  onNewAction_->setStatusTip(tr("Start new game"));

  onLoadAction_ = new QAction(tr("&Load"), this);
  onLoadAction_->setStatusTip(tr("Load previously saved game"));

  onSaveAction_ = new QAction(tr("&Save"), this);
  onSaveAction_->setStatusTip(tr("Save current game"));

  onPrevAction_ = new QAction(tr("&Undo move"), this);
  onPrevAction_->setStatusTip(tr("Undo last move. (only step of one color will be undone)"));

  onNextAction_ = new QAction(tr("&Redo move"), this);
  onNextAction_->setStatusTip(tr("Restore undone move"));

  onGoAction_ = new QAction(tr("&Go"), this);
  onGoAction_->setStatusTip(tr("Lets program make move"));

  onTurnBoardAction_ = new QAction(tr("&Turn board"), this);
  onTurnBoardAction_->setStatusTip(tr("Turn board to play another color"));
  onTurnBoardAction_->setCheckable(true);
  onTurnBoardAction_->setChecked(false);

  onHumanVsHumanAction_ = new QAction(tr("&Human vs. Human"), this);
  onHumanVsHumanAction_->setStatusTip(tr("Switch to Human with Human mode"));
  onHumanVsHumanAction_->setCheckable(true);
  onHumanVsHumanAction_->setChecked(false);

  QSettings settings(tr("Dimock"), tr("qchess"));
  onOpenBookAction_ = new QAction(tr("&Open book"), this);
  onOpenBookAction_->setStatusTip(tr("Use open book"));
  onOpenBookAction_->setCheckable(true);
  onOpenBookAction_->setChecked( settings.value(tr("open_book"), true).toBool() );

  onSettingsAction_ = new QAction(tr("Settin&gs"), this);
  onSettingsAction_->setStatusTip(tr("Change game settings"));

  gameMenu->addAction(onNewAction_);
  gameMenu->addAction(onLoadAction_);
  gameMenu->addAction(onSaveAction_);
  gameMenu->addAction(onPrevAction_);
  gameMenu->addAction(onNextAction_);
  gameMenu->addAction(onGoAction_);
  gameMenu->addAction(onTurnBoardAction_);
  gameMenu->addAction(onOpenBookAction_);
  gameMenu->addSeparator();
  gameMenu->addAction(onHumanVsHumanAction_);
  gameMenu->addSeparator();
  gameMenu->addAction(onSettingsAction_);

  connect(onNewAction_, SIGNAL(triggered()), this, SLOT(onNew()));
  connect(onLoadAction_, SIGNAL(triggered()), this, SLOT(onLoad()));
  connect(onSaveAction_, SIGNAL(triggered()), this, SLOT(onSave()));
  connect(onPrevAction_, SIGNAL(triggered()), this, SLOT(onPrev()));
  connect(onNextAction_, SIGNAL(triggered()), this, SLOT(onNext()));
  connect(onGoAction_, SIGNAL(triggered()), this, SLOT(onGo()));
  connect(onTurnBoardAction_, SIGNAL(toggled(bool)), this, SLOT(onTurnBoard(bool)));
  connect(onHumanVsHumanAction_, SIGNAL(toggled(bool)), this, SLOT(onHumanWithHumanMode(bool)));
  connect(onOpenBookAction_, SIGNAL(toggled(bool)), this, SLOT(onUseOpenBook(bool)));
  connect(onSettingsAction_, SIGNAL(triggered()), this, SLOT(onSettings()));
}