void TaskView::keyPressEvent(QKeyEvent* ke) { if (ActiveCtrl && ActiveDialog) { if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) { // get all buttons of the complete task dialog QList<QPushButton*> list = this->findChildren<QPushButton*>(); for (int i=0; i<list.size(); ++i) { QPushButton *pb = list.at(i); if (pb->isDefault() && pb->isVisible()) { if (pb->isEnabled()) pb->click(); return; } } } else if (ke->key() == Qt::Key_Escape) { // get only the buttons of the button box QDialogButtonBox* box = ActiveCtrl->standardButtons(); QList<QAbstractButton*> list = box->buttons(); for (int i=0; i<list.size(); ++i) { QAbstractButton *pb = list.at(i); if (box->buttonRole(pb) == QDialogButtonBox::RejectRole) { if (pb->isEnabled()) pb->click(); return; } } } } else { QScrollArea::keyPressEvent(ke); } }
bool QAquaAnimate::addWidget(QWidget *w) { if(focusable(w)) { if(w->hasFocus()) setFocusWidget(w); w->installEventFilter(this); } if(w == d->defaultButton || d->progressBars.contains((QProgressBar*)w)) //already knew of it return FALSE; if(w->inherits("QPushButton")){ QPushButton * btn = (QPushButton *) w; if(btn->isDefault() || (btn->autoDefault() && btn->hasFocus())){ d->defaultButton = btn; btn->installEventFilter(this); if(btn->isVisible() && d->buttonTimerId == -1) d->buttonTimerId = startTimer(50); } return TRUE; } else if(w->inherits("QProgressBar")){ w->installEventFilter(this); QObject::connect(w, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*))); if(w->isVisible() && d->progressTimerId == -1) { d->progressBars.append((QProgressBar*)w); d->progressTimerId = startTimer(50); } return TRUE; } else if(w->inherits("QListView")) {
/*! \reimp */ QString QAccessibleButton::text(Text t, int child) const { QString str; switch (t) { case Accelerator: { #ifndef QT_NO_SHORTCUT QPushButton *pb = qobject_cast<QPushButton*>(object()); if (pb && pb->isDefault()) str = (QString)QKeySequence(Qt::Key_Enter); #endif if (str.isEmpty()) str = qt_accHotKey(button()->text()); } break; case Name: str = widget()->accessibleName(); if (str.isEmpty()) str = button()->text(); break; default: break; } if (str.isEmpty()) str = QAccessibleWidgetEx::text(t, child); return qt_accStripAmp(str); }
void RadioGroup::slotToggled() { if (!m_bInit){ QPushButton *btnDefault = NULL; QObjectList *l = topLevelWidget()->queryList("QPushButton"); QObjectListIt it(*l); QObject *obj; while ((obj=it.current()) != NULL){ btnDefault = static_cast<QPushButton*>(obj); if (btnDefault->isDefault()) break; btnDefault = NULL; ++it; } delete l; if (btnDefault){ m_bInit = true; QObjectList *l = parentWidget()->queryList("QLineEdit"); QObjectListIt it(*l); QObject *obj; while ((obj=it.current()) != NULL){ connect(obj, SIGNAL(returnPressed()), btnDefault, SLOT(animateClick())); ++it; } delete l; } } slotToggled(m_button->isChecked()); }
/*! \reimp */ QString QAccessibleButton::text(QAccessible::Text t) const { QString str; switch (t) { case QAccessible::Accelerator: { #ifndef QT_NO_SHORTCUT QPushButton *pb = qobject_cast<QPushButton*>(object()); if (pb && pb->isDefault()) str = QKeySequence(Qt::Key_Enter).toString(QKeySequence::NativeText); #endif if (str.isEmpty()) str = qt_accHotKey(button()->text()); } break; case QAccessible::Name: str = widget()->accessibleName(); if (str.isEmpty()) str = qt_accStripAmp(button()->text()); break; default: break; } if (str.isEmpty()) str = QAccessibleWidget::text(t); return str; }
QAccessible::State QAccessibleButton::state() const { QAccessible::State state = QAccessibleWidget::state(); QAbstractButton *b = button(); QCheckBox *cb = qobject_cast<QCheckBox *>(b); if (b->isCheckable()) state.checkable = true; if (b->isChecked()) state.checked = true; else if (cb && cb->checkState() == Qt::PartiallyChecked) state.checkStateMixed = true; if (b->isDown()) state.pressed = true; QPushButton *pb = qobject_cast<QPushButton*>(b); if (pb) { if (pb->isDefault()) state.defaultButton = true; #ifndef QT_NO_MENU if (pb->menu()) state.hasPopup = true; #endif } return state; }
void TaskView::keyPressEvent(QKeyEvent* ke) { if (ActiveCtrl && ActiveDialog) { if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) { // get all buttons of the complete task dialog QList<QPushButton*> list = this->findChildren<QPushButton*>(); for (int i=0; i<list.size(); ++i) { QPushButton *pb = list.at(i); if (pb->isDefault() && pb->isVisible()) { if (pb->isEnabled()) { #if defined(FC_OS_MACOSX) // #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries QPoint pos = QCursor::pos(); QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos())); #endif pb->click(); #if defined(FC_OS_MACOSX) QCursor::setPos(pos); #endif } return; } } } else if (ke->key() == Qt::Key_Escape) { // get only the buttons of the button box QDialogButtonBox* box = ActiveCtrl->standardButtons(); QList<QAbstractButton*> list = box->buttons(); for (int i=0; i<list.size(); ++i) { QAbstractButton *pb = list.at(i); if (box->buttonRole(pb) == QDialogButtonBox::RejectRole) { if (pb->isEnabled()) { #if defined(FC_OS_MACOSX) // #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries QPoint pos = QCursor::pos(); QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos())); #endif pb->click(); #if defined(FC_OS_MACOSX) QCursor::setPos(pos); #endif } return; } } } } else { QScrollArea::keyPressEvent(ke); } }
int drv_button(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9) { handle_head* head = (handle_head*)a0; QPushButton *self = (QPushButton*)head->native; switch (drvid) { case BUTTON_INIT: { drvNewObj(a0,new QPushButton); break; } case BUTTON_SETFLAT: { self->setFlat(drvGetBool(a1)); break; } case BUTTON_ISFLAT: { drvSetBool(a1,self->isFlat()); break; } case BUTTON_SETDEFAULT: { self->setDefault(drvGetBool(a1)); break; } case BUTTON_ISDEFAULT: { drvSetBool(a1,self->isDefault()); break; } case BUTTON_SETMENU: { self->setMenu(drvGetMenu(a1)); break; } case BUTTON_MENU: { drvSetHandle(a1,self->menu()); break; } case BUTTON_ONCLICKED: { QObject::connect(self,SIGNAL(clicked()),drvNewSignal(self,a1,a2),SLOT(call())); break; } default: return 0; } return 1; }
/*! \reimp */ QAccessible::State QAccessibleButton::state(int child) const { State state = QAccessibleWidgetEx::state(child); QAbstractButton *b = button(); QCheckBox *cb = qobject_cast<QCheckBox *>(b); if (b->isChecked()) state |= Checked; else if (cb && cb->checkState() == Qt::PartiallyChecked) state |= Mixed; if (b->isDown()) state |= Pressed; QPushButton *pb = qobject_cast<QPushButton*>(b); if (pb) { if (pb->isDefault()) state |= DefaultButton; #ifndef QT_NO_MENU if (pb->menu()) state |= HasPopup; #endif } return state; }