Skip to content
This repository was archived by the owner on Jul 15, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ Files: toolGenerate/**/*
Copyright: None
License: CC0-1.0

Files: src/kernel/orgdeepindtkpreference.hpp
Copyright: None
License: CC0-1.0
22 changes: 10 additions & 12 deletions src/kernel/dguiapplicationhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#include "dguiapplicationhelper.h"
#include "private/dguiapplicationhelper_p.h"
#include "dplatformhandle.h"

#include <DFontManager>
#include <DStandardPaths>
#include <DSGApplication>

#include <QHash>
#include <QColor>
Expand Down Expand Up @@ -34,7 +36,6 @@
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QProcess>
#include <DConfig>
#endif
#include <QDir>
#include <QLockFile>
Expand All @@ -61,6 +62,8 @@
#include <unistd.h>
#endif

#include "orgdeepindtkpreference.hpp"

#ifdef Q_OS_UNIX
class EnvReplaceGuard
{
Expand Down Expand Up @@ -115,10 +118,9 @@ Q_GLOBAL_STATIC(DFontManager, _globalFM)

#define WINDOW_THEME_KEY "_d_platform_theme"

#define APP_THEME_TYPE "themeType"
#define DTK_ENABLE_ANIMATIONS "enableDtkAnimations"
#define DTK_ANIMATIONS_ENV "D_DTK_DISABLE_ANIMATIONS"
Q_GLOBAL_STATIC_WITH_ARGS(DTK_CORE_NAMESPACE::DConfig, _d_dconfig, ("org.deepin.dtk.preference"));
Q_GLOBAL_STATIC(OrgDeepinDTKPreference, _d_dconfig, DTK_CORE_NAMESPACE::DConfig::globalThread(), nullptr,
"org.deepin.dtk.preference", DTK_CORE_NAMESPACE::DSGApplication::id(), {}, false, nullptr)

/*!
@private
Expand Down Expand Up @@ -445,7 +447,7 @@ void DGuiApplicationHelperPrivate::initPaletteType() const
return;

auto applyThemeType = [this](bool emitSignal){
int ct = _d_dconfig->value(APP_THEME_TYPE, DGuiApplicationHelper::UnknownType).toInt();
int ct = _d_dconfig->themeType();
if (ct > DGuiApplicationHelper::DarkType || ct < DGuiApplicationHelper::UnknownType)
ct = DGuiApplicationHelper::UnknownType;

Expand All @@ -454,10 +456,7 @@ void DGuiApplicationHelperPrivate::initPaletteType() const

applyThemeType(false);

QObject::connect(_d_dconfig, &DConfig::valueChanged, _d_dconfig, [applyThemeType](const QString &key){
if (key != APP_THEME_TYPE)
return;

QObject::connect(_d_dconfig.operator ()(), &OrgDeepinDTKPreference::themeTypeChanged, _d_dconfig, [applyThemeType] {
applyThemeType(true);
});
}
Expand Down Expand Up @@ -1781,8 +1780,7 @@ bool DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::Attribute attri
if (isDisable)
return false;

static bool shouldEnable = _d_dconfig->value(DTK_ENABLE_ANIMATIONS, false).toBool();
return shouldEnable;
return _d_dconfig->enableDtkAnimations();
}
default:
return DGuiApplicationHelperPrivate::attributes.testFlag(attribute);
Expand Down Expand Up @@ -1823,7 +1821,7 @@ void DGuiApplicationHelper::setPaletteType(DGuiApplicationHelper::ColorType pale

d->initPaletteType();
d->setPaletteType(paletteType, true);
_d_dconfig->setValue(APP_THEME_TYPE, paletteType);
_d_dconfig->setThemeType(static_cast<int>(paletteType));
}

/*!
Expand Down
33 changes: 12 additions & 21 deletions src/kernel/dplatformtheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@
#include "plugins/platform/treeland/dtreelandplatforminterface.h"
#endif
#include "private/dplatforminterface_p.h"
#include "orgdeepindtkpreference.hpp"

#include <QVariant>
#include <QTimer>
#include <QMetaProperty>
#include <QDebug>
#include <DGuiApplicationHelper>
#include <DConfig>

DGUI_BEGIN_NAMESPACE
#define DTK_PREFERENCE_NAME "org.deepin.dtk.preference"
#define DTK_SIZE_MODE_KEY "sizeMode"
#define DTK_SCROLLBAR_POLICY_KEY "scrollBarPolicy"

static DPlatformInterfaceFactory::HelperCreator OutsideInterfaceCreator = nullptr;

Expand Down Expand Up @@ -78,18 +75,6 @@ void DPlatformThemePrivate::notifyPaletteChanged()
notifyPaletteChangeTimer->start(300);
}

void DPlatformThemePrivate::onDtkPreferenceDConfigChanged(const QString &key)
{
D_Q(DPlatformTheme);
if (key == DTK_SIZE_MODE_KEY) {
sizeMode = static_cast<DGuiApplicationHelper::SizeMode>(dtkPreferenceConfig->value(key).toInt());
Q_EMIT q->sizeModeChanged(sizeMode);
} else if (key == DTK_SCROLLBAR_POLICY_KEY) {
scrollBarPolicy = static_cast<Qt::ScrollBarPolicy>(dtkPreferenceConfig->value(key).toInt());
Q_EMIT q->scrollBarPolicyChanged(scrollBarPolicy);
}
}

/*!
\class Dtk::Gui::DPlatformTheme
\inmodule dtkgui
Expand Down Expand Up @@ -125,12 +110,18 @@ DPlatformTheme::DPlatformTheme(quint32 window, QObject *parent)

d->theme = new DNativeSettings(window, QByteArray(), this);

d->dtkPreferenceConfig = DConfig::createGeneric(DTK_PREFERENCE_NAME, "", this);
d->sizeMode = static_cast<DGuiApplicationHelper::SizeMode>(d->dtkPreferenceConfig->value(DTK_SIZE_MODE_KEY).toInt());
d->scrollBarPolicy = static_cast<Qt::ScrollBarPolicy>(d->dtkPreferenceConfig->value(DTK_SCROLLBAR_POLICY_KEY).toInt());
connect(d->dtkPreferenceConfig, &DConfig::valueChanged, this, [this](const QString &key) -> void{
d->dtkPreferenceConfig = OrgDeepinDTKPreference::createGeneric("", this);
d->sizeMode = static_cast<DGuiApplicationHelper::SizeMode>(d->dtkPreferenceConfig->sizeMode());
d->scrollBarPolicy = static_cast<Qt::ScrollBarPolicy>(d->dtkPreferenceConfig->scrollBarPolicy());
connect(d->dtkPreferenceConfig, &OrgDeepinDTKPreference::sizeModeChanged, this, [this] {
D_D(DPlatformTheme);
d->sizeMode = static_cast<DGuiApplicationHelper::SizeMode>(d->dtkPreferenceConfig->sizeMode());
Q_EMIT sizeModeChanged(d->sizeMode);
});
connect(d->dtkPreferenceConfig, &OrgDeepinDTKPreference::scrollBarPolicyChanged, this, [this] {
D_D(DPlatformTheme);
d->onDtkPreferenceDConfigChanged(key);
d->scrollBarPolicy = static_cast<Qt::ScrollBarPolicy>(d->dtkPreferenceConfig->scrollBarPolicy());
Q_EMIT scrollBarPolicyChanged(d->scrollBarPolicy);
});

#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
Expand Down
1 change: 1 addition & 0 deletions src/kernel/kernel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ file(GLOB KERNEL_SOURCE
set(kernel_SRC
${KERNEL_HEADER}
${KERNEL_SOURCE}
${CMAKE_CURRENT_LIST_DIR}/orgdeepindtkpreference.hpp
)
Loading