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 | |
7 | BinaryToolsSetting::BinaryToolsSetting() |
8 | { |
9 | settings = new QSettings; |
10 | } |
11 | |
12 | BinaryToolsSetting::BinaryToolsSetting(const QString &fileName, QObject *parent) |
13 | { |
14 | settings = new QSettings(fileName, QSettings::IniFormat, parent); |
15 | } |
16 | |
17 | void BinaryToolsSetting::setValue(const QString &key, const QVariant &value) |
18 | { |
19 | settings->setValue(key, value); |
20 | } |
21 | |
22 | QVariant BinaryToolsSetting::getValue(const QString &key, const QVariant &defaultValue) |
23 | { |
24 | return settings->value(key, defaultValue); |
25 | } |
26 | |
27 | QVariant BinaryToolsSetting::getValue(const QString &key) |
28 | { |
29 | return settings->value(key); |
30 | } |
31 | |
32 | void BinaryToolsSetting::deleteKey(const QString &key) |
33 | { |
34 | settings->remove(key); |
35 | } |
36 | |
37 | void BinaryToolsSetting::replaceKey(const QString &oldKey, const QString &newKey) |
38 | { |
39 | settings->setValue(newKey ,settings->value(oldKey)); |
40 | settings->remove(oldKey); |
41 | } |
42 | |
43 | bool BinaryToolsSetting::hasKey(const QString &key) |
44 | { |
45 | return settings->allKeys().contains(key); |
46 | } |
47 | |
48 | void BinaryToolsSetting::allValues() |
49 | { |
50 | QStringList keys = settings->allKeys(); |
51 | for (QString key : keys) { |
52 | QVariant temp = settings->value(key); |
53 | } |
54 | } |
55 | |