void PruebaConceptoApp::mouseReleased(int x, int y, int button){ cout<<currentState<<"-"<<states[STATE_AZUL]<<endl; if (currentState==states[STATE_AZUL]){ if (button==BOTON_IZQUIERDO){ cout <<"Cambiando a estado Rojo"<<endl; goToState(STATE_ROJO); } } if (currentState==states[STATE_ROJO]){ if (button==BOTON_DERECHO){ cout <<"Cambiando a estado Verde"<<endl; goToState(STATE_VERDE); } } cout <<"Mouse released: "<<button<<" ["<<x<<","<<y<<"]"<<endl; }
void PruebaConceptoApp::keyReleased(int key){ if (currentState==states[STATE_VERDE]){ if (key==KEY_N){ cout <<"Cambiando a estado Azul"<<endl; goToState(STATE_AZUL); } } cout <<"Key released: "<<key<<endl; }
void ApplicationCore::enterConfiguringState() { if (configure()) { // if all ok, go to connecting state emit goToState(Connecting); } else { // user has cancelled configure, exit the application QCoreApplication::quit(); } }
void CustomApp::keyPressed(int key){ switch(key){ case '0': goToState(STEINEN_STATE); break; case '1': goToState(SUPERFICIE_SINUSOIDAL_STATE); break; case '2': goToState(ELIPSES_COCENTRICAS_STATE); break; case '3': goToState(CUBETA_HUEVOS_STATE); break; case '4': goToState(TORO_PARTICULAS_STATE); break; default: StateMachineApp::keyPressed(key); } }
void PauseState::handleNotifiedEvents(sf::Event& event, float) { if (event.type == sf::Event::KeyPressed) { if (event.key.code == sf::Keyboard::F1) goToState(StateManager::getState("race")); else if (event.key.code == sf::Keyboard::Escape) { exit(); } } }
void ApplicationCore::enterConnectingState() { try { if (!m_controller.initializeBackEnd(CHARM_SQLITE_BACKEND_DESCRIPTOR)) QCoreApplication::quit(); } catch (const CharmException &e) { showCritical(tr("Database Backend Error"), tr("The backend could not be initialized: %1").arg(e.what())); slotQuitApplication(); return; } // tell storage to connect to database CONFIGURATION.failure = false; try { if (m_controller.connectToBackend()) { // delay switch to Connected state a bit to show the start screen: QTimer::singleShot(0, this, SLOT(slotGoToConnectedState())); } else { // go back to StartingUp state and reconfigure emit goToState(StartingUp); } } catch (const UnsupportedDatabaseVersionException &e) { qDebug() << e.what(); QFileInfo info(Configuration::instance().localStorageDatabase); QString message = QObject::tr("<html><body>" "<p>Your current Charm database is not supported by this version. " "The error message is: %1." "You have two options here:</p><ul>" "<li>Start over with an empty database by moving or deleting your %2 folder " "then re-running this version of Charm.</li>" "<li>Load an older version of Charm that supports your current database and select " "File->Export, and save that file somewhere. Then, either rename or delete your " "%2 folder and restart this version of Charm and select File->Import from " "previous export and select the file you saved in the previous step.</li>" "</ul></body></html>").arg( e.what().toHtmlEscaped(), info.absoluteDir().path()); showCritical(QObject::tr("Charm Database Error"), message); slotQuitApplication(); return; } }
void NewRecordState::handleNotifiedEvents(sf::Event& event, float) { if (event.type == sf::Event::KeyPressed) { if (event.key.code == sf::Keyboard::Escape) { exit(); } if (event.key.code == sf::Keyboard::BackSpace) { m_delChar = true; if (m_enteredPseudo.size() == 1) m_enteredPseudo = ""; else if (m_enteredPseudo.size() > 1) m_enteredPseudo = m_enteredPseudo.substr(0, m_enteredPseudo.size() - 1); } else if (event.key.code == sf::Keyboard::Return) { m_pScoreMgr->saveBestScore(m_enteredPseudo, m_score); goToState(StateManager::getState("menu")); } } else if (event.type == sf::Event::TextEntered && m_enteredPseudo.size() < 10 && !m_delChar) m_enteredPseudo += static_cast<char>(event.text.unicode); }
void ChooseScenarioGroupPageController::onStartClicked() { emit goToState(CentCapSetupState); }
void main(void) { ENTR_CRT_SECTION(); /* Setup STM32 system (clock, PLL and Flash configuration) */ SystemInit(); /* Set the Vector Table base location at 0x08000000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); // I2C1 init I2C1_Init(); EXT_CRT_SECTION(); // GLCD init GLCD_PowerUpInit(0x0); //( GLCD_Backlight(BACKLIGHT_ON); GLCD_SetFont(&Terminal_9_12_6,0x000F00,0x00FF0); GLCD_SetWindow(10,10,131,131); // Init Accl sensor if(FALSE == Accl_Init()) { // Initialization fault GLCD_TextSetPos(0,0); GLCD_print("\fLIS3LV020 Init.\r\nfault\r\n"); while(1); } //Init CarControl and Delay Car_Init(); DWT_Init(); HCSR04_Init(); // SysTick end of count event each 0.5s with input clock equal to 9MHz (HCLK/8, default) SysTick_Config(150000); SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8); DWT_Delayms(1000); while(1) { //while(1){GLCD_print("Current state: %d \r",GPIO_ReadInputDataBit(JS_LEFT_PORT, JS_LEFT_MASK));} //car_feedback=accl_feedback(); /* A = accX[1]; B = velX[1]; C = posX[1]; */ if(SysTickF1) { SysTickF1 = FALSE; //GLCD_TextSetPos(0,0); GLCD_print("%d, %d \r", get_Xvel(), accl_feedback()); DWT_Delayms(500); } if(NewInstr) // { DWT_Delayms(1000); NewInstr = FALSE; //GoCar(Test, TestTurn); // 1. Give command (desired state) //desiredState; // 2. Run machine learning to test action action = goToState(car_instr); GoCars(action); // testExp(); int runTime = 0; while (runTime < 1){ DWT_Delayms(700); runTime++; } GLCD_TextSetPos(0,0); GLCD_print("\f%d,%d;%d,%d\r\n", get_X_accFeedback(0), get_Y_accFeedback(0), get_X_vel(0), get_Y_vel(0)); GLCD_print("%d,%d;%d,%d\r\n", get_X_accFeedback(1), get_Y_accFeedback(1), get_X_vel(1), get_Y_vel(1)); GLCD_print("%d,%d;%d,%d\r\n", get_X_accFeedback(2), get_Y_accFeedback(2), get_X_vel(2), get_Y_vel(2)); GLCD_print("%d,%d;%d,%d\r\n", get_X_accFeedback(3), get_Y_accFeedback(3), get_X_vel(3), get_Y_vel(3)); GLCD_print("%d,%d;%d,%d\r\n", get_X_accFeedback(4), get_Y_accFeedback(4), get_X_vel(4), get_Y_vel(4)); GLCD_print("%d,%d;%d,%d\r\n", get_X_accFeedback(5), get_Y_accFeedback(5), get_X_vel(5), get_Y_vel(5)); GLCD_print("%d,%d;%d,%d\r\n", get_X_accFeedback(6), get_Y_accFeedback(6), get_X_vel(6), get_Y_vel(6)); // GLCD_print("%d,%d;%d,%d\r\n", get_X_accFeedback(7), get_Y_accFeedback(7), get_X_vel(7), get_Y_vel(7)); car_instr=car_stop; GoCars(car_instr); DWT_Delayms(2000); } //GoCars(3); //Stopping the car // 3. Wait x ms //Wait in ML-method testAllActions // 4. Return value from accelerometer //Return value from accelerometer in ML-method testAllActions // 5. Evaluate action compared to state //Already implemented in ML-file. No need to alter (probably) // 6. Repeat 3-5 until all actions has been tested //Already implemented in ML-file. No need to alter (probably) // 7. Choose the correct state //Already implemented in ML-file. No need to alter (probably) } }
Q_FOREACH( CharmWindow* window, m_windows ) { if ( window != &mainView() ) { // main view acts as the main relay connect( window, SIGNAL( emitCommand( CharmCommand* ) ), &mainView(), SLOT( sendCommand( CharmCommand* ) ) ); connect( window, SIGNAL( emitCommandRollback( CharmCommand* ) ), &mainView(), SLOT( sendCommandRollback( CharmCommand* ) ) ); } // save the configuration (configuration is managed by the application) connect( window, SIGNAL(saveConfiguration() ), SLOT( slotSaveConfiguration() ) ); connect( window, SIGNAL( visibilityChanged( bool ) ), this, SLOT( slotCharmWindowVisibilityChanged( bool ) ) ); } // my own signals: connect(this, SIGNAL(goToState(State)), SLOT(setState(State)), Qt::QueuedConnection); // system tray icon: m_actionStopAllTasks.setText( tr( "Stop &All Active Tasks" ) ); m_actionStopAllTasks.setShortcut( Qt::Key_Escape ); m_actionStopAllTasks.setShortcutContext( Qt::ApplicationShortcut ); mainView().addAction(&m_actionStopAllTasks); // for the shortcut to work connect( &m_actionStopAllTasks, SIGNAL( triggered() ), SLOT( slotStopAllTasks() ) ); m_systrayContextMenu.addAction( &m_actionStopAllTasks ); m_systrayContextMenu.addSeparator(); m_trayIcon.setContextMenu( &m_systrayContextMenu ); m_trayIcon.setToolTip( tr( "No active events" ) ); m_trayIcon.setIcon( Data::charmTrayIcon() );
void SummaryPageController::onNextClicked() { emit goToState(CentFeedbackState); }
void ApplicationCore::slotControllerReadyToQuit() { emit goToState(ShuttingDown); }
ApplicationCore::ApplicationCore(TaskId startupTask, bool hideAtStart, QObject *parent) : QObject(parent) , m_actionStopAllTasks(this) , m_actionQuit(this) , m_actionAboutDialog(this) , m_actionPreferences(this) , m_actionExportToXml(this) , m_actionImportFromXml(this) , m_actionSyncTasks(this) , m_actionImportTasks(this) , m_actionExportTasks(this) , m_actionCheckForUpdates(this) , m_actionEnterVacation(this) , m_actionActivityReport(this) , m_actionWeeklyTimesheetReport(this) , m_actionMonthlyTimesheetReport(this) , m_uiElements( { &m_timeTracker, &m_tasksView, &m_eventView }), m_startupTask(startupTask) , m_hideAtStart(hideAtStart) #ifdef Q_OS_WIN , m_windowsJumpList(new QWinJumpList(this)) #endif , m_dateChangeWatcher(new DateChangeWatcher(this)) { // QApplication setup QApplication::setQuitOnLastWindowClosed(false); // application metadata setup // note that this modifies the behaviour of QSettings: QCoreApplication::setOrganizationName(QStringLiteral("KDAB")); QCoreApplication::setOrganizationDomain(QStringLiteral("kdab.com")); QCoreApplication::setApplicationName(QStringLiteral("Charm")); QCoreApplication::setApplicationVersion(CharmVersion()); QLocalSocket uniqueApplicationSocket; QString serverName(QStringLiteral("com.kdab.charm")); QString charmHomeEnv(QString::fromLocal8Bit(qgetenv("CHARM_HOME"))); if (!charmHomeEnv.isEmpty()) { serverName.append(QStringLiteral("_%1").arg( charmHomeEnv.replace(QRegExp(QLatin1String(":?/|:?\\\\")), QStringLiteral("_")))); } #ifndef NDEBUG serverName.append(QStringLiteral("_debug")); #endif uniqueApplicationSocket.connectToServer(serverName, QIODevice::ReadWrite); if (uniqueApplicationSocket.waitForConnected(1000)) { QByteArray command; if (startupTask != -1) { command = StartTaskCommand + QByteArray::number(startupTask); } else { command = RaiseWindowCommand; } command += '\n'; qint64 written = uniqueApplicationSocket.write(command); if (written == -1 || written != command.length()) { qWarning() << "Failed to pass " << command << " to running charm instance, error: " << uniqueApplicationSocket.errorString(); } uniqueApplicationSocket.flush(); uniqueApplicationSocket.waitForBytesWritten(); throw AlreadyRunningException(); } connect(&m_uniqueApplicationServer, &QLocalServer::newConnection, this, &ApplicationCore::slotHandleUniqueApplicationConnection, Qt::QueuedConnection); QFile::remove(QDir::tempPath() + QLatin1Char('/') + serverName); bool listening = m_uniqueApplicationServer.listen(serverName); if (!listening) qDebug() << "Failed to create QLocalServer for unique application support:" << m_uniqueApplicationServer.errorString(); Q_INIT_RESOURCE(CharmResources); Q_ASSERT_X(m_instance == 0, "Application ctor", "Application is a singleton and cannot be created more than once"); m_instance = this; qRegisterMetaType<State>("State"); qRegisterMetaType<Event>("Event"); // exit process (app will only exit once controller says it is ready) connect(&m_controller, &Controller::readyToQuit, this, &ApplicationCore::slotControllerReadyToQuit); connectControllerAndModel(&m_controller, m_model.charmDataModel()); Charm::connectControllerAndView(&m_controller, &m_timeTracker); // save the configuration (configuration is managed by the application) connect(&m_timeTracker, &CharmWindow::saveConfiguration, this, &ApplicationCore::slotSaveConfiguration); connect(&m_timeTracker, &TimeTrackingWindow::showNotification, this, &ApplicationCore::slotShowNotification); connect(&m_timeTracker, &TimeTrackingWindow::taskMenuChanged, this, &ApplicationCore::slotPopulateTrayIconMenu); // save the configuration (configuration is managed by the application) connect(&m_tasksView, &TasksView::saveConfiguration, this, &ApplicationCore::slotSaveConfiguration); // due to multiple inheritence we can't use the new style connects here connect(&m_tasksView, SIGNAL(emitCommand(CharmCommand*)), &m_timeTracker, SLOT(sendCommand(CharmCommand*))); connect(&m_tasksView, SIGNAL(emitCommandRollback(CharmCommand*)), &m_timeTracker, SLOT(sendCommandRollback(CharmCommand*))); connect(&m_eventView, SIGNAL(emitCommand(CharmCommand*)), &m_timeTracker, SLOT(sendCommand(CharmCommand*))); connect(&m_eventView, SIGNAL(emitCommandRollback(CharmCommand*)), &m_timeTracker, SLOT(sendCommandRollback(CharmCommand*))); // my own signals: connect(this, &ApplicationCore::goToState, this, &ApplicationCore::setState, Qt::QueuedConnection); // system tray icon: m_actionStopAllTasks.setText(tr("Stop Current Task")); m_actionStopAllTasks.setShortcut(Qt::Key_Escape); m_actionStopAllTasks.setShortcutContext(Qt::ApplicationShortcut); mainView().addAction(&m_actionStopAllTasks); // for the shortcut to work connect(&m_actionStopAllTasks, &QAction::triggered, this, &ApplicationCore::slotStopAllTasks); m_systrayContextMenu.addAction(&m_actionStopAllTasks); m_systrayContextMenu.addSeparator(); m_systrayContextMenu.addAction(m_timeTracker.openCharmAction()); m_systrayContextMenu.addAction(&m_actionQuit); m_trayIcon.setContextMenu(&m_systrayContextMenu); m_trayIcon.setToolTip(tr("No active events")); m_trayIcon.setIcon(Data::charmTrayIcon()); m_trayIcon.show(); QApplication::setWindowIcon(Data::charmIcon()); // set up actions: m_actionQuit.setShortcut(Qt::CTRL + Qt::Key_Q); m_actionQuit.setText(tr("Quit")); m_actionQuit.setIcon(Data::quitCharmIcon()); connect(&m_actionQuit, &QAction::triggered, this, &ApplicationCore::slotQuitApplication); m_actionAboutDialog.setText(tr("About Charm")); connect(&m_actionAboutDialog, &QAction::triggered, &m_timeTracker, &TimeTrackingWindow::slotAboutDialog); m_actionPreferences.setText(tr("Preferences")); m_actionPreferences.setIcon(Data::configureIcon()); connect(&m_actionPreferences, &QAction::triggered, &m_timeTracker, &TimeTrackingWindow::slotEditPreferences); m_actionPreferences.setEnabled(true); m_actionImportFromXml.setText(tr("Import Database from Previous Export...")); connect(&m_actionImportFromXml, &QAction::triggered, &m_timeTracker, &TimeTrackingWindow::slotImportFromXml); m_actionExportToXml.setText(tr("Export Database...")); connect(&m_actionExportToXml, &QAction::triggered, &m_timeTracker, &TimeTrackingWindow::slotExportToXml); m_actionSyncTasks.setText(tr("Update Task Definitions...")); //the signature of QAction::triggered does not match slotSyncTasks connect(&m_actionSyncTasks,&QAction::triggered, &m_timeTracker, &TimeTrackingWindow::slotSyncTasksVerbose); m_actionImportTasks.setText(tr("Import and Merge Task Definitions...")); connect(&m_actionImportTasks, &QAction::triggered, &m_timeTracker, &TimeTrackingWindow::slotImportTasks); m_actionExportTasks.setText(tr("Export Task Definitions...")); connect(&m_actionExportTasks, &QAction::triggered, &m_timeTracker, &TimeTrackingWindow::slotExportTasks); m_actionCheckForUpdates.setText(tr("Check for Updates...")); #if 0 // TODO this role should be set to have the action in the app menu, but that // leads to duplicated entries, as each of the three main windows adds the action to the menu // and Qt doesn't prevent duplicates (#222) m_actionCheckForUpdates.setMenuRole(QAction::ApplicationSpecificRole); #endif connect(&m_actionCheckForUpdates, &QAction::triggered, &m_timeTracker, &TimeTrackingWindow::slotCheckForUpdatesManual); m_actionEnterVacation.setText(tr("Enter Vacation...")); connect(&m_actionEnterVacation, &QAction::triggered, &m_timeTracker, &TimeTrackingWindow::slotEnterVacation); m_actionActivityReport.setText(tr("Activity Report...")); m_actionActivityReport.setShortcut(Qt::CTRL + Qt::Key_A); connect(&m_actionActivityReport, &QAction::triggered, &m_timeTracker, &TimeTrackingWindow::slotActivityReport); m_actionWeeklyTimesheetReport.setText(tr("Weekly Timesheet...")); m_actionWeeklyTimesheetReport.setShortcut(Qt::CTRL + Qt::Key_R); connect(&m_actionWeeklyTimesheetReport, &QAction::triggered, &m_timeTracker, &TimeTrackingWindow::slotWeeklyTimesheetReport); m_actionMonthlyTimesheetReport.setText(tr("Monthly Timesheet...")); m_actionMonthlyTimesheetReport.setShortcut(Qt::CTRL + Qt::Key_M); connect(&m_actionMonthlyTimesheetReport, &QAction::triggered, &m_timeTracker, &TimeTrackingWindow::slotMonthlyTimesheetReport); // set up idle detection m_idleDetector = IdleDetector::createIdleDetector(this); Q_ASSERT(m_idleDetector); connect(m_idleDetector, SIGNAL(maybeIdle()), SLOT(slotMaybeIdle())); setHttpActionsVisible(Lotsofcake::Configuration().isConfigured()); // add default plugin path for deployment QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath() + QStringLiteral("/plugins")); if (QCoreApplication::applicationDirPath().endsWith(QLatin1String("MacOS"))) QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath() + QStringLiteral("/../plugins")); // set up command interface #ifdef CHARM_CI_SUPPORT m_cmdInterface = new CharmCommandInterface(this); #endif // CHARM_CI_SUPPORT // Ladies and gentlemen, please raise upon your seats - // the show is about to begin: emit goToState(StartingUp); }
void ApplicationCore::slotGoToConnectedState() { if (state() == Connecting) emit goToState(Connected); }
void ApplicationCore::slotQuitApplication() { emit goToState(Disconnecting); }
void IRoom::goToState( uint16_t nStateID ) { goToState(getRoomStateByID(nStateID)) ; }
void SummaryPageController::onParamsChangeRequest() { emit goToState(CentBaseLineInfoState); }
void ApplicationCore::enterStartingUpState() { emit goToState(Configuring); }
void SummaryPageController::onPlayAgain() { emit goToState(CentGameState); }
void SummaryPageController::onChangeGameRequest() { emit goToState(CentGameSelectState); }