aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@qt.io>2018-12-13 23:12:26 +0100
committerTim Jenssen <tim.jenssen@qt.io>2018-12-18 09:16:21 +0000
commitf377e81ca7b4b4f983b9771b90279fe28cfe7849 (patch)
tree7d695185abfb627cb30fe9532963689701589b04
parent267c1860f69a34dc05518ece8c55fd9653aa61c0 (diff)
QmlDesigner: show zoom percentage as tooltip
Because of wrong dpi behavior sometimes the combobox is not big enough to show the complete zoom value, with tooltip it can be made visible. Change-Id: Id3ef7b677ea8302e0a332ff9f118483b9bff8178 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r--src/plugins/qmldesigner/components/componentcore/zoomaction.cpp24
-rw-r--r--src/plugins/qmldesigner/components/componentcore/zoomaction.h3
2 files changed, 12 insertions, 15 deletions
diff --git a/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp b/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp
index 11fcad983f..9a1529414a 100644
--- a/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp
@@ -99,13 +99,24 @@ QWidget *ZoomAction::createWidget(QWidget *parent)
}
comboBox->setCurrentIndex(m_currentComboBoxIndex);
+ comboBox->setToolTip(comboBox->currentText());
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);
+ [this, comboBox](int index) {
+ m_currentComboBoxIndex = index;
+
+ if (index == -1)
+ return;
+
+ const QModelIndex modelIndex(m_comboBoxModel.data()->index(index, 0));
+ setZoomLevel(m_comboBoxModel.data()->data(modelIndex, Qt::UserRole).toFloat());
+ comboBox->setToolTip(modelIndex.data().toString());
+ });
+
connect(this, &ZoomAction::indexChanged, comboBox, &QComboBox::setCurrentIndex);
comboBox->setProperty("hideborder", true);
@@ -113,15 +124,4 @@ QWidget *ZoomAction::createWidget(QWidget *parent)
return comboBox;
}
-void ZoomAction::emitZoomLevelChanged(int index)
-{
- m_currentComboBoxIndex = index;
-
- if (index == -1)
- return;
-
- const QModelIndex modelIndex(m_comboBoxModel.data()->index(index, 0));
- setZoomLevel(m_comboBoxModel.data()->data(modelIndex, Qt::UserRole).toFloat());
-}
-
} // namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/components/componentcore/zoomaction.h b/src/plugins/qmldesigner/components/componentcore/zoomaction.h
index 2bf0219124..e93298d137 100644
--- a/src/plugins/qmldesigner/components/componentcore/zoomaction.h
+++ b/src/plugins/qmldesigner/components/componentcore/zoomaction.h
@@ -57,9 +57,6 @@ signals:
void reseted();
private:
- void emitZoomLevelChanged(int index);
-
-private:
QPointer<QAbstractItemModel> m_comboBoxModel;
float m_zoomLevel;
int m_currentComboBoxIndex;