Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QDir::setCurrent(QCoreApplication::applicationDirPath());
    QDir dir(QDir::current());

    // set the slide model.
    QFile xmlf(dir.absoluteFilePath("userdata/test.xml"));
    if (!xmlf.exists()) {
        QMessageBox::critical(0, "error", "no xml file...");
        return 0;
    }
    xmlf.open(QFile::ReadWrite);
    QSlideModel model(xmlf.readAll());
    xmlf.close();


    // set the slide scene
    QSlidePlayerScene *scene = new QSlidePlayerScene(0, &model);
    QPixmap pixmap(dir.absoluteFilePath("res/images/default-background.png"));
    scene->setBackgroundBrush(Qt::black);
    scene->setBackgroundPixmap(pixmap);

    //set slide view
    QGraphicsView *view = new QGraphicsView(scene);

    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setFrameShape(QFrame::NoFrame);
    // editing is not allowed.
    view->setInteractive(false);

    // scale
    double newScale = QApplication::desktop()->height() / scene->sceneRect().height();
    QMatrix oldMatrix = view->matrix();
    view->resetMatrix();
    view->translate(oldMatrix.dx(), oldMatrix.dy());
    view->scale(newScale, newScale);

    view->showFullScreen();

    QHidDevice * test = new QHidDevice(0x55, 0x32, &a);

    return a.exec();
}
Ejemplo n.º 2
0
void MapperGLCanvas::wheelEvent(QWheelEvent *event)
{
  int deltaLevel = event->delta() / 120;
  qreal zoomFactor = qPow(MM::ZOOM_FACTOR, _zoomLevel);
  if (deltaLevel > 0)
  {
    // First check if we're already at max.
    while (deltaLevel && zoomFactor < MM::ZOOM_MAX) {
      _zoomLevel++;
      deltaLevel--;
      zoomFactor = qPow(MM::ZOOM_FACTOR, _zoomLevel);
    }
    zoomFactor = qMin(zoomFactor, MM::ZOOM_MAX);
  }
  else
  {
    // First check if we're already at min.
    while (deltaLevel && zoomFactor > MM::ZOOM_MIN) {
      _zoomLevel--;
      deltaLevel++;
      zoomFactor = qPow(MM::ZOOM_FACTOR, _zoomLevel);
    }
    zoomFactor = qMax(zoomFactor, MM::ZOOM_MIN);
  }

  // Re-bound zoom (for consistency).
  zoomFactor = getZoomFactor();

  // Apply zoom to view.
  QGraphicsView* view = scene()->views().first();
  view->resetMatrix();
  view->scale(zoomFactor, zoomFactor);
  view->update();

  // Accept wheel scrolling event.
  event->accept();
}