Ejemplo n.º 1
0
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")) {
Ejemplo n.º 2
0
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);
    }
}
Ejemplo n.º 3
0
bool DialogyWidget::clickButton(QDialogButtonBox::StandardButton standardButton)
{
    QPushButton* pb = qobject_cast<QPushButton*>(focusWidget());
    if (pb && pb->isVisible() && pb->isEnabled() && pb->hasFocus()) {
        pb->click();
        return true;
    }

    QList<QDialogButtonBox*> buttonBoxes = findChildren<QDialogButtonBox*>();
    for (int i = 0; i < buttonBoxes.size(); ++i) {
        QDialogButtonBox* buttonBox = buttonBoxes.at(i);
        pb = buttonBox->button(standardButton);
        if (pb && pb->isVisible() && pb->isEnabled()) {
            pb->click();
            return true;
        }
    }

    return false;
}
Ejemplo n.º 4
0
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);
    }
}
Ejemplo n.º 5
0
void tst_Q3DockWindow::showChild()
{
    // task 26225
    // calling show dose not propergate to child widgets if
    // main window is already showing

    Q3MainWindow mw;
    mw.show();
    Q3DockWindow * dock = new Q3DockWindow(&mw);
    QPushButton  * qpb = new QPushButton("hi", dock);
    dock->setWidget(qpb);
    dock->show();
    QVERIFY( mw.isVisible() );
    QVERIFY( dock->isVisible() );
    QVERIFY( qpb->isVisible() );
}
Ejemplo n.º 6
0
// QTabBar::setTabButton(index, closeSide, closeButton);
void tst_QTabBar::tabButton()
{
    QFETCH(QTabBar::ButtonPosition, position);
    QTabBar::ButtonPosition otherSide = (position == QTabBar::LeftSide ? QTabBar::RightSide : QTabBar::LeftSide);

    QTabBar tabbar;
    tabbar.resize(500, 200);
    tabbar.show();
    QTRY_VERIFY(tabbar.isVisible());

    tabbar.setTabButton(-1, position, 0);
    QVERIFY(tabbar.tabButton(-1, position) == 0);
    QVERIFY(tabbar.tabButton(0, position) == 0);

    tabbar.addTab("foo");
    QCOMPARE(tabbar.count(), 1);
    tabbar.setTabButton(0, position, 0);
    QVERIFY(tabbar.tabButton(0, position) == 0);

    QPushButton *button = new QPushButton;
    button->show();
    button->setText("hi");
    button->resize(10, 10);
    QTRY_VERIFY(button->isVisible());
    QTRY_VERIFY(button->isVisible());

    tabbar.setTabButton(0, position, button);

    QCOMPARE(tabbar.tabButton(0, position), static_cast<QWidget *>(button));
    QTRY_VERIFY(!button->isHidden());
    QVERIFY(tabbar.tabButton(0, otherSide) == 0);
    QCOMPARE(button->parent(), static_cast<QObject *>(&tabbar));
    QVERIFY(button->pos() != QPoint(0, 0));

    QPushButton *button2 = new QPushButton;
    tabbar.setTabButton(0, position, button2);
    QVERIFY(button->isHidden());
}