From f7836de39dc8a606af4a3510a176994fbaddb6ea Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Fri, 3 Aug 2018 10:28:27 -0400 Subject: [PATCH] placeholder code for hiDPI display of conf pages. --- .../laybasic/layLayoutViewConfigPages.cc | 71 +++++++++++++------ 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.cc b/src/laybasic/laybasic/layLayoutViewConfigPages.cc index 6e8f00532..8ba355016 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.cc +++ b/src/laybasic/laybasic/layLayoutViewConfigPages.cc @@ -819,9 +819,20 @@ LayoutViewConfigPage4::update () } } +#if QT_VERSION > 0x050000 + unsigned int dpr = 1; //devicePixelRatio (); +#else + unsigned int dpr = 1; +#endif + QFontMetrics fm (font (), this); QRect rt (fm.boundingRect (QString::fromUtf8 ("AA"))); - QPixmap pxmp (rt.width () + 10, rt.height () + 10); + + const unsigned int h = rt.height () + 10; + const unsigned int w = rt.weight () + 10; + + QPixmap pxmp (w * dpr, h * dpr); + pxmp.setDevicePixelRatio(dpr); QPainter pxpainter (&pxmp); pxpainter.setPen (QPen (palette ().color (QPalette::Active, QPalette::Text))); @@ -1159,29 +1170,43 @@ LayoutViewConfigPage6::update () const unsigned int h = rt.height () + 10; const unsigned int w = rt.width () + 10; - unsigned int color0 = palette ().color (QPalette::Active, QPalette::Button).rgb(); - unsigned int color1 = palette ().color (QPalette::Active, QPalette::Dark).rgb(); + QColor color0 = palette ().color (QPalette::Active, QPalette::Button); + QColor color1 = palette ().color (QPalette::Active, QPalette::Dark); - QImage image (w, h, QImage::Format_RGB32); - if (s >= 0) { - const uint32_t * const *dp = m_pattern.pattern ((unsigned int) s).pattern (); - for (unsigned int l = 0; l < h; ++l, ++dp) { - uint32_t m = **dp; - if (l == 0 || l == h - 1) { - m |= ((1 << w) - 1); - } else { - m |= ((1 << (w - 1)) | 1); - } - color_t *pt = (color_t *) image.scanLine (h - 1 - l); - for (unsigned int b = 0; b < w; ++b) { - *pt++ = (m & 1) ? color1 : color0; - m >>= 1; - } - } - } +#if QT_VERSION > 0x050000 + unsigned int dpr = 1; //devicePixelRatio (); +#else + unsigned int dpr = 1; +#endif + + QImage image (w * dpr, h * dpr, QImage::Format_RGB32); + image.setDevicePixelRatio(dpr); + image.fill (color0.rgb ()); + // if (s >= 0) { + // const uint32_t * const *dp = m_pattern.pattern ((unsigned int) s).pattern (); + // for (unsigned int l = 0; l < h; ++l, ++dp) { + // uint32_t m = **dp; + // if (l == 0 || l == h - 1) { + // m |= ((1 << w) - 1); + // } else { + // m |= ((1 << (w - 1)) | 1); + // } + // color_t *pt = (color_t *) image.scanLine (h - 1 - l); + // for (unsigned int b = 0; b < w; ++b) { + // *pt++ = (m & 1) ? color1 : color0; + // m >>= 1; + // } + // } + // } + + // copying code from layLayerToolbox.cc + QBitmap bitmap = m_pattern.pattern ((unsigned int) s).get_bitmap (w * dpr, h * dpr); + QPainter painter (&image); + painter.setPen (QPen (color1)); + painter.setBackgroundMode (Qt::TransparentMode); + painter.drawPixmap (0, 0, w, h, bitmap); QPixmap pxmp = QPixmap::fromImage (image); // Qt 4.6.0 workaround - QPainter pxpainter (&pxmp); pxpainter.setPen (QPen (palette ().color (QPalette::Active, QPalette::Text))); QRect r (0, 0, pxmp.width () - 1, pxmp.height () - 1); @@ -1189,6 +1214,8 @@ LayoutViewConfigPage6::update () pxpainter.setFont (font ()); pxpainter.drawText (r, Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextSingleLine, text); + pxmp.setDevicePixelRatio(dpr); + (mp_ui->*(cfg6_buttons [i]))->setIconSize (pxmp.size ()); (mp_ui->*(cfg6_buttons [i]))->setIcon (QIcon (pxmp)); @@ -1367,7 +1394,7 @@ LayoutViewConfigPage6a::update () const unsigned int w = 26; #if QT_VERSION > 0x050000 - unsigned int dpr = devicePixelRatio (); + unsigned int dpr = 1; //devicePixelRatio (); #else unsigned int dpr = 1; #endif