📄 contextkeymanager.cpp
字号:
KeyMap::Iterator it = (*wit).find(key); if (it != (*wit).end()) { if ((*it).type(modal) != ModalState::NoLabel) return w; } } // Next see if key is set for the class (must accept focus) if (w->focusPolicy() != QWidget::NoFocus) { QValueList<ClassModalState>::Iterator cit; for (cit = contextClass.begin(); cit != contextClass.end(); ++cit) { if (w->inherits((*cit).className)) { KeyMap::Iterator it = (*cit).keyMap.find(key); if (it != (*cit).keyMap.end()) { if ((*it).type(modal) != ModalState::NoLabel) return w; } } } } // otherwise try our parent if (w->parentWidget() && !w->isTopLevel()) return findTargetWidget(w->parentWidget(), key, FALSE); // No one has claimed this key. return 0;}bool ContextKeyManager::haveLabelForWidget(QWidget *w, int key, bool modal){ if (buttons.count()) { QMap<QWidget*,KeyMap>::Iterator wit = contextWidget.find(w); if (wit != contextWidget.end()) { KeyMap::Iterator it = (*wit).find(key); if (it != (*wit).end()) { if ((*it).type(modal) != ModalState::NoLabel) return TRUE; } } } return FALSE;}void ContextKeyManager::setContextText(QWidget *w, int key, const QString &t, ContextBar::EditingState state){ if (!contextWidget.contains(w)) connect(w, SIGNAL(destroyed()), this, SLOT(removeSenderFromWidgetContext())); KeyMap &keyMap = contextWidget[w]; ModalState &ms = keyMap[key]; if (state & ContextBar::Modal) { ms.mType = ModalState::Custom; ms.mText = t; } if (state & ContextBar::NonModal) { ms.nmType = ModalState::Custom; ms.nmText = t; } updateContextLabels();}void ContextKeyManager::setContextPixmap(QWidget *w, int key, const QString &t, ContextBar::EditingState state){ if (!contextWidget.contains(w)) connect(w, SIGNAL(destroyed()), this, SLOT(removeSenderFromWidgetContext())); KeyMap &keyMap = contextWidget[w]; ModalState &ms = keyMap[key]; if (state & ContextBar::Modal) { ms.mType = ModalState::Custom; ms.mPixmap = t; } if (state & ContextBar::NonModal) { ms.nmType = ModalState::Custom; ms.nmPixmap = t; } updateContextLabels();}void ContextKeyManager::setContextStandardLabel(QWidget *w, int key, ContextBar::StandardLabel label, ContextBar::EditingState state){ if (!contextWidget.contains(w)) connect(w, SIGNAL(destroyed()), this, SLOT(removeSenderFromWidgetContext())); KeyMap &keyMap = contextWidget[w]; ModalState &ms = keyMap[key]; if (state & ContextBar::Modal) { ms.mType = ModalState::Standard; ms.mStandard = label; } if (state & ContextBar::NonModal) { ms.nmType = ModalState::Standard; ms.nmStandard = label; } updateContextLabels();}void ContextKeyManager::clearContextLabel(QWidget *w, int key, ContextBar::EditingState state){ KeyMap &keyMap = contextWidget[w]; ModalState &ms = keyMap[key]; if (state & ContextBar::Modal) { ms.mType = ModalState::NoLabel; } if (state & ContextBar::NonModal) { ms.nmType = ModalState::NoLabel; } updateContextLabels();}void ContextKeyManager::setClassText(const QCString &className, int key, const QString &t, ContextBar::EditingState state){ ClassModalState cms(className); QValueList<ClassModalState>::Iterator it = contextClass.find(cms); if (it == contextClass.end()) it = contextClass.prepend(cms); ModalState &ms = (*it).keyMap[key]; if (state & ContextBar::Modal) { ms.mType = ModalState::Custom; ms.mText = t; } if (state & ContextBar::NonModal) { ms.nmType = ModalState::Custom; ms.nmText = t; }}void ContextKeyManager::setClassPixmap(const QCString &className, int key, const QString &t, ContextBar::EditingState state){ ClassModalState cms(className); QValueList<ClassModalState>::Iterator it = contextClass.find(cms); if (it == contextClass.end()) it = contextClass.prepend(cms); ModalState &ms = (*it).keyMap[key]; if (state & ContextBar::Modal) { ms.mType = ModalState::Custom; ms.mPixmap = t; } if (state & ContextBar::NonModal) { ms.nmType = ModalState::Custom; ms.nmPixmap = t; }}void ContextKeyManager::setClassStandardLabel(const QCString &className, int key, ContextBar::StandardLabel label, ContextBar::EditingState state){ ClassModalState cms(className); QValueList<ClassModalState>::Iterator it = contextClass.find(cms); if (it == contextClass.end()) it = contextClass.prepend(cms); ModalState &ms = (*it).keyMap[key]; if (state & ContextBar::Modal) { ms.mType = ModalState::Standard; ms.mStandard = label; } if (state & ContextBar::NonModal) { ms.nmType = ModalState::Standard; ms.nmStandard = label; }}void ContextKeyManager::removeSenderFromWidgetContext(){ if ( contextWidget.contains((QWidget*)sender() )) { QWidget *w = (QWidget*)sender();#ifdef DEBUG_CONTEXT_KEYS qDebug("Removing context widget: %s(%p)", w->className(), w);#endif contextWidget.remove(w); updateContextLabels(); }}ContextKeyManager *ContextKeyManager::instance(){ if (!contextKeyMgr) contextKeyMgr = new ContextKeyManager(); return contextKeyMgr;}void ContextKeyManager::setStandard(int key, ContextBar::StandardLabel label){ QString l = standardPixmap(label); if (!!l) setPixmap(key, l); else setText(key, standardText(label));}void ContextKeyManager::setText(int key, const QString &text){ QCopEnvelope e( "QPE/ContextBar", "setLabelText(int,QString)"); e << key; e << text;}void ContextKeyManager::setPixmap(int key, const QString &pm){ QCopEnvelope e( "QPE/ContextBar", "setLabelPixmap(int,QString)"); e << key; e << pm;}void ContextKeyManager::clearLabel(int key){ QCopEnvelope e( "QPE/ContextBar", "clearLabel(int)"); e << key;}QString ContextKeyManager::standardText(ContextBar::StandardLabel l){ switch (l) { case ContextBar::NoLabel: return ""; case ContextBar::Options: return tr("Options"); case ContextBar::Ok: return tr("OK"); case ContextBar::Edit: return tr("Edit"); case ContextBar::Select: return tr("Select"); case ContextBar::View: return tr("View"); case ContextBar::Cancel: return tr("Cancel"); case ContextBar::Back: return tr("Back"); case ContextBar::BackSpace: return tr("Delete"); case ContextBar::Next: return tr("Next"); case ContextBar::Previous: return tr("Prev"); default: return QString::null; }}QString ContextKeyManager::standardPixmap(ContextBar::StandardLabel l){ switch (l) { case ContextBar::NoLabel: return ""; case ContextBar::Options: return "contextbar/options"; case ContextBar::Back: return "contextbar/back"; case ContextBar::Cancel: return "contextbar/cancel"; case ContextBar::Ok: return "contextbar/ok"; case ContextBar::Edit: return "contextbar/edit"; case ContextBar::Select: return "contextbar/select"; case ContextBar::View: return "contextbar/view"; case ContextBar::BackSpace: return "contextbar/backspace"; case ContextBar::Next: return "contextbar/next"; case ContextBar::Previous: return "contextbar/previous"; default: return QString::null; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -