]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/selectionmode/backgroundcolorhelper.cpp
Improve code quality
[dolphin.git] / src / selectionmode / backgroundcolorhelper.cpp
index 8a7d69758b200d9adae2e55090bc75fe4a960c8a..fc540315253d06eb7f8b6f6f8d00604e095edfa0 100644 (file)
@@ -1,6 +1,6 @@
 /*
     This file is part of the KDE project
-    SPDX-FileCopyrightText: 2022 Felix Ernst <fe.a.ernst@gmail.com>
+    SPDX-FileCopyrightText: 2022 Felix Ernst <felixernst@zohomail.eu>
 
     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
 */
@@ -14,6 +14,8 @@
 #include <QtGlobal>
 #include <QWidget>
 
+using namespace SelectionMode;
+
 BackgroundColorHelper *BackgroundColorHelper::instance()
 {
     if (!s_instance) {
@@ -52,9 +54,11 @@ void BackgroundColorHelper::slotPaletteChanged()
 {
     updateBackgroundColor();
     for (auto i = m_colorControlledWidgets.begin(); i != m_colorControlledWidgets.end(); ++i) {
-        if (!*i) {
+        while (!*i) {
             i = m_colorControlledWidgets.erase(i);
-            continue;
+            if (i == m_colorControlledWidgets.end()) {
+                break;
+            }
         }
         setBackgroundColorForWidget(*i, m_backgroundColor);
     }
@@ -81,7 +85,8 @@ void BackgroundColorHelper::updateBackgroundColor()
     }
 
     m_backgroundColor = QColor::fromHsv(newHue,
-                                        // Saturation should be closer to the active color because otherwise the selection mode color might overpower it.
+                                        // Saturation should be closer to the saturation of the active color
+                                        // because otherwise the selection mode color might overpower it.
                                         .7 * activeBackgroundColor.saturation() + .3 * positiveBackgroundColor.saturation(),
                                         (activeBackgroundColor.value() + positiveBackgroundColor.value()) / 2,
                                         (activeBackgroundColor.alpha() + positiveBackgroundColor.alpha()) / 2);