Ejemplo n.º 1
0
bool KKeyNative::init(const KKey &key)
{
    // Get any extra mods required by the sym.
    //  E.g., XK_Plus requires SHIFT on the en layout.
    m_sym = key.sym();
    uint modExtra = KKeyServer::Sym(m_sym).getModsRequired();
    // Get the X modifier equivalent.
    if(!m_sym || !KKeyServer::modToModX(key.modFlags() | modExtra, m_mod))
    {
        m_sym = m_mod = 0;
        m_code = 0;
        return false;
    }

    // XKeysymToKeycode returns the wrong keycode for XK_Print and XK_Break.
    // Specifically, it returns the code for SysReq instead of Print
    // Only do this for the default Xorg layout, other keycode mappings
    // (e.g. evdev) don't need or want it.
    if(m_sym == XK_Print && !(m_mod & Mod1Mask) && XKeycodeToKeysym(qt_xdisplay(), 111, 0) == XK_Print)
        m_code = 111; // code for Print
    else if(m_sym == XK_Break || ((m_sym == XK_Pause && (m_mod & ControlMask)) && XKeycodeToKeysym(qt_xdisplay(), 114, 0) == XK_Pause))
        m_code = 114;
    else
        m_code = XKeysymToKeycode(qt_xdisplay(), m_sym);

    if(!m_code && m_sym)
        kdDebug(125) << "Couldn't get code for sym" << endl;
    // Now get the true sym formed by the modifiers
    //  E.g., Shift+Equal => Plus on the en layout.
    if(key.modFlags() && ((m_sym < XK_Home || m_sym > XK_Begin) && m_sym != XK_Insert && m_sym != XK_Delete))
        KKeyServer::codeXToSym(m_code, m_mod, m_sym);

    return true;
}
Ejemplo n.º 2
0
// public static
bool kpTool::containsSingleKeyTrigger (const KKeySequence &seq)
{
    for (int i = 0; i < (int) seq.count (); i++)
    {
        const KKey key = seq.key (i);
        if (keyIsText (key.keyCodeQt ()))
            return true;
    }

    return false;
}
Ejemplo n.º 3
0
// __________________________________________________________________________________________________
bool KikiPageText::handleKey ( const KKey & key )
{   
    bool retval = false;
    std::string keyName = key.getUnmodifiedName ();
    
    if (keyName == "DOWN" || keyName == "PAGEDOWN" || keyName == "RIGHT" || 
        keyName == "RETURN" || keyName == "SPACE")
    {
        if (getEventWithName ("next"))
        {
            Controller.sound->playSound (KikiSound::MENU_SELECT);
            startTimedAction (getActionWithId (ACTION_NEXT_PAGE));
        }
        else
        {
            KikiEvent * prevEvent = getEventWithName ("previous");
            if (prevEvent)
            {
                events.erase (std::find (events.begin(), events.end(), prevEvent));
                delete prevEvent;
            }
            Controller.sound->playSound (KikiSound::MENU_ABORT);
            Controller.timer_event->addAction (getActionWithId (ACTION_HIDE));
        }
        retval = true;
    }
    else if (keyName == "UP" || keyName == "PAGEUP" || keyName == "LEFT")
    {
        if (getEventWithName ("previous"))
        {
            Controller.sound->playSound (KikiSound::MENU_SELECT);
            startTimedAction (getActionWithId (ACTION_PREVIOUS_PAGE));
        }
        retval = true;
    }
    else
    {
        if (keyName == "ESCAPE")  retval = true;
        
        KikiEvent * nextEvent = getEventWithName ("next");
        if (nextEvent)
        {
            events.erase (std::find (events.begin(), events.end(), nextEvent));
            delete nextEvent;
        }
        KikiEvent * prevEvent = getEventWithName ("previous");
        if (prevEvent)
        {
            events.erase (std::find (events.begin(), events.end(), prevEvent));
            delete prevEvent;
        }
        Controller.sound->playSound (KikiSound::MENU_ABORT);
        Controller.timer_event->addAction (getActionWithId (ACTION_HIDE));
    }
        
    return retval;
}
Ejemplo n.º 4
0
bool DOMTreeView::eventFilter(QObject *o, QEvent *e)
{
  if (e->type() == QEvent::AccelOverride) {
    QKeyEvent *ke = static_cast<QKeyEvent *>(e);
    kdDebug(90180) << " acceloverride " << ke->key() << " o " << o->name() << endl;

    if (o == m_listView) {	// DOM tree
      KKey ks = mainWindow()->deleteNodeAction()->shortcut().seq(0).key(0);
      if (ke->key() == ks.keyCodeQt())
        return true;

    } else if (o == nodeAttributes) {
      KKey ks = mainWindow()->deleteAttributeAction()->shortcut().seq(0).key(0);
      if (ke->key() == ks.keyCodeQt())
        return true;

    }

  } else if (e->type() == QEvent::FocusIn) {

    kdDebug(90180) << " focusin o " << o->name() << endl;
    if (o != this) {
      focused_child = o;
    }

  } else if (e->type() == QEvent::FocusOut) {

    kdDebug(90180) << " focusout o " << o->name() << endl;
    if (o != this) {
      focused_child = 0;
    }

  }

  return false;
}
Ejemplo n.º 5
0
// __________________________________________________________________________________________________
bool KikiScrollMenu::handleKey ( const KKey & key )
{    
    std::string keyName = key.getUnmodifiedName ();

    if (keyName == "LEFT" || keyName == "RIGHT")
    {
		active_index += ((keyName == "LEFT") ? -1 : 1) * num_rows;
		if (circular)
		{
			if (active_index < 0)
				active_index += (int)all_menu_items.size();
			else if ((active_index) >= (int)all_menu_items.size())
				active_index -= (int)all_menu_items.size();
		}
		else
		{
			if (active_index < 0)
			{
				offset = index_offset = active_index = 0;
			}
			else
			{
				active_index = kMin(all_menu_items.size()-1, active_index);
			}
		}
		
		activeIndexChanged ();
		getEventWithName ("changed")->triggerActions();
	}
	else
	{
		return KikiMenu::handleKey (key);
	}

	return true;
}
Ejemplo n.º 6
0
// __________________________________________________________________________________________________
bool KikiController::handleKey ( const KKey & key )
{
    //KConsole::printf("KikiController::handleKey %s", key.name.c_str());

    if (key.getUnmodifiedName() == "ESCAPE")
    {
        events[ESCAPE_KEY_EVENT]->triggerActions();
        return true;
    }

    if (key.name == quit_key)
    {
        SDL_Event event;
        event.type = SDL_QUIT;
        SDL_PushEvent (&event);
        return true;
    }

    if (key.name == "F9")
    {
        debug_version = !debug_version;
        KConsole::printf("toggle debug mode");
        if (debug_version)
          SDL_ShowCursor (SDL_ENABLE);
        else
          SDL_ShowCursor (SDL_DISABLE);
        return true;
    }

    if (isDebugVersion())
    {
    if (key.name == "e")
    {        
        world->setEditMode (!world->getEditMode()); 
        return true;
    }
    if (key.name == "f")
    {
        world->focusOnPickedPickable();
        return true;
    }
    if (key.name == "b")
    {
        world->setDisplayBorder (!world->flags[KikiWorld::DISPLAY_BORDER]);
        return true;
    }
    if (key.name == "r")
    {
        world->setDisplayRaster (!world->flags[KikiWorld::DISPLAY_RASTER]); 
        return true;
    }
    if (key.name == "d")
    {
        world->flags[KikiWorld::DISPLAY_DOTS] = !world->flags[KikiWorld::DISPLAY_DOTS];
        world->debug_cells = !world->debug_cells;
        return true;
    }
	if (key.name == "c")
	{
		KConsole::getConsole()->show();
	}
    }

    if (key.character >= '1' && key.character <= '9') { speed = key.character - '0'; return true; }
    //if (key.name == "c") { KConsole::getConsole()->clear(); return true; }
            
    return false;
}