File indexing completed on 2024-10-27 04:58:01
0001 /* 0002 SPDX-FileCopyrightText: 2010-2023 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 // This code was taken from kmail-account-wizard 0008 0009 #pragma once 0010 0011 #include "setupobject.h" 0012 #include <QVector> 0013 class KConfig; 0014 0015 struct Config { 0016 QString group; 0017 QString key; 0018 QString value; 0019 bool obscure; 0020 }; 0021 0022 class ConfigFile : public SetupObject 0023 { 0024 Q_OBJECT 0025 public: 0026 explicit ConfigFile(const QString &configName, QObject *parent = nullptr); 0027 ~ConfigFile() override; 0028 void create() override; 0029 void destroy() override; 0030 void edit(); 0031 public Q_SLOTS: 0032 Q_SCRIPTABLE void write(); 0033 Q_SCRIPTABLE void setName(const QString &name); 0034 Q_SCRIPTABLE void setConfig(const QString &group, const QString &key, const QString &value); 0035 Q_SCRIPTABLE void setPassword(const QString &group, const QString &key, const QString &value); 0036 Q_SCRIPTABLE void setEditMode(const bool editMode); 0037 Q_SCRIPTABLE void setEditName(const QString &name); 0038 0039 private: 0040 QVector<Config> m_configData; 0041 QString m_name; 0042 KConfig *const m_config; 0043 QString m_editName; 0044 bool m_editMode = false; 0045 }; 0046