Move a "scale" spinner to separate tool bar.

This commit is contained in:
Roman Telezhynskyi 2021-05-21 11:52:29 +03:00
parent e1b9fbaccd
commit 9c05894dac
3 changed files with 34 additions and 12 deletions

View file

@ -97,6 +97,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
InitMainGraphics();
InitZoomToolBar();
InitScaleToolBar();
SetPropertiesData();
@ -637,27 +638,29 @@ void VPMainWindow::InitZoomToolBar()
zoomFitBestShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Equal));
ui->actionZoomFitBest->setShortcuts(zoomFitBestShortcuts);
connect(ui->actionZoomFitBest, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomFitBest);
}
// defined the scale
ui->toolBarZoom->addSeparator();
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitScaleToolBar()
{
auto* zoomScale = new QLabel(tr("Scale:"), this);
ui->toolBarZoom->addWidget(zoomScale);
ui->toolBarScale->addWidget(zoomScale);
m_doubleSpinBoxScale = new QDoubleSpinBox(this);
m_doubleSpinBoxScale->setDecimals(1);
m_doubleSpinBoxScale->setSuffix("%");
m_doubleSpinBoxScale->setSuffix(QChar('%'));
on_ScaleChanged(m_graphicsView->transform().m11());
connect(m_doubleSpinBoxScale.data(), QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, [this](double d){m_graphicsView->Zoom(d/100.0);});
ui->toolBarZoom->addWidget(m_doubleSpinBoxScale);
ui->toolBarScale->addWidget(m_doubleSpinBoxScale);
// define the mouse position
ui->toolBarZoom->addSeparator();
ui->toolBarScale->addSeparator();
m_mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(UnitsToStr(m_layout->GetUnit(), true)));
ui->toolBarZoom->addWidget(m_mouseCoordinate);
ui->toolBarZoom->addSeparator();
m_mouseCoordinate = new QLabel(QStringLiteral("0, 0 (%1)").arg(UnitsToStr(m_layout->GetUnit(), true)));
ui->toolBarScale->addWidget(m_mouseCoordinate);
ui->toolBarScale->addSeparator();
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -471,6 +471,11 @@ private:
*/
void InitZoomToolBar();
/**
* @brief InitScaleToolBar Initialises the scale tool bar
*/
void InitScaleToolBar();
/**
* @brief SetPropertiesData Sets the values of UI elements
* in all the property tabs to the values saved in m_layout

View file

@ -99,7 +99,6 @@
<addaction name="actionOpen"/>
<addaction name="actionSave"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QDockWidget" name="dockWidgetCarrousel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@ -1134,7 +1133,7 @@
<x>0</x>
<y>0</y>
<width>356</width>
<height>717</height>
<height>706</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@ -1422,7 +1421,7 @@
<x>0</x>
<y>0</y>
<width>356</width>
<height>717</height>
<height>706</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
@ -1564,6 +1563,21 @@
<addaction name="actionZoomOriginal"/>
<addaction name="actionZoomFitBest"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QToolBar" name="toolBarScale">
<property name="windowTitle">
<string>Scale</string>
</property>
<property name="allowedAreas">
<set>Qt::AllToolBarAreas</set>
</property>
<attribute name="toolBarArea">
<enum>BottomToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<action name="actionOpen">
<property name="icon">
<iconset theme="document-open">