bool RenderWidget::eventFilter(QObject* obj, QEvent* event) { // handle event in this widget, is there a better way to do this? if (event->type() == QEvent::MouseButtonPress) mousePressEvent(static_cast<QMouseEvent*>(event)); if (event->type() == QEvent::MouseButtonRelease) mouseReleaseEvent(static_cast<QMouseEvent*>(event)); if (event->type() == QEvent::MouseMove) mouseMoveEvent(static_cast<QMouseEvent*>(event)); if (event->type() == QEvent::KeyPress) keyPressEvent(static_cast<QKeyEvent*>(event)); if (event->type() == QEvent::KeyRelease) keyReleaseEvent(static_cast<QKeyEvent*>(event)); if (event->type() == QEvent::Wheel) wheelEvent(static_cast<QWheelEvent *>(event)); // Always pass the event on to GLWidget, i.e. to OSG event queue return QObject::eventFilter(obj, event); }
void PlaylistView::RemoveSelected() { int rows_removed = 0; QItemSelection selection(selectionModel()->selection()); if (selection.isEmpty()) { return; } // Store the last selected row, which is the last in the list int last_row = selection.last().top(); // Sort the selection so we remove the items at the *bottom* first, ensuring // we don't have to mess around with changing row numbers qSort(selection.begin(), selection.end(), CompareSelectionRanges); for (const QItemSelectionRange& range : selection) { if (range.top() < last_row) rows_removed += range.height(); model()->removeRows(range.top(), range.height(), range.parent()); } int new_row = last_row - rows_removed; // Index of the first column for the row to select QModelIndex new_index = model()->index(new_row, 0); // Select the new current item, we want always the item after the last // selected if (new_index.isValid()) { // Workaround to update keyboard selected row, if it's not the first row // (this also triggers selection) if (new_row != 0) keyPressEvent( new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier)); // Update visual selection with the entire row selectionModel()->select(new_index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } else { // We're removing the last item, select the new last row selectionModel()->select( model()->index(model()->rowCount() - 1, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } }
bool MapViewerWidget::eventFilter(QObject *obj, QEvent *event) { // Check for Keyboard Events if (event->type() == QEvent::KeyPress) { // Cast to our keyboard event QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); keyPressEvent( keyEvent ); qDebug("Ate key press %d", keyEvent->key()); return true; } // Otherwise, pass on else { // standard event processing return QObject::eventFilter(obj, event); } }
bool CanvasQt::event(QEvent *e) { switch (e->type()) { case QEvent::KeyPress: keyPressEvent(static_cast<QKeyEvent*>(e)); return true; case QEvent::KeyRelease: keyReleaseEvent(static_cast<QKeyEvent*>(e)); return true; case QEvent::MouseButtonPress: if(!gestureMode_) mousePressEvent(static_cast<QMouseEvent*>(e)); return true; case QEvent::MouseButtonRelease: if(!gestureMode_) mouseReleaseEvent(static_cast<QMouseEvent*>(e)); return true; case QEvent::MouseMove: if(!gestureMode_) mouseMoveEvent(static_cast<QMouseEvent*>(e)); return true; case QEvent::Wheel: wheelEvent(static_cast<QWheelEvent*>(e)); return true; #ifndef QT_NO_GESTURES case QEvent::TouchBegin: case QEvent::TouchEnd: case QEvent::TouchUpdate: touchEvent(static_cast<QTouchEvent*>(e)); return true; case QEvent::Gesture: return gestureEvent(static_cast<QGestureEvent*>(e)); #endif #ifdef USE_QWINDOW case QEvent::UpdateRequest: paintGL(); return true; #endif default: return QGLWindow::event(e); } }
bool QShortcutButton::event(QEvent *e) { if (d->isRecording == true && e->type() == QEvent::KeyPress) { keyPressEvent(static_cast<QKeyEvent*>(e)); return true; } if (d->isRecording && e->type() == QEvent::ShortcutOverride) { e->accept(); return true; } if (d->isRecording == true && e->type() == QEvent::FocusOut) { d->cancelRecording(); return true; } return QPushButton::event(e); }
bool GraphicsViewPolylineInput_non_templated_base::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::GraphicsSceneMousePress) { QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event); if(!mousePressEvent(mouseEvent)) { // standard event processing if mousePressEvent has returned false return QObject::eventFilter(obj, event); } } else if (event->type() == QEvent::GraphicsSceneMouseMove) { QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event); mouseMoveEvent(mouseEvent); return QObject::eventFilter(obj, event); } else if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); if(!keyPressEvent(keyEvent)) { return QObject::eventFilter(obj, event); } } // standard event processing if keyPressEvent has returned false return QObject::eventFilter(obj, event); }
//----------------------------------------------------------------------------- // Function: eventFilter() //----------------------------------------------------------------------------- bool AssistedLineEdit::eventFilter(QObject* /*obj*/, QEvent* e) { // Cancel the assist if the main window is moved or resized. if (contentAssist_->isContentShown()) { if (e->type() == QEvent::Move || e->type() == QEvent::Resize) { contentAssist_->cancel(); } else if (e->type() == QEvent::KeyPress) { QKeyEvent* keyEvent = static_cast<QKeyEvent*>(e); if (keyEvent->key() == Qt::Key_Tab) { keyPressEvent(keyEvent); } } } return false; }
void MSWidget::event(const XEvent *pEvent_) { if (!_eventOverride||!(*_eventOverride)(pEvent_->type)) switch (pEvent_->type) { case Expose: expose(pEvent_); break; case NoExpose: noExpose(pEvent_); break; case GraphicsExpose: graphicsExpose(pEvent_); break; case VisibilityNotify: visibilityNotify(pEvent_); break; case EnterNotify: if (_server->eventGrabbed(pEvent_,this)==MSTrue) enterNotify(pEvent_); break; case LeaveNotify: leaveNotify(pEvent_); break; case ConfigureNotify: configureNotify(pEvent_); break; case CreateNotify: createNotify(pEvent_); break; case DestroyNotify: destroyNotify(pEvent_); break; case ReparentNotify: reparentNotify(pEvent_); break; case MapNotify: mapNotify(pEvent_); break; case UnmapNotify: unmapNotify(pEvent_); break; case PropertyNotify: propertyNotify(pEvent_); break; case SelectionNotify: selectionNotify(pEvent_); break; case SelectionClear: selectionClear(pEvent_); break; case SelectionRequest: selectionRequest(pEvent_); break; case ClientMessage: clientMessage(pEvent_); break; case MotionNotify: if (_server->eventGrabbed(pEvent_,this)==MSTrue) motionNotify(pEvent_); break; case ButtonRelease: if (_server->eventGrabbed(pEvent_,this)==MSTrue) buttonRelease(pEvent_); break; case ButtonPress: if (_server->eventGrabbed(pEvent_,this)==MSTrue) buttonPress(pEvent_); else _server->bell(); break; case KeyRelease: if (_server->eventGrabbed(pEvent_,this)==MSTrue) keyRelease(pEvent_); break; case KeyPress: if (_server->eventGrabbed(pEvent_,this)==MSTrue) keyPressEvent(pEvent_); else _server->bell(); break; case FocusIn: focusInEventNotify(pEvent_); break; case FocusOut: focusOutEventNotify(pEvent_); break; default: break; } // this event handler is intended to support the mstk builder // i.e. it is easier to get events this way rather than // subclass every widget and override the event methods if (_eventHandler!=0) (*_eventHandler)(this,pEvent_,_eventHandlerData); }
bool GLWidget::eventFilter(QObject*, QEvent* event) { switch (event->type()) { case QEvent::KeyPress: case QEvent::KeyRelease: case QEvent::ShortcutOverride: { QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event); if (keyEvent->key() == Qt::Key_Alt || keyEvent->key() == Qt::Key_Meta) { if (event->type() == QEvent::KeyPress) { keyPressEvent(keyEvent); } else if (event->type() == QEvent::KeyRelease) { keyReleaseEvent(keyEvent); } else { QGLWidget::event(event); } return true; } } default: break; } return false; }
bool MainView::event( QEvent *event ) { switch (event->type()) { case QEvent::KeyPress : { QKeyEvent *k = (QKeyEvent *)event; keyPressEvent(k); if (k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab ) event->accept(); return true; } break; case QEvent::KeyRelease : { QKeyEvent *k = (QKeyEvent *)event; keyReleaseEvent(k); if (k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab ) event->accept(); return true; } break; default: return View::event( event ); } }
bool Form3::eventFilter(QObject *target, QEvent *event) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = (QKeyEvent *)event; int key = keyEvent->key(); if (key == Qt::Key_Left || key == Qt::Key_Right ) { //focusNextPrevChild(true); keyPressEvent((QKeyEvent*)event); return true; } else { int ix = ui->stackedWidget->currentIndex(); if(ix==19) { if(key == Qt::Key_Down) ui->dial->setValue( ui->dial->value()>0?ui->dial->value() - 1:0); if(key == Qt::Key_Up) ui->dial->setValue( ui->dial->value() < 12? ui->dial->value() + 1 : 12); return true; } } } return QWidget::eventFilter(target, event); }
bool ShortcutWidget::event(QEvent * e) { switch (e->type()) { case QEvent::FocusOut: has_cursor_ = false; setFrameShadow(QFrame::Raised); break; case QEvent::FocusIn: has_cursor_ = true; setFrameShadow(QFrame::Sunken); break; case QEvent::ShortcutOverride: keyPressEvent(static_cast<QKeyEvent *>(e)); return true; case QEvent::KeyRelease: case QEvent::Shortcut: case QEvent::KeyPress: return true; default: break; } return QLabel::event(e); }
bool RangeProfilePlotManager::eventFilter(QObject* pObj, QEvent* pEvent) { PlotView* pView = dynamic_cast<PlotView*>(pObj); if (pView == NULL || pView->getCurrentMouseMode() != mpMode) { return QObject::eventFilter(pObj, pEvent); } switch(pEvent->type()) { case QEvent::MouseButtonPress: return mousePressEvent(pView, static_cast<QMouseEvent*>(pEvent)); case QEvent::MouseButtonRelease: return mouseReleaseEvent(pView, static_cast<QMouseEvent*>(pEvent)); case QEvent::MouseMove: return mouseMoveEvent(pView, static_cast<QMouseEvent*>(pEvent)); case QEvent::Wheel: return wheelEvent(pView, static_cast<QWheelEvent*>(pEvent)); case QEvent::KeyPress: return keyPressEvent(pView, static_cast<QKeyEvent*>(pEvent)); default: ; // do nothing } return QObject::eventFilter(pObj, pEvent); }
void ShopCategoriesScreen::drawList() { empt = false; listBox->getChildren().clear(); if (screenType == ST_AUCTIONS) { label = Util::createSubLabel("Create New Auction"); label->addWidgetListener(this); listBox->add(label); } for(Vector<String>::iterator itr = category.begin(); itr != category.end(); itr++) { label = Util::createSubLabel(itr->c_str()); label->addWidgetListener(this); listBox->add(label); } if (categories.size() > 1) { listBox->setSelectedIndex(0); } else if (categories.size() == 1) { listBox->setSelectedIndex(0); if ((screenType != ST_AUCTIONS)&&(screenType != ST_RANKING)&&(screenType != ST_FRIEND)) { keyPressEvent(MAK_FIRE); } } else { label = Util::createSubLabel("Empty"); //label->addWidgetListener(this); empt = true; listBox->add(label); //listBox->setSelectedIndex(0); } if (screenType == ST_FREEBIE) notice->setCaption("Received: 150 credits and a free starter pack."); }
void ribi::dws::QtMenuDialog::OnJoystickCheck() { #ifdef USE_SFML_FOR_JOYSTICK_SUPPORT sf::Joystick::update(); const int joystick_index{0}; if (sf::Joystick::isConnected(joystick_index)) { if (sf::Joystick::hasAxis(joystick_index, sf::Joystick::Y)) { const double dy{sf::Joystick::getAxisPosition(joystick_index, sf::Joystick::Y)}; if (dy > 50.0) { this->focusNextChild(); } if (dy < -50.0) { this->focusPreviousChild(); } } if (sf::Joystick::isButtonPressed(joystick_index,0)) { auto key = CreateEnter(); keyPressEvent(&key); } } #endif // USE_SFML_FOR_JOYSTICK_SUPPORT }
bool QDeclarativeViewInspector::eventFilter(QObject *obj, QEvent *event) { if (obj == data->view) { // Event from view if (event->type() == QEvent::ChildRemoved) { // Might mean that viewport has changed if (data->view->viewport() != data->viewport.data()) data->setViewport(data->view->viewport()); } return QObject::eventFilter(obj, event); } // Event from viewport switch (event->type()) { case QEvent::Leave: { if (leaveEvent(event)) return true; break; } case QEvent::MouseButtonPress: { if (mousePressEvent(static_cast<QMouseEvent*>(event))) return true; break; } case QEvent::MouseMove: { if (mouseMoveEvent(static_cast<QMouseEvent*>(event))) return true; break; } case QEvent::MouseButtonRelease: { if (mouseReleaseEvent(static_cast<QMouseEvent*>(event))) return true; break; } case QEvent::KeyPress: { if (keyPressEvent(static_cast<QKeyEvent*>(event))) return true; break; } case QEvent::KeyRelease: { if (keyReleaseEvent(static_cast<QKeyEvent*>(event))) return true; break; } case QEvent::MouseButtonDblClick: { if (mouseDoubleClickEvent(static_cast<QMouseEvent*>(event))) return true; break; } case QEvent::Wheel: { if (wheelEvent(static_cast<QWheelEvent*>(event))) return true; break; } default: { break; } } //switch // standard event processing return QObject::eventFilter(obj, event); }
void DhQPushButton::DvhkeyPressEvent(QKeyEvent* x1) { return keyPressEvent(x1); }
void LaunchyWidget::alternativesKeyPressEvent(QKeyEvent* event) { if (event->key() == Qt::Key_Escape) { showAlternatives(false); event->ignore(); this->input->setFocus(); } else if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter || event->key() == Qt::Key_Tab) { if (searchResults.count() > 0) { int row = alternatives->currentRow(); if (row > -1) { QString location = "History/" + input->text(); QStringList hist; hist << searchResults[row].lowName << searchResults[row].fullPath; gSettings->setValue(location, hist); if (row > 0) searchResults.move(row, 0); if (event->key() == Qt::Key_Tab) { doTab(); processKey(); } else { // Load up the inputData properly before running the command /* commented out until I find a fix for it breaking the history selection inputData.last().setTopResult(searchResults[0]); doTab(); inputData.parse(input->text()); inputData.erase(inputData.end() - 1);*/ updateOutputWidgets(); keyPressEvent(event); } } } } else if (event->key() == Qt::Key_Delete && (event->modifiers() & Qt::ShiftModifier) != 0) { int row = alternatives->currentRow(); if (row > -1) { if (searchResults[row].id == HASH_HISTORY) { // Delete selected history entry from the alternatives list history.removeAt(row); input->clear(); processKey(); alternativesRowChanged(alternatives->currentRow()); } else { // Demote the selected item down the alternatives list catalog->demoteItem(searchResults[row]); searchOnInput(); updateOutputWidgets(false); } showAlternatives(true, false); } } else if (event->key() == Qt::Key_Left || event->key() == Qt::Key_Right || event->text().length() > 0) { // Send text entry to the input control activateWindow(); input->setFocus(); event->ignore(); input->keyPressEvent(event); keyPressEvent(event); } alternatives->setFocus(); }
void DhQAbstractSpinBox::DvhkeyPressEvent(QKeyEvent* x1) { return keyPressEvent(x1); }
void DhQGroupBox::DvhkeyPressEvent(QKeyEvent* x1) { return keyPressEvent(x1); }
void TextGroup::undo() { QKeyEvent *event = new QKeyEvent(QEvent::KeyPress,Qt::CTRL + Qt::Key_Z, Qt::NoModifier); keyPressEvent(event); }
void TextGroup::deleteFunction() { QKeyEvent *event = new QKeyEvent(QEvent::KeyPress,Qt::Key_Delete, Qt::NoModifier); keyPressEvent(event); }
void DhQGraphicsItemGroup::DvhkeyPressEvent(QKeyEvent* x1) { return keyPressEvent(x1); }
/** * Go enter pressed event for current action. */ void RS_EventHandler::enter() { QKeyEvent e(QEvent::KeyPress, Qt::Key_Enter, 0); keyPressEvent(&e); }
void DeckListScreen::keyPressEvent(int keyCode) { int ind = listBox->getSelectedIndex(); int max = listBox->getChildren().size(); Widget *currentSoftKeys = mainLayout->getChildren()[mainLayout->getChildren().size() - 1]; switch(keyCode) { case MAK_SOFTRIGHT: case MAK_BACK: previous->show(); break; case MAK_FIRE: if(currentSoftKeys->getChildren()[0]->isSelected()){ keyPressEvent(MAK_SOFTLEFT); break; }else if(currentSoftKeys->getChildren()[2]->isSelected()){ keyPressEvent(MAK_SOFTRIGHT); break; } case MAK_SOFTLEFT: if (!selecting) { switch (screenType) { case ST_EDIT: if (listBox->getSelectedIndex() == 0) { if (next != NULL) { delete next; feed->remHttp(); next = NULL; } next = new NewDeckScreen(this, feed); next->show(); } else { if (next != NULL) { delete next; feed->remHttp(); next = NULL; } next = new EditDeckScreen(this, feed, albums[listBox->getSelectedIndex()-1]->getId()); next->show(); } break; case ST_SELECT: next = new OptionsScreen(feed, OptionsScreen::ST_NEW_GAME_OPTIONS, this, NULL, categoryId, albums[listBox->getSelectedIndex()]->getId()); next->show(); break; } } break; case MAK_DOWN: if (ind+1 < max) { listBox->setSelectedIndex(ind+1); } else { listBox->getChildren()[ind]->setSelected(false); for(int i = 0; i < currentSoftKeys->getChildren().size();i++){ if(((Button *)currentSoftKeys->getChildren()[i])->isSelectable()){ currentKeyPosition=i; currentSelectedKey= currentSoftKeys->getChildren()[i]; currentSelectedKey->setSelected(true); break; } } } break; case MAK_UP: if(currentSelectedKey!=NULL){ currentSelectedKey->setSelected(false); currentSelectedKey = NULL; currentKeyPosition = -1; listBox->getChildren()[listBox->getChildren().size()-1]->setSelected(true); } else if (ind == 0) { listBox->setSelectedIndex(max-1); } else { listBox->selectPreviousItem(); } break; case MAK_LEFT: if(currentSelectedKey!=NULL){ if(currentKeyPosition > 0){ currentKeyPosition = currentKeyPosition - 1; for(int i = currentKeyPosition; i >= 0;i--){ if(((Button *)currentSoftKeys->getChildren()[i])->isSelectable()){ currentSelectedKey->setSelected(false); currentKeyPosition=i; currentSelectedKey= currentSoftKeys->getChildren()[i]; currentSelectedKey->setSelected(true); break; } } } } break; case MAK_RIGHT: if(currentSelectedKey!=NULL){ if(currentKeyPosition+1 < currentSelectedKey->getParent()->getChildren().size()){ currentKeyPosition = currentKeyPosition + 1; for(int i = currentKeyPosition; i < currentSoftKeys->getChildren().size();i++){ if(((Button *)currentSoftKeys->getChildren()[i])->isSelectable()){ currentSelectedKey->setSelected(false); currentKeyPosition=i; currentSelectedKey= currentSoftKeys->getChildren()[i]; currentSelectedKey->setSelected(true); break; } } } } break; } }
void Sdl2Application::mainLoop() { #ifndef CORRADE_TARGET_EMSCRIPTEN const UnsignedInt timeBefore = _minimalLoopPeriod ? SDL_GetTicks() : 0; #endif SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_WINDOWEVENT: switch(event.window.event) { case SDL_WINDOWEVENT_RESIZED: { #ifndef CORRADE_TARGET_IOS viewportEvent({event.window.data1, event.window.data2}); #else /* On iOS the window event is in points and not pixels, but we need pixels to call glViewport() properly */ Vector2i drawableSize; SDL_GL_GetDrawableSize(_window, &drawableSize.x(), &drawableSize.y()); viewportEvent(drawableSize); #endif _flags |= Flag::Redraw; } break; case SDL_WINDOWEVENT_EXPOSED: _flags |= Flag::Redraw; break; } break; case SDL_KEYDOWN: case SDL_KEYUP: { KeyEvent e(static_cast<KeyEvent::Key>(event.key.keysym.sym), fixedModifiers(event.key.keysym.mod)); event.type == SDL_KEYDOWN ? keyPressEvent(e) : keyReleaseEvent(e); } break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { MouseEvent e(static_cast<MouseEvent::Button>(event.button.button), {event.button.x, event.button.y}); event.type == SDL_MOUSEBUTTONDOWN ? mousePressEvent(e) : mouseReleaseEvent(e); } break; case SDL_MOUSEWHEEL: if(event.wheel.y != 0) { MouseEvent e(event.wheel.y > 0 ? MouseEvent::Button::WheelUp : MouseEvent::Button::WheelDown, {event.wheel.x, event.wheel.y}); mousePressEvent(e); } break; case SDL_MOUSEMOTION: { MouseMoveEvent e({event.motion.x, event.motion.y}, {event.motion.xrel, event.motion.yrel}, static_cast<MouseMoveEvent::Button>(event.motion.state)); mouseMoveEvent(e); break; } case SDL_QUIT: #ifndef CORRADE_TARGET_EMSCRIPTEN _flags |= Flag::Exit; #else emscripten_cancel_main_loop(); #endif return; } } /* Tick event */ if(!(_flags & Flag::NoTickEvent)) tickEvent(); /* Draw event */ if(_flags & Flag::Redraw) { _flags &= ~Flag::Redraw; drawEvent(); #ifndef CORRADE_TARGET_EMSCRIPTEN /* If VSync is not enabled, delay to prevent CPU hogging (if set) */ if(!(_flags & Flag::VSyncEnabled) && _minimalLoopPeriod) { const UnsignedInt loopTime = SDL_GetTicks() - timeBefore; if(loopTime < _minimalLoopPeriod) SDL_Delay(_minimalLoopPeriod - loopTime); } #endif return; } #ifndef CORRADE_TARGET_EMSCRIPTEN /* If not drawing anything, delay to prevent CPU hogging (if set) */ if(_minimalLoopPeriod) { const UnsignedInt loopTime = SDL_GetTicks() - timeBefore; if(loopTime < _minimalLoopPeriod) SDL_Delay(_minimalLoopPeriod - loopTime); } /* Then, if the tick event doesn't need to be called periodically, wait indefinitely for next input event */ if(_flags & Flag::NoTickEvent) SDL_WaitEvent(nullptr); #endif }
void DhQGLWidget::DvhkeyPressEvent(QKeyEvent* x1) { return keyPressEvent(x1); }
void TextGroup::selectAll() { QKeyEvent *event = new QKeyEvent(QEvent::KeyPress,Qt::CTRL + Qt::Key_A, Qt::NoModifier); keyPressEvent(event); }
void Login::keyPressEvent(int keyCode) { error = false; Widget *currentSoftKeys = mainLayout->getChildren()[mainLayout->getChildren().size() - 1]; int index = kinListBox->getSelectedIndex(); switch(keyCode) { case MAK_FIRE: if(currentSoftKeys->getChildren()[0]->isSelected()){ keyPressEvent(MAK_SOFTLEFT); }else if(currentSoftKeys->getChildren()[2]->isSelected()){ keyPressEvent(MAK_SOFTRIGHT); } break; case MAK_SOFTLEFT: if (!isBusy) { switch (screen) { case S_LOGIN: if (editBoxLogin->getText()!="" & editBoxPass->getText()!="") { isBusy = true; notice->setCaption("Please wait, logging in..."); conCatenation = editBoxPass->getText().c_str(); value = Util::base64_encode(reinterpret_cast<const unsigned char*>(conCatenation.c_str()),conCatenation.length()); feed->setEncrypt(value.c_str()); feed->setUsername(editBoxLogin->getText().c_str()); feed->setUnsuccessful("true"); mHttp = HttpConnection(this); int urlLength = 71 + URLSIZE; char *url = new char[urlLength+1]; memset(url,'\0',urlLength+1); sprintf(url, "%s?userdetails=1", URL); lprintfln("%s", url); int res = mHttp.create(url, HTTP_GET); if(res < 0) { notice->setCaption("Unable to connect, try again later..."); } else { mHttp.setRequestHeader("AUTH_USER", feed->getUsername().c_str()); mHttp.setRequestHeader("AUTH_PW", feed->getEncrypt().c_str()); feed->addHttp(); mHttp.finish(); } delete url; url = NULL; conCatenation = ""; value = ""; } else { maVibrate(1000); notice->setCaption("Ensure that you have entered your username and password."); } break; case S_REGISTER: notice->setCaption(""); if ((strcmp(feed->getRegistered().c_str(), "1") == 0)) { notice->setCaption("Already registered for an account with this device."); maVibrate(1000); } else if (editBoxLogin->getText().length() < 6) { notice->setCaption("Your username needs to be at least 6 characters long"); maVibrate(1000); } else if (editBoxPass->getText().length() < 6) { notice->setCaption("Your password needs to be at least 6 characters long"); maVibrate(1000); } else if (editBoxEmail->getText().length() == 0) { notice->setCaption("You need to enter an email address"); maVibrate(1000); } else if (!Util::validateEmailAddress(editBoxEmail->getText())) { notice->setCaption("Please enter a valid email address"); maVibrate(1000); } else if (!Util::validateNoWhiteSpaces(editBoxLogin->getText())) { notice->setCaption("Please enter a username without spaces."); maVibrate(1000); } else if (!Util::validateNoWhiteSpaces(editBoxPass->getText())) { notice->setCaption("Please enter a password without spaces."); maVibrate(1000); } else if (!Util::validateNoWhiteSpaces(editBoxEmail->getText())) { notice->setCaption("Please enter a email address without spaces."); maVibrate(1000); } else if (!Util::validateNoWhiteSpaces(editBoxRefer->getText())) { notice->setCaption("Please enter a referer name."); maVibrate(1000); } else { result = ""; isBusy = true; notice->setCaption("Attempting to register user..."); conCatenation = editBoxPass->getText().c_str(); value = Util::base64_encode(reinterpret_cast<const unsigned char*>(conCatenation.c_str()),conCatenation.length()); feed->setEncrypt(value.c_str()); feed->setUsername(editBoxLogin->getText().c_str()); feed->setUnsuccessful("true"); char *url = NULL; //work out how long the url will be, the 2 is for the & and = symbols int urlLength = 89 + URLSIZE + editBoxLogin->getText().length() + editBoxPass->getText().length() + editBoxEmail->getText().length() + editBoxRefer->getText().length(); url = new char[urlLength+1]; memset(url,'\0',urlLength+1); sprintf(url, "%s?registeruser=1&username=%s&password=%s&email=%s&referer=%s", URL, editBoxLogin->getText().c_str(), editBoxPass->getText().c_str(), editBoxEmail->getText().c_str(), editBoxRefer->getText().c_str()); lprintfln("%s", url); mHttp = HttpConnection(this); int res = mHttp.create(url, HTTP_GET); if(res < 0) { notice->setCaption("Unable to connect, try again later..."); } else { mHttp.setRequestHeader("AUTH_USER", feed->getUsername().c_str()); mHttp.setRequestHeader("AUTH_PW", feed->getEncrypt().c_str()); feed->addHttp(); mHttp.finish(); } delete url; url = NULL; } break; } } break; case MAK_BACK: case MAK_SOFTRIGHT: if ((strcmp(feed->getRegistered().c_str(), "1") == 0)) { maExit(1); } else { previous->show(); } break; case MAK_UP: if(currentSelectedKey!=NULL){ currentSelectedKey->setSelected(false); currentSelectedKey = NULL; currentKeyPosition = -1; kinListBox->getChildren()[kinListBox->getChildren().size()-1]->setSelected(true); } else if (index-2 > 0) { kinListBox->setSelectedIndex(index-2); } break; case MAK_DOWN: if (index+2 < kinListBox->getChildren().size()) { kinListBox->setSelectedIndex(index+2); } else { kinListBox->getChildren()[index]->setSelected(false); for(int i = 0; i < currentSoftKeys->getChildren().size();i++){ if(((Button *)currentSoftKeys->getChildren()[i])->isSelectable()){ currentKeyPosition=i; currentSelectedKey= currentSoftKeys->getChildren()[i]; currentSelectedKey->setSelected(true); break; } } } break; case MAK_LEFT: if(currentSelectedKey!=NULL){ if(currentKeyPosition > 0){ currentKeyPosition = currentKeyPosition - 1; for(int i = currentKeyPosition; i >= 0;i--){ if(((Button *)currentSoftKeys->getChildren()[i])->isSelectable()){ currentSelectedKey->setSelected(false); currentKeyPosition=i; currentSelectedKey= currentSoftKeys->getChildren()[i]; currentSelectedKey->setSelected(true); break; } } } } break; case MAK_RIGHT: if(currentSelectedKey!=NULL){ if(currentKeyPosition+1 < currentSelectedKey->getParent()->getChildren().size()){ currentKeyPosition = currentKeyPosition + 1; for(int i = currentKeyPosition; i < currentSoftKeys->getChildren().size();i++){ if(((Button *)currentSoftKeys->getChildren()[i])->isSelectable()){ currentSelectedKey->setSelected(false); currentKeyPosition=i; currentSelectedKey= currentSoftKeys->getChildren()[i]; currentSelectedKey->setSelected(true); break; } } } } break; } }
void AWebView::scrollPage () { QKeyEvent event(QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier); keyPressEvent(&event); }