// public static KShortcut kpTool::shortcutForKey (int key) { KShortcut shortcut; if (key) { shortcut.append (KKeySequence (KKey (key))); // (CTRL+<key>, ALT+<key>, CTRL+ALT+<key>, CTRL+SHIFT+<key> // all clash with global KDE shortcuts) shortcut.append (KKeySequence (KKey (Qt::ALT + Qt::SHIFT + key))); } return shortcut; }
// public static bool kpTool::containsSingleKeyTrigger (const KShortcut &shortcut, KShortcut *shortcutWithoutSingleKeyTriggers) { if (shortcutWithoutSingleKeyTriggers) *shortcutWithoutSingleKeyTriggers = shortcut; KShortcut newShortcut; bool needNewShortcut = false; for (int i = 0; i < (int) shortcut.count (); i++) { const KKeySequence seq = shortcut.seq (i); if (containsSingleKeyTrigger (seq)) { needNewShortcut = true; } else { newShortcut.append (seq); } } if (needNewShortcut && shortcutWithoutSingleKeyTriggers) *shortcutWithoutSingleKeyTriggers = newShortcut; return needNewShortcut; }
/** * create the action events create the gui. */ void KJezzball::initXMLUI() { m_newAction = KStdGameAction::gameNew( this, SLOT(newGame()), actionCollection() ); // AB: originally KBounce/KJezzball used Space for new game - but Ctrl+N is // default. We solve this by providing space as an alternative key KShortcut s = m_newAction->shortcut(); s.append(KKeySequence(QKeySequence(Key_Space))); m_newAction->setShortcut(s); KStdGameAction::quit(this, SLOT(close()), actionCollection() ); KStdGameAction::highscores(this, SLOT(showHighscore()), actionCollection() ); m_pauseButton = KStdGameAction::pause(this, SLOT(pauseGame()), actionCollection()); KStdGameAction::end(this, SLOT(closeGame()), actionCollection()); KStdGameAction::configureHighscores(this, SLOT(configureHighscores()),actionCollection()); new KAction( i18n("&Select Background Folder..."), 0, this, SLOT(selectBackground()), actionCollection(), "background_select" ); m_backgroundShowAction = new KToggleAction( i18n("Show &Backgrounds"), 0, this, SLOT(showBackground()), actionCollection(), "background_show" ); m_backgroundShowAction->setCheckedState(i18n("Hide &Backgrounds")); m_backgroundShowAction->setEnabled( !m_backgroundDir.isEmpty() ); m_backgroundShowAction->setChecked( m_showBackground ); m_soundAction = new KToggleAction( i18n("&Play Sounds"), 0, 0, 0, actionCollection(), "toggle_sound"); }
KShortcut shortcutDefault3(StdAccel id) { KShortcut cut; KStdAccelInfo *pInfo = infoPtr(id); if(pInfo) { if(pInfo->cutDefault) cut.init(pInfo->cutDefault); // FIXME: if there is no cutDefault, then this we be made the primary // instead of alternate shortcut. if(pInfo->cutDefault3B) cut.append(KKey(pInfo->cutDefault3B)); } return cut; }
KShortcut shortcutDefault4(StdAccel id) { KShortcut cut; KStdAccelInfo *pInfo = infoPtr(id); if(pInfo) { KStdAccelInfo &info = *pInfo; KKeySequence key2; cut.init((info.cutDefault4) ? QKeySequence(info.cutDefault) : QKeySequence(info.cutDefault4)); if(info.cutDefault4B) key2.init(QKeySequence(info.cutDefault4B)); else if(info.cutDefault3B) key2.init(QKeySequence(info.cutDefault3B)); if(key2.count()) cut.append(key2); } return cut; }
//------------------------------------------------------------------------- KJSDebugWin::KJSDebugWin(QWidget *parent, const char *name) : KMainWindow(parent, name, WType_TopLevel), KInstance("kjs_debugger") { m_breakpoints = 0; m_breakpointCount = 0; m_curSourceFile = 0; m_mode = Continue; m_nextSourceUrl = ""; m_nextSourceBaseLine = 1; m_execs = 0; m_execsCount = 0; m_execsAlloc = 0; m_steppingDepth = 0; m_stopIcon = KGlobal::iconLoader()->loadIcon("stop", KIcon::Small); m_emptyIcon = QPixmap(m_stopIcon.width(), m_stopIcon.height()); QBitmap emptyMask(m_stopIcon.width(), m_stopIcon.height(), true); m_emptyIcon.setMask(emptyMask); setCaption(i18n("JavaScript Debugger")); QWidget *mainWidget = new QWidget(this); setCentralWidget(mainWidget); QVBoxLayout *vl = new QVBoxLayout(mainWidget, 5); // frame list & code QSplitter *hsplitter = new QSplitter(Qt::Vertical, mainWidget); QSplitter *vsplitter = new QSplitter(hsplitter); QFont font(KGlobalSettings::fixedFont()); QWidget *contextContainer = new QWidget(vsplitter); QLabel *contextLabel = new QLabel(i18n("Call stack"), contextContainer); QWidget *contextListContainer = new QWidget(contextContainer); m_contextList = new QListBox(contextListContainer); m_contextList->setMinimumSize(100, 200); connect(m_contextList, SIGNAL(highlighted(int)), this, SLOT(slotShowFrame(int))); QHBoxLayout *clistLayout = new QHBoxLayout(contextListContainer); clistLayout->addWidget(m_contextList); clistLayout->addSpacing(KDialog::spacingHint()); QVBoxLayout *contextLayout = new QVBoxLayout(contextContainer); contextLayout->addWidget(contextLabel); contextLayout->addSpacing(KDialog::spacingHint()); contextLayout->addWidget(contextListContainer); // source selection & display QWidget *sourceSelDisplay = new QWidget(vsplitter); QVBoxLayout *ssdvl = new QVBoxLayout(sourceSelDisplay); m_sourceSel = new QComboBox(toolBar()); connect(m_sourceSel, SIGNAL(activated(int)), this, SLOT(slotSourceSelected(int))); m_sourceDisplay = new SourceDisplay(this, sourceSelDisplay); ssdvl->addWidget(m_sourceDisplay); connect(m_sourceDisplay, SIGNAL(lineDoubleClicked(int)), SLOT(slotToggleBreakpoint(int))); QValueList< int > vsplitSizes; vsplitSizes.insert(vsplitSizes.end(), 120); vsplitSizes.insert(vsplitSizes.end(), 480); vsplitter->setSizes(vsplitSizes); // evaluate QWidget *evalContainer = new QWidget(hsplitter); QLabel *evalLabel = new QLabel(i18n("JavaScript console"), evalContainer); m_evalEdit = new EvalMultiLineEdit(evalContainer); m_evalEdit->setWordWrap(QMultiLineEdit::NoWrap); m_evalEdit->setFont(font); connect(m_evalEdit, SIGNAL(returnPressed()), SLOT(slotEval())); m_evalDepth = 0; QVBoxLayout *evalLayout = new QVBoxLayout(evalContainer); evalLayout->addSpacing(KDialog::spacingHint()); evalLayout->addWidget(evalLabel); evalLayout->addSpacing(KDialog::spacingHint()); evalLayout->addWidget(m_evalEdit); QValueList< int > hsplitSizes; hsplitSizes.insert(hsplitSizes.end(), 400); hsplitSizes.insert(hsplitSizes.end(), 200); hsplitter->setSizes(hsplitSizes); vl->addWidget(hsplitter); // actions KPopupMenu *debugMenu = new KPopupMenu(this); menuBar()->insertItem("&Debug", debugMenu); m_actionCollection = new KActionCollection(this); m_actionCollection->setInstance(this); // Venkman use F12, KDevelop F10 KShortcut scNext = KShortcut(KKeySequence(KKey(Qt::Key_F12))); scNext.append(KKeySequence(KKey(Qt::Key_F10))); m_nextAction = new KAction(i18n("Next breakpoint", "&Next"), "dbgnext", scNext, this, SLOT(slotNext()), m_actionCollection, "next"); m_stepAction = new KAction(i18n("&Step"), "dbgstep", KShortcut(Qt::Key_F11), this, SLOT(slotStep()), m_actionCollection, "step"); // Venkman use F5, Kdevelop F9 KShortcut scCont = KShortcut(KKeySequence(KKey(Qt::Key_F5))); scCont.append(KKeySequence(KKey(Qt::Key_F9))); m_continueAction = new KAction(i18n("&Continue"), "dbgrun", scCont, this, SLOT(slotContinue()), m_actionCollection, "cont"); m_stopAction = new KAction(i18n("St&op"), "stop", KShortcut(Qt::Key_F4), this, SLOT(slotStop()), m_actionCollection, "stop"); m_breakAction = new KAction(i18n("&Break at Next Statement"), "dbgrunto", KShortcut(Qt::Key_F8), this, SLOT(slotBreakNext()), m_actionCollection, "breaknext"); m_nextAction->setToolTip(i18n("Next breakpoint", "Next")); m_stepAction->setToolTip(i18n("Step")); m_continueAction->setToolTip(i18n("Continue")); m_stopAction->setToolTip(i18n("Stop")); m_breakAction->setToolTip("Break at next Statement"); m_nextAction->setEnabled(false); m_stepAction->setEnabled(false); m_continueAction->setEnabled(false); m_stopAction->setEnabled(false); m_breakAction->setEnabled(true); m_nextAction->plug(debugMenu); m_stepAction->plug(debugMenu); m_continueAction->plug(debugMenu); // m_stopAction->plug(debugMenu); ### disabled until DebuggerImp::stop() works reliably m_breakAction->plug(debugMenu); m_nextAction->plug(toolBar()); m_stepAction->plug(toolBar()); m_continueAction->plug(toolBar()); // m_stopAction->plug(toolBar()); ### m_breakAction->plug(toolBar()); toolBar()->insertWidget(1, 300, m_sourceSel); toolBar()->setItemAutoSized(1); updateContextList(); setMinimumSize(300, 200); resize(600, 450); }