comparison view/View.cpp @ 956:092de22db207 osx-retina

Make Retina layer rendering selectable in settings
author Chris Cannam
date Wed, 29 Apr 2015 13:28:44 +0100
parents 76b5eabd816b
children 5fdf5cd032ac
comparison
equal deleted inserted replaced
955:76b5eabd816b 956:092de22db207
36 #include <QProgressDialog> 36 #include <QProgressDialog>
37 #include <QTextStream> 37 #include <QTextStream>
38 #include <QFont> 38 #include <QFont>
39 #include <QMessageBox> 39 #include <QMessageBox>
40 #include <QPushButton> 40 #include <QPushButton>
41 #include <QSettings>
41 42
42 #include <iostream> 43 #include <iostream>
43 #include <cassert> 44 #include <cassert>
44 #include <cmath> 45 #include <cmath>
45 46
448 // cout << "zoom level: " << m_zoomLevel << endl; 449 // cout << "zoom level: " << m_zoomLevel << endl;
449 #endif 450 #endif
450 return m_zoomLevel; 451 return m_zoomLevel;
451 } 452 }
452 453
454 int
455 View::effectiveDevicePixelRatio() const
456 {
457 #ifdef Q_OS_MAC
458 int dpratio = devicePixelRatio();
459 if (dpratio > 1) {
460 QSettings settings;
461 settings.beginGroup("Preferences");
462 if (!settings.value("scaledHiDpi", true).toBool()) {
463 dpratio = 1;
464 }
465 settings.endGroup();
466 }
467 return dpratio;
468 #else
469 return 1;
470 #endif
471 }
472
453 void 473 void
454 View::setZoomLevel(int z) 474 View::setZoomLevel(int z)
455 { 475 {
456 int dpratio = devicePixelRatio(); 476 int dpratio = effectiveDevicePixelRatio();
457 if (z < dpratio) return; 477 if (z < dpratio) return;
458 if (z < 1) z = 1; 478 if (z < 1) z = 1;
459 if (m_zoomLevel != int(z)) { 479 if (m_zoomLevel != int(z)) {
460 m_zoomLevel = z; 480 m_zoomLevel = z;
461 emit zoomLevelChanged(z, m_followZoom); 481 emit zoomLevelChanged(z, m_followZoom);
1656 1676
1657 void 1677 void
1658 View::setPaintFont(QPainter &paint) 1678 View::setPaintFont(QPainter &paint)
1659 { 1679 {
1660 int scaleFactor = 1; 1680 int scaleFactor = 1;
1661 int dpratio = devicePixelRatio(); 1681 int dpratio = effectiveDevicePixelRatio();
1662 if (dpratio > 1) { 1682 if (dpratio > 1) {
1663 QPaintDevice *dev = paint.device(); 1683 QPaintDevice *dev = paint.device();
1664 if (dynamic_cast<QPixmap *>(dev) || dynamic_cast<QImage *>(dev)) { 1684 if (dynamic_cast<QPixmap *>(dev) || dynamic_cast<QImage *>(dev)) {
1665 scaleFactor = dpratio; 1685 scaleFactor = dpratio;
1666 } 1686 }
1712 #endif 1732 #endif
1713 } 1733 }
1714 1734
1715 QRect nonCacheRect(cacheRect); 1735 QRect nonCacheRect(cacheRect);
1716 1736
1717 int dpratio = devicePixelRatio(); 1737 int dpratio = effectiveDevicePixelRatio();
1718 1738
1719 // If not all layers are scrollable, but some of the back layers 1739 // If not all layers are scrollable, but some of the back layers
1720 // are, we should store only those in the cache. 1740 // are, we should store only those in the cache.
1721 1741
1722 bool layersChanged = false; 1742 bool layersChanged = false;