From 330b300f220a78cb71e30b898f43c19f41961c8b Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 27 May 2020 19:03:30 +0200 Subject: [PATCH] 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 --- desktop-widgets/simplewidgets.h | 1 - desktop-widgets/starwidget.cpp | 37 ++++++++++++++++----------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/desktop-widgets/simplewidgets.h b/desktop-widgets/simplewidgets.h index ed364e75f..706b46818 100644 --- a/desktop-widgets/simplewidgets.h +++ b/desktop-widgets/simplewidgets.h @@ -161,6 +161,5 @@ private: }; bool isGnome3Session(); -QImage grayImage(const QImage &coloredImg); #endif // SIMPLEWIDGETS_H diff --git a/desktop-widgets/starwidget.cpp b/desktop-widgets/starwidget.cpp index d4a63b273..8748d929b 100644 --- a/desktop-widgets/starwidget.cpp +++ b/desktop-widgets/starwidget.cpp @@ -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();