MCPcopy Create free account
hub / github.com/KDAB/KDChart / changeBackgroundColor

Method changeBackgroundColor

examples/demo/diagramsettings.cpp:101–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99 }
100}
101void DiagramSettings::Private::changeBackgroundColor()
102{
103 if (m_chart && m_chart->coordinatePlane() && m_chart->coordinatePlane()->diagram()) {
104 BackgroundAttributes bat = m_chart->coordinatePlane()->backgroundAttributes();
105 bat.setVisible(true);
106 ui->visibleBtn->setChecked(true);
107
108 if (ui->color->isChecked()) {
109
110 QBrush setBrush = bat.brush();
111 const QColor color = QColorDialog::getColor(setBrush.color(), qq, tr("Choose new color"));
112 if (!color.isValid())
113 return;
114 bat.setBrush(color);
115 QPalette palette = ui->diagramBackground->palette();
116 palette.setBrush(QPalette::Button, color);
117 ui->diagramBackground->setPalette(palette);
118 } else if (ui->textureBtn->isChecked()) {
119 // QBrush setBrush = m_chart->coordinatePlane()->diagram()->brush( index );
120 QImage texture;
121
122 const QString filename = QFileDialog::getOpenFileName(qq, tr("Choose Texture"), QString(), tr("Images (*.png *.xpm *.jpg)"));
123 if (filename.isEmpty())
124 return;
125 texture = QImage(filename);
126 bat.setBrush(texture);
127 QPalette palette = ui->diagramBackground->palette();
128 palette.setBrush(QPalette::Button, QBrush(texture));
129 ui->diagramBackground->setPalette(palette);
130 } else {
131 QBrush setBrush = bat.brush();
132 QGradient grad;
133 QLinearGradient lGrad;
134 lGrad.setColorAt(0, Qt::black);
135 lGrad.setColorAt(1, setBrush.color());
136 grad = lGrad;
137
138 if (setBrush.gradient())
139 grad = *setBrush.gradient();
140 const QGradient &color = GradientDialog::getGradient(grad, qq, tr("Choose new color"));
141 bat.setBrush(color);
142 QPalette palette = ui->diagramBackground->palette();
143 palette.setBrush(QPalette::Button, QBrush(color));
144 ui->diagramBackground->setPalette(palette);
145 }
146 bat.setVisible(true);
147 m_chart->coordinatePlane()->setBackgroundAttributes(bat);
148 qq->update();
149 }
150}
151
152void DiagramSettings::Private::changeBackgroundVisibility()
153{

Callers

nothing calls this directly

Calls 12

QStringClass · 0.85
gradientMethod · 0.80
coordinatePlaneMethod · 0.45
diagramMethod · 0.45
backgroundAttributesMethod · 0.45
setVisibleMethod · 0.45
brushMethod · 0.45
isValidMethod · 0.45
setBrushMethod · 0.45
isEmptyMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected