diff --git a/src/moodbar/moodbarbuilder.cpp b/src/moodbar/moodbarbuilder.cpp index e9b8b8d9..e6980a6c 100644 --- a/src/moodbar/moodbarbuilder.cpp +++ b/src/moodbar/moodbarbuilder.cpp @@ -26,12 +26,8 @@ namespace { -static const int sBarkBands[] = { - 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480, 1720, - 2000, 2320, 2700, 3150, 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500 -}; - -static const int sBarkBandCount = arraysize(sBarkBands); +constexpr int sBarkBands[] = { 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500 }; +constexpr int sBarkBandCount = arraysize(sBarkBands); } // namespace diff --git a/src/moodbar/moodbarproxystyle.cpp b/src/moodbar/moodbarproxystyle.cpp index 96ab2aba..4183911d 100644 --- a/src/moodbar/moodbarproxystyle.cpp +++ b/src/moodbar/moodbarproxystyle.cpp @@ -43,10 +43,12 @@ #include "moodbarrenderer.h" #include "settings/moodbarsettingspage.h" -const int MoodbarProxyStyle::kMarginSize = 3; -const int MoodbarProxyStyle::kBorderSize = 1; -const int MoodbarProxyStyle::kArrowWidth = 17; -const int MoodbarProxyStyle::kArrowHeight = 13; +namespace { +constexpr int kMarginSize = 3; +constexpr int kBorderSize = 1; +constexpr int kArrowWidth = 17; +constexpr int kArrowHeight = 13; +} // namespace MoodbarProxyStyle::MoodbarProxyStyle(Application *app, QSlider *slider, QObject*) : QProxyStyle(nullptr), @@ -145,8 +147,7 @@ void MoodbarProxyStyle::NextState() { fade_target_ = QPixmap(); } else { - // Stop an existing fade and start fading the other direction from the - // same place. + // Stop an existing fade and start fading the other direction from the same place. fade_timeline_->stop(); fade_timeline_->setDirection(direction); fade_timeline_->resume(); @@ -291,8 +292,7 @@ QRect MoodbarProxyStyle::subControlRect(ComplexControl cc, const QStyleOptionCom const QStyleOptionSlider *slider_opt = qstyleoption_cast(opt); int x_offset = 0; - /* slider_opt->{maximum,minimum} can have the value 0 (their default - values), so this check avoids a division by 0. */ + // slider_opt->{maximum,minimum} can have the value 0 (their default values), so this check avoids a division by 0. if (slider_opt->maximum > slider_opt->minimum) { qint64 slider_delta = slider_opt->sliderValue - slider_opt->minimum; qint64 slider_range = slider_opt->maximum - slider_opt->minimum; @@ -311,6 +311,7 @@ QRect MoodbarProxyStyle::subControlRect(ComplexControl cc, const QStyleOptionCom } return QProxyStyle::subControlRect(cc, opt, sc, widget); + } void MoodbarProxyStyle::DrawArrow(const QStyleOptionSlider *option, QPainter *painter) const { diff --git a/src/moodbar/moodbarproxystyle.h b/src/moodbar/moodbarproxystyle.h index 5fff61f5..42d1157e 100644 --- a/src/moodbar/moodbarproxystyle.h +++ b/src/moodbar/moodbarproxystyle.h @@ -65,11 +65,6 @@ class MoodbarProxyStyle : public QProxyStyle { void SetMoodbarEnabled(const bool enabled); private: - static const int kMarginSize; - static const int kBorderSize; - static const int kArrowWidth; - static const int kArrowHeight; - enum class State { MoodbarOn, MoodbarOff, diff --git a/src/moodbar/moodbarrenderer.cpp b/src/moodbar/moodbarrenderer.cpp index d14f703f..f4b92763 100644 --- a/src/moodbar/moodbarrenderer.cpp +++ b/src/moodbar/moodbarrenderer.cpp @@ -87,16 +87,13 @@ ColorVector MoodbarRenderer::Colors(const QByteArray &data, const MoodbarStyle s total = qMax(total, 1); - // Remap the hue values to be between rangeStart and - // rangeStart + rangeDelta. Every time we see an input hue - // above the threshold, increment the output hue by - // (1/total) * rangeDelta. + // Remap the hue values to be between rangeStart and rangeStart + rangeDelta. + // Every time we see an input hue above the threshold, increment the output hue by (1/total) * rangeDelta. for (int i = 0, n = 0; i < 360; i++) { hue_distribution[i] = ((hue_distribution[i] > properties.threshold_ ? n++ : n) * properties.range_delta_ / total + properties.range_start_) % 360; } - // Now huedist is a hue mapper: huedist[h] is the new hue value - // for a bar with hue h + // Now huedist is a hue mapper: huedist[h] is the new hue value for a bar with hue h for (ColorVector::iterator it = colors.begin(); it != colors.end(); ++it) { const int hue = qMax(0, it->hue()); @@ -104,6 +101,7 @@ ColorVector MoodbarRenderer::Colors(const QByteArray &data, const MoodbarStyle s } return colors; + } void MoodbarRenderer::Render(const ColorVector &colors, QPainter *p, const QRect rect) { @@ -148,6 +146,7 @@ void MoodbarRenderer::Render(const ColorVector &colors, QPainter *p, const QRect p->drawPoint(rect.left() + x, rect.top() + rect.height() - 1 - y); } } + } QImage MoodbarRenderer::RenderToImage(const ColorVector &colors, const QSize size) {