void startDisplay(void) { ssd1306Init(SSD1306_SWITCHCAPVCC); ssd1306TurnOn(); display.state = DISPLAY_ON; ssd1306DrawString(40, 20, "OpenQS", Font_System7x8); chThdSleepMilliseconds(100); // Fails serDbg("startDisplay Complete\r\n"); while (true) { serDbg("Display OFF\r\n"); ssd1306TurnOff(); display.state = DISPLAY_OFF; while (!BUTTON_SEL) /* Wait until the select button is pressed */ { palTogglePad(GPIOC, GPIOC_LED4); /* Display heartbeat */ chThdSleepMilliseconds(250); } serDbg("Display ON\r\n"); ssd1306ClearScreen(); ssd1306TurnOn(); display.state = DISPLAY_ON; openMenu(&mainMenu); } }
LUserButtonPlugin::LUserButtonPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ button = new QToolButton(this); button->setAutoRaise(true); button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); button->setPopupMode(QToolButton::DelayedPopup); //make sure it runs the update routine first connect(button, SIGNAL(clicked()), this, SLOT(openMenu())); this->layout()->setContentsMargins(0,0,0,0); this->layout()->addWidget(button); menu = new QMenu(this); menu->setContentsMargins(1,1,1,1); connect(menu, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); usermenu = new UserWidget(this); connect(usermenu, SIGNAL(CloseMenu()), this, SLOT(closeMenu()) ); mact = new QWidgetAction(this); mact->setDefaultWidget(usermenu); menu->addAction(mact); button->setMenu(menu); connect(menu, SIGNAL(aboutToHide()), this, SLOT(updateButtonVisuals()) ); //Setup the global shortcut handling for opening the start menu connect(QApplication::instance(), SIGNAL(StartButtonActivated()), this, SLOT(shortcutActivated()) ); LSession::handle()->registerStartButton(this->type()); QTimer::singleShot(0,this, SLOT(OrientationChange())); //Update icons/sizes }
void MainMenu::update() { #ifdef PROJECT_SURVIVOR //#define GC_BUILD_2007 1 #endif #ifdef GC_BUILD_2007 // open loadgame menu if(firstUpdate && currentActive == NULL) { firstUpdate = false; std::list< OguiButton* >::iterator i = buttons.begin(); for( i = buttons.begin(); i != buttons.end(); ++i ) { if( (*i)->GetId() == COMMANDS_LOAD_GAME ) { currentActive = (*i); } } if( currentActive ) { openMenu( MenuCollection::MENU_TYPE_LOADGAMEMENU ); currentActive->SetFont( fonts->medium.highlighted ); } } #endif }
void Options::initializeButtons() { DownButton = new QPushButton(this); DownButton->setDown(false); DownButton->setGeometry(10,10,70,70); DownButton->setIconSize(QSize(70, 70)); DownButton->setIcon(QIcon(QPixmap(":/Buttons/textures/Menu/Buttons/Back/back.png"))); DownButton->setStyleSheet( "QPushButton {" "background-color: none;" "border: none;" "}" "QPushButton:hover {" "background-color: none;" "image: url(:/Buttons/textures/Menu/Buttons/Back/back2.png);" "}" "QPushButton:pressed {" "background-color: none;" "image: url(:/Buttons/textures/Menu/Buttons/Back/back2.png);" "}" "QPushButton:focus { " "background-color: none;" "border: none;" "image: url(:/Buttons/textures/Menu/Buttons/Back/back2.png);" " }" ); connect(DownButton, SIGNAL(clicked()), parent(), SLOT(openMenu())); DownButton->setCheckable(true); DownButton->setChecked(true); DownButton->setFocus(); DownButton->setDown(true); DownButton->setCheckable(false); }
void MenuEscape::handleInput(int in) { const int maxUiSelection = 3; move(selection + 2, 0); clrtoeol(); if(in == KEY_ESCAPE){ closeThisMenu(); } else if(in == Key::interact || in == '\n'){ switch (selection) { case 0: closeThisMenu(); break; case 1: openMenu(new MenuControls()); break; case 2: openMenu(new MenuSettings()); break; case 3: if(Settings::autoSave && menuTime > Settings::autoSaveDelay){ closeAllMenus(); } else { openMenu(new MenuYesNo("Do you want to save '" + menuGame->currentWorld->name + "' ?", menuGame->saveAnswer, true)); } break; default: break; } }else if(in == Key::uiUp){ selection--; if (selection < 0) { selection = maxUiSelection; } }else if(in == Key::uiDown){ selection++; if (selection > maxUiSelection) { selection = 0; } } }
void MainMenu::menuSurvival() { #ifdef PROJECT_SURVIVOR // start as single player when clicked from mainmenu SurvivalMenu::startAsCoop = false; #endif openMenu( MenuCollection::MENU_TYPE_SURVIVALMENU ); }
void MainMenu::menuLoadGame() { #ifdef PROJECT_SURVIVOR // start as single player when clicked from mainmenu LoadGameMenu::startAsCoop = false; #endif openMenu( MenuCollection::MENU_TYPE_LOADGAMEMENU ); }
GUI::Menu::Menu::Menu(boost::shared_ptr<Widget> parent_) { const sf::Image& logoImage(images.get(Path::findDataPath("graphics/logo.png"))); logoSprite.SetImage(logoImage); logoSprite.SetCenter(logoImage.GetWidth() / 2, 0); logoSprite.SetPosition(320, 1); openMenu(parent_); }
void MenuBarButton::onMouseMove(APoint m_pos, AVec d_pos, bool direct) { if(direct && menu->submenuOpen()) { openMenu(); //setFocus(true); //getTopWindow()->setFocus(true); } }
void Menu::openSubMenu(Menu* m) { if( this == m ) { openMenu(); return; } for(std::vector<Menu*>::iterator it = mSubMenus.begin(); it != mSubMenus.end(); ++it) { if((*it)->hasSubMenu(m)) { openMenu(); (*it)->openSubMenu(m); } else (*it)->closeMenu(); } }
void ContextMenu::openSubMenu(Menu* m) { openMenu(mWidgetDesc->widget_dimensions.position); for(std::vector<Menu*>::iterator it = mSubMenus.begin(); it != mSubMenus.end(); ++it) { if((*it)->hasSubMenu(m)) (*it)->openSubMenu(m); else (*it)->closeMenu(); } }
void MainState::play () { if(_state == PLAYING && _messages.empty()) { log().warning("Turn"); if(_fight->game_over()) { _state = GAME_OVER; } else if(_fight->tick_fight()) { _state = BOSS_TURN; updateMenu(); openMenu(_mainMenu.get()); } updateHealthBars(); } }
void tst_WindowsMobile::testMainWindowAndMenuBar() { if (qt_wince_is_smartphone()) QSKIP("This test is only for Windows Mobile", SkipAll); QProcess process; process.start("testQMenuBar.exe"); QCOMPARE(process.state(), QProcess::Running); QTest::qWait(6000); openMenu(); QTest::qWait(1000); takeScreenShot("testQMenuBar_current.png"); process.close(); compareScreenshots("testQMenuBar_current.png", ":/testQMenuBar_current.png"); }
//Main menu function void openMenu(menuStruct_t *menuToShow) { int8_t selectedIndex = 0; //Current selected item chThdSleepMilliseconds(50); drawMenu(menuToShow, selectedIndex); do { if (BUTTON_DOWN) { selectedIndex--; if (selectedIndex < 0) { selectedIndex = menuToShow->numberItems + 1; } drawMenu(menuToShow, selectedIndex); } else if (BUTTON_UP) { selectedIndex++; if (selectedIndex > (menuToShow->numberItems + 1)) { selectedIndex = 0; } drawMenu(menuToShow, selectedIndex); } else if (BUTTON_SEL) { if (selectedIndex > menuToShow->numberItems) /* Last item is "exit" */ { return; } else if (menuToShow->items[selectedIndex].handler != NULL) { menuToShow->items[selectedIndex].handler(); } else if (menuToShow->items[selectedIndex].subMenu != NULL) { openMenu(menuToShow->items[selectedIndex].subMenu); } drawMenu(menuToShow, selectedIndex); } chThdSleepMilliseconds(250); } while (true); return; }
void CursesAction::feedback() { if(isMenuOpen()) closeMenu(); else openMenu(); CursesMenu* parentMenu = qobject_cast<CursesMenu*>(parent()); if(parentMenu) { parentMenu->showChain(); if(!isMenuOpen()) QTimer::singleShot(5, this, SLOT(focus())); } blinkTimer.start(); activateTimer.start(300); }
void ImageNavigator::initialize() { setWindowFlags(Qt::Window | windowFlags()); setAttribute(Qt::WA_DeleteOnClose); QRect screenRect = QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen()); screenWidth = screenRect.width(); screenHeight = screenRect.height(); // qDebug() << "Screen Dimensions are " << screenWidth << " x " << screenHeight << endl; initializeTools(); initializeActions(); setBackgroundRole(QPalette::Dark); setForegroundRole(QPalette::Dark); navOrigin = QPoint(0, 0); scrollSpeed = 150; scrollBorder = 100; horizontalScrollBar()->setRange(0, 200); verticalScrollBar()->setRange(0, 200); horScroll = 0; verScroll = 0; imageScale = 1.0; // maximumValueSearchRange=10; // sigma = 3.0; // maxSearchMethod = mrcImage::maximum_value; spotSelectMode = false; latticeRefinementMode = false; createPathMode = false; ctfView = false; viewDisplayParameters = false; fftSelectionMode = false; viewport()->setMouseTracking(true); connect(menu, SIGNAL(aboutToShow()), this, SLOT(openMenu())); if (imageType != "fft") image->setVisible("realOverlay", true); resize(1024, 768); showMaximized(); //showFullScreen(); }
void ofxClickDownMenu::mousePressed(ofMouseEventArgs &mouse){ hl = hilight; if (haveChild) return; if (haveFChild)return; if (phase == PHASE_SELECT) return; if ((phase == PHASE_WAIT)&&(Enable)){ if (((mouse.button == 2)&&(OnlyRightClick))||(!OnlyRightClick)) { openMenu(mouse.x,mouse.y); } }else if (phase == PHASE_CLICK){ if (menu_focused != -1){ doFunction(); }else{ menu_focused = menus.size()-1; doFunction(); } } }
LStartButtonPlugin::LStartButtonPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ button = new QToolButton(this); button->setAutoRaise(true); button->setToolButtonStyle(Qt::ToolButtonIconOnly); button->setPopupMode(QToolButton::DelayedPopup); //make sure it runs the update routine first connect(button, SIGNAL(clicked()), this, SLOT(openMenu())); this->layout()->setContentsMargins(0,0,0,0); this->layout()->addWidget(button); menu = new QMenu(this); menu->setContentsMargins(1,1,1,1); startmenu = new StartMenu(this); connect(startmenu, SIGNAL(CloseMenu()), this, SLOT(closeMenu()) ); mact = new QWidgetAction(this); mact->setDefaultWidget(startmenu); menu->addAction(mact); button->setMenu(menu); connect(menu, SIGNAL(aboutToHide()), this, SLOT(updateButtonVisuals()) ); QTimer::singleShot(0,this, SLOT(OrientationChange())); //Update icons/sizes }
void MainMenu::menuNewGame() { #ifdef PROJECT_SURVIVOR // start as single player when clicked from mainmenu NewGameMenu::selectedGameplaySelection = NewGameMenu::COMMANDS_SINGLEPLAYER; #endif openMenu( MenuCollection::MENU_TYPE_NEWGAMEMENU ); /*if( fromGame ) { // abortCurrentGame(); } else { // setDifficulty( difficultActiveSelection ); // menuCollection->loadMission( 5 ); menuCollection->newMission(); }*/ //menuCollection->loadMission( 1 ); // game->gameUI->openLoadingWindow( game->singlePlayerNumber ); // hide(); }
LStartButtonPlugin::LStartButtonPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ button = new QToolButton(this); button->setAutoRaise(true); button->setToolButtonStyle(Qt::ToolButtonIconOnly); button->setPopupMode(QToolButton::DelayedPopup); //make sure it runs the update routine first connect(button, SIGNAL(clicked()), this, SLOT(openMenu())); this->layout()->setContentsMargins(0,0,0,0); this->layout()->addWidget(button); menu = new ResizeMenu(this); menu->setContentsMargins(1,1,1,1); connect(menu, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); connect(menu, SIGNAL(MenuResized(QSize)), this, SLOT(SaveMenuSize(QSize)) ); startmenu = new StartMenu(this); connect(startmenu, SIGNAL(CloseMenu()), this, SLOT(closeMenu()) ); connect(startmenu, SIGNAL(UpdateQuickLaunch(QStringList)), this, SLOT(updateQuickLaunch(QStringList))); menu->setContents(startmenu); QSize saved = LSession::handle()->DesktopPluginSettings()->value("panelPlugs/"+this->type()+"/MenuSize", QSize(0,0)).toSize(); if(!saved.isNull()){ startmenu->setFixedSize(saved); } //re-load the previously saved value button->setMenu(menu); connect(menu, SIGNAL(aboutToHide()), this, SLOT(updateButtonVisuals()) ); QTimer::singleShot(0,this, SLOT(OrientationChange())); //Update icons/sizes QTimer::singleShot(0, startmenu, SLOT(ReLoadQuickLaunch()) ); }
LClock::LClock(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ button = new QToolButton(this); //RotateToolButton(this); button->setAutoRaise(true); button->setToolButtonStyle(Qt::ToolButtonTextOnly); button->setStyleSheet("font-weight: bold;"); button->setPopupMode(QToolButton::DelayedPopup); //make sure it runs the update routine first button->setMenu(new QMenu()); //button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); //this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); connect(button, SIGNAL(clicked()), this, SLOT(openMenu())); connect(button->menu(), SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); calendar = new QCalendarWidget(this); calAct = new QWidgetAction(this); calAct->setDefaultWidget(calendar); TZMenu = new QMenu(this); connect(TZMenu, SIGNAL(triggered(QAction*)), this, SLOT(ChangeTZ(QAction*)) ); //Now assemble the menu button->menu()->addAction(calAct); button->menu()->addMenu(TZMenu); this->layout()->setContentsMargins(0,0,0,0); //reserve some space on left/right this->layout()->addWidget(button); //Setup the timer timer = new QTimer(); //Load all the initial settings updateFormats(); LocaleChange(); ThemeChange(); OrientationChange(); //Now connect/start the timer connect(timer,SIGNAL(timeout()), this, SLOT(updateTime()) ); connect(QApplication::instance(), SIGNAL(SessionConfigChanged()), this, SLOT(updateFormats()) ); timer->start(); }
void ContextMenu::show(const Point& position) { openMenu(position); }
void MainMenu::menuCoop() { openMenu( MenuCollection::MENU_TYPE_COOPMENU ); }
void WatchCore::doInput() { while (Serial.available()) { String data = Serial.readStringUntil(':'); /* Try getting the time from serial. */ if (data.endsWith("Time")) { const time_t DEFAULT_TIME = 1357041600; time_t t = Serial.parseInt(); if (t > DEFAULT_TIME) setCurrentTime(t); } } uint32_t lft = 0; uint32_t rgt = 0; uint32_t up = 0; uint32_t dwn = 0; uint8_t lftNew = 0; uint8_t rgtNew = 0; uint8_t upNew = 0; uint8_t dwnNew = 0; /* Poll the hall effect sensors for any changes over 8 milliseconds. */ for(uint32_t time = millis() + 4; time > millis();) { lftNew = digitalReadFast(TRACKBALL_LFT); rgtNew = digitalReadFast(TRACKBALL_RGT); upNew = digitalReadFast(TRACKBALL_UP); dwnNew = digitalReadFast(TRACKBALL_DWN); lft += lftLast != lftNew; rgt += rgtLast != rgtNew; up += upLast != upNew; dwn += dwnLast != dwnNew; lftLast = lftNew; rgtLast = rgtNew; upLast = upNew; dwnLast = dwnNew; } /* LOW is pressed. */ if (digitalRead(TRACKBALL_BTN) == LOW) { if (buttonTime == 0) buttonTime = now(); } else { if(buttonTime != 0) { /* If the buzzer is enabled all pressing a button does is stop it. */ if (buzzer > now()) { buzzer = 0; } else if (currentMenu != nullptr) { if (currentMenu[currentMenuItem].callback != nullptr && currentMenu[currentMenuItem].callback(modes[currentMode], *this)) currentMenu = nullptr; else if (currentMenu[currentMenuItem].subMenu != nullptr) openMenu(currentMenu[currentMenuItem].subMenu); } else { modes[currentMode]->buttonPress(now() - buttonTime); } } buttonTime = 0; } if (currentMenu != nullptr) { currentMenuItem += dwn - up; if (currentMenuItem < 0) currentMenuItem = currentMenuLength - 1; else if (currentMenuItem >= currentMenuLength) currentMenuItem = 0; if (lft > 0) popMenu(); else if (rgt > 0 && currentMenu[currentMenuItem].subMenu != nullptr) openMenu(currentMenu[currentMenuItem].subMenu); } else { if (lft > 0) modes[currentMode]->left(lft); if (rgt > 0) modes[currentMode]->right(rgt); if (up > 0) modes[currentMode]->up(up); if (dwn > 0) modes[currentMode]->down(dwn); } }
GraphicsScene::GraphicsScene(GameType type, QSize fieldSize, QRect sceneSize): _type(type), QGraphicsScene(sceneSize) { int fszX =fieldSize.width(); int fszY =fieldSize.height(); cerr << "GraphicsScene : scene size : " << this->width() << ", " << this->height() << endl; int fct = max(fszX, fszY); int sz = min(width()/(fct+3), height()/(fct+3)); _scene = new Scene(QSize(width(), height()), QPoint(sz*1.5,sz*1.5), sz, fszX, fszY); _figures = new PlayersFigures(_scene); _gameRules = new GameRules(fszX, fszY, _figures); _timer = new QTimer(this); connect(_timer,SIGNAL(timeout()), this ,SLOT(update())); // set "Skip turn" button: _skipTurnButton = new QPushButton(tr("Skip turn")); _skipTurnButton->resize(80,40); connect(_skipTurnButton, SIGNAL(clicked()), SLOT(nextTurn())); _skipTurnButton->move(width() - 100, height() - 50); _skipTurnButton->setWindowOpacity(0.8); // set "Menu" button _menuOpenButton = new QPushButton(tr("Menu")); _menuOpenButton->resize(80,40); connect(_menuOpenButton, SIGNAL(clicked()), SLOT(openMenu())); _menuOpenButton->move((0.1)*sz, sz/3); _menuOpenButton->setWindowOpacity(0.8); // set "Menu" : _dialogMenu = new DialogMenu(); connect(_dialogMenu, SIGNAL(sendCloseMenu()), SLOT(closeMenu())); connect(_dialogMenu, SIGNAL(sendUndoLastMove()), SLOT(undoLastMove())); connect(_dialogMenu, SIGNAL(sendResetGame()), SLOT(resetGame())); connect(this, SIGNAL(sendAddToRedFigures(int)), _dialogMenu, SLOT(addToRedFigures(int))); connect(this, SIGNAL(sendAddToBlueFigures(int)), _dialogMenu, SLOT(addToBlueFigures(int))); _dialogMenu->move(_menuOpenButton->pos()); _dialogMenu->setWindowOpacity(0.85); _dialogMenu->hide(); QWidget * _dialogMenuWidget = dynamic_cast<QWidget *>(_dialogMenu); // add all widgets in GraphicsScene as QWidget *widgets[] = { _skipTurnButton, _menuOpenButton, _dialogMenuWidget }; for (uint i = 0; i < sizeof(widgets) / sizeof(*widgets); ++i) { QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0); proxy->setWidget(widgets[i]); addItem(proxy); } // setup ComputerPlayer: if (_type==HumanVsMachine){ _computerType = 1; _computerMind = new ComputerPlayer(_gameRules, _computerType); }else if (_type==MachineVsHuman){ _computerType = 0; _computerMind = new ComputerPlayer(_gameRules, _computerType); }else if (_type == MachineVsMachine){ _computerMind = new ComputerPlayer(_gameRules, 0); _computerMind2 = new ComputerPlayer(_gameRules, 1); } // initialize(): _scene->initialize(); _gameRules->displayGrid(); _timer->start(100); // start computerMind: if (_type==MachineVsHuman || _type==MachineVsMachine){ QPoint p = _computerMind->suggest(); cerr << "suggest: " << p.x() << ", " << p.y() << endl; if (p.x() >= 0 && p.y() >= 0){ moveOnPosition(p); }else{ // skip turn: nextTurn(); } } }
void LUserButtonPlugin::shortcutActivated(){ if(LSession::handle()->registerStartButton(this->type())){ if(menu->isVisible()){ closeMenu(); } else{ openMenu(); } } }
void MainMenu::menuProfiles() { openMenu( MenuCollection::MENU_TYPE_PROFILESMENU ); }
void MainMenu::menuOptions() { openMenu( MenuCollection::MENU_TYPE_OPTIONSMENU ); }
void MainMenu::menuCredits() { openMenu( MenuCollection::MENU_TYPE_CREDITSMENU ); // assert( false && "Credits:" ); }
void MenuBarButton::toggleMenu() { if(menuOpen) closeMenu(); else openMenu(); }