File indexing completed on 2024-12-08 07:34:23

0001 /*
0002    SPDX-FileCopyrightText: 2022 Nicolas Fella <nicolas.fella@gmx.de>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "colorsandmessageviewstyle.h"
0008 
0009 #include <QApplication>
0010 
0011 ColorsAndMessageViewStyle::ColorsAndMessageViewStyle()
0012     : QObject()
0013 {
0014     regenerateColorScheme();
0015 }
0016 
0017 ColorsAndMessageViewStyle &ColorsAndMessageViewStyle::self()
0018 {
0019     static ColorsAndMessageViewStyle c;
0020     return c;
0021 }
0022 
0023 KColorScheme ColorsAndMessageViewStyle::schemeView() const
0024 {
0025     return mSchemeView;
0026 }
0027 
0028 KColorScheme ColorsAndMessageViewStyle::schemeWindow() const
0029 {
0030     return mSchemeWindow;
0031 }
0032 
0033 void ColorsAndMessageViewStyle::regenerateColorScheme()
0034 {
0035     mSchemeView = KColorScheme();
0036     mSchemeWindow = KColorScheme(QPalette::Active, KColorScheme::Window);
0037     Q_EMIT needToUpdateColors();
0038 }
0039 
0040 bool ColorsAndMessageViewStyle::event(QEvent *e)
0041 {
0042     if (e->type() == QEvent::ApplicationPaletteChange) {
0043         regenerateColorScheme();
0044     }
0045     return QObject::event(e);
0046 }
0047 
0048 #include "moc_colorsandmessageviewstyle.cpp"