File indexing completed on 2024-04-21 04:35:59

0001 /* This file is part of KDevelop
0002    Copyright 2018 Anton Anikin <anton@anikin.xyz>
0003 
0004    This program is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This program is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0012    General Public License for more details.
0013 
0014    You should have received a copy of the GNU General Public License
0015    along with this program; see the file COPYING. If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017    Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #include "configpage.h"
0021 
0022 #include "config.h"
0023 #include "debug.h"
0024 
0025 #include <KConfigDialogManager>
0026 
0027 #include <QIcon>
0028 
0029 namespace Valgrind
0030 {
0031 
0032 ConfigPage::ConfigPage(QString title, QWidget* parent)
0033     : LaunchConfigurationPage(parent)
0034     , m_title(title)
0035     , m_config(nullptr)
0036     , m_manager(nullptr)
0037 {
0038 }
0039 
0040 ConfigPage::~ConfigPage() = default;
0041 
0042 void ConfigPage::init(Config* config)
0043 {
0044     Q_ASSERT(config);
0045 
0046     m_config.reset(config);
0047     m_manager.reset(new KConfigDialogManager(this, config));
0048 
0049     connect(m_manager.data(), &KConfigDialogManager::widgetModified, this, &ConfigPage::changed);
0050     connect(this, &ConfigPage::changed, this, &ConfigPage::check);
0051 
0052     check();
0053 }
0054 
0055 void ConfigPage::check()
0056 {
0057 }
0058 
0059 QString ConfigPage::title() const
0060 {
0061     return m_title;
0062 }
0063 
0064 QIcon ConfigPage::icon() const
0065 {
0066     return QIcon();
0067 }
0068 
0069 void ConfigPage::loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject*)
0070 {
0071     Q_ASSERT(m_config);
0072     Q_ASSERT(m_manager);
0073 
0074     m_config->setConfigGroup(cfg);
0075     m_config->load();
0076 
0077     m_manager->updateWidgets();
0078 }
0079 
0080 void ConfigPage::saveToConfiguration(KConfigGroup cfg, KDevelop::IProject*) const
0081 {
0082     Q_ASSERT(m_config);
0083     Q_ASSERT(m_manager);
0084 
0085     m_config->setConfigGroup(cfg);
0086     m_manager->updateSettings();
0087 }
0088 
0089 }