Zoom functions

This commit is contained in:
Ronan Le Tiec 2020-11-13 23:31:22 +01:00
parent 396443f60c
commit c497e325d8
4 changed files with 48 additions and 4 deletions

View File

@ -363,6 +363,7 @@ VPMainWindow *VPApplication::NewMainWindow(const VPCommandLinePtr &cmd)
{
puzzle->show();
}
puzzle->InitZoom();
return puzzle;
}

View File

@ -84,6 +84,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
InitCarrousel();
InitMainGraphics();
InitToolBar();
SetPropertiesData();
@ -185,6 +186,12 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitZoom()
{
m_graphicsView->ZoomFitBest();
}
//---------------------------------------------------------------------------------------------------------------------
VPPiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece)
{
@ -472,6 +479,32 @@ void VPMainWindow::InitMainGraphics()
m_graphicsView->RefreshLayout();
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitToolBar()
{
QList<QKeySequence> zoomInShortcuts;
zoomInShortcuts.append(QKeySequence(QKeySequence::ZoomIn));
zoomInShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Plus + Qt::KeypadModifier));
ui->actionZoomIn->setShortcuts(zoomInShortcuts);
connect(ui->actionZoomIn, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomIn);
QList<QKeySequence> zoomOutShortcuts;
zoomOutShortcuts.append(QKeySequence(QKeySequence::ZoomOut));
zoomOutShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier));
ui->actionZoomOut->setShortcuts(zoomOutShortcuts);
connect(ui->actionZoomOut, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomOut);
QList<QKeySequence> zoomOriginalShortcuts;
zoomOriginalShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0));
zoomOriginalShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0 + Qt::KeypadModifier));
ui->actionZoomOriginal->setShortcuts(zoomOriginalShortcuts);
connect(ui->actionZoomOriginal, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomOriginal);
QList<QKeySequence> zoomFitBestShortcuts;
zoomFitBestShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Equal));
ui->actionZoomFitBest->setShortcuts(zoomFitBestShortcuts);
connect(ui->actionZoomFitBest, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomFitBest);
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value)

View File

@ -74,6 +74,11 @@ public:
*/
void ImportRawLayouts(const QStringList &rawLayouts);
/**
* @brief InitZoom Initialises the zoom to fit best
*/
void InitZoom();
public slots:
/**
* @brief on_actionNew_triggered When the menu action File > New
@ -144,6 +149,11 @@ private:
*/
void InitMainGraphics();
/**
* @brief InitToolBar Initialises the tool bar
*/
void InitToolBar();
/**
* @brief SetPropertiesData Sets the values of UI elements
* in all the property tabs to the values saved in m_layout

View File

@ -1197,8 +1197,8 @@
</attribute>
<addaction name="actionZoomIn"/>
<addaction name="actionZoomOut"/>
<addaction name="actionOriginalZoom"/>
<addaction name="actionZoomSheet"/>
<addaction name="actionZoomOriginal"/>
<addaction name="actionZoomFitBest"/>
</widget>
<action name="actionOpen">
<property name="text">
@ -1296,7 +1296,7 @@
<string>Zoom out</string>
</property>
</action>
<action name="actionOriginalZoom">
<action name="actionZoomOriginal">
<property name="icon">
<iconset theme="zoom-original">
<normaloff>.</normaloff>.</iconset>
@ -1305,7 +1305,7 @@
<string>Zoom 1:1</string>
</property>
</action>
<action name="actionZoomSheet">
<action name="actionZoomFitBest">
<property name="icon">
<iconset theme="zoom-fit-best">
<normaloff>.</normaloff>.</iconset>