| 932 | } |
| 933 | |
| 934 | void |
| 935 | LayoutViewConfigPage4::update () |
| 936 | { |
| 937 | for (unsigned int i = 0; i < sizeof (cfg4_buttons) / sizeof (cfg4_buttons [0]); ++i) { |
| 938 | |
| 939 | QColor color; |
| 940 | if (i < m_palette.colors ()) { |
| 941 | color = QColor (m_palette.color_by_index (i)); |
| 942 | } |
| 943 | |
| 944 | QColor text_color = color.green () > 128 ? QColor (0, 0, 0) : QColor (255, 255, 255); |
| 945 | |
| 946 | QString text = QString::fromUtf8 (" "); |
| 947 | for (unsigned int j = 0; j < m_palette.luminous_colors (); ++j) { |
| 948 | if (i == m_palette.luminous_color_index_by_index (j)) { |
| 949 | text = tl::to_qstring (tl::sprintf ("%d", j)); |
| 950 | break; |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | #if QT_VERSION > 0x050000 |
| 955 | double dpr = devicePixelRatio (); |
| 956 | #else |
| 957 | double dpr = 1.0; |
| 958 | #endif |
| 959 | |
| 960 | QFontMetrics fm (font (), this); |
| 961 | QRect rt (fm.boundingRect (QString::fromUtf8 ("AA"))); |
| 962 | |
| 963 | const unsigned int h = rt.height () + 10; |
| 964 | const unsigned int w = rt.width () + 10; |
| 965 | |
| 966 | QImage img (w * dpr, h * dpr, QImage::Format_RGB32); |
| 967 | #if QT_VERSION > 0x050000 |
| 968 | img.setDevicePixelRatio (dpr); |
| 969 | #endif |
| 970 | |
| 971 | QPainter painter (&img); |
| 972 | QRectF r (0.0, 0.0, w, h); |
| 973 | painter.fillRect (r, QBrush (palette ().color (QPalette::Active, QPalette::ButtonText))); |
| 974 | r = QRectF (1.0, 1.0, w - 2.0, h - 2.0); |
| 975 | painter.fillRect (r, QBrush (color)); |
| 976 | painter.setFont (font ()); |
| 977 | painter.setPen (QPen (text_color)); |
| 978 | painter.drawText (r, Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextSingleLine, text); |
| 979 | |
| 980 | QPixmap pxmp = QPixmap::fromImage (img); |
| 981 | (mp_ui->*(cfg4_buttons [i]))->setIconSize (QSize (w, h)); |
| 982 | (mp_ui->*(cfg4_buttons [i]))->setIcon (QIcon (pxmp)); |
| 983 | |
| 984 | } |
| 985 | } |
| 986 | |
| 987 | // ------------------------------------------------------------ |
| 988 | // LayoutConfigPage5 implementation |
nothing calls this directly
no test coverage detected