当前位置: 首页>>代码示例>>C++>>正文


C++ KShortcut::count方法代码示例

本文整理汇总了C++中KShortcut::count方法的典型用法代码示例。如果您正苦于以下问题:C++ KShortcut::count方法的具体用法?C++ KShortcut::count怎么用?C++ KShortcut::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KShortcut的用法示例。


在下文中一共展示了KShortcut::count方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: keyConflict

// Returns iSeq index if cut2 has a sequence of equal or higher priority to a sequence in cut.
// else -1
static int keyConflict(const KShortcut &cut, const KShortcut &cut2)
{
    for(uint iSeq = 0; iSeq < cut.count(); iSeq++)
    {
        for(uint iSeq2 = 0; iSeq2 < cut2.count(); iSeq2++)
        {
            if(cut.seq(iSeq) == cut2.seq(iSeq2))
                return iSeq;
        }
    }
    return -1;
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例2: containsSingleKeyTrigger

// 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;
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:31,代码来源:kptool.cpp

示例3: setShortcut

void KKeyChooser::setShortcut(const KShortcut &cut)
{
    kdDebug(125) << "KKeyChooser::setShortcut( " << cut.toString() << " )" << endl;
    KKeyChooserItem *pItem = dynamic_cast< KKeyChooserItem * >(d->pList->currentItem());
    if(!pItem)
        return;

    for(uint i = 0; i < cut.count(); i++)
    {
        const KKeySequence &seq = cut.seq(i);
        const KKey &key = seq.key(0);

        if(!d->bAllowLetterShortcuts && key.modFlags() == 0 && key.sym() < 0x3000 && QChar(key.sym()).isLetterOrNumber())
        {
            QString s = i18n(
                            "In order to use the '%1' key as a shortcut, "
                            "it must be combined with the "
                            "Win, Alt, Ctrl, and/or Shift keys.")
                            .arg(QChar(key.sym()));
            KMessageBox::sorry(this, s, i18n("Invalid Shortcut Key"));
            return;
        }
    }

    // If key isn't already in use,
    if(!isKeyPresent(cut))
    {
        // Set new key code
        pItem->setShortcut(cut);
        // Update display
        updateButtons();
        emit keyChange();
    }
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例4: toolTipForTextAndShortcut

// public static
QString kpTool::toolTipForTextAndShortcut (const QString &text,
                                           const KShortcut &shortcut)
{
    for (int i = 0; i < (int) shortcut.count (); i++)
    {
        const KKeySequence seq = shortcut.seq (i);
        if (seq.count () == 1 && containsSingleKeyTrigger (seq))
        {
            return i18n ("<Tool Name> (<Single Accel Key>)",
                         "%1 (%2)")
                       .arg (text, seq.toString ());
        }
    }

    return text;
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:17,代码来源:kptool.cpp

示例5: text

QString KKeyChooserItem::text(int iCol) const
{
    if(iCol == 0)
    {
        // Quick HACK to get rid of '&'s.
        QString s = m_pList->label(m_iAction);
        QString s2;
        for(uint i = 0; i < s.length(); i++)
            if(s[i] != '&' || (i + 1 < s.length() && s[i + 1] == '&'))
                s2 += s[i];
        return s2;
    }
    else if(iCol <= (int)m_cut.count())
        return m_cut.seq(iCol - 1).toString();
    else
        return QString::null;
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例6: checkStandardShortcutsConflict

bool KKeyChooser::checkStandardShortcutsConflict(const KShortcut &cut, bool bWarnUser, QWidget *parent)
{
    // For each key sequence in the shortcut,
    for(uint i = 0; i < cut.count(); i++)
    {
        const KKeySequence &seq = cut.seq(i);
        KStdAccel::StdAccel id = KStdAccel::findStdAccel(seq);
        if(id != KStdAccel::AccelNone && keyConflict(cut, KStdAccel::shortcut(id)) > -1)
        {
            if(bWarnUser)
            {
                if(!promptForReassign(seq, KStdAccel::label(id), Standard, parent))
                    return true;
                removeStandardShortcut(KStdAccel::label(id), dynamic_cast< KKeyChooser * >(parent), KStdAccel::shortcut(id), cut);
            }
        }
    }
    return false;
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例7: displayAccessKeys

void KKbdAccessExtensions::displayAccessKeys()
{
    // Build a list of valid access keys that don't collide with shortcuts.
    QString availableAccessKeys = "ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890";
    QPtrList<KXMLGUIClient> allClients = d->mainWindow->factory()->clients();
    QPtrListIterator<KXMLGUIClient> it( allClients );
    KXMLGUIClient *client;
    while( (client=it.current()) !=0 )
    {
        ++it;
        KActionPtrList actions = client->actionCollection()->actions();
        for (int j = 0; j < (int)actions.count(); j++) {
            KAction* action = actions[j];
            KShortcut sc = action->shortcut();
            for (int i = 0; i < (int)sc.count(); i++) {
                KKeySequence seq = sc.seq(i);
                if (seq.count() == 1) {
                    QString s = seq.toString();
                    if (availableAccessKeys.contains(s))
                        availableAccessKeys.remove(s);
                }
            }
        }
    }
    // Find all visible, focusable widgets and create a QLabel for each.  Don't exceed
    // available list of access keys.
    QWidgetList* allWidgets = kapp->allWidgets();
    QWidget* widget = allWidgets->first();
    int accessCount = 0;
    int maxAccessCount = availableAccessKeys.length();
    int overlap = 20;
    QPoint prevGlobalPos = QPoint(-overlap, -overlap);
    while (widget && (accessCount < maxAccessCount)) {
        if (widget->isVisible() && widget->isFocusEnabled() ) {
            QRect r = widget->rect();
            QPoint p(r.x(), r.y());
            // Don't display an access key if within overlap pixels of previous one.
            QPoint globalPos = widget->mapToGlobal(p);
            QPoint diffPos = globalPos - prevGlobalPos;
            if (diffPos.manhattanLength() > overlap) {
                accessCount++;
                QLabel* lab=new QLabel(widget, "", widget, 0, Qt::WDestructiveClose);
                lab->setPalette(QToolTip::palette());
                lab->setLineWidth(2);
                lab->setFrameStyle(QFrame::Box | QFrame::Plain);
                lab->setMargin(3);
                lab->adjustSize();
                lab->move(p);
                if (!d->accessKeyLabels) {
                    d->accessKeyLabels = new QPtrList<QLabel>;
                    d->accessKeyLabels->setAutoDelete(true);
                }
                d->accessKeyLabels->append(lab);
                prevGlobalPos = globalPos;
            }
        }
        widget = allWidgets->next();
    }
    if (accessCount > 0) {
        // Sort the access keys from left to right and down the screen.
        QValueList<KSortedLabel> sortedLabels;
        for (int i = 0; i < accessCount; i++)
            sortedLabels.append(KSortedLabel(d->accessKeyLabels->at(i)));
        qHeapSort( sortedLabels );
        // Assign access key labels.
        for (int i = 0; i < accessCount; i++) {
            QLabel* lab = sortedLabels[i].label();
            QChar s = availableAccessKeys[i];
            lab->setText(s);
            lab->adjustSize();
            lab->show();
        }
    }
}
开发者ID:,项目名称:,代码行数:74,代码来源:

示例8: removeFromShortcut

// Removes the sequences in cut2 from cut1
static void removeFromShortcut(KShortcut &cut1, const KShortcut &cut2)
{
    for(uint iSeq2 = 0; iSeq2 < cut2.count(); iSeq2++)
        cut1.remove(cut2.seq(iSeq2));
}
开发者ID:,项目名称:,代码行数:6,代码来源:


注:本文中的KShortcut::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。