┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/selectionmode/backgroundcolorhelper.h
blob: 8d2730fcf1165e8291b96056465fb5ce06ea615a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
    This file is part of the KDE project
    SPDX-FileCopyrightText: 2022 Felix Ernst <[email protected]>

    SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/

#ifndef BACKGROUNDCOLORHELPER_H
#define BACKGROUNDCOLORHELPER_H

#include <QColor>
#include <QPointer>

#include <memory>

class QWidget;

namespace SelectionMode
{

/**
 * @brief A Singleton class for managing the colors of selection mode widgets.
 */
class BackgroundColorHelper
{
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.
     */
    void controlBackgroundColor(QWidget *widget);

private:
    BackgroundColorHelper();

    void slotPaletteChanged();

    void updateBackgroundColor();

private:
    std::vector<QPointer<QWidget>> m_colorControlledWidgets;
    QColor m_backgroundColor;

    static BackgroundColorHelper *s_instance;
};

}

#endif // BACKGROUNDCOLORHELPER_H