MainWindow::MainWindow( GameEngine * currentEngine) : isGameLaunched(false),keystate() { currentGameEngine = currentEngine ; // menubar creation menuBar = new QMenuBar(); QMenu * gameMenu = menuBar->addMenu("Game"); gameMenu->addAction("New Game",this,SLOT(diplayNewGame())); gameMenu->addAction("Stop Game",currentGameEngine, SLOT(stop())); gameMenu->addAction("Options",this, SLOT(displayOptions())); gameMenu->addSeparator(); gameMenu->addAction("Quit",qApp,SLOT(quit())); QMenu * helpMenu = menuBar->addMenu("Help"); helpMenu->addAction("About chmeup",this,SLOT(displayAbout())); setFixedSize(screenWidthGlobal + 2 * BORDER_WIDTH ,screenHeightGlobal + menuBar->sizeHint().height() + 2* BORDER_HEIGHT); // central widget setCentralWidget(&screen); connect(currentGameEngine, SIGNAL(updateUI()), this, SLOT(update())) ; connect(currentGameEngine, SIGNAL(requestKeyUI()),this,SLOT(keysNeeded())); connect(currentGameEngine, SIGNAL(displayGameOverScreen()), this, SLOT(gameOverDisplay())); connect(currentGameEngine, SIGNAL(displayGameWonScreen()),this,SLOT(gameWonDisplay())); connect(this,SIGNAL(sendKeys(KeyPressedFrame * )),currentGameEngine,SLOT(getKeyFrame(KeyPressedFrame *))); connect(this,SIGNAL(sendPause()), currentGameEngine, SLOT(pause())); setMenuBar(menuBar); }
void MainWindow::keyPressEvent(QKeyEvent* event) { if(isGameLaunched) { int currentKey = event->key() ; if(currentKey == keyType.upKey){ event->accept(); keystate.up = true ; } else if(currentKey == keyType.leftKey){ event->accept(); keystate.left = true ; } else if(currentKey == keyType.downKey){ event->accept(); keystate.down = true ; } else if(currentKey == keyType.rightKey){ event->accept(); keystate.right = true ; } else if(currentKey == keyType.shootKey){ event->accept(); keystate.shoot = true ; } else if(currentKey == keyType.pauseKey){ event->accept(); emit sendPause(); } else event->ignore(); } }
UniversalPana::UniversalPana(KInstance *inst,QObject *parent,QWidget *widgetParent, QString &desktopName, const char* name): KonqSidebarPlugin(inst,parent,widgetParent,desktopName,name) { KGlobal::iconLoader()->addAppDir( "pana" ); widget = new panaWidget( widgetParent ); // widgetParent->resize(580,300); KToolBar *topBar = new KToolBar( widget, "Topbar" ); topBar->setIconSize(16); topBar->insertButton( "today", 0, SIGNAL( clicked() ), this, SLOT( currentTrack() ) ); topBar->insertButton( "document", 0, SIGNAL( clicked() ), this, SLOT( lyrics() ) ); topBar->insertButton( "personal", 0, SIGNAL( clicked() ), this, SLOT( wiki() ) ); browser = new KHTMLPart(widget, "widget-browser"); //browser=new KHTMLPart(widget); kdDebug() << "parentPart() << " << browser->parentPart() << endl; browser->setDNDEnabled( true ); browser->setEncoding( "utf8", true ); updateBrowser( HTML_FILE ); browser->view()->installEventFilter( widget ); panaDCOP = new DCOPClient(); panaDCOP->attach(); playerStub = new PanaPlayerInterface_stub( panaDCOP, "pana", "player"); playlistStub = new PanaPlaylistInterface_stub( panaDCOP, "pana", "playlist"); contextStub = new PanaContextBrowserInterface_stub (panaDCOP, "pana", "contextbrowser"); KToolBar* toolBar=new KToolBar(widget, "PlayerControls"); toolBar->setIconSize(16); toolBar->insertButton( "player_start",0, SIGNAL( clicked() ), this, SLOT( sendPrev() ) ); toolBar->insertButton( "player_play", 0, SIGNAL( clicked() ), this, SLOT( sendPlay() ) ); toolBar->insertButton( "player_pause",0, SIGNAL( clicked() ), this, SLOT( sendPause() ) ); toolBar->insertButton( "player_stop", 0, SIGNAL( clicked() ), this, SLOT( sendStop() ) ); toolBar->insertButton( "player_end", 0, SIGNAL( clicked() ), this, SLOT( sendNext() ) ); toolBar->insertSeparator(); toolBar->insertButton( "arts", 0, SIGNAL( clicked() ), this, SLOT( sendMute() ) ); vol_slider = new QSlider(0,100,1,0,Qt::Horizontal, toolBar,"volume"); vol_slider->setLineStep(2); connect(vol_slider, SIGNAL( valueChanged(int) ), this, SLOT(volChanged(int ) ) ); toolBar->insertWidget(1,2, vol_slider); fileInfo = new QFileInfo(HTML_FILE); QTimer *t = new QTimer( this ); connect( t, SIGNAL(timeout()), SLOT(updateStatus() ) ); t->start( 2000, false ); kdDebug() << "Connecting widget signal" << endl; connect( widget, SIGNAL( emitURL( const KURL &)), this, SLOT( openURLRequest( const KURL &) ) ); connect( browser->browserExtension(), SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ), this, SLOT( openURLRequest( const KURL & ) ) ); widget->show(); }
void Tx433_Nexa::sendPackets(String grp, String dev, String onoff) { for (int i = 0; i < RETRANSMIT; i++) { sendSync(); sendCode(TxCode, TxCode.length()); sendCode(grp, grp.length()); sendCode(onoff, onoff.length()); sendCode(ChCode, ChCode.length()); sendCode(dev, dev.length()); sendPause(); } }