forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -99,13 +99,24 @@ QWidget *ZoomAction::createWidget(QWidget *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
comboBox->setCurrentIndex(m_currentComboBoxIndex);
|
comboBox->setCurrentIndex(m_currentComboBoxIndex);
|
||||||
|
comboBox->setToolTip(comboBox->currentText());
|
||||||
connect(this, &ZoomAction::reseted, comboBox, [this, comboBox]() {
|
connect(this, &ZoomAction::reseted, comboBox, [this, comboBox]() {
|
||||||
blockSignals(true);
|
blockSignals(true);
|
||||||
comboBox->setCurrentIndex(m_currentComboBoxIndex);
|
comboBox->setCurrentIndex(m_currentComboBoxIndex);
|
||||||
blockSignals(false);
|
blockSignals(false);
|
||||||
});
|
});
|
||||||
connect(comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
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);
|
connect(this, &ZoomAction::indexChanged, comboBox, &QComboBox::setCurrentIndex);
|
||||||
|
|
||||||
comboBox->setProperty("hideborder", true);
|
comboBox->setProperty("hideborder", true);
|
||||||
@@ -113,15 +124,4 @@ QWidget *ZoomAction::createWidget(QWidget *parent)
|
|||||||
return comboBox;
|
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
|
} // namespace QmlDesigner
|
||||||
|
@@ -56,9 +56,6 @@ signals:
|
|||||||
void indexChanged(int);
|
void indexChanged(int);
|
||||||
void reseted();
|
void reseted();
|
||||||
|
|
||||||
private:
|
|
||||||
void emitZoomLevelChanged(int index);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<QAbstractItemModel> m_comboBoxModel;
|
QPointer<QAbstractItemModel> m_comboBoxModel;
|
||||||
float m_zoomLevel;
|
float m_zoomLevel;
|
||||||
|
Reference in New Issue
Block a user