| 1 |
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#include "dtreelandplatforminterface.h" |
| 6 |
|
| 7 |
#include "dplatformtheme.h" |
| 8 |
#include "private/dplatforminterface_p.h" |
| 9 |
#include "personalizationwaylandclientextension.h" |
| 10 |
|
| 11 |
#include <QtWaylandClient/private/qwaylandwindow_p.h> |
| 12 |
#include <QtWaylandClient/private/qwaylandsurface_p.h> |
| 13 |
#include <QWindow> |
| 14 |
|
| 15 |
DGUI_BEGIN_NAMESPACE |
| 16 |
|
| 17 |
DTreelandPlatformInterface::DTreelandPlatformInterface(DPlatformTheme *platformTheme) |
| 18 |
: DPlatformInterface(platformTheme) |
| 19 |
{ |
| 20 |
m_manager = PersonalizationManager::instance(); |
| 21 |
connect(m_manager, &PersonalizationManager::activeChanged, this, [this](){ |
| 22 |
if (m_manager->isActive()) { |
| 23 |
initContext(); |
| 24 |
} |
| 25 |
}); |
| 26 |
} |
| 27 |
|
| 28 |
void DTreelandPlatformInterface::initContext() |
| 29 |
{ |
| 30 |
if (m_appearanceContext.isNull()) { |
| 31 |
m_appearanceContext.reset(new PersonalizationAppearanceContext(m_manager->get_appearance_context(), this)); |
| 32 |
} |
| 33 |
if (m_fontContext.isNull()) { |
| 34 |
m_fontContext.reset(new PersonalizationFontContext(m_manager->get_font_context(), this)); |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
QByteArray DTreelandPlatformInterface::iconThemeName() const |
| 39 |
{ |
| 40 |
return m_iconThemeName; |
| 41 |
} |
| 42 |
|
| 43 |
QByteArray DTreelandPlatformInterface::fontName() const |
| 44 |
{ |
| 45 |
return m_fontName; |
| 46 |
} |
| 47 |
|
| 48 |
QByteArray DTreelandPlatformInterface::monoFontName() const |
| 49 |
{ |
| 50 |
return m_monoFontName; |
| 51 |
} |
| 52 |
|
| 53 |
qreal DTreelandPlatformInterface::fontPointSize() const |
| 54 |
{ |
| 55 |
return m_fontPointSize; |
| 56 |
} |
| 57 |
|
| 58 |
QColor DTreelandPlatformInterface::activeColor() const |
| 59 |
{ |
| 60 |
return m_activeColor; |
| 61 |
} |
| 62 |
|
| 63 |
QByteArray DTreelandPlatformInterface::themeName() const |
| 64 |
{ |
| 65 |
return m_themeName; |
| 66 |
} |
| 67 |
|
| 68 |
void DTreelandPlatformInterface::setIconThemeName(const QByteArray &iconThemeName) |
| 69 |
{ |
| 70 |
if (m_appearanceContext) { |
| 71 |
m_appearanceContext->set_icon_theme(iconThemeName); |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
void DTreelandPlatformInterface::setFontName(const QByteArray &fontName) |
| 76 |
{ |
| 77 |
if (m_fontContext) { |
| 78 |
m_fontContext->set_font(fontName); |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
void DTreelandPlatformInterface::setMonoFontName(const QByteArray &monoFontName) |
| 83 |
{ |
| 84 |
if (m_fontContext) { |
| 85 |
m_fontContext->set_monospace_font(monoFontName); |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
void DTreelandPlatformInterface::setFontPointSize(qreal fontPointSize) |
| 90 |
{ |
| 91 |
if (m_fontContext) { |
| 92 |
m_fontContext->set_font_size(fontPointSize); |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
void DTreelandPlatformInterface::setActiveColor(const QColor activeColor) |
| 97 |
{ |
| 98 |
if (m_appearanceContext) { |
| 99 |
m_appearanceContext->set_active_color(activeColor.name()); |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
DGUI_END_NAMESPACE |