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

Method updatePenStyles

src/frontend/GuiTools.cpp:56–80  ·  view source on GitHub ↗

! fills the ComboBox \c combobox with the six possible Qt::PenStyles, the color \c color is used. */

Source from the content-addressed store, hash-verified

54 fills the ComboBox \c combobox with the six possible Qt::PenStyles, the color \c color is used.
55*/
56void GuiTools::updatePenStyles(QComboBox* comboBox, const QColor& color) {
57 int index = comboBox->currentIndex();
58 comboBox->clear();
59
60 QPainter pa;
61 int offset = 2;
62 int w = 50;
63 int h = 10;
64 QPixmap pm(w, h);
65 comboBox->setIconSize(QSize(w, h));
66
67 // loop over six possible Qt-PenStyles, draw on the pixmap and insert it
68 // TODO: avoid copy-paste in all finctions!
69 static std::array<QString, 6> list =
70 {i18n("No Line"), i18n("Solid Line"), i18n("Dash Line"), i18n("Dot Line"), i18n("Dash-dot Line"), i18n("Dash-dot-dot Line")};
71 for (int i = 0; i < 6; i++) {
72 pm.fill(Qt::transparent);
73 pa.begin(&pm);
74 pa.setPen(QPen(color, 1, (Qt::PenStyle)i));
75 pa.drawLine(offset, h / 2, w - offset, h / 2);
76 pa.end();
77 comboBox->addItem(QIcon(pm), list[i]);
78 }
79 comboBox->setCurrentIndex(index);
80}
81
82/*!
83 fills the QMenu \c menu with the six possible Qt::PenStyles, the color \c color is used.

Callers

nothing calls this directly

Calls 11

QIconClass · 0.85
setIconSizeMethod · 0.80
setPenMethod · 0.80
QPenClass · 0.50
currentIndexMethod · 0.45
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
setCurrentIndexMethod · 0.45
isEmptyMethod · 0.45
setIconMethod · 0.45

Tested by

no test coverage detected