File indexing completed on 2024-02-18 05:27:41

0001 /*
0002  *   SPDX-FileCopyrightText: 2013 Julien Borderie <frajibe@gmail.com>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-or-later
0005  *
0006  */
0007 
0008 #include "configurationmanager.h"
0009 #include <KSharedConfig>
0010 
0011 const QString ConfigurationManager::GENERAL_CONFIG_GROUP = QStringLiteral("General");
0012 const QString ConfigurationManager::SHOW_HIDDEN_ENTRIES_PROPERTY_NAME = QStringLiteral("ShowHidden");
0013 const QString ConfigurationManager::SPLITTER_SIZES_PROPERTY_NAME = QStringLiteral("SplitterSizes");
0014 
0015 ConfigurationManager *ConfigurationManager::m_instance = nullptr;
0016 
0017 ConfigurationManager::ConfigurationManager()
0018     : m_configGroup(KSharedConfig::openConfig(), GENERAL_CONFIG_GROUP)
0019 {
0020 }
0021 
0022 bool ConfigurationManager::hiddenEntriesVisible() const
0023 {
0024     return m_configGroup.readEntry(SHOW_HIDDEN_ENTRIES_PROPERTY_NAME, false);
0025 }
0026 
0027 void ConfigurationManager::setHiddenEntriesVisible(bool visible)
0028 {
0029     m_configGroup.writeEntry(SHOW_HIDDEN_ENTRIES_PROPERTY_NAME, visible);
0030     m_configGroup.sync();
0031 }
0032 
0033 QList<int> ConfigurationManager::getSplitterSizes() const
0034 {
0035     return m_configGroup.readEntry(SPLITTER_SIZES_PROPERTY_NAME, QList<int>());
0036 }
0037 
0038 void ConfigurationManager::setSplitterSizes(const QList<int> &sizes)
0039 {
0040     m_configGroup.writeEntry(SPLITTER_SIZES_PROPERTY_NAME, sizes);
0041     m_configGroup.sync();
0042 }