Example #1
0
void PatchScene::keyPressEvent(QKeyEvent* event)
{
    if (event->key() == Qt::Key_Control)
        ctrl_down = true;

    if (event->key() == Qt::Key_Home)
    {
        zoom_fit();
        event->accept();
    }

    else if (ctrl_down)
    {
        if (event->key() == Qt::Key_Plus)
        {
            zoom_in();
            event->accept();
        }
        else if (event->key() == Qt::Key_Minus)
        {
            zoom_out();
            event->accept();
        }
        else if (event->key() == Qt::Key_1)
        {
            zoom_reset();
            event->accept();
        }
        else
            QGraphicsScene::keyPressEvent(event);
    }
    else
        QGraphicsScene::keyPressEvent(event);
}
Example #2
0
void Window::create_actions()
{
    open_action = new QAction(QIcon(":/fileopen.ico"), tr("Open"), this);
    open_action->setShortcuts(QKeySequence::Open);
    connect(open_action, SIGNAL(triggered()), this, SLOT(open()));

    save_as_action = new QAction(QIcon(":/filesaveas.ico"), tr("Save As"), this);
    save_as_action->setShortcuts(QKeySequence::SaveAs);
    connect(save_as_action, SIGNAL(triggered()), this, SLOT(save_as()));
    save_as_action->setEnabled(false);

    exit_action = new QAction(QIcon(":/exit.ico"), tr("Quit"), this);
    exit_action->setShortcuts(QKeySequence::Quit);
    connect(exit_action, SIGNAL(triggered()), this, SLOT(close()));

    zoom_in_action = new QAction(QIcon(":/zoom_in.ico"),tr("Zoom &In (25%)"), this);
    zoom_in_action->setShortcuts(QList<QKeySequence>() << QKeySequence::ZoomIn << QKeySequence(tr("Ctrl++")));
    zoom_in_action->setEnabled(false);
    connect(zoom_in_action, SIGNAL(triggered()), this, SLOT(zoom_in()));

    zoom_out_action = new QAction(QIcon(":/zoom_out.ico"),tr("Zoom &Out (25%)"), this);
    zoom_out_action->setShortcuts(QList<QKeySequence>() << QKeySequence::ZoomOut << QKeySequence(tr("Ctrl+-")));
    zoom_out_action->setEnabled(false);
    connect(zoom_out_action, SIGNAL(triggered()), this, SLOT(zoom_out()));

    zoom_original_action = new QAction(QIcon(":/zoom_original.ico"),tr("&Normal Size"), this);
    zoom_original_action->setShortcut(tr("Ctrl+S"));
    zoom_original_action->setEnabled(false);
    connect(zoom_original_action, SIGNAL(triggered()), this, SLOT(zoom_original()));

    zoom_fit_action = new QAction(QIcon(":/zoom_fit_best.ico"),tr("&Fit to Window"), this);
    zoom_fit_action->setShortcut(tr("Ctrl+F"));
    zoom_fit_action->setEnabled(false);
    zoom_fit_action->setCheckable(true);
    connect(zoom_fit_action, SIGNAL(triggered()), this, SLOT(zoom_fit()));

    gaussian_blur_action = new QAction(tr("Gaussian blur"), this);
    gaussian_blur_action->setShortcut(tr("Ctrl+g"));
    gaussian_blur_action->setEnabled(false);
    connect(gaussian_blur_action, SIGNAL(triggered()), this, SLOT(gaussian_blur()));
}
void WholeSceneView::update_draw()
{
    my_scene.update_draw();
    zoom_fit();
}
void WholeSceneView::resizeEvent(QResizeEvent *event)
{
    zoom_fit();
}
WholeSceneView::WholeSceneView(Dataset& dataset, QWidget* parent):
  my_scene(dataset)
{
    setScene(&my_scene);
    zoom_fit();
}