! fills the ComboBox for the symbol filling patterns with the 14 possible Qt::BrushStyles. */
| 138 | fills the ComboBox for the symbol filling patterns with the 14 possible Qt::BrushStyles. |
| 139 | */ |
| 140 | void GuiTools::updateBrushStyles(QComboBox* comboBox, const QColor& color) { |
| 141 | int index = comboBox->currentIndex(); |
| 142 | comboBox->clear(); |
| 143 | |
| 144 | int offset = 2; |
| 145 | int w = 50; |
| 146 | int h = 20; |
| 147 | QPixmap pm(w, h); |
| 148 | comboBox->setIconSize(QSize(w, h)); |
| 149 | |
| 150 | static std::array<QString, 15> list = {i18n("None"), |
| 151 | i18n("Uniform"), |
| 152 | i18n("Extremely Dense"), |
| 153 | i18n("Very Dense"), |
| 154 | i18n("Somewhat Dense"), |
| 155 | i18n("Half Dense"), |
| 156 | i18n("Somewhat Sparse"), |
| 157 | i18n("Very Sparse"), |
| 158 | i18n("Extremely Sparse"), |
| 159 | i18n("Horiz. Lines"), |
| 160 | i18n("Vert. Lines"), |
| 161 | i18n("Crossing Lines"), |
| 162 | i18n("Backward Diag. Lines"), |
| 163 | i18n("Forward Diag. Lines"), |
| 164 | i18n("Crossing Diag. Lines")}; |
| 165 | const QColor& borderColor = GuiTools::isDarkMode() ? Qt::white : Qt::black; |
| 166 | QPen pen(Qt::SolidPattern, 1); |
| 167 | pen.setColor(borderColor); |
| 168 | |
| 169 | for (int i = 0; i < 15; i++) { |
| 170 | QPainter pa; |
| 171 | |
| 172 | pm.fill(Qt::transparent); |
| 173 | pa.begin(&pm); |
| 174 | pa.setPen(pen); |
| 175 | pa.setRenderHint(QPainter::Antialiasing); |
| 176 | pa.setBrush(QBrush(color, (Qt::BrushStyle)i)); |
| 177 | pa.drawRect(offset, offset, w - 2 * offset, h - 2 * offset); |
| 178 | pa.end(); |
| 179 | comboBox->addItem(QIcon(pm), list[i]); |
| 180 | } |
| 181 | |
| 182 | comboBox->setCurrentIndex(index); |
| 183 | } |
| 184 | |
| 185 | void GuiTools::fillColorMenu(QMenu* menu, QActionGroup* actionGroup) { |
| 186 | static const std::array<QString, colorsCount> colorNames = { |
nothing calls this directly
no test coverage detected