void GraphicsView::keyPressEvent(QKeyEvent *event) { emit pressedKey(event->key()); if (event_listening_timer_.isActive()) { event_listening_timer_.stop(); sendEvent(keyPressed(event->key(), event->modifiers())); } QGraphicsView::keyPressEvent(event); }
int QKeyPushButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QPushButton::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: pressedKey((*reinterpret_cast< bool(*)>(_a[1]))); break; case 1: getKeyPress((*reinterpret_cast< bool(*)>(_a[1]))); break; default: ; } _id -= 2; } return _id; }
QvkShowkeyController::QvkShowkeyController( QCheckBox *value ) { checkBox = value; // Fenster das den Key anzeigt showkeyWindow = new QvkShowkeyWindow(); connect( checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( showkeyReadKey( int ) ) ); pThread = new QThread(); xev = new QvkShowkeyGetkey(); xev->moveToThread( pThread ); connect( xev, SIGNAL( pressedKey( QString ) ), this, SLOT( showScreenkeyWindow( QString ) ) ); connect( xev, SIGNAL( finished() ), this, SLOT( finished() ) ); screenkeyTimer = new QTimer( this ); connect( screenkeyTimer, SIGNAL( timeout() ), this, SLOT( hideScreenkeyWindow() ) ); }
void QKeyPushButton::mousePressEvent(QMouseEvent * /*event */) { static bool m_capsActive = true; widgetKeyBoard *tmpKeyBoard = (widgetKeyBoard *) this->m_parent; static int yMarginKeyboard = tmpKeyBoard->rect().y(); QString text = this->text(); short adjustZoomedKey = HEIGHT_ZOOM_KEY; QString defaultStyleButton = QString(DEFAULT_STYLE_BUTTON); QString changedColorButton = QString(CHANGED_BACKGROUND_BUTTON); // // se si tratta del maiuscolo: if (IS_CAPS(text) == true) { if (m_capsActive == false) m_capsActive = true; else { changedColorButton = QString(DEFAULT_BACKGROUND_BUTTON); m_capsActive = false; } this->setStyleSheet(defaultStyleButton + changedColorButton + this->style_embedded); this->repaint(); QCoreApplication::processEvents(); } else if (tmpKeyBoard->isEnabledSwitchingEcho() == true && (IS_PASSWORD(text) == true || IS_PASSWORD_EMB(text) == true)) tmpKeyBoard->switchKeyEchoMode(tmpKeyBoard->currentTextBox()); else { this->setStyleSheet(defaultStyleButton + changedColorButton + this->style_embedded); this->repaint(); QCoreApplication::processEvents(); emit pressedKey(m_capsActive); } this->m_oldYKey = 0; if (tmpKeyBoard->isEmbeddedKeyboard() == true && tmpKeyBoard->isZoomFacilityEnable() && NO_SPECIAL_KEY(text) && text.trimmed().length() != 0) { tmpKeyBoard->setCursor(Qt::BlankCursor); if (this->y() - adjustZoomedKey - KEY_HEIGHT_EMBEDDED < yMarginKeyboard) this->m_oldYKey = this->y(); else adjustZoomedKey = -HEIGHT_ZOOM_KEY; this->setGeometry(this->x() - 10, this->y() + adjustZoomedKey - KEY_HEIGHT_EMBEDDED, KEY_WIDTH_EMBEDDED + WIDTH_ZOOM_KEY, KEY_HEIGHT_EMBEDDED + HEIGHT_ZOOM_KEY); this->setStyleSheet(changedColorButton + defaultStyleButton); QCoreApplication::processEvents(); } }
void QvkShowkeyGetkey::run() { const timespec sleeptime = { 0, 1000000 }; /* * open the display */ if (! ( display = XOpenDisplay( NULL ) ) ) { std::cerr << "Can't open display NULL" << '\n'; std::exit(1); } /* * fill up keyboard mapping */ //fill_mappings(); // keys aus eigene Routine ermitteln QStringList keyList = PrintKeyTable(); /* * fill relevant key buffers */ char keys[32]; // buffer for reading keys in char lastkeys[32]; // previous keys state std::fill(lastkeys, lastkeys + sizeof(lastkeys), 0); /* * query keyboard in loop */ bool last_is_nav = false; // navigation key indicator // bool last_is_char = false; // spaces adjustment while (cont) { nanosleep(&sleeptime, 0); // avoid busy waiting XQueryKeymap( display, keys ); // read modifiers (caps lock is ignored) bool shift = false; bool ctrl = false; bool alt = false; bool meta = false; for (unsigned i = 0; i < sizeof(keys); ++i) for (unsigned j = 0, test = 1; j < 8; ++j, test *= 2) if (keys[i] & test) { const int code = i*8+j; if (shift_set.find(code) != shift_set.end()) { shift = true; qDebug() << "Shift = true"; } if (ctrl_set.find(code) != ctrl_set.end()) ctrl = true; if (alt_set.find(code) != alt_set.end()) alt = true; if (meta_set.find(code) != meta_set.end()) meta = true; } // print changed keys for (unsigned i = 0; i < sizeof(keys); ++i) if (keys[i] != lastkeys[i]) { // check which key got changed for (unsigned j = 0, test = 1; j < 8; ++j, test *= 2) // if the key was pressed, and it wasn't before, print this if ((keys[i] & test) && ((keys[i] & test) != (lastkeys[i] & test))) { const int code = i*8+j; QString key = getKey( keyList, code ); const bool key_is_nav = ( key == "Nav" ); // only print navigation keys once if ( ! (last_is_nav && key_is_nav) && key.size() > 0 ) { // change key according to modifiers if ( ! key_is_nav) { if ( meta ) key = " Meta-" + key + " "; if ( alt ) key = " Alt-" + key + " "; if ( ctrl ) key = " Ctrl-" + key + " "; if ( ( not shift ) ) { emit pressedKey( key ); } // shift if ( shift ) { emit pressedKey( getKeyShift( keyList, code ) ); } } last_is_nav = key_is_nav; } } lastkeys[i] = keys[i]; } } XCloseDisplay(display); }