| 1 |
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#include "dplatformtheme.h" |
| 6 |
#include "dguiapplicationhelper.h" |
| 7 |
#include "private/dplatformtheme_p.h" |
| 8 |
|
| 9 |
#ifndef DTK_DISABLE_XCB |
| 10 |
#include "plugins/platform/xcb/dxcbplatforminterface.h" |
| 11 |
#endif |
| 12 |
#ifndef DTK_DISABLE_TREELAND |
| 13 |
#include "plugins/platform/treeland/dtreelandplatforminterface.h" |
| 14 |
#endif |
| 15 |
#include "private/dplatforminterface_p.h" |
| 16 |
|
| 17 |
#include <QVariant> |
| 18 |
#include <QTimer> |
| 19 |
#include <QMetaProperty> |
| 20 |
#include <QDebug> |
| 21 |
#include <DGuiApplicationHelper> |
| 22 |
#include <DConfig> |
| 23 |
|
| 24 |
DGUI_BEGIN_NAMESPACE |
| 25 |
#define DTK_PREFERENCE_NAME "org.deepin.dtk.preference" |
| 26 |
#define DTK_SIZE_MODE_KEY "sizeMode" |
| 27 |
#define DTK_SCROLLBAR_POLICY_KEY "scrollBarPolicy" |
| 28 |
|
| 29 |
static DPlatformInterfaceFactory::HelperCreator OutsideInterfaceCreator = nullptr; |
| 30 |
|
| 31 |
void DPlatformInterfaceFactory::registerInterface(HelperCreator creator) |
| 32 |
{ |
| 33 |
OutsideInterfaceCreator = creator; |
| 34 |
} |
| 35 |
|
| 36 |
// "/deepin/palette" 为调色板属性的存储位置 |
| 37 |
// 在x11平台下,将使用_DEEPIN_PALETTE作为存储调色板数据的窗口属性 |
| 38 |
DPlatformThemePrivate::DPlatformThemePrivate(Dtk::Gui::DPlatformTheme *qq) |
| 39 |
: DNativeSettingsPrivate(qq, QByteArrayLiteral("/deepin/palette")) |
| 40 |
{ |
| 41 |
|
| 42 |
} |
| 43 |
|
| 44 |
void DPlatformThemePrivate::onQtColorChanged(QPalette::ColorRole role, const QColor &color) |
| 45 |
{ |
| 46 |
if (!palette) { |
| 47 |
palette = new DPalette(); |
| 48 |
} |
| 49 |
|
| 50 |
palette->setColor(QPalette::Normal, role, color); |
| 51 |
notifyPaletteChanged(); |
| 52 |
} |
| 53 |
|
| 54 |
void DPlatformThemePrivate::onDtkColorChanged(DPalette::ColorType type, const QColor &color) |
| 55 |
{ |
| 56 |
if (!palette) { |
| 57 |
palette = new DPalette(); |
| 58 |
} |
| 59 |
|
| 60 |
palette->setColor(QPalette::Normal, type, color); |
| 61 |
notifyPaletteChanged(); |
| 62 |
} |
| 63 |
|
| 64 |
void DPlatformThemePrivate::notifyPaletteChanged() |
| 65 |
{ |
| 66 |
if (notifyPaletteChangeTimer && notifyPaletteChangeTimer->isActive()) |
| 67 |
return; |
| 68 |
|
| 69 |
D_Q(DPlatformTheme); |
| 70 |
|
| 71 |
if (!notifyPaletteChangeTimer) { |
| 72 |
notifyPaletteChangeTimer = new QTimer(q); |
| 73 |
q->connect(notifyPaletteChangeTimer, &QTimer::timeout, q, [q, this] { |
| 74 |
Q_EMIT q->paletteChanged(*palette); |
| 75 |
}); |
| 76 |
} |
| 77 |
|
| 78 |
notifyPaletteChangeTimer->start(300); |
| 79 |
} |
| 80 |
|
| 81 |
void DPlatformThemePrivate::onDtkPreferenceDConfigChanged(const QString &key) |
| 82 |
{ |
| 83 |
D_Q(DPlatformTheme); |
| 84 |
if (key == DTK_SIZE_MODE_KEY) { |
| 85 |
sizeMode = static_cast<DGuiApplicationHelper::SizeMode>(dtkPreferenceConfig->value(key).toInt()); |
| 86 |
Q_EMIT q->sizeModeChanged(sizeMode); |
| 87 |
} else if (key == DTK_SCROLLBAR_POLICY_KEY) { |
| 88 |
scrollBarPolicy = static_cast<Qt::ScrollBarPolicy>(dtkPreferenceConfig->value(key).toInt()); |
| 89 |
Q_EMIT q->scrollBarPolicyChanged(scrollBarPolicy); |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
/*! |
| 94 |
\class Dtk::Gui::DPlatformTheme |
| 95 |
\inmodule dtkgui |
| 96 |
\brief 一个提供窗口主题的类. |
| 97 |
|
| 98 |
*/ |
| 99 |
DPlatformTheme::DPlatformTheme(quint32 window, QObject *parent) |
| 100 |
: DNativeSettings(*new DPlatformThemePrivate(this), |
| 101 |
&DPlatformTheme::staticMetaObject, |
| 102 |
window, parent) |
| 103 |
{ |
| 104 |
D_D(DPlatformTheme); |
| 105 |
|
| 106 |
if (OutsideInterfaceCreator) { |
| 107 |
d->platformInterface = OutsideInterfaceCreator(this); |
| 108 |
} else { |
| 109 |
#ifndef DTK_DISABLE_XCB |
| 110 |
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsXWindowPlatform)) { |
| 111 |
d->platformInterface = new DXCBPlatformInterface(0, this); |
| 112 |
} |
| 113 |
#endif |
| 114 |
|
| 115 |
#ifndef DTK_DISABLE_TREELAND |
| 116 |
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) { |
| 117 |
d->platformInterface = new DTreelandPlatformInterface(this); |
| 118 |
} |
| 119 |
#endif |
| 120 |
} |
| 121 |
|
| 122 |
if (!d->platformInterface) { |
| 123 |
d->platformInterface = new DPlatformInterface(this); |
| 124 |
} |
| 125 |
|
| 126 |
d->theme = new DNativeSettings(window, QByteArray(), this); |
| 127 |
|
| 128 |
d->dtkPreferenceConfig = DConfig::createGeneric(DTK_PREFERENCE_NAME, "", this); |
| 129 |
d->sizeMode = static_cast<DGuiApplicationHelper::SizeMode>(d->dtkPreferenceConfig->value(DTK_SIZE_MODE_KEY).toInt()); |
| 130 |
d->scrollBarPolicy = static_cast<Qt::ScrollBarPolicy>(d->dtkPreferenceConfig->value(DTK_SCROLLBAR_POLICY_KEY).toInt()); |
| 131 |
connect(d->dtkPreferenceConfig, &DConfig::valueChanged, this, [this](const QString &key) -> void{ |
| 132 |
D_D(DPlatformTheme); |
| 133 |
d->onDtkPreferenceDConfigChanged(key); |
| 134 |
}); |
| 135 |
|
| 136 |
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) |
| 137 |
connect(this, &DPlatformTheme::windowChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::Window, std::placeholders::_1)); |
| 138 |
connect(this, &DPlatformTheme::windowTextChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::WindowText, std::placeholders::_1)); |
| 139 |
connect(this, &DPlatformTheme::baseChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::Base, std::placeholders::_1)); |
| 140 |
connect(this, &DPlatformTheme::alternateBaseChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::AlternateBase, std::placeholders::_1)); |
| 141 |
connect(this, &DPlatformTheme::toolTipBaseChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::ToolTipBase, std::placeholders::_1)); |
| 142 |
connect(this, &DPlatformTheme::toolTipTextChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::ToolTipText, std::placeholders::_1)); |
| 143 |
connect(this, &DPlatformTheme::textChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::Text, std::placeholders::_1)); |
| 144 |
connect(this, &DPlatformTheme::buttonChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::Button, std::placeholders::_1)); |
| 145 |
connect(this, &DPlatformTheme::buttonTextChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::ButtonText, std::placeholders::_1)); |
| 146 |
connect(this, &DPlatformTheme::brightTextChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::BrightText, std::placeholders::_1)); |
| 147 |
connect(this, &DPlatformTheme::lightChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::Light, std::placeholders::_1)); |
| 148 |
connect(this, &DPlatformTheme::midlightChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::Midlight, std::placeholders::_1)); |
| 149 |
connect(this, &DPlatformTheme::darkChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::Dark, std::placeholders::_1)); |
| 150 |
connect(this, &DPlatformTheme::midChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::Mid, std::placeholders::_1)); |
| 151 |
connect(this, &DPlatformTheme::shadowChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::Shadow, std::placeholders::_1)); |
| 152 |
connect(this, &DPlatformTheme::highlightChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::Highlight, std::placeholders::_1)); |
| 153 |
connect(this, &DPlatformTheme::highlightedTextChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::HighlightedText, std::placeholders::_1)); |
| 154 |
connect(this, &DPlatformTheme::linkChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::Link, std::placeholders::_1)); |
| 155 |
connect(this, &DPlatformTheme::linkVisitedChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::LinkVisited, std::placeholders::_1)); |
| 156 |
connect(this, &DPlatformTheme::itemBackgroundChanged, std::bind(&DPlatformThemePrivate::onDtkColorChanged, d, DPalette::ItemBackground, std::placeholders::_1)); |
| 157 |
connect(this, &DPlatformTheme::textTitleChanged, std::bind(&DPlatformThemePrivate::onDtkColorChanged, d, DPalette::TextTitle, std::placeholders::_1)); |
| 158 |
connect(this, &DPlatformTheme::textTipsChanged, std::bind(&DPlatformThemePrivate::onDtkColorChanged, d, DPalette::TextTips, std::placeholders::_1)); |
| 159 |
connect(this, &DPlatformTheme::textWarningChanged, std::bind(&DPlatformThemePrivate::onDtkColorChanged, d, DPalette::TextWarning, std::placeholders::_1)); |
| 160 |
connect(this, &DPlatformTheme::textLivelyChanged, std::bind(&DPlatformThemePrivate::onDtkColorChanged, d, DPalette::TextLively, std::placeholders::_1)); |
| 161 |
connect(this, &DPlatformTheme::lightLivelyChanged, std::bind(&DPlatformThemePrivate::onDtkColorChanged, d, DPalette::LightLively, std::placeholders::_1)); |
| 162 |
connect(this, &DPlatformTheme::darkLivelyChanged, std::bind(&DPlatformThemePrivate::onDtkColorChanged, d, DPalette::DarkLively, std::placeholders::_1)); |
| 163 |
connect(this, &DPlatformTheme::frameBorderChanged, std::bind(&DPlatformThemePrivate::onDtkColorChanged, d, DPalette::FrameBorder, std::placeholders::_1)); |
| 164 |
#endif |
| 165 |
} |
| 166 |
|
| 167 |
DPlatformTheme::DPlatformTheme(quint32 window, DPlatformTheme *parent) |
| 168 |
: DPlatformTheme(window, static_cast<QObject*>(parent)) |
| 169 |
{ |
| 170 |
d_func()->parent = parent; |
| 171 |
|
| 172 |
// 将主题相关的属性改变信号从父主题中继承 |
| 173 |
// 假设 A 被 B 继承,B 被 C 继承,当 A 中出发属性变化时,不仅要能通知到B,还要能通知到C |
| 174 |
connect(parent->d_func()->theme, SIGNAL(propertyChanged(const QByteArray &, const QVariant &)), |
| 175 |
d_func()->theme, SIGNAL(propertyChanged(const QByteArray &, const QVariant &))); |
| 176 |
} |
| 177 |
|
| 178 |
DPlatformTheme::~DPlatformTheme() |
| 179 |
{ |
| 180 |
D_D(DPlatformTheme); |
| 181 |
|
| 182 |
if (d->palette) { |
| 183 |
delete d->palette; |
| 184 |
} |
| 185 |
if (d->platformInterface) { |
| 186 |
delete d->platformInterface; |
| 187 |
} |
| 188 |
} |
| 189 |
|
| 190 |
bool DPlatformTheme::isValid() const |
| 191 |
{ |
| 192 |
return !themeName().isEmpty() || isValidPalette() || activeColor().isValid(); |
| 193 |
} |
| 194 |
|
| 195 |
DPlatformTheme *DPlatformTheme::parentTheme() const |
| 196 |
{ |
| 197 |
D_DC(DPlatformTheme); |
| 198 |
|
| 199 |
return d->parent; |
| 200 |
} |
| 201 |
|
| 202 |
void DPlatformTheme::setFallbackProperty(bool fallback) |
| 203 |
{ |
| 204 |
D_D(DPlatformTheme); |
| 205 |
|
| 206 |
d->fallbackProperty = fallback; |
| 207 |
} |
| 208 |
|
| 209 |
DPalette DPlatformTheme::palette() const |
| 210 |
{ |
| 211 |
D_DC(DPlatformTheme); |
| 212 |
|
| 213 |
if (!d->palette) { |
| 214 |
if (!isValid()) |
| 215 |
return DPalette(); |
| 216 |
|
| 217 |
DPalette *pa = new DPalette(); |
| 218 |
const_cast<DPlatformThemePrivate*>(d)->palette = pa; |
| 219 |
|
| 220 |
#define SET_PALETTE_COLOR(Role) \ |
| 221 |
pa->setColor(DPalette::Role, qvariant_cast<QColor>(getSetting(QByteArrayLiteral(#Role)))) |
| 222 |
|
| 223 |
SET_PALETTE_COLOR(Window); |
| 224 |
SET_PALETTE_COLOR(WindowText); |
| 225 |
SET_PALETTE_COLOR(Base); |
| 226 |
SET_PALETTE_COLOR(AlternateBase); |
| 227 |
SET_PALETTE_COLOR(ToolTipBase); |
| 228 |
SET_PALETTE_COLOR(ToolTipText); |
| 229 |
SET_PALETTE_COLOR(Text); |
| 230 |
SET_PALETTE_COLOR(Button); |
| 231 |
SET_PALETTE_COLOR(ButtonText); |
| 232 |
SET_PALETTE_COLOR(BrightText); |
| 233 |
SET_PALETTE_COLOR(Light); |
| 234 |
SET_PALETTE_COLOR(Midlight); |
| 235 |
SET_PALETTE_COLOR(Dark); |
| 236 |
SET_PALETTE_COLOR(Mid); |
| 237 |
SET_PALETTE_COLOR(Shadow); |
| 238 |
SET_PALETTE_COLOR(Highlight); |
| 239 |
SET_PALETTE_COLOR(HighlightedText); |
| 240 |
SET_PALETTE_COLOR(Link); |
| 241 |
SET_PALETTE_COLOR(LinkVisited); |
| 242 |
SET_PALETTE_COLOR(ItemBackground); |
| 243 |
SET_PALETTE_COLOR(TextTitle); |
| 244 |
SET_PALETTE_COLOR(TextTips); |
| 245 |
SET_PALETTE_COLOR(TextWarning); |
| 246 |
SET_PALETTE_COLOR(TextLively); |
| 247 |
SET_PALETTE_COLOR(LightLively); |
| 248 |
SET_PALETTE_COLOR(DarkLively); |
| 249 |
SET_PALETTE_COLOR(FrameBorder); |
| 250 |
} |
| 251 |
|
| 252 |
return *d->palette; |
| 253 |
} |
| 254 |
|
| 255 |
DPalette DPlatformTheme::fetchPalette(const DPalette &base, bool *ok) const |
| 256 |
{ |
| 257 |
D_DC(DPlatformTheme); |
| 258 |
|
| 259 |
DPalette palette = base; |
| 260 |
|
| 261 |
if (isValidPalette() && d->palette) { |
| 262 |
if (ok) { |
| 263 |
*ok = true; |
| 264 |
} |
| 265 |
|
| 266 |
const DPalette *pa = d->palette; |
| 267 |
|
| 268 |
for (int i = 0; i < QPalette::NColorRoles; ++i) { |
| 269 |
const QColor &color = pa->color(QPalette::Normal, static_cast<QPalette::ColorRole>(i)); |
| 270 |
|
| 271 |
if (color.isValid()) { |
| 272 |
palette.setColor(QPalette::Normal, static_cast<QPalette::ColorRole>(i), color); |
| 273 |
} |
| 274 |
} |
| 275 |
|
| 276 |
for (int i = 0; i < DPalette::NColorTypes; ++i) { |
| 277 |
const QColor &color = pa->color(QPalette::Normal, static_cast<DPalette::ColorType>(i)); |
| 278 |
|
| 279 |
if (color.isValid()) { |
| 280 |
palette.setColor(QPalette::Normal, static_cast<DPalette::ColorType>(i), color); |
| 281 |
} |
| 282 |
} |
| 283 |
|
| 284 |
return d->parent ? d->parent->fetchPalette(palette, nullptr) : palette; |
| 285 |
} |
| 286 |
|
| 287 |
return d->parent ? d->parent->fetchPalette(palette, ok) : palette; |
| 288 |
} |
| 289 |
|
| 290 |
void DPlatformTheme::setPalette(const DPalette &palette) |
| 291 |
{ |
| 292 |
#define SET_PALETTE(Role) \ |
| 293 |
set##Role(palette.color(QPalette::Normal, DPalette::Role)) |
| 294 |
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) |
| 295 |
SET_PALETTE(Window); |
| 296 |
SET_PALETTE(WindowText); |
| 297 |
SET_PALETTE(Base); |
| 298 |
SET_PALETTE(AlternateBase); |
| 299 |
SET_PALETTE(ToolTipBase); |
| 300 |
SET_PALETTE(ToolTipText); |
| 301 |
SET_PALETTE(Text); |
| 302 |
SET_PALETTE(Button); |
| 303 |
SET_PALETTE(ButtonText); |
| 304 |
SET_PALETTE(BrightText); |
| 305 |
SET_PALETTE(Light); |
| 306 |
SET_PALETTE(Midlight); |
| 307 |
SET_PALETTE(Dark); |
| 308 |
SET_PALETTE(Mid); |
| 309 |
SET_PALETTE(Shadow); |
| 310 |
SET_PALETTE(Highlight); |
| 311 |
SET_PALETTE(HighlightedText); |
| 312 |
SET_PALETTE(Link); |
| 313 |
SET_PALETTE(LinkVisited); |
| 314 |
SET_PALETTE(ItemBackground); |
| 315 |
SET_PALETTE(TextTitle); |
| 316 |
SET_PALETTE(TextTips); |
| 317 |
SET_PALETTE(TextWarning); |
| 318 |
SET_PALETTE(TextLively); |
| 319 |
SET_PALETTE(LightLively); |
| 320 |
SET_PALETTE(DarkLively); |
| 321 |
SET_PALETTE(FrameBorder); |
| 322 |
#endif |
| 323 |
} |
| 324 |
|
| 325 |
int DPlatformTheme::cursorBlinkTime() const |
| 326 |
{ |
| 327 |
D_DC(DPlatformTheme); |
| 328 |
return d->platformInterface->cursorBlinkTime(); |
| 329 |
} |
| 330 |
|
| 331 |
int DPlatformTheme::cursorBlinkTimeout() const |
| 332 |
{ |
| 333 |
D_DC(DPlatformTheme); |
| 334 |
return d->platformInterface->cursorBlinkTimeout(); |
| 335 |
} |
| 336 |
|
| 337 |
bool DPlatformTheme::cursorBlink() const |
| 338 |
{ |
| 339 |
D_DC(DPlatformTheme); |
| 340 |
return d->platformInterface->cursorBlink(); |
| 341 |
} |
| 342 |
|
| 343 |
int DPlatformTheme::doubleClickDistance() const |
| 344 |
{ |
| 345 |
D_DC(DPlatformTheme); |
| 346 |
return d->platformInterface->doubleClickDistance(); |
| 347 |
} |
| 348 |
|
| 349 |
int DPlatformTheme::doubleClickTime() const |
| 350 |
{ |
| 351 |
D_DC(DPlatformTheme); |
| 352 |
return d->platformInterface->doubleClickTime(); |
| 353 |
} |
| 354 |
|
| 355 |
int DPlatformTheme::dndDragThreshold() const |
| 356 |
{ |
| 357 |
D_DC(DPlatformTheme); |
| 358 |
return d->platformInterface->dndDragThreshold(); |
| 359 |
} |
| 360 |
|
| 361 |
int DPlatformTheme::windowRadius() const |
| 362 |
{ |
| 363 |
D_DC(DPlatformTheme); |
| 364 |
return d->platformInterface->windowRadius(); |
| 365 |
} |
| 366 |
|
| 367 |
int DPlatformTheme::windowRadius(int defaultValue) const |
| 368 |
{ |
| 369 |
D_DC(DPlatformTheme); |
| 370 |
return d->platformInterface->windowRadius(defaultValue); |
| 371 |
} |
| 372 |
|
| 373 |
QByteArray DPlatformTheme::themeName() const |
| 374 |
{ |
| 375 |
D_DC(DPlatformTheme); |
| 376 |
return d->platformInterface->themeName(); |
| 377 |
} |
| 378 |
|
| 379 |
QByteArray DPlatformTheme::iconThemeName() const |
| 380 |
{ |
| 381 |
D_DC(DPlatformTheme); |
| 382 |
return d->platformInterface->iconThemeName(); |
| 383 |
} |
| 384 |
|
| 385 |
QByteArray DPlatformTheme::soundThemeName() const |
| 386 |
{ |
| 387 |
D_DC(DPlatformTheme); |
| 388 |
return d->platformInterface->soundThemeName(); |
| 389 |
} |
| 390 |
|
| 391 |
QByteArray DPlatformTheme::fontName() const |
| 392 |
{ |
| 393 |
D_DC(DPlatformTheme); |
| 394 |
return d->platformInterface->fontName(); |
| 395 |
} |
| 396 |
|
| 397 |
QByteArray DPlatformTheme::monoFontName() const |
| 398 |
{ |
| 399 |
D_DC(DPlatformTheme); |
| 400 |
return d->platformInterface->monoFontName(); |
| 401 |
} |
| 402 |
|
| 403 |
qreal DPlatformTheme::fontPointSize() const |
| 404 |
{ |
| 405 |
D_DC(DPlatformTheme); |
| 406 |
return d->platformInterface->fontPointSize(); |
| 407 |
} |
| 408 |
|
| 409 |
QByteArray DPlatformTheme::gtkFontName() const |
| 410 |
{ |
| 411 |
D_DC(DPlatformTheme); |
| 412 |
return d->platformInterface->gtkFontName(); |
| 413 |
} |
| 414 |
|
| 415 |
QColor DPlatformTheme::activeColor() const |
| 416 |
{ |
| 417 |
D_DC(DPlatformTheme); |
| 418 |
return d->platformInterface->activeColor(); |
| 419 |
} |
| 420 |
|
| 421 |
QColor DPlatformTheme::darkActiveColor() const |
| 422 |
{ |
| 423 |
D_DC(DPlatformTheme); |
| 424 |
return d->platformInterface->darkActiveColor(); |
| 425 |
} |
| 426 |
|
| 427 |
bool DPlatformTheme::isValidPalette() const |
| 428 |
{ |
| 429 |
return !allKeys().isEmpty(); |
| 430 |
} |
| 431 |
|
| 432 |
#define GET_COLOR(Role) qvariant_cast<QColor>(getSetting(QByteArrayLiteral(#Role))) |
| 433 |
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) |
| 434 |
QColor DPlatformTheme::window() const |
| 435 |
{ |
| 436 |
D_DC(DPlatformTheme); |
| 437 |
return d->platformInterface->window(); |
| 438 |
} |
| 439 |
|
| 440 |
QColor DPlatformTheme::windowText() const |
| 441 |
{ |
| 442 |
D_DC(DPlatformTheme); |
| 443 |
return d->platformInterface->windowText(); |
| 444 |
} |
| 445 |
|
| 446 |
QColor DPlatformTheme::base() const |
| 447 |
{ |
| 448 |
D_DC(DPlatformTheme); |
| 449 |
return d->platformInterface->base(); |
| 450 |
} |
| 451 |
|
| 452 |
QColor DPlatformTheme::alternateBase() const |
| 453 |
{ |
| 454 |
D_DC(DPlatformTheme); |
| 455 |
return d->platformInterface->alternateBase(); |
| 456 |
} |
| 457 |
|
| 458 |
QColor DPlatformTheme::toolTipBase() const |
| 459 |
{ |
| 460 |
D_DC(DPlatformTheme); |
| 461 |
return d->platformInterface->toolTipBase(); |
| 462 |
} |
| 463 |
|
| 464 |
QColor DPlatformTheme::toolTipText() const |
| 465 |
{ |
| 466 |
D_DC(DPlatformTheme); |
| 467 |
return d->platformInterface->toolTipText(); |
| 468 |
} |
| 469 |
|
| 470 |
QColor DPlatformTheme::text() const |
| 471 |
{ |
| 472 |
D_DC(DPlatformTheme); |
| 473 |
return d->platformInterface->text(); |
| 474 |
} |
| 475 |
|
| 476 |
QColor DPlatformTheme::button() const |
| 477 |
{ |
| 478 |
D_DC(DPlatformTheme); |
| 479 |
return d->platformInterface->button(); |
| 480 |
} |
| 481 |
|
| 482 |
QColor DPlatformTheme::buttonText() const |
| 483 |
{ |
| 484 |
D_DC(DPlatformTheme); |
| 485 |
return d->platformInterface->buttonText(); |
| 486 |
} |
| 487 |
|
| 488 |
QColor DPlatformTheme::brightText() const |
| 489 |
{ |
| 490 |
D_DC(DPlatformTheme); |
| 491 |
return d->platformInterface->brightText(); |
| 492 |
} |
| 493 |
|
| 494 |
QColor DPlatformTheme::light() const |
| 495 |
{ |
| 496 |
D_DC(DPlatformTheme); |
| 497 |
return d->platformInterface->light(); |
| 498 |
} |
| 499 |
|
| 500 |
QColor DPlatformTheme::midlight() const |
| 501 |
{ |
| 502 |
D_DC(DPlatformTheme); |
| 503 |
return d->platformInterface->midlight(); |
| 504 |
} |
| 505 |
|
| 506 |
QColor DPlatformTheme::dark() const |
| 507 |
{ |
| 508 |
D_DC(DPlatformTheme); |
| 509 |
return d->platformInterface->dark(); |
| 510 |
} |
| 511 |
|
| 512 |
QColor DPlatformTheme::mid() const |
| 513 |
{ |
| 514 |
D_DC(DPlatformTheme); |
| 515 |
return d->platformInterface->mid(); |
| 516 |
} |
| 517 |
|
| 518 |
QColor DPlatformTheme::shadow() const |
| 519 |
{ |
| 520 |
D_DC(DPlatformTheme); |
| 521 |
return d->platformInterface->shadow(); |
| 522 |
} |
| 523 |
|
| 524 |
QColor DPlatformTheme::highlight() const |
| 525 |
{ |
| 526 |
D_DC(DPlatformTheme); |
| 527 |
return d->platformInterface->highlight(); |
| 528 |
} |
| 529 |
|
| 530 |
QColor DPlatformTheme::highlightedText() const |
| 531 |
{ |
| 532 |
D_DC(DPlatformTheme); |
| 533 |
return d->platformInterface->highlightedText(); |
| 534 |
} |
| 535 |
|
| 536 |
QColor DPlatformTheme::link() const |
| 537 |
{ |
| 538 |
D_DC(DPlatformTheme); |
| 539 |
return d->platformInterface->link(); |
| 540 |
} |
| 541 |
|
| 542 |
QColor DPlatformTheme::linkVisited() const |
| 543 |
{ |
| 544 |
D_DC(DPlatformTheme); |
| 545 |
return d->platformInterface->linkVisited(); |
| 546 |
} |
| 547 |
|
| 548 |
QColor DPlatformTheme::itemBackground() const |
| 549 |
{ |
| 550 |
D_DC(DPlatformTheme); |
| 551 |
return d->platformInterface->itemBackground(); |
| 552 |
} |
| 553 |
|
| 554 |
QColor DPlatformTheme::textTitle() const |
| 555 |
{ |
| 556 |
D_DC(DPlatformTheme); |
| 557 |
return d->platformInterface->textTitle(); |
| 558 |
} |
| 559 |
|
| 560 |
QColor DPlatformTheme::textTips() const |
| 561 |
{ |
| 562 |
D_DC(DPlatformTheme); |
| 563 |
return d->platformInterface->textTips(); |
| 564 |
} |
| 565 |
|
| 566 |
QColor DPlatformTheme::textWarning() const |
| 567 |
{ |
| 568 |
D_DC(DPlatformTheme); |
| 569 |
return d->platformInterface->textWarning(); |
| 570 |
} |
| 571 |
|
| 572 |
QColor DPlatformTheme::textLively() const |
| 573 |
{ |
| 574 |
D_DC(DPlatformTheme); |
| 575 |
return d->platformInterface->textLively(); |
| 576 |
} |
| 577 |
|
| 578 |
QColor DPlatformTheme::lightLively() const |
| 579 |
{ |
| 580 |
D_DC(DPlatformTheme); |
| 581 |
return d->platformInterface->lightLively(); |
| 582 |
} |
| 583 |
|
| 584 |
QColor DPlatformTheme::darkLively() const |
| 585 |
{ |
| 586 |
D_DC(DPlatformTheme); |
| 587 |
return d->platformInterface->darkLively(); |
| 588 |
} |
| 589 |
|
| 590 |
QColor DPlatformTheme::frameBorder() const |
| 591 |
{ |
| 592 |
D_DC(DPlatformTheme); |
| 593 |
return d->platformInterface->frameBorder(); |
| 594 |
} |
| 595 |
#endif |
| 596 |
|
| 597 |
int DPlatformTheme::dotsPerInch(const QString &screenName) const |
| 598 |
{ |
| 599 |
D_DC(DPlatformTheme); |
| 600 |
return d->platformInterface->dotsPerInch(screenName); |
| 601 |
} |
| 602 |
|
| 603 |
/*! |
| 604 |
\property DPlatformTheme::sizeMode |
| 605 |
\brief This property holds the sizeMode of the system's SizeMode. |
| 606 |
*/ |
| 607 |
int DPlatformTheme::sizeMode() const |
| 608 |
{ |
| 609 |
D_DC(DPlatformTheme); |
| 610 |
return d->sizeMode; |
| 611 |
} |
| 612 |
|
| 613 |
/*! |
| 614 |
\property DPlatformTheme::scrollBarPolicy |
| 615 |
\brief This property holds the scrollBarPolicy of the system. same as Qt::ScrollBarPolicy |
| 616 |
\retval 0 show as needed auto hide, default |
| 617 |
\retval 1 always off |
| 618 |
\retval 2 always on |
| 619 |
*/ |
| 620 |
int DPlatformTheme::scrollBarPolicy() const |
| 621 |
{ |
| 622 |
D_DC(DPlatformTheme); |
| 623 |
return d->scrollBarPolicy; |
| 624 |
} |
| 625 |
|
| 626 |
void DPlatformTheme::setCursorBlinkTime(int cursorBlinkTime) |
| 627 |
{ |
| 628 |
D_DC(DPlatformTheme); |
| 629 |
return d->platformInterface->setCursorBlinkTime(cursorBlinkTime); |
| 630 |
} |
| 631 |
|
| 632 |
void DPlatformTheme::setCursorBlinkTimeout(int cursorBlinkTimeout) |
| 633 |
{ |
| 634 |
D_DC(DPlatformTheme); |
| 635 |
return d->platformInterface->setCursorBlinkTimeout(cursorBlinkTimeout); |
| 636 |
} |
| 637 |
|
| 638 |
void DPlatformTheme::setCursorBlink(bool cursorBlink) |
| 639 |
{ |
| 640 |
D_DC(DPlatformTheme); |
| 641 |
return d->platformInterface->setCursorBlink(cursorBlink); |
| 642 |
} |
| 643 |
|
| 644 |
void DPlatformTheme::setDoubleClickDistance(int doubleClickDistance) |
| 645 |
{ |
| 646 |
D_DC(DPlatformTheme); |
| 647 |
return d->platformInterface->setDoubleClickDistance(doubleClickDistance); |
| 648 |
} |
| 649 |
|
| 650 |
void DPlatformTheme::setDoubleClickTime(int doubleClickTime) |
| 651 |
{ |
| 652 |
D_DC(DPlatformTheme); |
| 653 |
return d->platformInterface->setDoubleClickTime(doubleClickTime); |
| 654 |
} |
| 655 |
|
| 656 |
void DPlatformTheme::setDndDragThreshold(int dndDragThreshold) |
| 657 |
{ |
| 658 |
D_DC(DPlatformTheme); |
| 659 |
return d->platformInterface->setDndDragThreshold(dndDragThreshold); |
| 660 |
} |
| 661 |
|
| 662 |
void DPlatformTheme::setThemeName(const QByteArray &themeName) |
| 663 |
{ |
| 664 |
D_DC(DPlatformTheme); |
| 665 |
return d->platformInterface->setThemeName(themeName); |
| 666 |
} |
| 667 |
|
| 668 |
void DPlatformTheme::setIconThemeName(const QByteArray &iconThemeName) |
| 669 |
{ |
| 670 |
D_DC(DPlatformTheme); |
| 671 |
return d->platformInterface->setIconThemeName(iconThemeName); |
| 672 |
} |
| 673 |
|
| 674 |
void DPlatformTheme::setSoundThemeName(const QByteArray &soundThemeName) |
| 675 |
{ |
| 676 |
D_DC(DPlatformTheme); |
| 677 |
return d->platformInterface->setSoundThemeName(soundThemeName); |
| 678 |
} |
| 679 |
|
| 680 |
void DPlatformTheme::setFontName(const QByteArray &fontName) |
| 681 |
{ |
| 682 |
D_DC(DPlatformTheme); |
| 683 |
return d->platformInterface->setFontName(fontName); |
| 684 |
} |
| 685 |
|
| 686 |
void DPlatformTheme::setMonoFontName(const QByteArray &monoFontName) |
| 687 |
{ |
| 688 |
D_DC(DPlatformTheme); |
| 689 |
return d->platformInterface->setMonoFontName(monoFontName); |
| 690 |
} |
| 691 |
|
| 692 |
void DPlatformTheme::setFontPointSize(qreal fontPointSize) |
| 693 |
{ |
| 694 |
D_DC(DPlatformTheme); |
| 695 |
return d->platformInterface->setFontPointSize(fontPointSize); |
| 696 |
} |
| 697 |
|
| 698 |
void DPlatformTheme::setGtkFontName(const QByteArray &fontName) |
| 699 |
{ |
| 700 |
D_DC(DPlatformTheme); |
| 701 |
return d->platformInterface->setGtkFontName(fontName); |
| 702 |
} |
| 703 |
|
| 704 |
void DPlatformTheme::setActiveColor(const QColor activeColor) |
| 705 |
{ |
| 706 |
D_DC(DPlatformTheme); |
| 707 |
return d->platformInterface->setActiveColor(activeColor); |
| 708 |
} |
| 709 |
|
| 710 |
void DPlatformTheme::setDarkActiveColor(const QColor &activeColor) |
| 711 |
{ |
| 712 |
D_DC(DPlatformTheme); |
| 713 |
return d->platformInterface->setDarkActiveColor(activeColor); |
| 714 |
} |
| 715 |
|
| 716 |
#define SET_COLOR(Role) setSetting(QByteArrayLiteral(#Role), Role) |
| 717 |
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) |
| 718 |
void DPlatformTheme::setWindow(const QColor &window) |
| 719 |
{ |
| 720 |
D_DC(DPlatformTheme); |
| 721 |
return d->platformInterface->setWindow(window); |
| 722 |
} |
| 723 |
|
| 724 |
void DPlatformTheme::setWindowText(const QColor &windowText) |
| 725 |
{ |
| 726 |
D_DC(DPlatformTheme); |
| 727 |
return d->platformInterface->setWindowText(windowText); |
| 728 |
} |
| 729 |
|
| 730 |
void DPlatformTheme::setBase(const QColor &base) |
| 731 |
{ |
| 732 |
D_DC(DPlatformTheme); |
| 733 |
return d->platformInterface->setBase(base); |
| 734 |
} |
| 735 |
|
| 736 |
void DPlatformTheme::setAlternateBase(const QColor &alternateBase) |
| 737 |
{ |
| 738 |
D_DC(DPlatformTheme); |
| 739 |
return d->platformInterface->setAlternateBase(alternateBase); |
| 740 |
} |
| 741 |
|
| 742 |
void DPlatformTheme::setToolTipBase(const QColor &toolTipBase) |
| 743 |
{ |
| 744 |
D_DC(DPlatformTheme); |
| 745 |
return d->platformInterface->setToolTipBase(toolTipBase); |
| 746 |
} |
| 747 |
|
| 748 |
void DPlatformTheme::setToolTipText(const QColor &toolTipText) |
| 749 |
{ |
| 750 |
D_DC(DPlatformTheme); |
| 751 |
return d->platformInterface->setToolTipText(toolTipText); |
| 752 |
} |
| 753 |
|
| 754 |
void DPlatformTheme::setText(const QColor &text) |
| 755 |
{ |
| 756 |
D_DC(DPlatformTheme); |
| 757 |
return d->platformInterface->setText(text); |
| 758 |
} |
| 759 |
|
| 760 |
void DPlatformTheme::setButton(const QColor &button) |
| 761 |
{ |
| 762 |
D_DC(DPlatformTheme); |
| 763 |
return d->platformInterface->setButton(button); |
| 764 |
} |
| 765 |
|
| 766 |
void DPlatformTheme::setButtonText(const QColor &buttonText) |
| 767 |
{ |
| 768 |
D_DC(DPlatformTheme); |
| 769 |
return d->platformInterface->setButtonText(buttonText); |
| 770 |
} |
| 771 |
|
| 772 |
void DPlatformTheme::setBrightText(const QColor &brightText) |
| 773 |
{ |
| 774 |
D_DC(DPlatformTheme); |
| 775 |
return d->platformInterface->setBrightText(brightText); |
| 776 |
} |
| 777 |
|
| 778 |
void DPlatformTheme::setLight(const QColor &light) |
| 779 |
{ |
| 780 |
D_DC(DPlatformTheme); |
| 781 |
return d->platformInterface->setLight(light); |
| 782 |
} |
| 783 |
|
| 784 |
void DPlatformTheme::setMidlight(const QColor &midlight) |
| 785 |
{ |
| 786 |
D_DC(DPlatformTheme); |
| 787 |
return d->platformInterface->setMidlight(midlight); |
| 788 |
} |
| 789 |
|
| 790 |
void DPlatformTheme::setDark(const QColor &dark) |
| 791 |
{ |
| 792 |
D_DC(DPlatformTheme); |
| 793 |
return d->platformInterface->setDark(dark); |
| 794 |
} |
| 795 |
|
| 796 |
void DPlatformTheme::setMid(const QColor &mid) |
| 797 |
{ |
| 798 |
D_DC(DPlatformTheme); |
| 799 |
return d->platformInterface->setMid(mid); |
| 800 |
} |
| 801 |
|
| 802 |
void DPlatformTheme::setShadow(const QColor &shadow) |
| 803 |
{ |
| 804 |
D_DC(DPlatformTheme); |
| 805 |
return d->platformInterface->setShadow(shadow); |
| 806 |
} |
| 807 |
|
| 808 |
void DPlatformTheme::setHighlight(const QColor &highlight) |
| 809 |
{ |
| 810 |
D_DC(DPlatformTheme); |
| 811 |
return d->platformInterface->setHighlight(highlight); |
| 812 |
} |
| 813 |
|
| 814 |
void DPlatformTheme::setHighlightedText(const QColor &highlightText) |
| 815 |
{ |
| 816 |
D_DC(DPlatformTheme); |
| 817 |
return d->platformInterface->setHighlightedText(highlightText); |
| 818 |
} |
| 819 |
|
| 820 |
void DPlatformTheme::setLink(const QColor &link) |
| 821 |
{ |
| 822 |
D_DC(DPlatformTheme); |
| 823 |
return d->platformInterface->setLink(link); |
| 824 |
} |
| 825 |
|
| 826 |
void DPlatformTheme::setLinkVisited(const QColor &linkVisited) |
| 827 |
{ |
| 828 |
D_DC(DPlatformTheme); |
| 829 |
return d->platformInterface->setLinkVisited(linkVisited); |
| 830 |
} |
| 831 |
|
| 832 |
void DPlatformTheme::setItemBackground(const QColor &itemBackground) |
| 833 |
{ |
| 834 |
D_DC(DPlatformTheme); |
| 835 |
return d->platformInterface->setItemBackground(itemBackground); |
| 836 |
} |
| 837 |
|
| 838 |
void DPlatformTheme::setTextTitle(const QColor &textTitle) |
| 839 |
{ |
| 840 |
D_DC(DPlatformTheme); |
| 841 |
return d->platformInterface->setTextTitle(textTitle); |
| 842 |
} |
| 843 |
|
| 844 |
void DPlatformTheme::setTextTips(const QColor &textTips) |
| 845 |
{ |
| 846 |
D_DC(DPlatformTheme); |
| 847 |
return d->platformInterface->setTextTips(textTips); |
| 848 |
} |
| 849 |
|
| 850 |
void DPlatformTheme::setTextWarning(const QColor &textWarning) |
| 851 |
{ |
| 852 |
D_DC(DPlatformTheme); |
| 853 |
return d->platformInterface->setTextWarning(textWarning); |
| 854 |
} |
| 855 |
|
| 856 |
void DPlatformTheme::setTextLively(const QColor &textLively) |
| 857 |
{ |
| 858 |
D_DC(DPlatformTheme); |
| 859 |
return d->platformInterface->setTextLively(textLively); |
| 860 |
} |
| 861 |
|
| 862 |
void DPlatformTheme::setLightLively(const QColor &lightLively) |
| 863 |
{ |
| 864 |
D_DC(DPlatformTheme); |
| 865 |
return d->platformInterface->setLightLively(lightLively); |
| 866 |
} |
| 867 |
|
| 868 |
void DPlatformTheme::setDarkLively(const QColor &darkLively) |
| 869 |
{ |
| 870 |
D_DC(DPlatformTheme); |
| 871 |
return d->platformInterface->setDarkLively(darkLively); |
| 872 |
} |
| 873 |
|
| 874 |
void DPlatformTheme::setFrameBorder(const QColor &frameBorder) |
| 875 |
{ |
| 876 |
D_DC(DPlatformTheme); |
| 877 |
return d->platformInterface->setFrameBorder(frameBorder); |
| 878 |
} |
| 879 |
#endif |
| 880 |
|
| 881 |
void DPlatformTheme::setDotsPerInch(const QString &screenName, int dpi) |
| 882 |
{ |
| 883 |
D_DC(DPlatformTheme); |
| 884 |
return d->platformInterface->setDotsPerInch(screenName, dpi); |
| 885 |
} |
| 886 |
|
| 887 |
void DPlatformTheme::setWindowRadius(int windowRadius) |
| 888 |
{ |
| 889 |
D_DC(DPlatformTheme); |
| 890 |
return d->platformInterface->setWindowRadius(windowRadius); |
| 891 |
} |
| 892 |
|
| 893 |
DGUI_END_NAMESPACE |
| 894 |
|
| 895 |
#include "moc_dplatformtheme.cpp" |