Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

适配dconfig2cpp #309

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -2,14 +2,16 @@
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "dguiapplicationhelper.h"

Check warning on line 5 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dguiapplicationhelper.h" not found.

Check warning on line 5 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "dguiapplicationhelper.h" not found.
#include "private/dguiapplicationhelper_p.h"

Check warning on line 6 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "private/dguiapplicationhelper_p.h" not found.

Check warning on line 6 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "private/dguiapplicationhelper_p.h" not found.
#include "dplatformhandle.h"

Check warning on line 7 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dplatformhandle.h" not found.

Check warning on line 7 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "dplatformhandle.h" not found.

#include <DFontManager>

Check warning on line 9 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DFontManager> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 9 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <DFontManager> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DStandardPaths>

Check warning on line 10 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DStandardPaths> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 10 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <DStandardPaths> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DSGApplication>

Check warning on line 11 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DSGApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 11 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <DSGApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QHash>

Check warning on line 13 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QHash> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 13 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QHash> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QColor>

Check warning on line 14 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QColor> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 14 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QColor> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPalette>
#include <QWindow>
#include <QGuiApplication>
Expand All @@ -34,10 +36,9 @@
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QProcess>
#include <DConfig>
#endif
#include <QDir>

Check warning on line 40 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDir> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 40 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDir> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QLockFile>

Check warning on line 41 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QLockFile> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 41 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QLockFile> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDirIterator>
#include <QDesktopServices>

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 @@

#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 @@
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 @@

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 @@
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 @@

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
Loading