┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/selectionmode/backgroundcolorhelper.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/selectionmode/backgroundcolorhelper.h')
-rw-r--r--src/selectionmode/backgroundcolorhelper.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/selectionmode/backgroundcolorhelper.h b/src/selectionmode/backgroundcolorhelper.h
new file mode 100644
index 000000000..0e8a61b34
--- /dev/null
+++ b/src/selectionmode/backgroundcolorhelper.h
@@ -0,0 +1,45 @@
+/*
+ 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;
+
+/**
+ * @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