forked from qt-creator/qt-creator
QmlDesigner: add resetZoomLevel to ZoomAction
we always start from 100% Change-Id: I7877fe36430e1a80dc5258ee4ed2ed68ffaadd81 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "zoomaction.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QAbstractItemView>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
@@ -55,6 +56,13 @@ void ZoomAction::zoomOut()
|
||||
emit indexChanged(m_currentComboBoxIndex + 1);
|
||||
}
|
||||
|
||||
void ZoomAction::resetZoomLevel()
|
||||
{
|
||||
m_zoomLevel = 1.0;
|
||||
m_currentComboBoxIndex = 8;
|
||||
emit reseted();
|
||||
}
|
||||
|
||||
void ZoomAction::setZoomLevel(double zoomLevel)
|
||||
{
|
||||
m_zoomLevel = qBound(0.1, zoomLevel, 16.0);
|
||||
@@ -90,7 +98,12 @@ QWidget *ZoomAction::createWidget(QWidget *parent)
|
||||
comboBox->setModel(m_comboBoxModel.data());
|
||||
}
|
||||
|
||||
comboBox->setCurrentIndex(8);
|
||||
comboBox->setCurrentIndex(m_currentComboBoxIndex);
|
||||
connect(this, &ZoomAction::reseted, comboBox, [this, comboBox]() {
|
||||
blockSignals(true);
|
||||
comboBox->setCurrentIndex(m_currentComboBoxIndex);
|
||||
blockSignals(false);
|
||||
});
|
||||
connect(comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &ZoomAction::emitZoomLevelChanged);
|
||||
connect(this, &ZoomAction::indexChanged, comboBox, &QComboBox::setCurrentIndex);
|
||||
|
@@ -44,6 +44,7 @@ public:
|
||||
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void resetZoomLevel();
|
||||
|
||||
protected:
|
||||
QWidget *createWidget(QWidget *parent);
|
||||
@@ -51,6 +52,7 @@ protected:
|
||||
signals:
|
||||
void zoomLevelChanged(double zoom);
|
||||
void indexChanged(int);
|
||||
void reseted();
|
||||
|
||||
private:
|
||||
void emitZoomLevelChanged(int index);
|
||||
|
Reference in New Issue
Block a user