Exemplo n.º 1
0
bool ShortcutButton::focusNextPrevChild(bool next)
{
    if ( m_buttonAddShortcut->hasFocus() ) {
        if (next || shortcutButtonCount() == 0)
            return QWidget::focusNextPrevChild(next);
        shortcutButton(shortcutButtonCount() - 1)->setFocus();
        return true;
    } else if (shortcutButtonCount() == 0) {
        m_buttonAddShortcut->setFocus();
        return true;
    }

    int current = -1;
    for ( int i = 0; i < shortcutButtonCount(); ++i ) {
        if ( shortcutButton(i)->hasFocus() ) {
            current = i;
            break;
        }
    }

    if (current == 0 && !next)
        return QWidget::focusNextPrevChild(next);

    if (current == shortcutButtonCount() - 1 && next) {
        m_buttonAddShortcut->setFocus();
    } else if (current == -1 && !next) {
        shortcutButton(shortcutButtonCount() - 1)->setFocus();
    } else {
        shortcutButton(current + (next ? 1 : -1))->setFocus();
    }

    return true;
}
Exemplo n.º 2
0
void ShortcutButton::clearShortcuts()
{
    while ( shortcutCount() > 0 ) {
        QWidget *w = shortcutButton(0);
        emit shortcutRemoved( shortcutForButton(*w) );
        delete w;
    }
}
Exemplo n.º 3
0
QList<QKeySequence> ShortcutButton::shortcuts() const
{
    QList<QKeySequence> shortcuts;

    for ( int i = 0; i < shortcutCount(); ++i ) {
        QWidget *w = shortcutButton(i);
        shortcuts.append( shortcutForButton(*w) );
    }

    return shortcuts;
}
Exemplo n.º 4
0
void ShortcutButton::checkAmbiguousShortcuts(const QList<QKeySequence> &ambiguousShortcuts,
                                             const QIcon &warningIcon, const QString &warningToolTip)
{
    QList<QKeySequence> shortcuts = this->shortcuts();
    for ( int i = 0; i < shortcuts.size(); ++i ) {
        QWidget *w = shortcutButton(i);
        if ( ambiguousShortcuts.contains(shortcuts[i]) ) {
            w->setProperty("icon", warningIcon);
            w->setProperty("toolTip", warningToolTip);
        } else if ( w->property("toolTip").toString() == warningToolTip ) {
            w->setProperty("icon", QIcon());
            w->setProperty("toolTip", QString());
        }
    }
}