void RegionGrabber::grabRect()
{
    QRect r = selection;
    if ( !r.isNull() && r.isValid() )
    {
        grabbing = true;
        emit regionUpdated( r );
        emit regionGrabbed( pixmap.copy(r) );
    }
}
void Ut_MImToolbar::testShowToolbarWidget()
{
    QSignalSpy spy(m_subject, SIGNAL(regionUpdated()));
    QVERIFY(spy.isValid());
    m_subject->showToolbarWidget(toolbarData);
    //toolbar buttons depend on the its data
    //including spacing widget and close button
    QCOMPARE(m_subject->leftBar.layout()->count(), 2);
    QCOMPARE(m_subject->rightBar.layout()->count(), 1);
    QCOMPARE(spy.count(), 1);
    spy.clear();
}
void Ut_MImToolbar::testRegion()
{
    QSKIP("Skip this case because Qt (4.7.1~git20101130) break the vkb toolbar.",
          SkipAll);
    QSignalSpy regionSignals(m_subject, SIGNAL(regionUpdated()));

    m_subject->showToolbarWidget(toolbarData);
    QCOMPARE(regionSignals.count(), 1);
    m_subject->updateVisibility();
    QCOMPARE(regionSignals.count(), 1);

    // Get region when there are two buttons on the right.
    const QRegion regionTwoButtons = m_subject->region();

    // When the region is substracted from rightRect there should be nothing left.
    const QRect rightRect = m_subject->rightBar.geometry().toRect();
    QVERIFY((QRegion(rightRect) - regionTwoButtons).isEmpty());

    // We need to add a new button, let's use groups.
    // Clicking testbutton1 will add one button to the right.
    MButton *button = qobject_cast<MButton *>(find("testbutton1"));
    QVERIFY(button != 0);
    button->click();

    while (QCoreApplication::hasPendingEvents()) {
        QCoreApplication::processEvents();
    }

    // Button added, check that regionUpdate() was emitted.
    QCOMPARE(regionSignals.count(), 2);

    // Get region when there are three buttons on the right.
    const QRegion regionThreeButtons = m_subject->region();

    // Toolbar always occupy the same region,
    // because our toolbar contains one line only.
    QCOMPARE(regionThreeButtons, regionTwoButtons);

    m_subject->finalizeOrientationChange();
    QCOMPARE(regionSignals.count(), 2);

    m_subject->hideToolbarWidget();

    QCOMPARE(regionSignals.count(), 3);

    m_subject->hide();

    QCOMPARE(regionSignals.count(), 4);
    QVERIFY(m_subject->region().isEmpty());
}
Exemplo n.º 4
0
void RegionGrab::grabRect()
{
  const QRect &r = m_selection;
  if (!r.isNull() && r.isValid()) {
    m_grabbing = true;
    emit regionUpdated(r);
    emit regionGrabbed(m_pixmap.copy(r));
  }

# ifdef Q_OS_MAC
  showNormal();
# endif
  close();
}
void RegionGrabber::keyPressEvent( QKeyEvent* e )
{
    QRect r = selection;
    if ( e->key() == Qt::Key_Escape )
    {
        emit regionUpdated( r );
        emit regionGrabbed( QPixmap() );
    }
    else if ( e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return )
    {
        grabRect();
    }
    else
    {
        e->ignore();
    }
}
Exemplo n.º 6
0
void RegionGrab::keyPressEvent(QKeyEvent* event)
{
  if (event->key() == Qt::Key_Escape) {
    emit regionUpdated(m_selection);
    emit regionGrabbed(QPixmap());

#   ifdef Q_OS_MAC
    showNormal();
#   endif

    close();
  }
  else if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
    grabRect();
  }
  else
    event->ignore();
}