MCPcopy Create free account
hub / github.com/KDE/labplot / updateBrushStyles

Method updateBrushStyles

src/frontend/GuiTools.cpp:140–183  ·  view source on GitHub ↗

! fills the ComboBox for the symbol filling patterns with the 14 possible Qt::BrushStyles. */

Source from the content-addressed store, hash-verified

138 fills the ComboBox for the symbol filling patterns with the 14 possible Qt::BrushStyles.
139*/
140void 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
185void GuiTools::fillColorMenu(QMenu* menu, QActionGroup* actionGroup) {
186 static const std::array<QString, colorsCount> colorNames = {

Callers

nothing calls this directly

Calls 11

QIconClass · 0.85
setIconSizeMethod · 0.80
setPenMethod · 0.80
setBrushMethod · 0.80
QBrushClass · 0.50
currentIndexMethod · 0.45
clearMethod · 0.45
setColorMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
setCurrentIndexMethod · 0.45

Tested by

no test coverage detected