Fixed issue #156.

--HG--
branch : develop
This commit is contained in:
dismine 2014-06-02 21:42:46 +03:00
parent 543758a80c
commit 81ef55abfd
5 changed files with 86 additions and 0 deletions

View file

@ -85,6 +85,8 @@ MainWindow::MainWindow(QWidget *parent)
helpLabel = new QLabel(QObject::tr("Create new pattern piece to start working."));
ui->statusBar->addWidget(helpLabel);
ToolBarZoom();
pattern = new VContainer();
doc = new VPattern(pattern, comboBoxDraws, &mode);
@ -843,6 +845,24 @@ void MainWindow::ToolBarDraws()
ui->actionLayout->setEnabled(false);
}
void MainWindow::ToolBarZoom()
{
/*First we will try use Standard Shortcuts from Qt, but because keypad "-" and "+" not the same keys like in main
keypad, shortcut Ctrl+"-" or "+" from keypad will not working with standard shortcut (QKeySequence::ZoomIn or
QKeySequence::ZoomOut). For examle "+" is Qt::Key_Plus + Qt::KeypadModifier for keypad.
Also for me don't work Qt:CTRL and work Qt::ControlModifier.*/
const QList<QKeySequence> zoomInShortcuts = {QKeySequence::ZoomIn,
Qt::ControlModifier + Qt::Key_Plus + Qt::KeypadModifier};
ui->actionZoomIn->setShortcuts(zoomInShortcuts);
connect(ui->actionZoomIn, &QAction::triggered, view, &VMainGraphicsView::ZoomIn);
const QList<QKeySequence> zoomOutShortcuts = {QKeySequence::ZoomOut,
Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier};
ui->actionZoomOut->setShortcuts(zoomOutShortcuts);
connect(ui->actionZoomOut, &QAction::triggered, view, &VMainGraphicsView::ZoomOut);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::InitToolButtons()
{
@ -1300,6 +1320,8 @@ void MainWindow::Clear()
ui->actionOptionDraw->setEnabled(false);
ui->actionSave->setEnabled(false);
ui->actionPattern_properties->setEnabled(false);
ui->actionZoomIn->setEnabled(false);
ui->actionZoomOut->setEnabled(false);
SetEnableTool(false);
qApp->setPatternUnit(Valentina::Cm);
qApp->setPatternType(Pattern::Individual);
@ -1374,6 +1396,8 @@ void MainWindow::SetEnableWidgets(bool enable)
}
ui->actionTable->setEnabled(enable);
ui->actionHistory->setEnabled(enable);
ui->actionZoomIn->setEnabled(enable);
ui->actionZoomOut->setEnabled(enable);
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -203,6 +203,7 @@ private:
QTimer *autoSaveTimer;
void ToolBarOption();
void ToolBarDraws();
void ToolBarZoom();
void InitToolButtons();
void CancelTool();
void ArrowTool();

View file

@ -694,6 +694,8 @@
<addaction name="actionTable"/>
<addaction name="actionHistory"/>
<addaction name="actionLayout"/>
<addaction name="actionZoomIn"/>
<addaction name="actionZoomOut"/>
<addaction name="separator"/>
<addaction name="actionPattern_properties"/>
<addaction name="actionOptions"/>
@ -757,6 +759,19 @@
<bool>false</bool>
</attribute>
</widget>
<widget class="QToolBar" name="toolBarZoom">
<property name="windowTitle">
<string>toolBar_2</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionZoomIn"/>
<addaction name="actionZoomOut"/>
</widget>
<action name="actionNew">
<property name="icon">
<iconset theme="document-new">
@ -1002,6 +1017,34 @@
<string>Pattern properties</string>
</property>
</action>
<action name="actionZoomIn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset theme="zoom-in"/>
</property>
<property name="text">
<string>Zoom In</string>
</property>
<property name="toolTip">
<string>zoom in</string>
</property>
</action>
<action name="actionZoomOut">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset theme="zoom-out"/>
</property>
<property name="text">
<string>Zoom Out</string>
</property>
<property name="toolTip">
<string>Zoom out</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>

View file

@ -123,6 +123,22 @@ void VMainGraphicsView::animFinished()
sender()->~QObject();
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsView::ZoomIn()
{
scale(1.1, 1.1);
VAbstractTool::NewSceneRect(this->scene(), this);
emit NewFactor(1.1);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsView::ZoomOut()
{
scale(1.0/1.1, 1.0/1.1);
VAbstractTool::NewSceneRect(this->scene(), this);
emit NewFactor(1.0/1.1);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
{

View file

@ -64,6 +64,8 @@ public slots:
* @brief animFinished
*/
void animFinished();
void ZoomIn();
void ZoomOut();
protected:
/**
* @brief wheelEvent handle wheel events.