X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/402b4a5698f3d12d1848b298c38828d509abfd0d..9f233850beb60168e8773623e0b5ae052c5287e9:/src/selectionmode/backgroundcolorhelper.h diff --git a/src/selectionmode/backgroundcolorhelper.h b/src/selectionmode/backgroundcolorhelper.h index 013d33685..f274593b8 100644 --- a/src/selectionmode/backgroundcolorhelper.h +++ b/src/selectionmode/backgroundcolorhelper.h @@ -1,6 +1,6 @@ /* This file is part of the KDE project - SPDX-FileCopyrightText: 2022 Felix Ernst + SPDX-FileCopyrightText: 2022 Felix Ernst SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ @@ -9,37 +9,57 @@ #define BACKGROUNDCOLORHELPER_H #include +#include #include #include class QWidget; +namespace SelectionMode +{ + /** * @brief A Singleton class for managing the colors of selection mode widgets. */ -class BackgroundColorHelper +class BackgroundColorHelper : public QObject { + Q_OBJECT public: static BackgroundColorHelper *instance(); /** * Changes the background color of @p widget to a distinct color scheme matching color which makes it clear that the widget belongs to the selection mode. + * The background color of @p widget will from now on be updated automatically when the palette of the application changes. */ void controlBackgroundColor(QWidget *widget); +protected: + bool eventFilter(QObject *obj, QEvent *event) override; + private: BackgroundColorHelper(); + /** + * Called when the palette of the application changes. + * Triggers updateBackgroundColor() and the updates the background color of m_colorControlledWidgets. + * @see updateBackgroundColor + */ void slotPaletteChanged(); + /** Calculates a new m_colorControlledWidgets based on the current color scheme of the application. */ void updateBackgroundColor(); private: + /// The widgets who have given up control over the background color to BackgroundColorHelper. std::vector> m_colorControlledWidgets; + /// The color to be used for the widgets' backgrounds. QColor m_backgroundColor; + /// Singleton object static BackgroundColorHelper *s_instance; }; +} + #endif // BACKGROUNDCOLORHELPER_H