cleanup: unglobalize grayImage()

This function was globalized in be462ae1a6 to be used for the calender
widget, but that never came to be. Therefore, for now unglobalize it
until it is needed. That said, there probably is a helper function to
turn pictures into gray-scale.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-05-27 19:03:30 +02:00 committed by Dirk Hohndel
parent 2690325623
commit 330b300f22
2 changed files with 18 additions and 20 deletions

View file

@ -161,6 +161,5 @@ private:
};
bool isGnome3Session();
QImage grayImage(const QImage &coloredImg);
#endif // SIMPLEWIDGETS_H

View file

@ -36,7 +36,6 @@ QImage focusedImage(const QImage& coloredImg)
return img;
}
int StarWidget::currentStars() const
{
return current;
@ -91,6 +90,24 @@ void StarWidget::setCurrentStars(int value)
emit valueChanged(current);
}
static QImage grayImage(const QImage &coloredImg)
{
QImage img = coloredImg;
for (int i = 0; i < img.width(); ++i) {
for (int j = 0; j < img.height(); ++j) {
QRgb rgb = img.pixel(i, j);
if (!rgb)
continue;
QColor c(rgb);
int gray = 204 + (c.red() + c.green() + c.blue()) / 15;
img.setPixel(i, j, qRgb(gray, gray, gray));
}
}
return img;
}
StarWidget::StarWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f),
current(0),
readOnly(false)
@ -113,24 +130,6 @@ StarWidget::StarWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f),
setFocusPolicy(Qt::StrongFocus);
}
QImage grayImage(const QImage& coloredImg)
{
QImage img = coloredImg;
for (int i = 0; i < img.width(); ++i) {
for (int j = 0; j < img.height(); ++j) {
QRgb rgb = img.pixel(i, j);
if (!rgb)
continue;
QColor c(rgb);
int gray = 204 + (c.red() + c.green() + c.blue()) / 15;
img.setPixel(i, j, qRgb(gray, gray, gray));
}
}
return img;
}
QSize StarWidget::sizeHint() const
{
const IconMetrics& metrics = defaultIconMetrics();