/** Method to handle key presses. WASD keys move the main character, arrow keys shoot fireballs, and other keys can access start, pause, and quit */ void MainWindow::keyPressEvent(QKeyEvent *e) { if(gameInProgress) { if(e->key() == Qt::Key_D) { game->getNinja()->moveRight(); } if(e->key() == Qt::Key_A) { game->getNinja()->moveLeft(); } if(e->key() == Qt::Key_W) { game->getNinja()->jump(); } if(e->key() == Qt::Key_Right) { game->fireball(0); } if(e->key() == Qt::Key_Left) { game->fireball(1); } if(e->key() == Qt::Key_Up) { game->fireball(2); } if(e->key() == Qt::Key_Down) { game->fireball(3); } if(e->key() == Qt::Key_P) { pause(); } } if(e->key() == Qt::Key_F1) { startSlot(); } if(e->key() == Qt::Key_Escape) { quitGame(); } }
void ServiceManager::ProgramInit(QString chroot, QString IP) { // Set any warden stuff wDir = chroot; wIP = IP; listServices->setColumnHidden(0, true); listServices->setColumnHidden(1, true); pushStart->setEnabled(FALSE); pushStop->setEnabled(FALSE); pushRestart->setEnabled(FALSE); pushEnableStartup->setEnabled(FALSE); pushDisableStartup->setEnabled(FALSE); // Connect the buttons connect( pushStart, SIGNAL( clicked() ), this, SLOT( startSlot() ) ); connect( pushStop, SIGNAL( clicked() ), this, SLOT( stopSlot() ) ); connect( pushRestart, SIGNAL( clicked() ), this, SLOT( restartSlot() ) ); connect( pushEnableStartup, SIGNAL( clicked() ), this, SLOT( enableSlot() ) ); connect( pushDisableStartup, SIGNAL( clicked() ), this, SLOT( disableSlot() ) ); // Connect the list box connect( listServices, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT( listSelectionChanged() ) ); // Start loading the various service files populateList(); // Start checking the status of these services currentCheckRunningItem = new QTreeWidgetItemIterator(listServices); checkRunning(); // Start checking if services are enabled checkEnabled(); if ( ! wDir.isEmpty() ) textTopLabel->setText(tr("Managing services for Warden IP:") + " " + wIP); }
/** Default constructor for MainWindow */ MainWindow::MainWindow() { error = new QErrorMessage; inputName = new QInputDialog(); inputName->setLabelText("Please enter your name"); inputName->setInputMode(QInputDialog::TextInput); //MENU BAR mb = menuBar(); file = new QMenu("File"); quit = new QAction("Quit", file); start = new QAction("Start Game", file); file->addAction(start); file->addAction(quit); connect(quit, SIGNAL(triggered()), this, SLOT(quitGame())); connect(start, SIGNAL(triggered()), this, SLOT(startSlot())); mb->addMenu(file); //TOOL BAR toolBar = new QToolBar(); startButton = new QPushButton("Start (F1)"); quitButton = new QPushButton("Quit (Esc)"); pauseButton = new QPushButton("Pause/Resume (P)"); connect(startButton, SIGNAL(clicked()), this, SLOT(startSlot())); connect(quitButton, SIGNAL(clicked()), this, SLOT(quitGame())); connect(pauseButton, SIGNAL(clicked()), this, SLOT(pause())); toolBar->addWidget(startButton); toolBar->addSeparator(); toolBar->addWidget(quitButton); toolBar->addSeparator(); toolBar->addWidget(pauseButton); addToolBar(toolBar); //TOP WIDGET display = new QDockWidget; displayWidget = new DisplayWidget; display->setWidget(displayWidget); addDockWidget(Qt::TopDockWidgetArea, display); display->setMaximumSize(1200, 100); display->setFeatures(0x00); //GAME DISPLAY title = new InfoScreen(0); gameOver = new InfoScreen(1); setCentralWidget(title); gameInProgress = 0; setMinimumSize(1200, 700); setMaximumSize(1200, 700); paused = 0; setWindowTitle("MAGIC NINJA"); setFocus(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), settings(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "settings.ini", QSettings::IniFormat), first(true), started(true) { srand(QDateTime::currentDateTime().toTime_t()); ui->setupUi(this); ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables); // Axes ui->customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime); ui->customPlot->xAxis->setDateTimeFormat("hh:mm:ss"); ui->customPlot->xAxis->setAutoTickStep(false); ui->customPlot->xAxis->setTickStep(2); ui->customPlot->xAxis->setLabel("Time"); ui->customPlot->xAxis->setLabelPadding(0); ui->customPlot->xAxis->setSelectableParts(QCPAxis::spAxis); ui->customPlot->yAxis->setRange(-20, 20); ui->customPlot->yAxis->setLabel("Acceleration (m/s^2)"); ui->customPlot->yAxis->setLabelPadding(0); ui->customPlot->yAxis->setSelectableParts(QCPAxis::spAxis); ui->customPlot->axisRect()->setupFullAxesBox(); // Legend ui->customPlot->legend->setVisible(true); QFont legendFont = font(); legendFont.setPointSize(10); ui->customPlot->legend->setFont(legendFont); ui->customPlot->legend->setSelectedFont(legendFont); ui->customPlot->legend->setSelectableParts(QCPLegend::spNone); // X, Y, Z reading graphs ui->customPlot->addGraph(); // blue line ui->customPlot->graph(0)->setPen(QPen(Qt::blue)); ui->customPlot->graph(0)->setName("X"); ui->customPlot->graph(0)->setSelectable(false); ui->customPlot->addGraph(); // red line ui->customPlot->graph(1)->setPen(QPen(Qt::red)); ui->customPlot->graph(1)->setName("Y"); ui->customPlot->graph(1)->setSelectable(false); ui->customPlot->addGraph(); // green line ui->customPlot->graph(2)->setPen(QPen(Qt::green)); ui->customPlot->graph(2)->setName("Z"); ui->customPlot->graph(2)->setSelectable(false); // Scale in a particular direction when an axis is selected connect(ui->customPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress())); connect(ui->customPlot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel())); // Make bottom and left axes transfer their ranges to top and right axes: connect(ui->customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->xAxis2, SLOT(setRange(QCPRange))); connect(ui->customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->yAxis2, SLOT(setRange(QCPRange))); // Adjust the tick marks on x-axis scale connect(ui->customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); // Context menu popup ui->customPlot->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->customPlot, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint))); // Buttons connect(ui->buttonStartStop, SIGNAL(released()), this, SLOT(pressedStartStop())); connect(ui->buttonAnalyze, SIGNAL(released()), this, SLOT(pressedAnalyze())); connect(ui->buttonSave, SIGNAL(released()), this, SLOT(pressedSave())); // Setup accelerometer accelerometer = new QAccelerometer(this); accelerometer->setAccelerationMode(QAccelerometer::Combined); accelerometer->setDataRate(30); accelerometer->addFilter(&filter); // We'll always keep it running since on the phone apparently calling // stop makes the whole application freeze. Thus, we'll just start/stop // recording data not actually requesting data from the accelerometer accelerometer->start(); // Button enabled/disabled coloring button_enabled = ui->buttonStartStop->palette(); button_disabled = ui->buttonStartStop->palette(); button_enabled.setColor(QPalette::Button, QColor(Qt::white)); button_disabled.setColor(QPalette::Button, QColor(Qt::lightGray)); // Load previous settings bool timed = settings.value("timed").toBool(); ui->checkBoxTimed->setChecked(timed); // When we start the application, either start it automatically if we're // not using a fixed period of time or set it up so we can press Start to // start it if we are using a fixed period of time if (timed) stop(); else start(); // Setup a timer that repeatedly calls MainWindow::realtimeDataSlot connect(&dataTimer, SIGNAL(timeout()), this, SLOT(realtimeDataSlot())); // Stop it after a certain period of time connect(&finishTimer, SIGNAL(timeout()), this, SLOT(finishSlot())); // Start with delay to reduce effect of touching the "Start" // button when recording for set amount of time connect(&startTimer, SIGNAL(timeout()), this, SLOT(startSlot())); }
QSslConfiguration newSslConfiguration2 = QSslConfiguration::defaultConfiguration(); newCertificates2 = newSslConfiguration2.caCertificates(); foreach (QSslCertificate c, newCertificates2) { QStringList list = QStringList(c.subjectInfo(QSslCertificate::CommonName)); for(QStringList::iterator i = list.begin(); i != list.end(); i++){ qDebug(i->toLatin1()); } } QObject::connect(manager, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), this, SLOT(authenticationSlot(QNetworkReply*, QAuthenticator*))); QObject::connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(finishedSlot(QNetworkReply*))); // Starte den Login nach 100ms // Bei 0ms wird der Shot unter Mac nicht ausgeführt!? QTimer::singleShot(100, this, SLOT(startSlot())); } LoginTester::~LoginTester() { delete ui; } void LoginTester::authenticationSlot(QNetworkReply* , QAuthenticator* authenticator) { qDebug("authenticationSlot call"); // Logindaten nur ausfüllen, falls nicht mehr als die maximale Anzahl an Versuchen durchgeführt wurden if (tryCounter < maxTries) { authenticator->setUser(username); authenticator->setPassword(password);