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 "zoomaction.h"
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QAbstractItemView>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -55,6 +56,13 @@ void ZoomAction::zoomOut()
|
|||||||
emit indexChanged(m_currentComboBoxIndex + 1);
|
emit indexChanged(m_currentComboBoxIndex + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZoomAction::resetZoomLevel()
|
||||||
|
{
|
||||||
|
m_zoomLevel = 1.0;
|
||||||
|
m_currentComboBoxIndex = 8;
|
||||||
|
emit reseted();
|
||||||
|
}
|
||||||
|
|
||||||
void ZoomAction::setZoomLevel(double zoomLevel)
|
void ZoomAction::setZoomLevel(double zoomLevel)
|
||||||
{
|
{
|
||||||
m_zoomLevel = qBound(0.1, zoomLevel, 16.0);
|
m_zoomLevel = qBound(0.1, zoomLevel, 16.0);
|
||||||
@@ -90,7 +98,12 @@ QWidget *ZoomAction::createWidget(QWidget *parent)
|
|||||||
comboBox->setModel(m_comboBoxModel.data());
|
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),
|
connect(comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
this, &ZoomAction::emitZoomLevelChanged);
|
this, &ZoomAction::emitZoomLevelChanged);
|
||||||
connect(this, &ZoomAction::indexChanged, comboBox, &QComboBox::setCurrentIndex);
|
connect(this, &ZoomAction::indexChanged, comboBox, &QComboBox::setCurrentIndex);
|
||||||
|
@@ -44,6 +44,7 @@ public:
|
|||||||
|
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
void zoomOut();
|
void zoomOut();
|
||||||
|
void resetZoomLevel();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QWidget *createWidget(QWidget *parent);
|
QWidget *createWidget(QWidget *parent);
|
||||||
@@ -51,6 +52,7 @@ protected:
|
|||||||
signals:
|
signals:
|
||||||
void zoomLevelChanged(double zoom);
|
void zoomLevelChanged(double zoom);
|
||||||
void indexChanged(int);
|
void indexChanged(int);
|
||||||
|
void reseted();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void emitZoomLevelChanged(int index);
|
void emitZoomLevelChanged(int index);
|
||||||
|
Reference in New Issue
Block a user