]> cloud.milkyroute.net Git - dolphin.git/blob - src/selectionmode/backgroundcolorhelper.h
Better separation of classes
[dolphin.git] / src / selectionmode / backgroundcolorhelper.h
1 /*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2022 Felix Ernst <felixernst@zohomail.eu>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7
8 #ifndef BACKGROUNDCOLORHELPER_H
9 #define BACKGROUNDCOLORHELPER_H
10
11 #include <QColor>
12 #include <QPointer>
13
14 #include <memory>
15
16 class QWidget;
17
18 namespace SelectionMode
19 {
20
21 /**
22 * @brief A Singleton class for managing the colors of selection mode widgets.
23 */
24 class BackgroundColorHelper
25 {
26 public:
27 static BackgroundColorHelper *instance();
28
29 /**
30 * 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.
31 */
32 void controlBackgroundColor(QWidget *widget);
33
34 private:
35 BackgroundColorHelper();
36
37 void slotPaletteChanged();
38
39 void updateBackgroundColor();
40
41 private:
42 std::vector<QPointer<QWidget>> m_colorControlledWidgets;
43 QColor m_backgroundColor;
44
45 static BackgroundColorHelper *s_instance;
46 };
47
48 }
49
50 #endif // BACKGROUNDCOLORHELPER_H