Debian Codegraph @

src/dconfig.cpp

raw
1 // SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd.
2 //
3 // SPDX-License-Identifier: LGPL-3.0-or-later
4
5 #include "dconfig.h"
6 #ifndef D_DISABLE_DCONFIG
7 #include "dconfigfile.h"
8 #ifndef D_DISABLE_DBUS_CONFIG
9 #include "configmanager_interface.h"
10 #include "manager_interface.h"
11 #endif
12 #else
13 #include <QSettings>
14 #endif
15 #include "dobject_p.h"
16 #include <DSGApplication>
17
18 #include <QLoggingCategory>
19 #include <QCoreApplication>
20 #include <unistd.h>
21
22 // https://gitlabwh.uniontech.com/wuhan/se/deepin-specifications/-/issues/3
23
24 DCORE_BEGIN_NAMESPACE
25
26 Q_DECLARE_LOGGING_CATEGORY(cfLog)
27 static QString NoAppId;
28
29 /*!
30 @~english
31 @class Dtk::Core::DConfigBackend
32 \inmodule dtkcore
33
34 @brief Configure the abstract interface of the backend.
35
36 All configuration backends used by DConfig inherit this class, and users can inherit this class to implement their own configuration backends.
37 */
38
39 /*!
40 @~english
41 @fn bool DConfigBackend::load(const QString &) = 0
42
43 @brief Initialize the backend
44
45 \a appId Managed configuration information key value, the default is the application name.
46 */
47
48 /*!
49 @~english
50 @fn bool DConfigBackend::isValid() const = 0
51
52 @sa DConfig::isValid().
53
54 */
55
56 /*!
57 @~english
58 @fn QStringList DConfigBackend::keyList() const = 0
59
60 @sa DConfig::keyList()
61
62 */
63
64 /*!
65 @~english
66 @fn QVariant DConfigBackend::value(const QString &key, const QVariant &fallback = QVariant()) const = 0
67
68 @sa DConfig::value()
69 */
70
71 /*!
72 @~english
73 @fn void DConfigBackend::setValue(const QString &key, const QVariant &value) = 0
74
75 @sa DConfig::setValue()
76 */
77
78 /*!
79 @~english
80 @fn void DConfigBackend::reset(const QString &key)
81
82 @sa DConfig::reset()
83 */
84
85 /*!
86 @~english
87 @fn QString DConfigBackend::name() const = 0
88
89 @brief The unique identity of the backend configuration
90 */
91
92 /*!
93 @~english
94 @fn bool DConfigBackend::isDefaultValue(const QString &key) const = 0
95
96 @sa DConfig::isDefaultValue()
97
98 */
99
100 DConfigBackend::~DConfigBackend()
101 {
102 }
103
104 static QString _globalAppId;
105 class Q_DECL_HIDDEN DConfigPrivate : public DObjectPrivate
106 {
107 public:
108 explicit DConfigPrivate(DConfig *qq,
109 const QString &appId,
110 const QString &name,
111 const QString &subpath)
112 : DObjectPrivate(qq)
113 , appId(appId)
114 , name(name)
115 , subpath(subpath)
116 {
117 }
118
119 virtual ~DConfigPrivate() override;
120
121 inline bool invalid() const
122 {
123 const bool valid = backend && backend->isValid();
124 if (!valid)
125 qCWarning(cfLog, "DConfig is invalid of appid=%s name=%s, subpath=%s",
126 qPrintable(appId), qPrintable(name), qPrintable(subpath));
127
128 return !valid;
129 }
130
131 DConfigBackend *getOrCreateBackend();
132 DConfigBackend *createBackendByEnv();
133
134 QString appId;
135 QString name;
136 QString subpath;
137 QScopedPointer<DConfigBackend> backend;
138
139 D_DECLARE_PUBLIC(DConfig)
140 };
141
142 namespace {
143
144 #ifndef D_DISABLE_DCONFIG
145 class Q_DECL_HIDDEN FileBackend : public DConfigBackend
146 {
147 public:
148 explicit FileBackend(DConfigPrivate *o)
149 : owner(o)
150 {
151 }
152
153 virtual ~FileBackend() override;
154
155 virtual bool isValid() const override
156 {
157 return configFile && configFile->isValid();
158 }
159
160 virtual bool load(const QString &/*appId*/) override
161 {
162 if (configFile)
163 return true;
164
165 configFile.reset(new DConfigFile(owner->appId,owner->name, owner->subpath));
166 configCache.reset(configFile->createUserCache(getuid()));
167 const QString &prefix = localPrefix();
168
169 if (!configFile->load(prefix) || !configCache->load(prefix))
170 return false;
171
172 // generic config doesn't need to fallback to generic configration.
173 if (owner->appId == NoAppId)
174 return true;
175
176 QScopedPointer<DConfigFile> file(new DConfigFile(NoAppId, owner->name, owner->subpath));
177 const bool canFallbackToGeneric = !file->meta()->metaPath(prefix).isEmpty();
178 if (canFallbackToGeneric) {
179 QScopedPointer<DConfigCache> cache(file->createUserCache(getuid()));
180 if (file->load(prefix) && cache->load(prefix)) {
181 genericConfigFile.reset(file.take());
182 genericConfigCache.reset(cache.take());
183 }
184 }
185 return true;
186 }
187
188 virtual QStringList keyList() const override
189 {
190 return configFile->meta()->keyList();
191 }
192
193 virtual QVariant value(const QString &key, const QVariant &fallback) const override
194 {
195 const QVariant &vc = configFile->cacheValue(configCache.get(), key);
196 if (vc.isValid())
197 return vc;
198
199 // fallback to generic configuration, and use itself's configuration if generic isn't set.
200 if (genericConfigFile) {
201 const auto &tmp = genericConfigFile->cacheValue(genericConfigCache.get(), key);
202 if (tmp.isValid())
203 return tmp;
204 }
205 const QVariant &v = configFile->value(key);
206 if (v.isValid())
207 return v;
208 // fallback to default value of generic configuration.
209 const QVariant &vg = genericConfigFile->value(key);
210 return vg.isValid() ? vg : fallback;
211 }
212
213 virtual bool isDefaultValue(const QString &key) const override
214 {
215 // Don't fallback to generic configuration
216 const QVariant &vc = configFile->cacheValue(configCache.get(), key);
217 return !vc.isValid();
218 }
219
220 virtual void setValue(const QString &key, const QVariant &value) override
221 {
222 // setValue's callerAppid is itself instead of config's appId.
223 if (configFile->setValue(key, value, DSGApplication::id(), configCache.get())) {
224 Q_EMIT owner->q_func()->valueChanged(key);
225 }
226 }
227
228 virtual void reset(const QString &key) override
229 {
230 setValue(key, QVariant());
231 }
232
233 virtual QString name() const override
234 {
235 return QString("FileBackend");
236 }
237
238 private:
239 QString localPrefix() const
240 {
241 if (!envLocalPrefix.isEmpty()) {
242 return QString::fromLocal8Bit(envLocalPrefix);
243 }
244 return QString();
245 }
246
247 private:
248 QScopedPointer<DConfigFile> configFile;
249 QScopedPointer<DConfigCache> configCache;
250 QScopedPointer<DConfigFile> genericConfigFile;
251 QScopedPointer<DConfigCache> genericConfigCache;
252 DConfigPrivate* owner;
253 const QByteArray envLocalPrefix = qgetenv("DSG_DCONFIG_FILE_BACKEND_LOCAL_PREFIX");
254 };
255
256 FileBackend::~FileBackend()
257 {
258 const QString &prefix = localPrefix();
259 if (configCache) {
260 configCache->save(prefix);
261 configCache.reset();
262 }
263 if (configFile) {
264 configFile->save(prefix);
265 configFile.reset();
266 }
267 if (genericConfigCache) {
268 genericConfigCache->save(prefix);
269 genericConfigCache.reset();
270 }
271 if (genericConfigFile) {
272 genericConfigFile->save(prefix);
273 genericConfigFile.reset();
274 }
275 }
276
277 #ifndef D_DISABLE_DBUS_CONFIG
278
279 #define DSG_CONFIG "org.desktopspec.ConfigManager"
280 #define DSG_CONFIG_MANAGER "org.desktopspec.ConfigManager"
281
282 class Q_DECL_HIDDEN DBusBackend : public DConfigBackend
283 {
284 public:
285 explicit DBusBackend(DConfigPrivate* o):
286 owner(o)
287 {
288 }
289
290 virtual ~DBusBackend() override;
291
292 static bool isServiceRegistered()
293 {
294 return QDBusConnection::systemBus().interface()->isServiceRegistered(DSG_CONFIG);
295 }
296
297 static bool isServiceActivatable()
298 {
299 const QDBusReply<QStringList> activatableNames = QDBusConnection::systemBus().interface()->
300 callWithArgumentList(QDBus::AutoDetect,
301 QLatin1String("ListActivatableNames"),
302 QList<QVariant>());
303 // qInfo() << activatableNames.value() << activatableNames.value().contains(DSG_CONFIG);
304
305 return activatableNames.value().contains(DSG_CONFIG);
306 }
307
308 virtual bool isValid() const override
309 {
310 return config && config->isValid();
311 }
312
313 /*!
314 @~english
315 \internal
316
317 Initialize the DBus connection, the call acquireManager dynamically obtains a configuration connection,
318 The configuration file is then accessed through this configuration connection.
319 */
320 virtual bool load(const QString &/*appId*/) override
321 {
322 if (config)
323 return true;
324
325 qCDebug(cfLog, "Try acquire config manager object form DBus");
326 DSGConfig dsg_config(DSG_CONFIG, "/", QDBusConnection::systemBus());
327 QDBusPendingReply<QDBusObjectPath> dbus_reply = dsg_config.acquireManager(owner->appId, owner->name, owner->subpath);
328 const QDBusObjectPath dbus_path = dbus_reply.value();
329 if (dbus_reply.isError() || dbus_path.path().isEmpty()) {
330 qCWarning(cfLog, "Can't acquire config manager. error:\"%s\"", qPrintable(dbus_reply.error().message()));
331 return false;
332 } else {
333 qCDebug(cfLog(), "dbus path=\"%s\"", qPrintable(dbus_path.path()));
334 config.reset(new DSGConfigManager(DSG_CONFIG_MANAGER, dbus_path.path(),
335 QDBusConnection::systemBus(), owner->q_func()));
336 if (!config->isValid()) {
337 qCWarning(cfLog(), "Can't acquire config path=\"%s\"", qPrintable(dbus_path.path()));
338 config.reset();
339 return false;
340 } else {
341 QObject::connect(config.data(), &DSGConfigManager::valueChanged, owner->q_func(), &DConfig::valueChanged);
342 }
343 }
344 return true;
345 }
346
347 virtual QStringList keyList() const override
348 {
349 return config->keyList();
350 }
351
352 static QVariant decodeQDBusArgument(const QVariant &v)
353 {
354 if (v.canConvert<QDBusArgument>()) {
355 // we use QJsonValue to resolve all data type in DConfigInfo class, so it's type is equal QJsonValue::Type,
356 // now we parse Map and Array type to QVariant explicitly.
357 const QDBusArgument &complexType = v.value<QDBusArgument>();
358 switch (complexType.currentType()) {
359 case QDBusArgument::MapType: {
360 QVariantMap list;
361 complexType >> list;
362 QVariantMap res;
363 for (auto iter = list.begin(); iter != list.end(); iter++) {
364 res[iter.key()] = decodeQDBusArgument(iter.value());
365 }
366 return res;
367 }
368 case QDBusArgument::ArrayType: {
369 QVariantList list;
370 complexType >> list;
371 QVariantList res;
372 res.reserve(list.size());
373 for (const auto &item : qAsConst(list)) {
374 res << decodeQDBusArgument(item);
375 }
376 return res;
377 }
378 default:
379 qWarning("Can't parse the type, it maybe need user to do it, "
380 "QDBusArgument::ElementType: %d.", complexType.currentType());
381 }
382 }
383 return v;
384 }
385
386 virtual QVariant value(const QString &key, const QVariant &fallback) const override
387 {
388 auto reply = config->value(key);
389 reply.waitForFinished();
390 if (reply.isError()) {
391 qWarning() << "value error key:" << key << ", error message:" << reply.error().message();
392 return fallback;
393 }
394 return decodeQDBusArgument(reply.value().variant());
395 }
396
397 virtual bool isDefaultValue(const QString &key) const override
398 {
399 auto reply = config->isDefaultValue(key);
400 reply.waitForFinished();
401 if (reply.isError()) {
402 qWarning() << "Failed to call `isDefaultValue`, key:" << key
403 << ", error message:" << reply.error().message();
404 return false;
405 }
406 return reply.value();
407 }
408
409 virtual void setValue(const QString &key, const QVariant &value) override
410 {
411 auto reply = config->setValue(key, QDBusVariant(value));
412 reply.waitForFinished();
413 if (reply.isError())
414 qCWarning(cfLog) << "Failed to setValue for the key:" << key
415 << ", error message:" << reply.error();
416 }
417
418 virtual void reset(const QString &key) override
419 {
420 auto reply = config->reset(key);
421 reply.waitForFinished();
422 if (reply.isError())
423 qCWarning(cfLog) << "Failed to reset for the key:" << key
424 << ", error message:" << reply.error();
425 }
426
427 virtual QString name() const override
428 {
429 return QString("DBusBackend");
430 }
431
432 private:
433 QScopedPointer<DSGConfigManager> config;
434 DConfigPrivate* owner;
435 };
436
437 DBusBackend::~DBusBackend()
438 {
439 if (config) {
440 config->release();
441 }
442 }
443 #endif //D_DISABLE_DBUS_CONFIG
444 #else
445
446 class Q_DECL_HIDDEN QSettingBackend : public DConfigBackend
447 {
448 public:
449 explicit QSettingBackend(DConfigPrivate* o):
450 owner(o)
451 {
452 }
453
454 virtual ~QSettingBackend() override;
455
456 virtual bool isValid() const override
457 {
458 return settings;
459 }
460
461 virtual bool load(const QString &appid) override
462 {
463 Q_UNUSED(appid);
464
465 if (settings)
466 return true;
467
468 settings = new QSettings(owner->name, QSettings::IniFormat, owner->q_func());
469 settings->beginGroup(owner->subpath);
470 return true;
471 }
472
473 virtual QStringList keyList() const override
474 {
475 return settings->childKeys();
476 }
477
478 virtual QVariant value(const QString &key, const QVariant &fallback) const override
479 {
480 return settings->value(key, fallback);
481 }
482
483 virtual void setValue(const QString &key, const QVariant &value) override
484 {
485 settings->setValue(key, value);
486 }
487
488 virtual QString name() const override
489 {
490 return QString("QSettingBackend");
491 }
492
493 private:
494 QSettings *settings = nullptr;
495 DConfigPrivate* owner;
496 };
497
498 QSettingBackend::~QSettingBackend()
499 {
500 }
501
502 #endif //D_DISABLE_DCONFIG
503 }
504
505 DConfigPrivate::~DConfigPrivate()
506 {
507 backend.reset();
508 }
509
510 /*!
511 @~english
512 \internal
513
514 @brief Create a configuration backend
515
516 The default configuration backend preferentially selects the D-Bus interface in the configuration center or the file configuration backend interface based on environment variables.
517 If this environment variable is not configured, the configuration center service or file configuration backend interface will be selected according to whether the configuration center provides D-Bus services
518 */
519 DConfigBackend *DConfigPrivate::getOrCreateBackend()
520 {
521 if (backend) {
522 return backend.data();
523 }
524 if (auto backendEnv = createBackendByEnv()) {
525 backend.reset(backendEnv);
526 return backend.data();
527 }
528 #ifndef D_DISABLE_DCONFIG
529 #ifndef D_DISABLE_DBUS_CONFIG
530 if (DBusBackend::isServiceRegistered() || DBusBackend::isServiceActivatable()) {
531 qCDebug(cfLog, "Fallback to DBus mode");
532 backend.reset(new DBusBackend(this));
533 }
534 if (!backend) {
535 qCDebug(cfLog, "Can't use DBus config service, fallback to DConfigFile mode");
536 backend.reset(new FileBackend(this));
537 }
538 #else
539 backend.reset(new FileBackend(this));
540 #endif //D_DISABLE_DBUS_CONFIG
541 #else
542 qCDebug(cfLog, "Fallback to QSettings mode");
543 backend.reset(new QSettingBackend(this));
544 #endif //D_DISABLE_DCONFIG
545 return backend.data();
546 }
547
548 /*!
549 @~english
550 \internal
551
552 @brief Create a configuration backend
553
554 Try to choose between configuring the D-Bus interface in the center or the file configuration backend interface based on the environment variables.
555 */
556 DConfigBackend *DConfigPrivate::createBackendByEnv()
557 {
558 const QByteArray &envBackend = qgetenv("DSG_DCONFIG_BACKEND_TYPE");
559 if (!envBackend.isEmpty()) {
560 if (envBackend == "DBusBackend") {
561
562 #ifndef D_DISABLE_DCONFIG
563 #ifndef D_DISABLE_DBUS_CONFIG
564 if (DBusBackend::isServiceRegistered() || DBusBackend::isServiceActivatable()) {
565 qCDebug(cfLog, "Fallback to DBus mode");
566 return new DBusBackend(this);
567 }
568 #endif //D_DISABLE_DBUS_CONFIG
569 #endif //D_DISABLE_DCONFIG
570 } else if (envBackend == "FileBackend") {
571
572 #ifndef D_DISABLE_DCONFIG
573 qCDebug(cfLog, "Fallback to DConfigFile mode");
574 return new FileBackend(this);
575 #endif //D_DISABLE_DCONFIG
576 } else {
577
578 #ifndef D_DISABLE_DCONFIG
579 #else
580 qCDebug(cfLog, "Fallback to QSettings mode");
581 return new QSettingBackend(this);
582 #endif //D_DISABLE_DCONFIG
583 }
584 }
585 return nullptr;
586 }
587
588 /*!
589 @~english
590 @class Dtk::Core::DConfig
591 \inmodule dtkcore
592
593 @brief Configure the interface class provided by the policy
594
595
596 This interface specification defines the relevant interfaces provided by the development library for reading and writing configuration files,
597 If the application uses a development library that implements this specification, the application should use the interfaces provided by the development library first.
598 */
599
600
601 /*!
602 @~english
603 * @brief Constructs the objects provided by the configuration policy
604 * \a name Configuration File Name
605 * \a subpath Subdirectory corresponding to the configuration file
606 * \a parent Parent object
607 */
608 DConfig::DConfig(const QString &name, const QString &subpath, QObject *parent)
609 : DConfig(nullptr, name, subpath, parent)
610 {
611 }
612
613 DConfig::DConfig(DConfigBackend *backend, const QString &name, const QString &subpath, QObject *parent)
614 : DConfig(backend, _globalAppId.isEmpty() ? DSGApplication::id() : _globalAppId, name, subpath, parent)
615 {
616
617 }
618
619 /*!
620 @~english
621 * @brief Constructs the object provided by the configuration policy, specifying the application Id to which the configuration belongs.
622 * \a appId
623 * \a name
624 * \a subpath
625 * \a parent
626 * @return The constructed configuration policy object, which is released by the caller
627 * @note \a appId is not empty.
628 */
629 DConfig *DConfig::create(const QString &appId, const QString &name, const QString &subpath, QObject *parent)
630 {
631 Q_ASSERT(appId != NoAppId);
632 return new DConfig(nullptr, appId, name, subpath, parent);
633 }
634
635 DConfig *DConfig::create(DConfigBackend *backend, const QString &appId, const QString &name, const QString &subpath, QObject *parent)
636 {
637 Q_ASSERT(appId != NoAppId);
638 return new DConfig(backend, appId, name, subpath, parent);
639 }
640
641 /*!
642 * \brief Constructs the object, and which is application.
643 * \param name
644 * \param subpath
645 * \param parent
646 * \return Dconfig object, which is released by the caller
647 * @note It's usually used for application independent, we should use DConfig::create if the configuration is a specific application.
648 */
649 DConfig *DConfig::createGeneric(const QString &name, const QString &subpath, QObject *parent)
650 {
651 return new DConfig(nullptr, NoAppId, name, subpath, parent);
652 }
653
654 DConfig *DConfig::createGeneric(DConfigBackend *backend, const QString &name, const QString &subpath, QObject *parent)
655 {
656 return new DConfig(backend, NoAppId, name, subpath, parent);
657 }
658
659 /*!
660 * \brief Explicitly specify application Id for config.
661 * \param appId
662 * @note It's should be called before QCoreApplication constructed.
663 */
664 void DConfig::setAppId(const QString &appId)
665 {
666 if (!_globalAppId.isEmpty()) {
667 qCWarning(cfLog, "`setAppId`should only be called once.");
668 }
669 _globalAppId = appId;
670 qCDebug(cfLog, "Explicitly specify application Id as appId=%s for config.", qPrintable(appId));
671 }
672
673 class DConfigThread : public QThread
674 {
675 public:
676 DConfigThread() {
677 setObjectName("DConfigGlobalThread");
678 start();
679 }
680
681 ~DConfigThread() override {
682 if (isRunning()) {
683 quit();
684 wait();
685 }
686 }
687 };
688
689 Q_GLOBAL_STATIC(DConfigThread, _globalThread)
690
691 QThread *DConfig::globalThread()
692 {
693 return _globalThread;
694 }
695
696 /*!
697 @~english
698 * @brief Use custom configuration policy backend to construct objects
699 * \a backend The caller inherits the configuration policy backend of DConfigBackend
700 * \a appId The application Id of the configuration file. If it is blank, it will be the application Id by default
701 * \a name Configuration File Name
702 * \a subpath Subdirectory corresponding to the configuration file
703 * \a parent Parent object
704 * @note The caller only constructs backend, which is released by DConfig.
705 */
706 DConfig::DConfig(DConfigBackend *backend, const QString &appId, const QString &name, const QString &subpath, QObject *parent)
707 : QObject(parent)
708 , DObject(*new DConfigPrivate(this, appId, name, subpath))
709 {
710 D_D(DConfig);
711
712 qCDebug(cfLog, "Load config of appid=%s name=%s, subpath=%s",
713 qPrintable(d->appId), qPrintable(d->name), qPrintable(d->subpath));
714
715 if (backend) {
716 d->backend.reset(backend);
717 }
718
719 if (auto backend = d->getOrCreateBackend()) {
720 backend->load(d->appId);
721 }
722 }
723
724 /*!
725 @~english
726 * @brief DConfig::backendName
727 * @return Configure policy backend name
728 * @note The caller can only access the DConfigBackend object with DConfig, so the DConfigBackend object is not returned.
729 */
730 QString DConfig::backendName() const
731 {
732 D_DC(DConfig);
733 if (d->invalid())
734 return QString();
735
736 return d->backend->name();
737 }
738
739 /*!
740 @~english
741 * @brief Get all available configuration item names
742 * @return Configuration item name collection
743 */
744 QStringList DConfig::keyList() const
745 {
746 D_DC(DConfig);
747 if (d->invalid())
748 return QStringList();
749
750 return d->backend->keyList();
751 }
752
753 /*!
754 @~english
755 * @brief Check whether the backend is available
756 * @return
757 */
758 bool DConfig::isValid() const
759 {
760 D_DC(DConfig);
761 return !d->invalid();
762 }
763
764 /*!
765 @~english
766 * @brief Check whether the value is default according to the configuration item name
767 * @param key Configuration Item Name
768 * @return Return `true` if the value isn't been set, otherwise return `false`
769 */
770 bool DConfig::isDefaultValue(const QString &key) const
771 {
772 D_DC(DConfig);
773 if (d->invalid())
774 return false;
775 return d->backend->isDefaultValue(key);
776 }
777
778 /*!
779 @~english
780 * @brief Get the corresponding value according to the configuration item name
781 * @param key Configuration Item Name
782 * @param fallback The default value provided after the configuration item value is not obtained
783 * @return
784 */
785 QVariant DConfig::value(const QString &key, const QVariant &fallback) const
786 {
787 D_DC(DConfig);
788 if (d->invalid())
789 return fallback;
790
791 return d->backend->value(key, fallback);
792 }
793
794 /*!
795 @~english
796 * @brief Set the value according to the configuration item name
797 * @param key Configuration Item Name
798 * @param value Values that need to be updated
799 */
800 void DConfig::setValue(const QString &key, const QVariant &value)
801 {
802 D_D(DConfig);
803 if (d->invalid())
804 return;
805
806 d->backend->setValue(key, value);
807 }
808
809 /*!
810 @~english
811 * @brief Set the default value corresponding to its configuration item. This value is overridden by the override mechanism. It is not necessarily the value defined in the meta in this configuration file
812 * @param key Configuration Item Name
813 */
814 void DConfig::reset(const QString &key)
815 {
816 D_D(DConfig);
817 if (d->invalid())
818 return;
819
820 d->backend->reset(key);
821 }
822
823 /*!
824 @~english
825 * @brief Return configuration file name
826 * @return
827 */
828 QString DConfig::name() const
829 {
830 D_DC(DConfig);
831 return d->name;
832 }
833
834 /*!
835 @~english
836 * @brief Return the subdirectory corresponding to the configuration file
837 * @return
838 */
839 QString DConfig::subpath() const
840 {
841 D_DC(DConfig);
842 return d->subpath;
843 }
844
845 DCORE_END_NAMESPACE