55#include " dguiapplicationhelper.h"
66#include " private/dguiapplicationhelper_p.h"
77#include " dplatformhandle.h"
8+
89#include < DFontManager>
910#include < DStandardPaths>
11+ #include < DSGApplication>
1012
1113#include < QHash>
1214#include < QColor>
3436#include < QDBusConnection>
3537#include < QDBusConnectionInterface>
3638#include < QProcess>
37- #include < DConfig>
3839#endif
3940#include < QDir>
4041#include < QLockFile>
6162#include < unistd.h>
6263#endif
6364
65+ #include " orgdeepindtkpreference.hpp"
66+
6467#ifdef Q_OS_UNIX
6568class EnvReplaceGuard
6669{
@@ -115,10 +118,9 @@ Q_GLOBAL_STATIC(DFontManager, _globalFM)
115118
116119#define WINDOW_THEME_KEY " _d_platform_theme"
117120
118- #define APP_THEME_TYPE " themeType"
119- #define DTK_ENABLE_ANIMATIONS " enableDtkAnimations"
120121#define DTK_ANIMATIONS_ENV " D_DTK_DISABLE_ANIMATIONS"
121- Q_GLOBAL_STATIC_WITH_ARGS (DTK_CORE_NAMESPACE::DConfig, _d_dconfig, (" org.deepin.dtk.preference" ));
122+ Q_GLOBAL_STATIC (OrgDeepinDTKPreference, _d_dconfig, DTK_CORE_NAMESPACE::DConfig::globalThread(), nullptr,
123+ "org.deepin.dtk.preference", DTK_CORE_NAMESPACE::DSGApplication::id(), {}, false , nullptr )
122124
123125/* !
124126 @private
@@ -445,7 +447,7 @@ void DGuiApplicationHelperPrivate::initPaletteType() const
445447 return ;
446448
447449 auto applyThemeType = [this ](bool emitSignal){
448- int ct = _d_dconfig->value (APP_THEME_TYPE, DGuiApplicationHelper::UnknownType). toInt ();
450+ int ct = _d_dconfig->themeType ();
449451 if (ct > DGuiApplicationHelper::DarkType || ct < DGuiApplicationHelper::UnknownType)
450452 ct = DGuiApplicationHelper::UnknownType;
451453
@@ -454,10 +456,7 @@ void DGuiApplicationHelperPrivate::initPaletteType() const
454456
455457 applyThemeType (false );
456458
457- QObject::connect (_d_dconfig, &DConfig::valueChanged, _d_dconfig, [applyThemeType](const QString &key){
458- if (key != APP_THEME_TYPE)
459- return ;
460-
459+ QObject::connect (_d_dconfig.operator ()(), &OrgDeepinDTKPreference::themeTypeChanged, _d_dconfig, [applyThemeType] {
461460 applyThemeType (true );
462461 });
463462}
@@ -1781,8 +1780,7 @@ bool DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::Attribute attri
17811780 if (isDisable)
17821781 return false ;
17831782
1784- static bool shouldEnable = _d_dconfig->value (DTK_ENABLE_ANIMATIONS, false ).toBool ();
1785- return shouldEnable;
1783+ return _d_dconfig->enableDtkAnimations ();
17861784 }
17871785 default :
17881786 return DGuiApplicationHelperPrivate::attributes.testFlag (attribute);
@@ -1823,7 +1821,7 @@ void DGuiApplicationHelper::setPaletteType(DGuiApplicationHelper::ColorType pale
18231821
18241822 d->initPaletteType ();
18251823 d->setPaletteType (paletteType, true );
1826- _d_dconfig->setValue (APP_THEME_TYPE, paletteType);
1824+ _d_dconfig->setThemeType ( static_cast < int >( paletteType) );
18271825}
18281826
18291827/* !
0 commit comments