File indexing completed on 2024-07-14 05:24:25

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2023 Ismael Asensio <isma.af@gmail.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #include "soundthemeconfig.h"
0009 
0010 const QString DEFAULT_SOUND_THEME = QStringLiteral("ocean");
0011 
0012 SoundThemeConfig::SoundThemeConfig(QObject *parent)
0013     : QObject(parent)
0014     , m_soundTheme(DEFAULT_SOUND_THEME)
0015 {
0016     m_configWatcher = KConfigWatcher::create(KSharedConfig::openConfig(QStringLiteral("kdeglobals")));
0017     connect(m_configWatcher.get(), &KConfigWatcher::configChanged, this, &SoundThemeConfig::kdeglobalsChanged);
0018 
0019     const KConfigGroup soundGroup = m_configWatcher->config()->group("Sounds");
0020     m_soundTheme = soundGroup.readEntry("Theme", DEFAULT_SOUND_THEME);
0021 }
0022 
0023 QString SoundThemeConfig::soundTheme() const
0024 {
0025     return m_soundTheme;
0026 }
0027 
0028 void SoundThemeConfig::kdeglobalsChanged(const KConfigGroup &group, const QByteArrayList &names)
0029 {
0030     if (group.name() != QLatin1String("Sounds") || !names.contains(QByteArrayLiteral("Theme"))) {
0031         return;
0032     }
0033 
0034     m_soundTheme = group.readEntry("Theme", DEFAULT_SOUND_THEME);
0035     Q_EMIT soundThemeChanged(m_soundTheme);
0036 }
0037 
0038 #include "moc_soundthemeconfig.cpp"