diff --git a/src/plugins/qmldesigner/components/propertyeditor/contextpanewidgetimage.cpp b/src/plugins/qmldesigner/components/propertyeditor/contextpanewidgetimage.cpp index a3c18f716fc87699c6d55cd7b1508995494ca615..60b45d6a75cb0eb362354b9a963ef8186362ee85 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/contextpanewidgetimage.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/contextpanewidgetimage.cpp @@ -622,6 +622,13 @@ void PreviewLabel::mouseReleaseEvent(QMouseEvent * event) } +static inline int limitPositive(int i) +{ + if (i >= 0) + return i; + return 0; +} + static inline int limit(int i, int zoom) { static bool flag1 = 1; @@ -791,9 +798,9 @@ void PreviewDialog::setPixmap(const QPixmap &p, int zoom) m_label->adjustSize(); m_zoom = zoom; m_label->setZoom(m_zoom); - QSize size = m_label->pixmap()->size() + QSize(44, 44); - if (size.width() < 140) - size.setWidth(140); + QSize size = m_label->pixmap()->size() + QSize(54, 44); + if (size.width() < 180) + size.setWidth(180); resize(size); } @@ -803,26 +810,26 @@ void PreviewDialog::wheelEvent(QWheelEvent* event) event->accept(); if (delta > 0) { if (m_zoom == 1) - m_zoom = 2; + setZoom(2); else if (m_zoom == 2) - m_zoom = 4; + setZoom(4); else if (m_zoom == 4) - m_zoom = 6; + setZoom(6); else if (m_zoom == 6) - m_zoom = 8; + setZoom(8); else if (m_zoom == 8) - m_zoom = 10; + setZoom(10); } else { if (m_zoom == 10) - m_zoom = 8; + setZoom(8); else if (m_zoom == 8) - m_zoom = 6; + setZoom(6); else if (m_zoom == 6) - m_zoom = 4; + setZoom(4); else if (m_zoom == 4) - m_zoom = 2; + setZoom(2); else if (m_zoom == 2) - m_zoom = 1; + setZoom(1); } setPixmap(m_pixmap, m_zoom); } @@ -832,4 +839,17 @@ void PreviewDialog::onTogglePane() hide(); } +void PreviewDialog::onSliderMoved(int value) +{ + switch (value) { + case 1: setZoom(1); break; + case 2: setZoom(2); break; + case 3: setZoom(4); break; + case 4: setZoom(6); break; + case 5: setZoom(8); break; + case 6: setZoom(10); break; + default: break; + } +} + } //QmlDesigner diff --git a/src/plugins/qmldesigner/components/propertyeditor/contextpanewidgetimage.h b/src/plugins/qmldesigner/components/propertyeditor/contextpanewidgetimage.h index d5a266a152c995cd68d662cfa9ece14bb3d461a7..90767ffae85197fea973a31d6945967da123217a 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/contextpanewidgetimage.h +++ b/src/plugins/qmldesigner/components/propertyeditor/contextpanewidgetimage.h @@ -76,6 +76,7 @@ public: public slots: void onTogglePane(); + void onSliderMoved(int value); protected: void wheelEvent(QWheelEvent* event); @@ -83,6 +84,7 @@ protected: private: PreviewLabel *m_label; QSlider *m_slider; + QLabel *m_zoomLabel; int m_zoom; QPixmap m_pixmap; bool m_borderImage;