diff options
Diffstat (limited to 'examples/svg/svgviewer/mainwindow.cpp')
-rw-r--r-- | examples/svg/svgviewer/mainwindow.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/svg/svgviewer/mainwindow.cpp b/examples/svg/svgviewer/mainwindow.cpp index 8cb94d2..7dd240a 100644 --- a/examples/svg/svgviewer/mainwindow.cpp +++ b/examples/svg/svgviewer/mainwindow.cpp @@ -64,6 +64,7 @@ static inline QString picturesLocation() MainWindow::MainWindow() : QMainWindow() , m_view(new SvgView) + , m_zoomLabel(new QLabel) { QToolBar *toolBar = new QToolBar(this); addToolBar(Qt::TopToolBarArea, toolBar); @@ -94,6 +95,14 @@ MainWindow::MainWindow() m_outlineAction->setChecked(true); connect(m_outlineAction, &QAction::toggled, m_view, &SvgView::setViewOutline); + viewMenu->addSeparator(); + QAction *zoomAction = viewMenu->addAction(tr("Zoom &In"), m_view, &SvgView::zoomIn); + zoomAction->setShortcut(QKeySequence::ZoomIn); + zoomAction = viewMenu->addAction(tr("Zoom &Out"), m_view, &SvgView::zoomOut); + zoomAction->setShortcut(QKeySequence::ZoomOut); + zoomAction = viewMenu->addAction(tr("Reset Zoom"), m_view, &SvgView::resetZoom); + zoomAction->setShortcut(Qt::CTRL + Qt::Key_0); + QMenu *rendererMenu = menuBar()->addMenu(tr("&Renderer")); m_nativeAction = rendererMenu->addAction(tr("&Native")); m_nativeAction->setCheckable(true); @@ -134,6 +143,11 @@ MainWindow::MainWindow() help->addAction(tr("About Qt"), qApp, &QApplication::aboutQt); setCentralWidget(m_view); + + m_zoomLabel->setToolTip(tr("Use the mouse wheel to zoom")); + statusBar()->addPermanentWidget(m_zoomLabel); + updateZoomLabel(); + connect(m_view, &SvgView::zoomChanged, this, &MainWindow::updateZoomLabel); } void MainWindow::openFile() @@ -221,3 +235,9 @@ void MainWindow::exportImage() } } } + +void MainWindow::updateZoomLabel() +{ + const int percent = qRound(m_view->zoomFactor() * qreal(100)); + m_zoomLabel->setText(QString::number(percent) + QLatin1Char('%')); +} |