1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "binarytoolssetting.h"
6
7BinaryToolsSetting::BinaryToolsSetting()
8{
9 settings = new QSettings;
10}
11
12BinaryToolsSetting::BinaryToolsSetting(const QString &fileName, QObject *parent)
13{
14 settings = new QSettings(fileName, QSettings::IniFormat, parent);
15}
16
17void BinaryToolsSetting::setValue(const QString &key, const QVariant &value)
18{
19 settings->setValue(key, value);
20}
21
22QVariant BinaryToolsSetting::getValue(const QString &key, const QVariant &defaultValue)
23{
24 return settings->value(key, defaultValue);
25}
26
27QVariant BinaryToolsSetting::getValue(const QString &key)
28{
29 return settings->value(key);
30}
31
32void BinaryToolsSetting::deleteKey(const QString &key)
33{
34 settings->remove(key);
35}
36
37void BinaryToolsSetting::replaceKey(const QString &oldKey, const QString &newKey)
38{
39 settings->setValue(newKey ,settings->value(oldKey));
40 settings->remove(oldKey);
41}
42
43bool BinaryToolsSetting::hasKey(const QString &key)
44{
45 return settings->allKeys().contains(key);
46}
47
48void BinaryToolsSetting::allValues()
49{
50 QStringList keys = settings->allKeys();
51 for (QString key : keys) {
52 QVariant temp = settings->value(key);
53 }
54}
55