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

View file

@ -471,6 +471,11 @@ private:
*/ */
void InitZoomToolBar(); void InitZoomToolBar();
/**
* @brief InitScaleToolBar Initialises the scale tool bar
*/
void InitScaleToolBar();
/** /**
* @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

@ -99,7 +99,6 @@
<addaction name="actionOpen"/> <addaction name="actionOpen"/>
<addaction name="actionSave"/> <addaction name="actionSave"/>
</widget> </widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QDockWidget" name="dockWidgetCarrousel"> <widget class="QDockWidget" name="dockWidgetCarrousel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@ -1134,7 +1133,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>356</width> <width>356</width>
<height>717</height> <height>706</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
@ -1422,7 +1421,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>356</width> <width>356</width>
<height>717</height> <height>706</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
@ -1564,6 +1563,21 @@
<addaction name="actionZoomOriginal"/> <addaction name="actionZoomOriginal"/>
<addaction name="actionZoomFitBest"/> <addaction name="actionZoomFitBest"/>
</widget> </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"> <action name="actionOpen">
<property name="icon"> <property name="icon">
<iconset theme="document-open"> <iconset theme="document-open">