void QGroupBox::fixFocus()
{
    QFocusData * fd = focusData();
    QWidget * orig = fd->home();
    QWidget * best = 0;
    QWidget * candidate = 0;
    QWidget * w = orig;
    do {
        QWidget * p = w;
        while( p && p != this && !p->isTopLevel() )
            p = p->parentWidget();
        if ( p == this && ( w->focusPolicy() & TabFocus ) == TabFocus
                && w->isVisibleTo(this) ) {
            if ( w->hasFocus()
#ifndef QT_NO_RADIOBUTTON
                    || ( !best && ::qt_cast<QRadioButton*>(w)
                         && ((QRadioButton*)w)->isChecked() )
#endif
               )
                // we prefer a checked radio button or a widget that
                // already has focus, if there is one
                best = w;
            else if ( !candidate )
                // but we'll accept anything that takes focus
                candidate = w;
        }
        w = fd->next();
    } while( w != orig );
    if ( best )
        best->setFocus();
    else if ( candidate )
        candidate->setFocus();
}
Example #2
0
void TabWidget::setCurrentIndex(int tabIndex)
{
    QWidget *w = currentWidget();
    const int current = (isTreeModeEnabled() && w != NULL && w->isHidden()) ? -1 : currentIndex();

    if (tabIndex == current)
        return;

    if (tabIndex != -1) {
        m_stackedWidget->setCurrentIndex(tabIndex);

        w = currentWidget();
        if (w == NULL)
            return;

        w->show();
        if (isTreeModeEnabled() ? m_tabTree->hasFocus() : m_tabBar->hasFocus())
            w->setFocus();

        if ( isTreeModeEnabled() )
            m_tabTree->setCurrentTabIndex(tabIndex);
        else
            m_tabBar->setCurrentIndex(tabIndex);
    } else if (w != NULL) {
        if (w->hasFocus())
            isTreeModeEnabled() ? m_tabTree->setFocus() : m_tabBar->setFocus();
        w->hide();
    }

    emit currentChanged(tabIndex, current);
}
Example #3
0
void OutputWidget::eventuallyDoFocus()
{
    QWidget* widget = currentWidget();
    if( focusOnSelect->isChecked() && !widget->hasFocus() ) {
        widget->setFocus( Qt::OtherFocusReason );
    }
}
bool ShortcutOverrideFilter::eventFilter(QObject* object, QEvent* event) {
    QWidget* widget = qobject_cast<QWidget*>(object);
    int i;
    if (!widget)
        return false;

    // If a key sequence is bound to a shortcut, Qt dispatches a ShortcutOverride
    // event event instead of a KeyPress, if it is handled, then the normal keypress
    // event will follow, otherwise the shortcut is activated
    if (event->type() == QEvent::ShortcutOverride) {
        QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
        QKeySequence pressed(keyEvent->key() + keyEvent->modifiers());

        if (keyEvent->key() == Qt::Key_Escape) {
            if (widget->hasFocus()) {
                if (qobject_cast<QLineEdit*>(object) || qobject_cast<QComboBox*>(object)) {
                    event->accept();
                    return true;
                }
            }
        } else {
            for (i=0; i<overrides.size(); i++) {
                if (pressed == overrides.at(i)) {
                    event->accept();
                    return true;
                }
            }
        }
    }
    return false;
}
Example #5
0
void FLDataTable::selectRow(int r, int c)
{
  if (!cursor_ || !cursor_->metadata())
    return ;

  if (r < 0) {
    if (cursor_->isValid()) {
      rowSelected = cursor_->at();
      colSelected = currentColumn();
    } else {
      rowSelected = 0;
      colSelected = 0;
    }
  } else {
    rowSelected = r;
    colSelected = c;
  }

  QObject *snd = const_cast<QObject *>(sender());
  if (!snd || (snd && !snd ->isA("FLSqlCursor"))) {
    QWidget *sndw = ::qt_cast<QWidget *>(snd);
    if (sndw) {
      if (!sndw->hasFocus() || !sndw->isVisible()) {
        setCurrentCell(rowSelected, colSelected);
        return ;
      }
    }
    if (numRows() != cursor_->size())
      setNumRows(cursor_->size());
    cursor_->seek(rowSelected);
  }
  setCurrentCell(rowSelected, colSelected);
}
Example #6
0
bool QWidgetProto::hasFocus() const
{
  QWidget *item = qscriptvalue_cast<QWidget*>(thisObject());
  if (item)
    return item->hasFocus();
  return false;
}
/*! \reimp */
QAccessible::State QAccessibleWidget::state(int child) const
{
    if (child)
        return Normal;

    QAccessible::State state = Normal;

    QWidget *w = widget();
    if (w->testAttribute(Qt::WA_WState_Visible) == false)
        state |= Invisible;
    if (w->focusPolicy() != Qt::NoFocus)
        state |= Focusable;
    if (w->hasFocus())
        state |= Focused;
    if (!w->isEnabled())
        state |= Unavailable;
    if (w->isWindow()) {
        if (w->windowFlags() & Qt::WindowSystemMenuHint)
            state |= Movable;
        if (w->minimumSize() != w->maximumSize())
            state |= Sizeable;
    }

    return state;
}
Example #8
0
bool QWebFramePrivate::handleProgressFinished(QPoint *localPos)
{
    QWidget *view = q->page()->view();
    if (!view || !localPos)
        return false;
    *localPos = view->mapFromGlobal(QCursor::pos());
    return view->hasFocus() && view->rect().contains(*localPos);
}
Example #9
0
void MainWindow::toggleComandLineFocus()
{
    QWidget *cmd = cmdLine();
    if(cmd->hasFocus()) {
        QWidget *editor = mEditors->currentEditor();
        if(editor) editor->setFocus(Qt::OtherFocusReason);
    }
    else
        cmd->setFocus(Qt::OtherFocusReason);
}
Example #10
0
void FrameLoaderClientQt::postProgressFinishedNotification()
{
    // send a mousemove event to
    // (1) update the cursor to change according to whatever is underneath the mouse cursor right now
    // (2) display the tool tip if the mouse hovers a node which has a tool tip
    if (m_frame && m_frame->eventHandler() && m_webFrame->page()) {
        QWidget* view = m_webFrame->page()->view();
        if (view && view->hasFocus()) {
            QPoint localPos = view->mapFromGlobal(QCursor::pos());
            if (view->rect().contains(localPos)) {
                QMouseEvent event(QEvent::MouseMove, localPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
                m_frame->eventHandler()->mouseMoved(PlatformMouseEvent(&event, 0));
            }
        }
    }

    if (m_webFrame && m_frame->page())
        emit loadFinished(m_loadError.isNull());
}
/*! \reimp */
QAccessible::State QAccessibleWidget::state() const
{
    QAccessible::State state;

    QWidget *w = widget();
    if (w->testAttribute(Qt::WA_WState_Visible) == false)
        state.invisible = true;
    if (w->focusPolicy() != Qt::NoFocus)
        state.focusable = true;
    if (w->hasFocus())
        state.focused = true;
    if (!w->isEnabled())
        state.disabled = true;
    if (w->isWindow()) {
        if (w->windowFlags() & Qt::WindowSystemMenuHint)
            state.movable = true;
        if (w->minimumSize() != w->maximumSize())
            state.sizeable = true;
        if (w->isActiveWindow())
            state.active = true;
    }

    return state;
}