void EngineInputManager::keyPress(Input::Key key) { switch(key) { case Input::KEY_RSHIFT:; case Input::KEY_LSHIFT:; case Input::KEY_RCTRL:; case Input::KEY_LCTRL:; case Input::KEY_RALT:; case Input::KEY_LALT:; case Input::KEY_RSUPER:; case Input::KEY_LSUPER:; case Input::KEY_NUMLOCK:; case Input::KEY_SCROLLOCK: return; default: { break; } } Input::Hotkey hotkey; hotkey.key = key; Input::InputManager& input = *Input::InputManager::get(); uint32_t modifiers = input.getModifiers(); switch(modifiers) { case 0: break; case 1: hotkey.ctrl = true; break; case 2: hotkey.alt = true; break; case 3: hotkey.ctrl = true; hotkey.alt = true; break; case 4: hotkey.shift = true; break; case 5: hotkey.ctrl = true; hotkey.shift = true; break; case 6: hotkey.alt = true; hotkey.shift = true; break; case 7: hotkey.ctrl = true; hotkey.alt = true; hotkey.shift = true; break; } FAGui::Console & console = FAGui::Console::getInstance(FARender::Renderer::get()->getRocketContext()); if(hotkey == getHotkey(TOGGLE_CONSOLE)) { mToggleConsole = true; } else if(console.isVisible() == false) { for(int action = 0; action < KEYBOARD_INPUT_ACTION_MAX; action++) { KeyboardInputAction keyAction = (KeyboardInputAction)action; if (hotkey == getHotkey(keyAction)) { notifyKeyboardObservers(keyAction); } } } }
HotkeyData ExtraContainerChanges::FindHotkey(TESForm * form) const { FoundHotkeyData hotkeyData; if (data && data->objList) { HotkeyDataFinder getHotkey(form); data->objList->Visit(getHotkey); hotkeyData = getHotkey.Found(); } return hotkeyData; }
void LaunchyWidget::keyPressEvent(QKeyEvent* event) { #ifdef Q_WS_X11 // ignore hotkey if (event->modifiers() + event->key() == getHotkey()) { return; } #endif if (event->key() == Qt::Key_Escape) { if (alternatives->isVisible()) showAlternatives(false); else hideLaunchy(); } else if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { doEnter(); } else if (event->key() == Qt::Key_Down || event->key() == Qt::Key_PageDown || event->key() == Qt::Key_Up || event->key() == Qt::Key_PageUp) { if (alternatives->isVisible()) { if (!alternatives->isActiveWindow()) { // Don't refactor the activateWindow outside the if, it won't work properly any other way! if (alternatives->currentRow() < 0 && alternatives->count() > 0) { alternatives->activateWindow(); alternatives->setCurrentRow(0); } else { alternatives->activateWindow(); qApp->sendEvent(alternatives, event); } } } else if (event->key() == Qt::Key_Down || event->key() == Qt::Key_PageDown) { // do a search and show the results, selecting the first one searchOnInput(); if (searchResults.count() > 0) { showAlternatives(); alternatives->activateWindow(); if (alternatives->count() > 0) alternatives->setCurrentRow(0); } } } else if ((event->key() == Qt::Key_Tab || event->key() == Qt::Key_Backspace) && event->modifiers() == Qt::ShiftModifier) { doBackTab(); processKey(); } else if (event->key() == Qt::Key_Tab) { doTab(); processKey(); } /* else if (event->key() == Qt::Key_Slash || event->key() == Qt::Key_Backslash) { if (inputData.count() > 0 && inputData.last().hasLabel(LABEL_FILE)) doTab(); processKey(); } */ else if (event->text().length() > 0) { // process any other key with character output event->ignore(); processKey(); } }
LaunchyWidget::LaunchyWidget(CommandFlags command) : #ifdef Q_WS_WIN QWidget(NULL, Qt::FramelessWindowHint | Qt::Tool), #endif #ifdef Q_WS_X11 QWidget(NULL, Qt::FramelessWindowHint), #endif #ifdef Q_WS_MAC QWidget(NULL, Qt::FramelessWindowHint), #endif frameGraphic(NULL), trayIcon(NULL), alternatives(NULL), updateTimer(NULL), dropTimer(NULL), condensedTempIcon(NULL) { setObjectName("launchy"); setWindowTitle(tr("Launchy")); #ifdef Q_WS_WIN setWindowIcon(QIcon(":/resources/launchy128.png")); #endif #ifdef Q_WS_MAC setWindowIcon(QIcon("../Resources/launchy_icon_mac.icns")); //setAttribute(Qt::WA_MacAlwaysShowToolWindow); #endif setAttribute(Qt::WA_AlwaysShowToolTips); setAttribute(Qt::WA_InputMethodEnabled); if (platform->supportsAlphaBorder()) { setAttribute(Qt::WA_TranslucentBackground); } setFocusPolicy(Qt::ClickFocus); createActions(); gMainWidget = this; menuOpen = false; optionsOpen = false; dragging = false; gSearchText = ""; alwaysShowLaunchy = false; connect(&iconExtractor, SIGNAL(iconExtracted(int, QIcon)), this, SLOT(iconExtracted(int, QIcon))); fader = new Fader(this); connect(fader, SIGNAL(fadeLevel(double)), this, SLOT(setFadeLevel(double))); optionsButton = new QPushButton(this); optionsButton->setObjectName("opsButton"); optionsButton->setToolTip(tr("Launchy Options")); optionsButton->setGeometry(QRect()); connect(optionsButton, SIGNAL(clicked()), this, SLOT(showOptionsDialog())); closeButton = new QPushButton(this); closeButton->setObjectName("closeButton"); closeButton->setToolTip(tr("Close Launchy")); closeButton->setGeometry(QRect()); connect(closeButton, SIGNAL(clicked()), qApp, SLOT(quit())); output = new QLabel(this); output->setObjectName("output"); output->setAlignment(Qt::AlignHCenter); input = new CharLineEdit(this); #ifdef Q_WS_MAC QMacStyle::setFocusRectPolicy(input, QMacStyle::FocusDisabled); #endif input->setObjectName("input"); connect(input, SIGNAL(keyPressed(QKeyEvent*)), this, SLOT(inputKeyPressEvent(QKeyEvent*))); connect(input, SIGNAL(focusIn(QFocusEvent*)), this, SLOT(focusInEvent(QFocusEvent*))); connect(input, SIGNAL(focusOut(QFocusEvent*)), this, SLOT(focusOutEvent(QFocusEvent*))); connect(input, SIGNAL(inputMethod(QInputMethodEvent*)), this, SLOT(inputMethodEvent(QInputMethodEvent*))); outputIcon = new QLabel(this); outputIcon->setObjectName("outputIcon"); workingAnimation = new AnimationLabel(this); workingAnimation->setObjectName("workingAnimation"); workingAnimation->setGeometry(QRect()); // Load settings settings.load(); // If this is the first time running or a new version, call updateVersion if (gSettings->value("version", 0).toInt() != LAUNCHY_VERSION) { updateVersion(gSettings->value("version", 0).toInt()); command |= ShowLaunchy; } alternatives = new CharListWidget(this); alternatives->setObjectName("alternatives"); alternatives->setWindowFlags(Qt::Window | Qt::Tool | Qt::FramelessWindowHint); alternatives->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); alternatives->setTextElideMode(Qt::ElideLeft); alternatives->setUniformItemSizes(true); listDelegate = new IconDelegate(this); defaultListDelegate = alternatives->itemDelegate(); setSuggestionListMode(gSettings->value("GenOps/condensedView", 0).toInt()); altScroll = alternatives->verticalScrollBar(); altScroll->setObjectName("altScroll"); connect(alternatives, SIGNAL(currentRowChanged(int)), this, SLOT(alternativesRowChanged(int))); connect(alternatives, SIGNAL(keyPressed(QKeyEvent*)), this, SLOT(alternativesKeyPressEvent(QKeyEvent*))); connect(alternatives, SIGNAL(focusOut(QFocusEvent*)), this, SLOT(focusOutEvent(QFocusEvent*))); alternativesPath = new QLabel(alternatives); alternativesPath->setObjectName("alternativesPath"); alternativesPath->hide(); listDelegate->setAlternativesPathWidget(alternativesPath); // Load the plugins plugins.loadPlugins(); // Set the general options if (setAlwaysShow(gSettings->value("GenOps/alwaysshow", false).toBool())) command |= ShowLaunchy; setAlwaysTop(gSettings->value("GenOps/alwaystop", false).toBool()); // Check for udpates? if (gSettings->value("GenOps/updatecheck", true).toBool()) { checkForUpdate(); } // Set the hotkey QKeySequence hotkey = getHotkey(); if (!setHotkey(hotkey)) { QMessageBox::warning(this, tr("Launchy"), tr("The hotkey %1 is already in use, please select another.").arg(hotkey.toString())); command = ShowLaunchy | ShowOptions; } // Set the timers updateTimer = new QTimer(this); dropTimer = new QTimer(this); dropTimer->setSingleShot(true); connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateTimeout())); connect(dropTimer, SIGNAL(timeout()), this, SLOT(dropTimeout())); int time = gSettings->value("GenOps/updatetimer", 10).toInt(); if (time > 0) updateTimer->start(time * 60000); // Load the catalog catalog.reset(CatalogBuilder::createCatalog()); catalog->load(settings.catalogFilename()); // Load the history history.load(settings.historyFilename()); // Load the skin applySkin(gSettings->value("GenOps/skin", "Default").toString()); // Move to saved position loadPosition(gSettings->value("Display/pos", QPoint(0,0)).toPoint()); loadOptions(); executeStartupCommand(command); }