Exemplo n.º 1
0
void WebView::wheelEvent(QWheelEvent *event)
{
    if (event->modifiers() & Qt::ControlModifier) {
        m_zoomFactor += event->delta() / 120;
        updateZoomFactor();
    } else {
        QWebView::wheelEvent(event);
    }
}
PrintPreviewDialog::PrintPreviewDialog(QPrinter *printer, QWidget *parent)
	: QDialog(parent)
{
	m_initialized = false;

	QVBoxLayout *mainLayout = new QVBoxLayout;

	m_printPreviewWidget = new QPrintPreviewWidget(printer, this);
	connect(m_printPreviewWidget, SIGNAL(paintRequested(QPrinter*)), this, SIGNAL(paintRequested(QPrinter*)));
	connect(m_printPreviewWidget, SIGNAL(previewChanged()), this, SLOT(updateZoomFactor()));

	ToolBar *toolBar = new ToolBar("printpreview_toolbar", this);
	Action *action = new Action(Icon("zoom-fit-width"), tr("Fit &width"), this, "printpreview_fit_width");
	connect(action, SIGNAL(triggered()), m_printPreviewWidget, SLOT(fitToWidth()));
	toolBar->addAction(action);
	action = new Action(Icon("zoom-fit-best"), tr("Fit p&age"), this, "printpreview_fit_page");
	connect(action, SIGNAL(triggered()), m_printPreviewWidget, SLOT(fitInView()));
	toolBar->addAction(action);
	m_zoomToAction = new ZoomAction(Icon("zoom-original"), tr("&Zoom"), this, "printpreview_zoom_to");
	connect(m_zoomToAction, SIGNAL(zoomFactorAdded(qreal)), this, SLOT(setZoomFactor(qreal)));
	toolBar->addAction(m_zoomToAction);
	toolBar->addAction(StandardAction::zoomIn(this, SLOT(zoomIn()), this));
	toolBar->addAction(StandardAction::zoomOut(this, SLOT(zoomOut()), this));
	action = new Action(Icon("document-print"), tr("&Print"), this, "printpreview_print");
	connect(action, SIGNAL(triggered()), this, SLOT(print()));
	toolBar->addAction(action);
	action = new Action(Icon("window-close"), tr("&Close"), this, "printpreview_close");
	connect(action, SIGNAL(triggered()), this, SLOT(reject()));
	toolBar->addAction(action);

	mainLayout->addWidget(toolBar);
	mainLayout->addWidget(m_printPreviewWidget);
	setLayout(mainLayout);

	m_zoomToAction->setZoomFactor(1.0);
}
Exemplo n.º 3
0
void WebView::setZealZoomFactor(int zf)
{
    m_zoomFactor = zf;
    updateZoomFactor();
}