| 183 | } |
| 184 | |
| 185 | void GuiTools::fillColorMenu(QMenu* menu, QActionGroup* actionGroup) { |
| 186 | static const std::array<QString, colorsCount> colorNames = { |
| 187 | i18n("White"), i18n("Black"), i18n("Dark Red"), i18n("Red"), i18n("Light Red"), i18n("Dark Green"), i18n("Green"), |
| 188 | i18n("Light Green"), i18n("Dark Blue"), i18n("Blue"), i18n("Light Blue"), i18n("Dark Yellow"), i18n("Yellow"), i18n("Light Yellow"), |
| 189 | i18n("Dark Cyan"), i18n("Cyan"), i18n("Light Cyan"), i18n("Dark Magenta"), i18n("Magenta"), i18n("Light Magenta"), i18n("Dark Orange"), |
| 190 | i18n("Orange"), i18n("Light Orange"), i18n("Dark Grey"), i18n("Grey"), i18n("Light Grey")}; |
| 191 | |
| 192 | QPixmap pix(16, 16); |
| 193 | QPainter p(&pix); |
| 194 | for (int i = 0; i < colorsCount; ++i) { |
| 195 | p.fillRect(pix.rect(), colors[i]); |
| 196 | auto* action = new QAction(QIcon(pix), colorNames[i], actionGroup); |
| 197 | action->setCheckable(true); |
| 198 | menu->addAction(action); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | /*! |
| 203 | * Selects (checks) the action in the group \c actionGroup that corresponds to the color \c color. |