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->show();
} }
puzzle->InitZoom();
return puzzle; return puzzle;
} }

View File

@ -84,6 +84,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
InitCarrousel(); InitCarrousel();
InitMainGraphics(); InitMainGraphics();
InitToolBar();
SetPropertiesData(); SetPropertiesData();
@ -185,6 +186,12 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitZoom()
{
m_graphicsView->ZoomFitBest();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPPiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece) VPPiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece)
{ {
@ -472,6 +479,32 @@ void VPMainWindow::InitMainGraphics()
m_graphicsView->RefreshLayout(); 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) void VPMainWindow::SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value)

View File

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

View File

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