Compare commits
160 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
b03849d6de | |
|
|
187be9a947 | |
|
|
16145642e1 | |
|
|
39a50cca37 | |
|
|
2767618f84 | |
|
|
36c06be095 | |
|
|
80db4dd238 | |
|
|
3d0713f7a2 | |
|
|
af1259edbb | |
|
|
3b5ba9bbda | |
|
|
c8f2955bd0 | |
|
|
96d0b45dd0 | |
|
|
00109d07e3 | |
|
|
d2c2efc49a | |
|
|
9842a0644e | |
|
|
9d3d659afe | |
|
|
eaf96e824d | |
|
|
7c05bace4a | |
|
|
a892ddc4e2 | |
|
|
65cf7b4161 | |
|
|
6b7e941839 | |
|
|
dc2eaeb61c | |
|
|
4dd22b538d | |
|
|
2ea4e762fe | |
|
|
18388f26f8 | |
|
|
9e54cbfad4 | |
|
|
6ff5c37579 | |
|
|
dd35e33644 | |
|
|
f834cb588d | |
|
|
9f500cbe94 | |
|
|
44bed9e070 | |
|
|
3f1cfd6800 | |
|
|
1f44c47e55 | |
|
|
28c53f37e7 | |
|
|
75d176f234 | |
|
|
6d6a4a4380 | |
|
|
ed252239b2 | |
|
|
aa13f2a82f | |
|
|
decbf724b3 | |
|
|
7c2b35ae42 | |
|
|
ec6fbaf651 | |
|
|
d3b68df561 | |
|
|
5eb6b4c403 | |
|
|
75208f151f | |
|
|
5ce8bf3755 | |
|
|
0a0182faac | |
|
|
c52610f23c | |
|
|
6cc9f8ac48 | |
|
|
8110fd861e | |
|
|
3c16e777fe | |
|
|
c0812b7af6 | |
|
|
b0c91b8714 | |
|
|
dc5aa91b44 | |
|
|
976aa9113c | |
|
|
b566c12e40 | |
|
|
329bf5a247 | |
|
|
7362e047b7 | |
|
|
1ede364ac6 | |
|
|
e0873d04b3 | |
|
|
acd947fa3e | |
|
|
b152721ae8 | |
|
|
4bdfc69e31 | |
|
|
e33a3945b2 | |
|
|
7871d7c448 | |
|
|
df159744c6 | |
|
|
4ff3a644af | |
|
|
3a2792c869 | |
|
|
06dedd11df | |
|
|
00584efe94 | |
|
|
f5a7cc22cd | |
|
|
79440d4b47 | |
|
|
726790ee06 | |
|
|
cf97c88b76 | |
|
|
76d00b0301 | |
|
|
fed4aae652 | |
|
|
e10215f3c1 | |
|
|
16d4999f1b | |
|
|
1f0b9ed118 | |
|
|
b75b68a604 | |
|
|
d07aca6786 | |
|
|
5ad7ed1ce8 | |
|
|
de728b0bee | |
|
|
d435f92784 | |
|
|
43624a42e9 | |
|
|
b975592ce1 | |
|
|
f0a7d5d44d | |
|
|
a0398d03d5 | |
|
|
a407dc4032 | |
|
|
255f171e9f | |
|
|
525beab369 | |
|
|
231c29ac65 | |
|
|
6038e6fcf8 | |
|
|
316a3e741c | |
|
|
806457e8bc | |
|
|
b25353026b | |
|
|
8cf037d44b | |
|
|
af9a6fc359 | |
|
|
2dae5b2e82 | |
|
|
7a49e9c164 | |
|
|
b2c91d0c2e | |
|
|
4fb86c1204 | |
|
|
afe212871f | |
|
|
3a6a15b9f2 | |
|
|
c227e1adce | |
|
|
9c99626771 | |
|
|
6f375cfc0c | |
|
|
7ec030f0b9 | |
|
|
1ab1d9234f | |
|
|
75ce762ed0 | |
|
|
820e3030be | |
|
|
1ffd986e97 | |
|
|
b10836217d | |
|
|
12b60a3c8a | |
|
|
b23ef7058a | |
|
|
8900594c9f | |
|
|
da12696b21 | |
|
|
9c06164a2e | |
|
|
da27fb74b3 | |
|
|
7fee7b54b1 | |
|
|
46d504a819 | |
|
|
1c814a9217 | |
|
|
51c7e35161 | |
|
|
aeaccd30ce | |
|
|
1b9c238bbc | |
|
|
bffcdde9ea | |
|
|
c42d36671e | |
|
|
f9607e01a4 | |
|
|
069289d500 | |
|
|
1aa57f8b4e | |
|
|
20f5fc1d3b | |
|
|
f08256da6e | |
|
|
9d2673082e | |
|
|
4013869e09 | |
|
|
3b6cb2e9f2 | |
|
|
8561847a13 | |
|
|
754d5baff5 | |
|
|
0f079b0838 | |
|
|
d5c1ae779b | |
|
|
01af1cbc93 | |
|
|
2299e3137e | |
|
|
2d7435324c | |
|
|
7e3569496e | |
|
|
3ea215d46f | |
|
|
0dfac4ca6e | |
|
|
df8a05e159 | |
|
|
9e0396c5e6 | |
|
|
8cabfe86aa | |
|
|
a66d7ccbf3 | |
|
|
d471c7221a | |
|
|
d35f8e10fd | |
|
|
71aaf6a024 | |
|
|
dec5572b9b | |
|
|
0e8a4e0b91 | |
|
|
d6434448c1 | |
|
|
3b2949bbf3 | |
|
|
75633580dc | |
|
|
6bee9a679d | |
|
|
4f8d3739b5 | |
|
|
eef2f42fea | |
|
|
1da5179b08 |
|
|
@ -0,0 +1,13 @@
|
|||
name: apiCheck
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
api-check:
|
||||
uses: linuxdeepin/.github/.github/workflows/api-check.yml@master
|
||||
secrets: inherit
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
name: Auto Release
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Release version (e.g., 1.0.0)'
|
||||
type: string
|
||||
required: false
|
||||
name:
|
||||
description: 'The name of the person to release the version'
|
||||
type: string
|
||||
required: false
|
||||
email:
|
||||
description: 'The email of the person to release the version'
|
||||
type: string
|
||||
required: false
|
||||
timezone:
|
||||
description: 'The timezone in the debian changelog file'
|
||||
required: false
|
||||
type: string
|
||||
default: 'Asia/Shanghai'
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Release version (e.g., 1.0.0)'
|
||||
type: string
|
||||
required: true
|
||||
name:
|
||||
description: 'The name of the person to release the version'
|
||||
type: string
|
||||
required: false
|
||||
email:
|
||||
description: 'The email of the person to release the version'
|
||||
type: string
|
||||
required: false
|
||||
timezone:
|
||||
description: 'The timezone in the debian changelog file'
|
||||
required: false
|
||||
type: string
|
||||
default: 'Asia/Shanghai'
|
||||
|
||||
jobs:
|
||||
auto_release:
|
||||
uses: linuxdeepin/.github/.github/workflows/auto-release.yml@master
|
||||
secrets: inherit
|
||||
with:
|
||||
version: ${{ inputs.version }}
|
||||
name: ${{ inputs.name }}
|
||||
email: ${{ inputs.email }}
|
||||
timezone: ${{ inputs.timezone }}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
name: debianCheck
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
debian-check:
|
||||
uses: linuxdeepin/.github/.github/workflows/debian-check.yml@master
|
||||
secrets: inherit
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
name: staticCheck
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
static-check:
|
||||
uses: linuxdeepin/.github/.github/workflows/static-check.yml@master
|
||||
secrets: inherit
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
name: Call synchronize to dtk6
|
||||
on:
|
||||
pull_request_target:
|
||||
paths-ignore:
|
||||
- "debian/**"
|
||||
- "archlinux/**"
|
||||
- "rpm/**"
|
||||
- ".obs/**"
|
||||
- ".github/**"
|
||||
|
||||
jobs:
|
||||
call-synchronize:
|
||||
uses: linuxdeepin/dtk/.github/workflows/synchronize-to-dtk6.yml@master
|
||||
secrets: inherit
|
||||
with:
|
||||
dest_repo: linuxdeepin/dtk6gui
|
||||
source_repo: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
source_ref: ${{ github.event.pull_request.head.ref }}
|
||||
pull_number: ${{ github.event.pull_request.number }}
|
||||
14
.reuse/dep5
14
.reuse/dep5
|
|
@ -9,7 +9,7 @@ Copyright: None
|
|||
License: CC0-1.0
|
||||
|
||||
# gitignore
|
||||
Files: .gitignore
|
||||
Files: .gitignore .syncexclude
|
||||
Copyright: None
|
||||
License: CC0-1.0
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ Copyright: None
|
|||
License: LGPL-3.0-or-later
|
||||
|
||||
# README
|
||||
Files: *README.md *README.zh_CN.md
|
||||
Files: *README.md *README.zh_CN.md CHANGELOG.md
|
||||
Copyright: None
|
||||
License: CC-BY-4.0
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ Copyright: None
|
|||
License: CC0-1.0
|
||||
|
||||
# Project file
|
||||
Files: *.pro *.prf *.pri *.qrc *CMakeLists.txt *.cmake *.in
|
||||
Files: *.pro *.prf *.pri *.qrc *CMakeLists.txt *.cmake *.in VERSION
|
||||
Copyright: None
|
||||
License: CC0-1.0
|
||||
|
||||
|
|
@ -58,3 +58,11 @@ Files: src/util/icons/actions/* src/util/icons/icons/* src/util/icons/texts/*
|
|||
src/util/icons/dci/* tests/images/* tests/actions/* tests/dcis/* examples/animation-dci/*
|
||||
Copyright: UnionTech Software Technology Co., Ltd.
|
||||
License: LGPL-3.0-or-later
|
||||
|
||||
Files: toolGenerate/**/*
|
||||
Copyright: None
|
||||
License: CC0-1.0
|
||||
|
||||
Files: src/kernel/orgdeepindtkpreference.hpp
|
||||
Copyright: None
|
||||
License: CC0-1.0
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
# Paths that will be exclude from synchronize workflow
|
||||
# Please use relative path which use project directory as root
|
||||
# Notice that
|
||||
# * .git
|
||||
# * debian
|
||||
# * archlinux
|
||||
# * .obs
|
||||
# * .github
|
||||
# are always ignored
|
||||
linglong.yaml
|
||||
conanfile.py
|
||||
VERSION
|
||||
CHANGELOG.md
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [5.7.25] - 2025-10-30
|
||||
|
||||
### Changed
|
||||
|
||||
- Improve icon theme generation with scalable support
|
||||
|
||||
## [5.7.24] - 2025-10-16
|
||||
|
||||
### Added
|
||||
|
||||
- Support Qt 6.10
|
||||
|
||||
### Changed
|
||||
|
||||
- Improve icon size detection and duplicate handling
|
||||
|
||||
### Fixed
|
||||
|
||||
- Correct lockfile path construction
|
||||
- Fix Qt6 compilation error with libxdg
|
||||
|
||||
## [5.7.23] - 2025-09-25
|
||||
|
||||
### Fixed
|
||||
|
||||
- 解决控制中心闪烁问题
|
||||
- Fix build for Qt 6.9
|
||||
|
||||
## [5.7.22] - 2025-09-04
|
||||
|
||||
### Added
|
||||
|
||||
- Add T11 font size and adjust T5 default
|
||||
|
||||
### Fixed
|
||||
|
||||
- Improve PID namespace detection in setSingleInstance
|
||||
|
||||
## [5.7.21] - 2025-08-14
|
||||
|
||||
### Added
|
||||
|
||||
- Add flags parameter to DDciIconPlayer play method
|
||||
|
||||
### Fixed
|
||||
|
||||
- Resolve compilation warnings and deprecation issues
|
||||
|
||||
## [5.7.20] - 2025-07-31
|
||||
|
||||
### Added
|
||||
|
||||
- Add pid namespace isolation to setSingleInstance
|
||||
- Add concurrent processing for DCI icon conversion
|
||||
|
||||
### Changed
|
||||
|
||||
- Update REUSE license file for CHANGELOG
|
||||
- Move icon finder functionality to separate tool
|
||||
- Switch to QGuiApplication for SVG rendering
|
||||
|
||||
## [5.7.19] - 2025-07-03
|
||||
|
||||
### Fixed
|
||||
|
||||
- Enhance build security hardening
|
||||
|
||||
## [5.7.18] - 2025-06-27
|
||||
|
||||
### Fixed
|
||||
|
||||
- Make version parameter optional in release workflow
|
||||
|
||||
## [5.7.17] - 2025-06-19
|
||||
|
||||
### Added
|
||||
|
||||
- Add missing header
|
||||
- Fix: add missing prefix for QTranslator::load()
|
||||
|
||||
### Changed
|
||||
|
||||
- Chore: use another QTranslator::load overload to tidy code
|
||||
- Support VERSION file
|
||||
- Add auto release workflow
|
||||
- Update .syncexclude
|
||||
|
||||
[5.7.17]: https://github.com/linuxdeepin/dtkgui/compare/5.7.16..5.7.17
|
||||
|
||||
<!-- generated by git-cliff -->
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
cmake_minimum_required(VERSION 3.13)
|
||||
cmake_minimum_required(VERSION 3.25)
|
||||
|
||||
set(DTK_VERSION "5.6.11" CACHE STRING "define project version")
|
||||
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" DTK_FILE_VERSION)
|
||||
string(STRIP "${DTK_FILE_VERSION}" DTK_FILE_VERSION)
|
||||
set(DTK_VERSION "${DTK_FILE_VERSION}" CACHE STRING "define project version")
|
||||
project(DtkGui
|
||||
VERSION ${DTK_VERSION}
|
||||
DESCRIPTION "DTK Gui module"
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
@version@
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# Maintainer: justforlxz <justforlxz@gmail.com>
|
||||
pkgname=dtkgui-git
|
||||
pkgver=5.5.22.r8.g6ef1509
|
||||
pkgver=5.7.25
|
||||
pkgrel=1
|
||||
sourcename=dtkgui
|
||||
sourcetars=("$sourcename"_"$pkgver".tar.xz)
|
||||
|
|
@ -9,10 +9,10 @@ pkgdesc='Deepin Toolkit, gui module for DDE look and feel'
|
|||
arch=('x86_64' 'aarch64')
|
||||
url="https://github.com/linuxdeepin/dtkgui"
|
||||
license=('LGPL3')
|
||||
depends=('dtkcore-git' 'dtkcommon-git' 'qt5-svg' 'libqtxdg' 'freeimage' 'librsvg')
|
||||
depends=('dtkcore-git' 'dtkcommon-git' 'qt5-svg' 'libqtxdg' 'freeimage' 'librsvg' 'qt5-wayland')
|
||||
# INFO: you can disable freeimage not to support RAW images
|
||||
# Then set DTK_DISABLE_EX_IMAGE_FORMAT=OFF
|
||||
makedepends=('git' 'qt5-tools' 'gtest' 'gmock' 'ninja' 'cmake' 'doxygen')
|
||||
makedepends=('git' 'qt5-tools' 'gtest' 'gmock' 'ninja' 'cmake' 'doxygen' 'extra-cmake-modules')
|
||||
conflicts=('dtkgui')
|
||||
provides=('dtkgui')
|
||||
groups=('deepin-git')
|
||||
|
|
@ -25,7 +25,6 @@ build() {
|
|||
cmake -GNinja \
|
||||
-DMKSPECS_INSTALL_DIR=lib/qt/mkspecs/modules/ \
|
||||
-DBUILD_DOCS=ON \
|
||||
-DDTK_DISABLE_LIBRSVG=ON \
|
||||
-DQCH_INSTALL_DESTINATION=share/doc/qt \
|
||||
-DCMAKE_INSTALL_LIBDIR=lib \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
|
|
|
|||
|
|
@ -1,3 +1,307 @@
|
|||
dtkgui (5.7.25) unstable; urgency=medium
|
||||
|
||||
* Release 5.7.25
|
||||
|
||||
-- yeshanshan <yeshanshan@uniontech.com> Thu, 30 Oct 2025 21:47:33 +0800
|
||||
|
||||
dtkgui (5.7.24) unstable; urgency=medium
|
||||
|
||||
* Release 5.7.24
|
||||
|
||||
-- yeshanshan <yeshanshan@uniontech.com> Thu, 16 Oct 2025 19:45:30 +0800
|
||||
|
||||
dtkgui (5.7.23) unstable; urgency=medium
|
||||
|
||||
* Release 5.7.23
|
||||
|
||||
-- yeshanshan <packages@deepin.org> Thu, 25 Sep 2025 16:49:18 +0800
|
||||
|
||||
dtkgui (5.7.22) unstable; urgency=medium
|
||||
|
||||
* Release 5.7.22
|
||||
|
||||
-- yeshanshan <yeshanshan@uniontech.com> Thu, 04 Sep 2025 19:27:38 +0800
|
||||
|
||||
dtkgui (5.7.21) unstable; urgency=medium
|
||||
|
||||
* Release 5.7.21
|
||||
|
||||
-- yeshanshan <packages@deepin.org> Thu, 14 Aug 2025 19:47:40 +0800
|
||||
|
||||
dtkgui (5.7.20) unstable; urgency=medium
|
||||
|
||||
* Release 5.7.20
|
||||
|
||||
-- yeshanshan <yeshanshan@uniontech.com> Thu, 31 Jul 2025 19:59:35 +0800
|
||||
|
||||
dtkgui (5.7.19) unstable; urgency=medium
|
||||
|
||||
* Release 5.7.19
|
||||
|
||||
-- yeshanshan <yeshanshan@uniontech.com> Thu, 03 Jul 2025 21:12:27 +0800
|
||||
|
||||
dtkgui (5.7.18) unstable; urgency=medium
|
||||
|
||||
* Release 5.7.18
|
||||
|
||||
-- yeshanshan <yeshanshan@uniontech.com> Fri, 27 Jun 2025 17:09:35 +0800
|
||||
|
||||
dtkgui (5.7.17) unstable; urgency=medium
|
||||
|
||||
* Release 5.7.17
|
||||
|
||||
-- yeshanshan <yeshanshan@uniontech.com> Thu, 19 Jun 2025 10:03:48 +0800
|
||||
|
||||
dtkgui (5.7.16) unstable; urgency=medium
|
||||
|
||||
* Release 5.7.16
|
||||
|
||||
-- YeShanShan <yeshanshan@uniontech.com> Mon, 19 May 2025 17:21:59 +0800
|
||||
|
||||
dtkgui (5.7.15) unstable; urgency=medium
|
||||
|
||||
* fix: correct bitwise operation in preference handling
|
||||
* fix: prevent theme saving when DontSaveApplicationTheme is set
|
||||
* refactor: improve thread safety in OrgDeepinDTKPreference
|
||||
* fix: build failed in qt5
|
||||
* feat: use dconfig2cpp for read/write the DConfig
|
||||
* fix: fix build on Qt 6.8
|
||||
|
||||
-- YeShanShan <yeshanshan@uniontech.com> Thu, 08 May 2025 17:53:09 +0800
|
||||
|
||||
dtkgui (5.7.14) unstable; urgency=medium
|
||||
|
||||
* build: compiling failed with Qt 6.9
|
||||
|
||||
-- YeShanShan <yeshanshan@uniontech.com> Thu, 17 Apr 2025 21:51:32 +0800
|
||||
|
||||
dtkgui (5.7.13) unstable; urgency=medium
|
||||
|
||||
* Release 5.7.13
|
||||
|
||||
-- YeShanShan <yeshanshan@uniontech.com> Thu, 20 Mar 2025 17:05:55 +0800
|
||||
|
||||
dtkgui (5.7.12) unstable; urgency=medium
|
||||
|
||||
* fix: palette refresh delayed in qt6
|
||||
* feat: Add files generated by qdbusXML2cpp and DCONG2cpp
|
||||
|
||||
-- YeShanShan <yeshanshan@uniontech.com> Thu, 06 Mar 2025 17:29:35 +0800
|
||||
|
||||
dtkgui (5.7.11) unstable; urgency=medium
|
||||
|
||||
* Release 5.7.11
|
||||
|
||||
-- YeShanShan <yeshanshan@uniontech.com> Thu, 27 Feb 2025 20:47:39 +0800
|
||||
|
||||
dtkgui (5.7.10) unstable; urgency=medium
|
||||
|
||||
* fix: icon is blurry
|
||||
|
||||
-- YeShanShan <yeshanshan@uniontech.com> Thu, 13 Feb 2025 17:18:19 +0800
|
||||
|
||||
dtkgui (5.7.9) unstable; urgency=medium
|
||||
|
||||
[ root ]
|
||||
* UNRELEASED
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Thu, 23 Jan 2025 09:07:08 +0000
|
||||
|
||||
dtkgui (5.7.8) unstable; urgency=medium
|
||||
|
||||
* fix: missing window decoration for treeland
|
||||
* chore: update default window corner size
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Tue, 14 Jan 2025 11:17:31 +0000
|
||||
|
||||
dtkgui (5.7.7) unstable; urgency=medium
|
||||
|
||||
* fix: accessing wild pointer in qt6
|
||||
* chore: correct typos about Dtk::Gui::DDciIcon::IconAttribute
|
||||
Thanks to Felix Yan
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Thu, 09 Jan 2025 09:28:38 +0000
|
||||
|
||||
dtkgui (5.7.6) unstable; urgency=medium
|
||||
|
||||
* refact: refacting DPlatformHandle to adap treeland
|
||||
* Revert "refact: refacting DPlatformHandle to adap treeland"
|
||||
* refact: refacting DPlatformHandle to adapt treeland
|
||||
* fix: iterator out of bounds for dciicon
|
||||
* fix: set font family invalid
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Thu, 02 Jan 2025 05:43:53 +0000
|
||||
|
||||
dtkgui (5.7.5) unstable; urgency=medium
|
||||
|
||||
* fix: availableSizes not work on Qt6
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Thu, 12 Dec 2024 03:03:53 +0000
|
||||
|
||||
dtkgui (5.7.4) unstable; urgency=medium
|
||||
|
||||
* chore(CI): add debian check workflow
|
||||
Thanks to kuchune
|
||||
* refactor: xcb platform theme interface
|
||||
* refactor: treeland platform theme interface 扩展Treeland的个性化接口
|
||||
* fix: Possible null pointer dereference and Notitlebar input parameter error
|
||||
* feat: support treeland platform for wmHelper
|
||||
* fix: blur is invalid for treeland
|
||||
* feat: Limit maximum and minimum fonts
|
||||
* fix: app crashed when window destroyed in quick
|
||||
* fix: app crashed when window destroyed in quick
|
||||
* fix: linglong app load qt translations failed
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Tue, 03 Dec 2024 02:00:46 +0000
|
||||
|
||||
dtkgui (5.7.3) unstable; urgency=medium
|
||||
|
||||
* fix: No judgment on the validity of the protocol(Bug: 286859)
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Wed, 20 Nov 2024 02:19:06 +0000
|
||||
|
||||
dtkgui (5.7.2) unstable; urgency=medium
|
||||
|
||||
* chore: Correct the name of TreelandProtocols package in cmake
|
||||
* fix: Under treeland, the dialog has not disabled titlebar
|
||||
* fix: Print "load translate" debug log to channels(Bug: 284539)
|
||||
* chore: add IsWaylandPlatform attribute
|
||||
* chore: highlight color is inconsistency
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Wed, 13 Nov 2024 01:53:26 +0000
|
||||
|
||||
dtkgui (5.7.1) unstable; urgency=medium
|
||||
|
||||
* Revert "feat: add close.dci"(Issue: https://github.com/linuxdeepin/developer-center/issues/10482)
|
||||
* feat: Add notitlebar function on wayland platform
|
||||
* feat: support qt5 and qt6
|
||||
* fix: cannot move window on wayland
|
||||
* fix: remove treeland personalization protocols useless function
|
||||
* feat: add fixme note
|
||||
* chore: update license info
|
||||
* chore: add build dep
|
||||
* chore: update license
|
||||
* chore: add extra cmake modules
|
||||
* chore: add dtkgui namespace
|
||||
* fix: app crashed in x11
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Wed, 16 Oct 2024 03:30:46 +0000
|
||||
|
||||
dtkgui (5.6.34) unstable; urgency=medium
|
||||
|
||||
* feat: add close.dci
|
||||
Thanks to Yixue Wang
|
||||
* chore: animation-dci supports custom icon
|
||||
* fix: wrong judgment conditions
|
||||
* feat: support to change window effects(Bug: 244347)
|
||||
* feat: add window startup effect Type(Issue: https://github.com/linuxdeepin/developer-center/issues/10322)
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Tue, 20 Aug 2024 05:03:52 +0000
|
||||
|
||||
dtkgui (5.6.32) unstable; urgency=medium
|
||||
|
||||
* Revert "fix: jagged edges on ddciicon"(Issue: https://github.com/linuxdeepin/developer-center/issues/9443)
|
||||
* chore: dci-icon-theme tool tweak
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Mon, 08 Jul 2024 02:29:21 +0000
|
||||
|
||||
dtkgui (5.6.31) unstable; urgency=medium
|
||||
|
||||
* fix: jagged edges on ddciicon(Issue: https://github.com/linuxdeepin/developer-center/issues/8691)
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Thu, 27 Jun 2024 09:11:34 +0000
|
||||
|
||||
dtkgui (5.6.30) unstable; urgency=medium
|
||||
|
||||
[ root ]
|
||||
* UNRELEASED
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Thu, 30 May 2024 02:46:31 +0000
|
||||
|
||||
dtkgui (5.6.29) unstable; urgency=medium
|
||||
|
||||
[ root ]
|
||||
* UNRELEASED
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Mon, 13 May 2024 03:02:53 +0000
|
||||
|
||||
dtkgui (5.6.28) unstable; urgency=medium
|
||||
|
||||
* chore: insert to cache when icon is not null
|
||||
* chore: add flag to disable noncache flag
|
||||
* fix: missing initialization for baseFont of fontManager(Issue: https://github.com/linuxdeepin/developer-center/issues/8040)
|
||||
* feat: dci-icon-theme support multiple icon size
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Mon, 29 Apr 2024 08:23:44 +0000
|
||||
|
||||
dtkgui (5.6.27) unstable; urgency=medium
|
||||
|
||||
* fix: setWindowBlurAreaByWM only work once in qt6
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Fri, 19 Apr 2024 08:55:34 +0000
|
||||
|
||||
dtkgui (5.6.26) unstable; urgency=medium
|
||||
|
||||
* fix: wrong availableSizes for DIconProxyEngine
|
||||
* fix: PlaceholderText color tweak(Issue: https://github.com/linuxdeepin/developer-center/issues/7554)
|
||||
* feat: support to get specified palette
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Tue, 26 Mar 2024 05:47:35 +0000
|
||||
|
||||
dtkgui (5.6.25) unstable; urgency=medium
|
||||
|
||||
* fix: icon doesn't update when iconTheme changed
|
||||
* fix: font can't follow changes in qt6
|
||||
* fix: app refresh slowly
|
||||
* fix: changed paletteType's config value
|
||||
* fix: search icon can't change with theme change(Issue: #6230)
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Mon, 11 Mar 2024 01:16:27 +0000
|
||||
|
||||
dtkgui (5.6.22) unstable; urgency=medium
|
||||
|
||||
* fix: menu icon incorrect in dark mode(Issue: https://github.com/linuxdeepin/developer-center/issues/6624)
|
||||
* feat: enable xdgIconLoader under Qt6
|
||||
* chore: warning for connect
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Wed, 10 Jan 2024 02:30:59 +0000
|
||||
|
||||
dtkgui (5.6.21) unstable; urgency=medium
|
||||
|
||||
* chore: update cmake version
|
||||
* fix: xdg icon loading failed with qt6(Issue: https://github.com/linuxdeepin/developer-center/issues/6459)
|
||||
* fix: debian build failed
|
||||
* fix: DIconProxyEngine read not ensureEngine
|
||||
* chore: fix ut_dciiconengine failed on dark theme
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Tue, 09 Jan 2024 01:45:43 +0000
|
||||
|
||||
dtkgui (5.6.20) unstable; urgency=medium
|
||||
|
||||
* chore: add synchronization workflow
|
||||
* fix: indirect inclusion of QSharedPointer
|
||||
* feat: move ddesktopservices to dtkgui(Issue: #134)
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Tue, 28 Nov 2023 05:40:52 +0000
|
||||
|
||||
dtkgui (5.6.19) unstable; urgency=medium
|
||||
|
||||
[ root ]
|
||||
* UNRELEASED
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Mon, 23 Oct 2023 07:33:18 +0000
|
||||
|
||||
dtkgui (5.6.18) unstable; urgency=medium
|
||||
|
||||
* fix: Wrong value of DPalette::TextLively
|
||||
* chore: find qhelpgenerator from property
|
||||
* fix: svg with filter attribute rendering exception
|
||||
* fix: when iconName is absolute path
|
||||
* fix: missing link when disable librsvg
|
||||
* fix: Wrong IconName for DIconEngine(Issue: https://github.com/linuxdeepin/developer-center/issues/5760)
|
||||
|
||||
-- Deepin Packages Builder <packages@deepin.org> Wed, 18 Oct 2023 06:01:44 +0000
|
||||
|
||||
dtkgui (5.6.17) unstable; urgency=medium
|
||||
|
||||
* Release 5.6.17
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@ Source: dtkgui
|
|||
Section: libdevel
|
||||
Priority: optional
|
||||
Maintainer: Deepin Packages Builder <packages@deepin.com>
|
||||
Build-Depends: debhelper-compat (= 12), pkg-config,
|
||||
qtbase5-private-dev, qtbase5-dev-tools, doxygen, graphviz, qttools5-dev-tools,
|
||||
Build-Depends: debhelper-compat (= 12), pkg-config,
|
||||
qtbase5-private-dev, qtbase5-dev-tools, doxygen, graphviz, qttools5-dev,
|
||||
libdtkcore-dev, librsvg2-dev, libfreeimage-dev, libraw-dev, libgtest-dev, libgmock-dev,
|
||||
libqt5xdg-dev, libqt5xdgiconloader-dev, cmake, qt5-image-formats-plugins
|
||||
libqt5xdg-dev, libqt5xdgiconloader-dev, cmake, qt5-image-formats-plugins, libqt5waylandclient5-dev,
|
||||
extra-cmake-modules, qtwayland5-dev-tools, qtwayland5-private-dev, libkf5wayland-dev, treeland-protocols
|
||||
Standards-Version: 3.9.8
|
||||
|
||||
Package: libdtkgui5
|
||||
|
|
@ -36,6 +37,7 @@ Description: Deepin Tool Kit Gui Devel library
|
|||
This package contains the header files and static libraries of DtkGui
|
||||
|
||||
Package: libdtkgui-doc
|
||||
Build-Profiles: <!nodoc>
|
||||
Architecture: any
|
||||
Depends: ${misc:Depends}
|
||||
Description: Deepin Tool Kit Gui (Document)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@ DPKG_EXPORT_BUILDFLAGS = 1
|
|||
include /usr/share/dpkg/default.mk
|
||||
export QT_SELECT = qt5
|
||||
|
||||
# 安全编译参数
|
||||
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
|
||||
export DEB_CFLAGS_MAINT_APPEND = -Wall
|
||||
export DEB_CXXFLAGS_MAINT_APPEND = -Wall
|
||||
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-E
|
||||
|
||||
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
|
||||
|
||||
VERSION = $(DEB_VERSION_UPSTREAM)
|
||||
|
|
|
|||
|
|
@ -12,13 +12,24 @@ set (DOXYGEN_PROJECT_NUMBER ${CMAKE_PROJECT_VERSION} CACHE STRING "") # Should b
|
|||
set (DOXYGEN_EXTRACT_STATIC YES)
|
||||
set (DOXYGEN_OUTPUT_LANGUAGE "Chinese" CACHE STRING "Doxygen Output Language")
|
||||
set (DOXYGEN_IMAGE_PATH ${CMAKE_CURRENT_LIST_DIR}/images/)
|
||||
set (DOXYGEN_QHG_LOCATION "qhelpgenerator" CACHE STRING "Doxygen QHG path")
|
||||
set (DOXYGEN_QHP_NAMESPACE "org.deepin.dtk.gui")
|
||||
set (DOXYGEN_QCH_FILE "dtkgui.qch")
|
||||
set (DOXYGEN_QHP_VIRTUAL_FOLDER "dtkgui")
|
||||
set (DOXYGEN_HTML_EXTRA_STYLESHEET "" CACHE STRING "Doxygen custom stylesheet for HTML output")
|
||||
set (DOXYGEN_TAGFILES "qtcore.tags=qthelp://org.qt-project.qtcore/qtcore/" CACHE STRING "Doxygen tag files")
|
||||
|
||||
# find from cmake target property
|
||||
if("${QT_VERSION_MAJOR}" STREQUAL "5")
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Help)
|
||||
else()
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ToolsTools)
|
||||
endif()
|
||||
get_target_property(_qhelpgenerator_location Qt${QT_VERSION_MAJOR}::qhelpgenerator IMPORTED_LOCATION)
|
||||
if("${_qhelpgenerator_location}" STREQUAL "")
|
||||
set(_qhelpgenerator_location "qhelpgenerator")
|
||||
endif()
|
||||
set (DOXYGEN_QHG_LOCATION ${_qhelpgenerator_location} CACHE STRING "Doxygen QHG path")
|
||||
|
||||
set (DOXYGEN_PREDEFINED
|
||||
"D_DECL_DEPRECATED_X(x)="
|
||||
"DCORE_BEGIN_NAMESPACE=namespace Dtk { namespace Core {"
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ cmake --build build
|
|||
| Light | 0 |
|
||||
| Dark | 1 |
|
||||
|
||||
@enum Dtk::Gui::DDciIcon::IconAttibute
|
||||
@enum Dtk::Gui::DDciIcon::IconAttribute
|
||||
@brief DCI图标属性
|
||||
@details
|
||||
| 键 | 值 |
|
||||
|
|
@ -282,7 +282,7 @@ cmake --build build
|
|||
@param[in] theme 图标主题
|
||||
@param[in] mode 图标模式,默认为Normal
|
||||
|
||||
@fn bool Dtk::Gui::DDciIcon::isSupportedAttribute(DDciIconMatchResult result, IconAttibute attr)
|
||||
@fn bool Dtk::Gui::DDciIcon::isSupportedAttribute(DDciIconMatchResult result, IconAttribute attr)
|
||||
@brief 判断DCI图标是否支持指定属性
|
||||
@param[in] result DCI图标匹配结果
|
||||
@param[in] attr 图标属性
|
||||
|
|
|
|||
|
|
@ -171,6 +171,11 @@
|
|||
@details 为指定的图标模式计算要显示的内容,这可能会导致 currentImage 发生变化。这是个一次性行为,不会影响下一次调用 setMode 后的结果。
|
||||
@param[in] mode 指定要播放的图标模式,如果此模式支持动画,会触发此模式自身的动画播放(与 setMode 导致的动画不同的是,此动画不涉及两种模式变化时的过渡规则),否则将修改 currentImage 为此模式对应的静态图片资源。
|
||||
|
||||
@fn Dtk::Gui::DDciIconPlayer::play(DDciIcon::Mode mode, DDciIconImagePlayer::Flags flags)
|
||||
@details 为指定的图标模式和播放参数计算要显示的内容。
|
||||
@param[in] mode 指定要播放的图标模式。
|
||||
@param[in] flags 播放参数
|
||||
|
||||
@fn Dtk::Gui::DDciIconPlayer::stop()
|
||||
@details 如果当前正在播放动画,则停止当前动画的播放,但不会影响队列中下一个动画的播放。可能会导致 DDciIconPlayer::state 发生变化。
|
||||
@sa DDciIconPlayer::abort
|
||||
|
|
|
|||
|
|
@ -0,0 +1,164 @@
|
|||
/*!
|
||||
@~chinese
|
||||
@file include/util/ddesktopservices.h
|
||||
@ingroup DesktopServices
|
||||
@brief Dtk 提供常见桌面服务的方法工具类
|
||||
|
||||
@namespace Dtk::Gui::DDesktopServices ddesktopservices.h
|
||||
@details 用于提供一些接口,包括在文件管理器中显示目录,显示文件,显示文件属性,移入回收站,播放系统音效等。
|
||||
|
||||
@enum Dtk::Gui::DDesktopServices::SystemSoundEffect
|
||||
@brief 系统音效的枚举
|
||||
@var Dtk::Gui::DDesktopServices::SSE_Notifications
|
||||
@brief 显示通知的音效
|
||||
@var Dtk::Gui::DDesktopServices::SEE_Screenshot
|
||||
@brief 截屏的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_EmptyTrash
|
||||
@brief 清空回收站的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_SendFileComplete
|
||||
@brief 完成发送文件(到桌面)的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_BootUp
|
||||
@brief 开机的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_Shutdown
|
||||
@brief 关机的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_Logout
|
||||
@brief 注销的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_WakeUp
|
||||
@brief 唤醒的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_VolumeChange
|
||||
@brief 音量调节的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_LowBattery
|
||||
@brief 低电量的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_PlugIn
|
||||
@brief 电源接入的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_PlugOut
|
||||
@brief 电源移除的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_DeviceAdded
|
||||
@brief 移动设备接入的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_DeviceRemoved
|
||||
@brief 移动设备移除的音效
|
||||
@var Dtk::Gui::DDesktopServices::SSE_Error
|
||||
@brief 错误提示的音效
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::showFolder(const QString &localFilePath, const QString &startupId = QString())
|
||||
@details 通过文件管理器显示目录
|
||||
@param[in] localFilePath 要显示的目录路径
|
||||
@param[in] startupId 本次启动的id, 默认为空
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::showFolders(const QList<QString> &localFilePaths, const QString &startupId = QString())
|
||||
@details 通过文件管理器显示多个目录
|
||||
@param[in] localFilePaths 要显示的目录路径列表
|
||||
@param[in] startupId 本次启动的id, 默认为空
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::showFolder(const QUrl &url, const QString &startupId = QString())
|
||||
@details 通过文件管理器显示目录
|
||||
@param[in] url 要显示的目录 QUrl 形式路径
|
||||
@param[in] startupId 本次启动的id, 默认为空
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::showFolders(const QList<QUrl> &urls, const QString &startupId = QString())
|
||||
@details 通过文件管理器显示多个目录
|
||||
@param[in] urls 要显示的目录路径 url 列表
|
||||
@param[in] startupId 本次启动的id, 默认为空
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::showFileItemProperty(const QString &localFilePath, const QString &startupId = QString())
|
||||
@details 通过文件管理器显示文件的属性
|
||||
@param[in] localFilePath 要显示的文件路径
|
||||
@param[in] startupId 本次启动的id, 默认为空
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::showFileItemProperties(const QList<QString> &localFilePaths, const QString &startupId = QString())
|
||||
@details 通过文件管理器显示多个文件的属性
|
||||
@param[in] localFilePaths 要显示的文件路径列表
|
||||
@param[in] startupId 本次启动的id, 默认为空
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::showFileItemProperty(const QUrl &url, const QString &startupId = QString())
|
||||
@details 通过文件管理器显示文件的属性
|
||||
@param[in] url 要显示的文件 QUrl 形式路径
|
||||
@param[in] startupId 本次启动的id, 默认为空
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::showFileItemProperties(const QList<QUrl> &urls, const QString &startupId = QString())
|
||||
@details 通过文件管理器显示多个文件的属性
|
||||
@param[in] urls 要显示的目录路径 url 列表
|
||||
@param[in] startupId 本次启动的id, 默认为空
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::showFileItem(const QString &localFilePath, const QString &startupId = QString())
|
||||
@details 通过文件管理器在父目录中显示并选中文件(目录)
|
||||
@param[in] localFilePath 要显示(选中)的文件(目录)路径
|
||||
@param[in] startupId 本次启动的id, 默认为空
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::showFileItems(const QList<QString> &localFilePaths, const QString &startupId = QString())
|
||||
@details 通过文件管理器父目录中显示并选中多个文件(目录)
|
||||
@param[in] localFilePaths 要显示(选中)的文件(目录)路径列表
|
||||
@param[in] startupId 本次启动的id, 默认为空
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::showFileItem(const QUrl &url, const QString &startupId = QString())
|
||||
@details 通过文件管理器在父目录中显示并选中文件(目录)
|
||||
@param[in] url 要显示(选中)的文件(目录)QUrl 形式路径
|
||||
@param[in] startupId 本次启动的id, 默认为空
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::showFileItems(const QList<QUrl> &urls, const QString &startupId = QString())
|
||||
@details 通过文件管理器父目录中显示并选中多个文件(目录)
|
||||
@param[in] urls 要显示选中)的文件(目录)路径 url 列表
|
||||
@param[in] startupId 本次启动的id, 默认为空
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::trash(const QString &localFilePath)
|
||||
@details 通过文件管理器将文件移入回收站
|
||||
@param[in] localFilePath 要移入回收站的文件路径
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::trash(const QList<QString> &localFilePaths)
|
||||
@details 通过文件管理器将多个文件移入回收站
|
||||
@param[in] localFilePaths 要移入回收站的文件路径列表
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::trash(const QUrl &url)
|
||||
@details 通过文件管理器将文件移入回收站
|
||||
@param[in] url 要移入回收站的文件 url 路径
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::trash(const QList<QUrl> &urls)
|
||||
@details 通过文件管理器将多个文件移入回收站
|
||||
@param[in] urls 要移入回收站的文件路径 url 列表
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::playSystemSoundEffect(const SystemSoundEffect &effect)
|
||||
@details 播放系统音效。如果系统音效被禁用或者要播放音效被禁用将播放失败
|
||||
@param[in] effect 要播放的音效,见枚举 Dtk::Gui::DDesktopServices::SystemSoundEffect
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::playSystemSoundEffect(const QString &name)
|
||||
@details 根据音效名播放系统音效。如果系统音效被禁用或者要播放音效被禁用将播放失败
|
||||
@param[in] name 要播放的音效名称,见 Dtk::Gui::DDesktopServices::getNameByEffectType
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::previewSystemSoundEffect(const SystemSoundEffect &effect)
|
||||
@details 系统音效预览。
|
||||
@param[in] effect 要播放的音效,见枚举 Dtk::Gui::DDesktopServices::SystemSoundEffect
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::previewSystemSoundEffect(const QString &name)
|
||||
@details 根据音效名预览系统音效。
|
||||
@param[in] name 要播放的音效名称,见 Dtk::Gui::DDesktopServices::getNameByEffectType
|
||||
@return 调用成功返回 true, 否则返回 false
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::getNameByEffectType(const SystemSoundEffect &effect)
|
||||
@details 根据音效名预览系统音效。
|
||||
@param[in] effect 要获取名称的音效,见枚举 Dtk::Gui::DDesktopServices::SystemSoundEffect
|
||||
@return QString effect 对应的音效名称
|
||||
|
||||
@fn Dtk::Gui::DDesktopServices::errorMessage()
|
||||
@details 文件管理器相关调用出错时可以通过此接口获取错误信息
|
||||
@return 错误信息
|
||||
|
||||
*/
|
||||
19
dtkgui.cmake
19
dtkgui.cmake
|
|
@ -18,11 +18,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||
|
||||
# Set build option
|
||||
option(DTK_DISABLE_LIBXDG "Disable libxdg" OFF)
|
||||
find_package(Qt${QT_VERSION_MAJOR}XdgIconLoader)
|
||||
if (NOT Qt${QT_VERSION_MAJOR}XdgIconLoader_FOUND)
|
||||
message(WARNING " XdgIconLoader Not Found, DISABLE LIBXDG !")
|
||||
set (DTK_DISABLE_LIBXDG ON)
|
||||
endif()
|
||||
option(DTK_DISABLE_LIBRSVG "Disable librsvg" OFF)
|
||||
option(DTK_DISABLE_EX_IMAGE_FORMAT "Disable libraw and freeimage" OFF)
|
||||
|
||||
|
|
@ -43,7 +38,6 @@ set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/Dtk${DTK_VERSION_MAJOR}Gui
|
|||
set(PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra -fopenmp")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(BUILD_TESTING ON)
|
||||
|
|
@ -121,6 +115,19 @@ find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED Core)
|
|||
find_package(DtkBuildHelper REQUIRED)
|
||||
pkg_check_modules(librsvg REQUIRED IMPORTED_TARGET librsvg-2.0)
|
||||
|
||||
if(NOT DTK_DISABLE_LIBXDG)
|
||||
# Only use libxdg under Qt5
|
||||
if (${QT_VERSION_MAJOR} STREQUAL "5")
|
||||
find_package(Qt5XdgIconLoader REQUIRED)
|
||||
if (NOT Qt5XdgIconLoader_FOUND)
|
||||
message(WARNING " XdgIconLoader Not Found, DISABLE LIBXDG !")
|
||||
set (DTK_DISABLE_LIBXDG ON)
|
||||
endif()
|
||||
else()
|
||||
set (DTK_DISABLE_LIBXDG ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Check optional image handler dependencies.
|
||||
find_package(FreeImage)
|
||||
pkg_check_modules(libraw IMPORTED_TARGET libraw)
|
||||
|
|
|
|||
|
|
@ -16,9 +16,12 @@
|
|||
#include <QMenuBar>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <DDciIcon>
|
||||
#include <DDciIconPlayer>
|
||||
#include <QDropEvent>
|
||||
#include <QMimeData>
|
||||
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
|
|
@ -46,6 +49,7 @@ public:
|
|||
IconWidget(const QString &iconName)
|
||||
{
|
||||
setCentralWidget(label = new QLabel(this));
|
||||
label->setAcceptDrops(true);
|
||||
centralWidget()->setAttribute(Qt::WA_MouseTracking);
|
||||
centralWidget()->installEventFilter(this);
|
||||
statusBar()->addWidget(message = new QLabel());
|
||||
|
|
@ -66,12 +70,21 @@ public:
|
|||
connect(disabled, &QPushButton::clicked, this, [this] {
|
||||
player.setMode(DDciIcon::Disabled);
|
||||
});
|
||||
|
||||
auto open = new QPushButton("...");
|
||||
connect(open, &QPushButton::clicked, this, [this] {
|
||||
QString dciFile = QFileDialog::getOpenFileName(this, "select a dci icon file", "", "*.dci");
|
||||
player.setIcon(DDciIcon(dciFile));
|
||||
player.setMode(DDciIcon::Normal);
|
||||
});
|
||||
|
||||
QWidget *menuWidget = new QWidget(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(menuWidget);
|
||||
layout->addWidget(normal);
|
||||
layout->addWidget(hover);
|
||||
layout->addWidget(pressed);
|
||||
layout->addWidget(disabled);
|
||||
layout->addWidget(open);
|
||||
setMenuWidget(menuWidget);
|
||||
|
||||
icon = DDciIcon::fromTheme(iconName);
|
||||
|
|
@ -112,6 +125,20 @@ private:
|
|||
player.setMode(DDciIcon::Pressed);
|
||||
} else if (event->type() == QEvent::MouseButtonRelease) {
|
||||
player.setMode(label->hasMouseTracking() ? DDciIcon::Hover : DDciIcon::Normal);
|
||||
} else if (event->type() == QEvent::DragEnter) {
|
||||
event->accept();
|
||||
} else if (event->type() == QEvent::Drop) {
|
||||
auto de = static_cast<QDropEvent *>(event);
|
||||
if (de->mimeData()->hasFormat("text/uri-list")) {
|
||||
QString uris = de->mimeData()->data("text/uri-list");
|
||||
QUrl url(uris.split("\r\n").value(0));
|
||||
|
||||
DDciIcon icon(url.path());
|
||||
if (!icon.isNull()) {
|
||||
player.setIcon(icon);
|
||||
player.setMode(DDciIcon::Normal);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
#include "ddesktopservices.h"
|
||||
|
|
@ -59,7 +59,10 @@ public:
|
|||
IsXWindowPlatform = ReadOnlyLimit << 2,
|
||||
IsTableEnvironment = ReadOnlyLimit << 3,
|
||||
IsDeepinEnvironment = ReadOnlyLimit << 4,
|
||||
IsSpecialEffectsEnvironment = ReadOnlyLimit << 5
|
||||
IsSpecialEffectsEnvironment = ReadOnlyLimit << 5,
|
||||
IsWaylandPlatform = ReadOnlyLimit << 6,
|
||||
IsTreelandPlatform Q_DECL_ENUMERATOR_DEPRECATED_X("Use DGuiApplicationHelper::IsWaylandPlatform instead") = IsWaylandPlatform,
|
||||
HasAnimations = ReadOnlyLimit << 7,
|
||||
};
|
||||
Q_ENUM(Attribute)
|
||||
Q_DECLARE_FLAGS(Attributes, Attribute)
|
||||
|
|
@ -98,6 +101,7 @@ public:
|
|||
#endif
|
||||
|
||||
DPalette applicationPalette() const;
|
||||
DPalette applicationPalette(ColorType paletteType) const;
|
||||
void setApplicationPalette(const DPalette &palette);
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
D_DECL_DEPRECATED DPalette windowPalette(QWindow *window) const;
|
||||
|
|
@ -120,6 +124,7 @@ public:
|
|||
static QStringList userManualPaths(const QString &appName);
|
||||
bool hasUserManual() const;
|
||||
|
||||
static bool loadTranslator(const QString &fileName, const QString &appName, const QList<QLocale> &localeFallback = QList<QLocale>() << QLocale::system());
|
||||
static bool loadTranslator(const QString &fileName, const QList<QString> &translateDirs, const QList<QLocale> &localeFallback);
|
||||
static bool loadTranslator(const QList<QLocale> &localeFallback = QList<QLocale>() << QLocale::system());
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class QWindow;
|
|||
QT_END_NAMESPACE
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
// TODO: class DPlatformHandle will be removed in the future
|
||||
class DPlatformHandle : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -30,6 +30,8 @@ class DPlatformHandle : public QObject
|
|||
Q_PROPERTY(int shadowRadius READ shadowRadius WRITE setShadowRadius NOTIFY shadowRadiusChanged)
|
||||
Q_PROPERTY(QPoint shadowOffset READ shadowOffset WRITE setShadowOffset NOTIFY shadowOffsetChanged)
|
||||
Q_PROPERTY(QColor shadowColor READ shadowColor WRITE setShadowColor NOTIFY shadowColorChanged)
|
||||
Q_PROPERTY(EffectScene windowEffect READ windowEffect WRITE setWindowEffect NOTIFY windowEffectChanged)
|
||||
Q_PROPERTY(EffectType windowStartUpEffect READ windowStartUpEffect WRITE setWindowStartUpEffect NOTIFY windowStartUpEffectChanged)
|
||||
Q_PROPERTY(QPainterPath clipPath READ clipPath WRITE setClipPath NOTIFY clipPathChanged)
|
||||
Q_PROPERTY(QRegion frameMask READ frameMask WRITE setFrameMask NOTIFY frameMaskChanged)
|
||||
Q_PROPERTY(QMargins frameMargins READ frameMargins NOTIFY frameMarginsChanged)
|
||||
|
|
@ -42,6 +44,7 @@ class DPlatformHandle : public QObject
|
|||
|
||||
public:
|
||||
explicit DPlatformHandle(QWindow *window, QObject *parent = 0);
|
||||
~DPlatformHandle();
|
||||
|
||||
static QString pluginVersion();
|
||||
static bool isDXcbPlatform();
|
||||
|
|
@ -72,6 +75,31 @@ public:
|
|||
PreserveAspectFit = 0x00000001
|
||||
};
|
||||
|
||||
enum EffectScene {
|
||||
EffectNoRadius = 0x01, // 取消窗口圆角
|
||||
EffectNoShadow = 0x02, // 取消窗口阴影
|
||||
EffectNoBorder = 0x04, // 取消窗口边框
|
||||
EffectNoStart = 0x10, // 取消启动场景动效
|
||||
EffectNoClose = 0x20, // 取消关闭场景动效
|
||||
EffectNoMaximize = 0x40, // 取消最大化场景动效
|
||||
EffectNoMinimize = 0x80 // 取消最小化场景动效
|
||||
};
|
||||
|
||||
enum EffectType {
|
||||
EffectNormal = 0x01, // 标准缩放动效
|
||||
EffectCursor = 0x02, // 鼠标位置展开动效
|
||||
EffectTop = 0x04, // 从上往下展开
|
||||
EffectBottom = 0x08, // 从下往上展开
|
||||
EffectOut = 0x10 // 由外向内
|
||||
};
|
||||
|
||||
Q_ENUM(EffectScene)
|
||||
Q_ENUM(EffectType)
|
||||
Q_DECLARE_FLAGS(EffectScenes, EffectScene)
|
||||
Q_DECLARE_FLAGS(EffectTypes, EffectType)
|
||||
Q_ENUM(EffectScenes)
|
||||
Q_ENUM(EffectTypes)
|
||||
|
||||
static bool setWindowBlurAreaByWM(QWindow *window, const QVector<WMBlurArea> &area);
|
||||
static bool setWindowBlurAreaByWM(QWindow *window, const QList<QPainterPath> &paths);
|
||||
static bool setWindowWallpaperParaByWM(QWindow *window, const QRect &area, WallpaperScaleMode sMode, WallpaperFillMode fMode);
|
||||
|
|
@ -92,6 +120,9 @@ public:
|
|||
QPoint shadowOffset() const;
|
||||
QColor shadowColor() const;
|
||||
|
||||
EffectScene windowEffect();
|
||||
EffectType windowStartUpEffect();
|
||||
|
||||
QPainterPath clipPath() const;
|
||||
QRegion frameMask() const;
|
||||
QMargins frameMargins() const;
|
||||
|
|
@ -107,10 +138,12 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
void setWindowRadius(int windowRadius);
|
||||
|
||||
void setBorderWidth(int borderWidth);
|
||||
void setBorderColor(const QColor &borderColor);
|
||||
|
||||
void setWindowEffect(EffectScenes effectScene);
|
||||
void setWindowStartUpEffect(EffectTypes effectType);
|
||||
|
||||
void setShadowRadius(int shadowRadius);
|
||||
void setShadowOffset(const QPoint &shadowOffset);
|
||||
void setShadowColor(const QColor &shadowColor);
|
||||
|
|
@ -132,6 +165,8 @@ Q_SIGNALS:
|
|||
void shadowRadiusChanged();
|
||||
void shadowOffsetChanged();
|
||||
void shadowColorChanged();
|
||||
void windowEffectChanged();
|
||||
void windowStartUpEffectChanged();
|
||||
void clipPathChanged();
|
||||
void frameMaskChanged();
|
||||
void translucentBackgroundChanged();
|
||||
|
|
@ -173,5 +208,7 @@ Q_DECLARE_METATYPE(QPainterPath)
|
|||
Q_DECLARE_METATYPE(QMargins)
|
||||
#endif
|
||||
Q_DECLARE_METATYPE(QRegion)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(DPlatformHandle::EffectScenes)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(DPlatformHandle::EffectTypes)
|
||||
|
||||
#endif // DPLATFORMHANDLE_H
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class DPlatformThemePrivate;
|
||||
// TODO: class DPlatformTheme will be removed in the future
|
||||
class DPlatformTheme : public DNativeSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -35,6 +36,7 @@ class DPlatformTheme : public DNativeSettings
|
|||
Q_PROPERTY(QByteArray gtkFontName READ gtkFontName WRITE setGtkFontName NOTIFY gtkFontNameChanged)
|
||||
|
||||
Q_PROPERTY(QColor activeColor READ activeColor WRITE setActiveColor NOTIFY activeColorChanged)
|
||||
Q_PROPERTY(QColor darkActiveColor READ darkActiveColor WRITE setDarkActiveColor NOTIFY darkActiveColorChanged)
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
// QPalette
|
||||
Q_PROPERTY(QColor window READ window WRITE setWindow NOTIFY windowChanged)
|
||||
|
|
@ -101,6 +103,7 @@ public:
|
|||
QByteArray gtkFontName() const;
|
||||
|
||||
QColor activeColor() const;
|
||||
QColor darkActiveColor() const;
|
||||
|
||||
bool isValidPalette() const;
|
||||
|
||||
|
|
@ -152,6 +155,7 @@ public Q_SLOTS:
|
|||
void setFontPointSize(qreal fontPointSize);
|
||||
void setGtkFontName(const QByteArray &fontName);
|
||||
void setActiveColor(const QColor activeColor);
|
||||
void setDarkActiveColor(const QColor &activeColor);
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
void setWindow(const QColor &window);
|
||||
void setWindowText(const QColor &windowText);
|
||||
|
|
@ -201,6 +205,7 @@ Q_SIGNALS:
|
|||
void fontPointSizeChanged(qreal fontPointSize);
|
||||
void gtkFontNameChanged(QByteArray fontName);
|
||||
void activeColorChanged(QColor activeColor);
|
||||
void darkActiveColorChanged(QColor activeColor);
|
||||
void paletteChanged(DPalette palette);
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
void windowChanged(QColor window);
|
||||
|
|
@ -238,9 +243,6 @@ Q_SIGNALS:
|
|||
|
||||
private:
|
||||
friend class DPlatformThemePrivate;
|
||||
|
||||
private:
|
||||
D_PRIVATE_SLOT(void _q_onThemePropertyChanged(const QByteArray &name, const QVariant &value))
|
||||
};
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <dtkgui_global.h>
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QSharedPointer>
|
||||
|
||||
DCORE_BEGIN_NAMESPACE
|
||||
class DDciFile;
|
||||
|
|
@ -76,9 +77,11 @@ public:
|
|||
Light = 0,
|
||||
Dark = 1
|
||||
};
|
||||
// IconAttibute is deprecated, please use IconAttribute instead.
|
||||
enum IconAttibute {
|
||||
HasPalette = 0x001
|
||||
};
|
||||
using IconAttribute = DDciIcon::IconAttibute;
|
||||
enum IconMatchedFlag {
|
||||
None = 0,
|
||||
DontFallbackMode = 0x01,
|
||||
|
|
@ -105,8 +108,8 @@ public:
|
|||
int actualSize(int size, Theme theme, Mode mode = Normal) const;
|
||||
|
||||
QList<int> availableSizes(Theme theme, Mode mode = Normal) const;
|
||||
bool isSupportedAttribute(DDciIconMatchResult result, IconAttibute attr) const;
|
||||
static bool isSupportedAttribute(const DDciIconImage &image, IconAttibute attr);
|
||||
bool isSupportedAttribute(DDciIconMatchResult result, IconAttribute attr) const;
|
||||
static bool isSupportedAttribute(const DDciIconImage &image, IconAttribute attr);
|
||||
|
||||
QPixmap pixmap(qreal devicePixelRatio, int iconSize, Theme theme, Mode mode = Normal,
|
||||
const DDciIconPalette &palette = DDciIconPalette()) const;
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ public:
|
|||
|
||||
QImage currentImage() const;
|
||||
void play(DDciIcon::Mode mode);
|
||||
void play(DDciIcon::Mode mode, DDciIconImagePlayer::Flags flags);
|
||||
void stop();
|
||||
void abort();
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <dtkgui_global.h>
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QUrl>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class DDesktopServices
|
||||
{
|
||||
public:
|
||||
|
||||
enum SystemSoundEffect {
|
||||
SSE_Notifications,
|
||||
SEE_Screenshot,
|
||||
SSE_EmptyTrash,
|
||||
SSE_SendFileComplete,
|
||||
SSE_BootUp,
|
||||
SSE_Shutdown,
|
||||
SSE_Logout,
|
||||
SSE_WakeUp,
|
||||
SSE_VolumeChange,
|
||||
SSE_LowBattery,
|
||||
SSE_PlugIn,
|
||||
SSE_PlugOut,
|
||||
SSE_DeviceAdded,
|
||||
SSE_DeviceRemoved,
|
||||
SSE_Error,
|
||||
};
|
||||
|
||||
static bool showFolder(const QString &localFilePath, const QString &startupId = QString());
|
||||
static bool showFolders(const QList<QString> &localFilePaths, const QString &startupId = QString());
|
||||
static bool showFolder(const QUrl &url, const QString &startupId = QString());
|
||||
static bool showFolders(const QList<QUrl> &urls, const QString &startupId = QString());
|
||||
|
||||
static bool showFileItemProperty(const QString &localFilePath, const QString &startupId = QString());
|
||||
static bool showFileItemProperties(const QList<QString> &localFilePaths, const QString &startupId = QString());
|
||||
static bool showFileItemProperty(const QUrl &url, const QString &startupId = QString());
|
||||
static bool showFileItemProperties(const QList<QUrl> &urls, const QString &startupId = QString());
|
||||
|
||||
static bool showFileItem(const QString &localFilePath, const QString &startupId = QString());
|
||||
static bool showFileItems(const QList<QString> &localFilePaths, const QString &startupId = QString());
|
||||
static bool showFileItem(const QUrl &url, const QString &startupId = QString());
|
||||
static bool showFileItems(const QList<QUrl> &urls, const QString &startupId = QString());
|
||||
|
||||
static bool trash(const QString &localFilePath);
|
||||
static bool trash(const QList<QString> &localFilePaths);
|
||||
static bool trash(const QUrl &url);
|
||||
static bool trash(const QList<QUrl> &urls);
|
||||
|
||||
static bool playSystemSoundEffect(const SystemSoundEffect &effect);
|
||||
static bool playSystemSoundEffect(const QString &name);
|
||||
static bool previewSystemSoundEffect(const SystemSoundEffect &effect);
|
||||
static bool previewSystemSoundEffect(const QString &name);
|
||||
static QString getNameByEffectType(const SystemSoundEffect &effect);
|
||||
|
||||
static QString errorMessage();
|
||||
};
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
Q_DECLARE_METATYPE(DTK_GUI_NAMESPACE::DDesktopServices::SystemSoundEffect)
|
||||
#endif
|
||||
|
||||
|
|
@ -44,6 +44,7 @@ public:
|
|||
T8,
|
||||
T9,
|
||||
T10,
|
||||
T11,
|
||||
NSizeTypes
|
||||
};
|
||||
Q_ENUM(SizeType)
|
||||
|
|
@ -110,6 +111,10 @@ public:
|
|||
{
|
||||
return get(T10);
|
||||
}
|
||||
inline const QFont t11() const
|
||||
{
|
||||
return get(T11);
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void fontChanged();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ namespace DIconTheme
|
|||
enum Option {
|
||||
DontFallbackToQIconFromTheme = 1 << 0,
|
||||
IgnoreBuiltinIcons = 1 << 1,
|
||||
IgnoreDciIcons = 1 << 2
|
||||
IgnoreDciIcons = 1 << 2,
|
||||
IgnoreIconCache = 1 << 3
|
||||
};
|
||||
Q_DECLARE_FLAGS(Options, Option)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Name: dtkgui
|
||||
Version: 5.5.17
|
||||
Version: 5.7.25
|
||||
Release: 1%{?dist}
|
||||
Summary: Deepin dtkgui
|
||||
License: LGPLv3+
|
||||
|
|
|
|||
|
|
@ -1,3 +1,14 @@
|
|||
if("${QT_VERSION_MAJOR}" STREQUAL "6")
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets WaylandClient)
|
||||
|
||||
if (${Qt6Core_VERSION} VERSION_GREATER_EQUAL "6.10.0")
|
||||
set(QT_NO_PRIVATE_MODULE_WARNING ON)
|
||||
find_package(Qt6 REQUIRED COMPONENTS CorePrivate GuiPrivate WaylandClientPrivate)
|
||||
endif()
|
||||
else()
|
||||
find_package(Qt5 REQUIRED COMPONENTS WaylandClient XkbCommonSupport)
|
||||
endif()
|
||||
|
||||
add_library(${LIB_NAME} SHARED)
|
||||
|
||||
include(dbus/dbus.cmake)
|
||||
|
|
@ -5,6 +16,7 @@ include(filedrag/dfiledrag.cmake)
|
|||
include(kernel/kernel.cmake)
|
||||
include(private/private.cmake)
|
||||
include(util/util.cmake)
|
||||
include(plugins/plugins.cmake)
|
||||
|
||||
target_sources(${LIB_NAME} PRIVATE
|
||||
${dbus_SRC}
|
||||
|
|
@ -34,9 +46,23 @@ PRIVATE
|
|||
Qt${QT_VERSION_MAJOR}::GuiPrivate
|
||||
Qt${QT_VERSION_MAJOR}::CorePrivate
|
||||
Qt${QT_VERSION_MAJOR}::DBus
|
||||
PkgConfig::librsvg
|
||||
Qt${QT_VERSION_MAJOR}::WaylandClientPrivate
|
||||
)
|
||||
|
||||
if("${QT_VERSION_MAJOR}" STREQUAL "5")
|
||||
target_link_libraries(${LIB_NAME}
|
||||
PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::XkbCommonSupportPrivate
|
||||
)
|
||||
endif()
|
||||
|
||||
if(DTK_DISABLE_LIBRSVG)
|
||||
find_package(Qt${QT_VERSION_MAJOR}Svg REQUIRED)
|
||||
target_link_libraries(${LIB_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Svg)
|
||||
else()
|
||||
target_link_libraries(${LIB_NAME} PRIVATE PkgConfig::librsvg)
|
||||
endif()
|
||||
|
||||
if(NOT DTK_DISABLE_EX_IMAGE_FORMAT AND EX_IMAGE_FORMAT_LIBS_FOUND)
|
||||
target_link_libraries(${LIB_NAME} PRIVATE
|
||||
${libraw_LIBRARIES}
|
||||
|
|
@ -79,4 +105,3 @@ set(EnableCov CACHE BOOL OFF)
|
|||
if (EnableCov)
|
||||
dtk_setup_code_coverage(${LIB_NAME})
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -24,6 +26,7 @@
|
|||
#include <QDirIterator>
|
||||
#include <QDesktopServices>
|
||||
#include <QLibraryInfo>
|
||||
#include <QTimer>
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
#include <QDBusError>
|
||||
|
|
@ -33,7 +36,6 @@
|
|||
#include <QDBusConnection>
|
||||
#include <QDBusConnectionInterface>
|
||||
#include <QProcess>
|
||||
#include <DConfig>
|
||||
#endif
|
||||
#include <QDir>
|
||||
#include <QLockFile>
|
||||
|
|
@ -57,9 +59,13 @@
|
|||
#include <qpa/qplatformtheme.h>
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "orgdeepindtkpreference.hpp"
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
class EnvReplaceGuard
|
||||
{
|
||||
|
|
@ -114,8 +120,9 @@ Q_GLOBAL_STATIC(DFontManager, _globalFM)
|
|||
|
||||
#define WINDOW_THEME_KEY "_d_platform_theme"
|
||||
|
||||
#define APP_THEME_TYPE "themeType"
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(DTK_CORE_NAMESPACE::DConfig, _d_dconfig, ("org.deepin.dtk.preference"));
|
||||
#define DTK_ANIMATIONS_ENV "D_DTK_DISABLE_ANIMATIONS"
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(OrgDeepinDTKPreference, _d_dconfig, (DTK_CORE_NAMESPACE::DConfig::globalThread(), nullptr,
|
||||
"org.deepin.dtk.preference", DTK_CORE_NAMESPACE::DSGApplication::id(), {}, false, nullptr))
|
||||
|
||||
/*!
|
||||
@private
|
||||
|
|
@ -193,6 +200,40 @@ void LoadManualServiceWorker::checkManualServiceWakeUp()
|
|||
start();
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
class Q_DECL_HIDDEN GuiApplicationEventFilter : public QObject
|
||||
{
|
||||
public:
|
||||
explicit GuiApplicationEventFilter(DGuiApplicationHelperPrivate *transmitter,
|
||||
QObject *parent = nullptr)
|
||||
: QObject(parent)
|
||||
, m_transmitter(transmitter)
|
||||
{
|
||||
}
|
||||
virtual bool eventFilter(QObject *watched, QEvent *event) override
|
||||
{
|
||||
if (watched != qApp)
|
||||
return QObject::eventFilter(watched, event);
|
||||
|
||||
switch(event->type()) {
|
||||
case QEvent::ApplicationFontChange: {
|
||||
const QFont font(qGuiApp->font());
|
||||
m_transmitter->q_func()->fontChanged(font);
|
||||
} break;
|
||||
case QEvent::ApplicationPaletteChange: {
|
||||
m_transmitter->onApplicationPaletteChanged();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
private:
|
||||
DGuiApplicationHelperPrivate *m_transmitter = nullptr;
|
||||
};
|
||||
#endif
|
||||
|
||||
HelperCreator _DGuiApplicationHelper::creator = _DGuiApplicationHelper::defaultCreator;
|
||||
Q_GLOBAL_STATIC(_DGuiApplicationHelper, _globalHelper)
|
||||
|
||||
|
|
@ -234,18 +275,15 @@ void DGuiApplicationHelperPrivate::initApplication(QGuiApplication *app)
|
|||
// 跟随application销毁
|
||||
qAddPostRoutine(staticCleanApplication);
|
||||
|
||||
q->connect(app, &QGuiApplication::paletteChanged, q, [q, this, app] {
|
||||
// 如果用户没有自定义颜色类型, 则应该通知程序的颜色类型发送变化
|
||||
if (Q_LIKELY(!isCustomPalette())) {
|
||||
Q_EMIT q->themeTypeChanged(q->toColorType(app->palette()));
|
||||
Q_EMIT q->applicationPaletteChanged();
|
||||
} else {
|
||||
qWarning() << "DGuiApplicationHelper: Don't use QGuiApplication::setPalette on DTK application.";
|
||||
}
|
||||
});
|
||||
|
||||
// 转发程序自己变化的信号
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
app->installEventFilter(new GuiApplicationEventFilter(this, app));
|
||||
#else
|
||||
q->connect(app, &QGuiApplication::fontChanged, q, &DGuiApplicationHelper::fontChanged);
|
||||
q->connect(app, &QGuiApplication::paletteChanged, q, [this] {
|
||||
onApplicationPaletteChanged();
|
||||
});
|
||||
#endif
|
||||
|
||||
if (Q_UNLIKELY(!appTheme)) { // 此时说明appTheme可能已经被初始化为了systemtheme
|
||||
if (QGuiApplicationPrivate::is_app_running) {
|
||||
|
|
@ -284,7 +322,7 @@ DPlatformTheme *DGuiApplicationHelperPrivate::initWindow(QWindow *window) const
|
|||
window->setProperty(WINDOW_THEME_KEY, QVariant::fromValue(theme));
|
||||
theme->setParent(window); // 跟随窗口销毁
|
||||
|
||||
auto onWindowThemeChanged = [window, theme, this] {
|
||||
auto onWindowThemeChanged = [window, this] {
|
||||
// 如果程序自定义了调色板, 则没有必要再关心窗口自身平台主题的变化
|
||||
// 需要注意的是, 这里的信号和事件可能会与 notifyAppThemeChanged 中的重复
|
||||
// 但是不能因此而移除这里的通知, 当窗口自身所对应的平台主题发生变化时, 这里
|
||||
|
|
@ -318,10 +356,19 @@ void DGuiApplicationHelperPrivate::_q_initApplicationTheme(bool notifyChange)
|
|||
// 监听与程序主题相关的改变
|
||||
QObject::connect(appTheme, &DPlatformTheme::themeNameChanged, app, onAppThemeChanged);
|
||||
QObject::connect(appTheme, &DPlatformTheme::paletteChanged, app, onAppThemeChanged);
|
||||
QObject::connect(appTheme, &DPlatformTheme::activeColorChanged, app, [this] {
|
||||
QTimer *timer = new QTimer(app);
|
||||
timer->setInterval(100);
|
||||
timer->setSingleShot(true);
|
||||
QObject::connect(timer, &QTimer::timeout, timer, [this] {
|
||||
if (!appPalette)
|
||||
notifyAppThemeChanged();
|
||||
});
|
||||
QObject::connect(appTheme, &DPlatformTheme::activeColorChanged, app, [timer]{
|
||||
timer->start();
|
||||
});
|
||||
QObject::connect(appTheme, &DPlatformTheme::darkActiveColorChanged, app, [timer] {
|
||||
timer->start();
|
||||
});
|
||||
|
||||
// appTheme在此之前可能由systemTheme所代替被使用,此时在创建appTheme
|
||||
// 并初始化之后,应当发送信号通知程序主题的改变
|
||||
|
|
@ -334,21 +381,40 @@ void DGuiApplicationHelperPrivate::notifyAppThemeChanged()
|
|||
{
|
||||
D_Q(DGuiApplicationHelper);
|
||||
notifyAppThemeChangedByEvent();
|
||||
// 通知主题类型发生变化, 此处可能存在误报的行为, 不过不应该对此做额外的约束
|
||||
// 此信号的行为应当等价于 applicationPaletteChanged
|
||||
Q_EMIT q->themeTypeChanged(q->themeType());
|
||||
// 通知调色板对象的改变
|
||||
Q_EMIT q->applicationPaletteChanged();
|
||||
QMetaObject::invokeMethod(q, [q] () {
|
||||
// 通知主题类型发生变化, 此处可能存在误报的行为, 不过不应该对此做额外的约束
|
||||
// 此信号的行为应当等价于 applicationPaletteChanged
|
||||
Q_EMIT q->themeTypeChanged(q->themeType());
|
||||
// 通知调色板对象的改变
|
||||
Q_EMIT q->applicationPaletteChanged();
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void DGuiApplicationHelperPrivate::notifyAppThemeChangedByEvent()
|
||||
{
|
||||
// https://github.com/qt/qtbase/commit/68a9c5fe513e147e4cffd29b50a4714813df411e
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
|
||||
QWindowSystemInterfacePrivate::ThemeChangeEvent event;
|
||||
#else
|
||||
QWindowSystemInterfacePrivate::ThemeChangeEvent event(nullptr);
|
||||
#endif
|
||||
// 此事件会促使QGuiApplication重新从QPlatformTheme中获取系统级别的QPalette.
|
||||
// 而在deepin平台下, 系统级别的QPalette来源自 \a applicationPalette()
|
||||
QGuiApplicationPrivate::processThemeChanged(&event);
|
||||
}
|
||||
|
||||
void DGuiApplicationHelperPrivate::onApplicationPaletteChanged()
|
||||
{
|
||||
D_Q(DGuiApplicationHelper);
|
||||
// 如果用户没有自定义颜色类型, 则应该通知程序的颜色类型发送变化
|
||||
if (Q_LIKELY(!isCustomPalette())) {
|
||||
Q_EMIT q->themeTypeChanged(q->toColorType(qGuiApp->palette()));
|
||||
Q_EMIT q->applicationPaletteChanged();
|
||||
} else {
|
||||
qWarning() << "DGuiApplicationHelper: Don't use QGuiApplication::setPalette on DTK application.";
|
||||
}
|
||||
}
|
||||
|
||||
bool DGuiApplicationHelperPrivate::isCustomPalette() const
|
||||
{
|
||||
return appPalette || paletteType != DGuiApplicationHelper::UnknownType;
|
||||
|
|
@ -376,8 +442,6 @@ void DGuiApplicationHelperPrivate::setPaletteType(DGuiApplicationHelper::ColorTy
|
|||
|
||||
D_Q(DGuiApplicationHelper);
|
||||
Q_EMIT q->paletteTypeChanged(paletteType);
|
||||
|
||||
_d_dconfig->setValue(APP_THEME_TYPE, paletteType);
|
||||
}
|
||||
|
||||
void DGuiApplicationHelperPrivate::initPaletteType() const
|
||||
|
|
@ -390,19 +454,19 @@ 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;
|
||||
|
||||
const_cast<DGuiApplicationHelperPrivate *>(this)->setPaletteType(DGuiApplicationHelper::ColorType(ct), emitSignal);
|
||||
};
|
||||
|
||||
applyThemeType(false);
|
||||
|
||||
QObject::connect(_d_dconfig, &DConfig::valueChanged, _d_dconfig, [applyThemeType](const QString &key){
|
||||
if (key != APP_THEME_TYPE)
|
||||
return;
|
||||
// 读取配置文件中的主题类型并立即应用
|
||||
DTK_CORE_NAMESPACE::DConfig dconfig("org.deepin.dtk.preference");
|
||||
int ct = dconfig.value("themeType", DGuiApplicationHelper::UnknownType).toInt();
|
||||
const_cast<DGuiApplicationHelperPrivate *>(this)->setPaletteType(DGuiApplicationHelper::ColorType(ct), false);
|
||||
|
||||
QObject::connect(_d_dconfig.operator ()(), &OrgDeepinDTKPreference::themeTypeChanged, _d_dconfig, [applyThemeType] {
|
||||
applyThemeType(true);
|
||||
});
|
||||
}
|
||||
|
|
@ -450,13 +514,13 @@ DGuiApplicationHelper::SizeMode DGuiApplicationHelperPrivate::fetchSizeMode(bool
|
|||
/*!
|
||||
\enum DGuiApplicationHelper::ColorType
|
||||
DGuiApplicationHelper::ColorType 定义了主题类型.
|
||||
|
||||
|
||||
\var DGuiApplicationHelper::ColorType DGuiApplicationHelper::UnknownType
|
||||
未知主题(浅色主题或深色主题)
|
||||
|
||||
|
||||
\var DGuiApplicationHelper::ColorType DGuiApplicationHelper::LightType
|
||||
浅色主题
|
||||
|
||||
|
||||
\var DGuiApplicationHelper::ColorType DGuiApplicationHelper::DarkType
|
||||
深色主题
|
||||
*/
|
||||
|
|
@ -464,28 +528,28 @@ DGuiApplicationHelper::SizeMode DGuiApplicationHelperPrivate::fetchSizeMode(bool
|
|||
/*!
|
||||
\enum DGuiApplicationHelper::Attribute
|
||||
DGuiApplicationHelper::Attribute 定义了功能属性
|
||||
|
||||
|
||||
\var DGuiApplicationHelper::Attribute DGuiApplicationHelper::UseInactiveColorGroup
|
||||
如果开启,当窗口处于Inactive状态时就会使用QPalette::Inactive的颜色,否则窗口将没有任何颜色变化。
|
||||
|
||||
|
||||
\var DGuiApplicationHelper::Attribute DGuiApplicationHelper::ColorCompositing
|
||||
是否采用半透明样式的调色板。
|
||||
|
||||
|
||||
\var DGuiApplicationHelper::Attribute DGuiApplicationHelper::ReadOnlyLimit
|
||||
区分只读枚举。
|
||||
|
||||
|
||||
\var DGuiApplicationHelper::Attribute DGuiApplicationHelper::IsDeepinPlatformTheme
|
||||
获取当前是否使用deepin的platformtheme插件,platformtheme插件可以为Qt程序提供特定的控件样式,默认使用chameleon主题。
|
||||
|
||||
|
||||
\var DGuiApplicationHelper::Attribute DGuiApplicationHelper::IsDXcbPlatform
|
||||
获取当前使用的是不是dtk的xcb窗口插件,dxcb插件提供了窗口圆角和阴影功能。
|
||||
|
||||
|
||||
\var DGuiApplicationHelper::Attribute DGuiApplicationHelper::IsXWindowPlatform
|
||||
获取当前是否运行在X11环境中。
|
||||
|
||||
|
||||
\var DGuiApplicationHelper::Attribute DGuiApplicationHelper::IsTableEnvironment
|
||||
获取当前是否运行在deepin平板环境中,检测XDG_CURRENT_DESKTOP环境变量是不是tablet结尾。
|
||||
|
||||
|
||||
\var DGuiApplicationHelper::Attribute DGuiApplicationHelper::IsDeepinEnvironment
|
||||
获取当前是否运行在deepin桌面环境中,检测XDG_CURRENT_DESKTOP环境变量是不是deepin。
|
||||
*/
|
||||
|
|
@ -713,7 +777,7 @@ static QColor dark_qpalette[QPalette::NColorRoles] {
|
|||
QColor("#282828"), //Base
|
||||
QColor("#252525"), //Window
|
||||
QColor(0, 0, 0, 0.05 * 255), //Shadow
|
||||
QColor("#0081ff"), //Highlight
|
||||
QColor("#024CCA"), //Highlight
|
||||
QColor("#F1F6FF"), //HighlightedText
|
||||
QColor("#0082fa"), //Link
|
||||
QColor("#ad4579"), //LinkVisited
|
||||
|
|
@ -729,7 +793,7 @@ static QColor light_dpalette[DPalette::NColorTypes] {
|
|||
QColor(0, 0, 0, 0.85 * 255), //TextTitle
|
||||
QColor(0, 0, 0, 0.6 * 255), //TextTips
|
||||
QColor("#FF5736"), //TextWarning
|
||||
Qt::white, //TextLively
|
||||
Qt::black, //TextLively
|
||||
QColor("#0081FF"), //LightLively
|
||||
QColor("#0081FF"), //DarkLively
|
||||
QColor(0, 0, 0, 0.05 * 255), //FrameBorder
|
||||
|
|
@ -820,9 +884,7 @@ DPalette DGuiApplicationHelper::standardPalette(DGuiApplicationHelper::ColorType
|
|||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
|
||||
if (role == QPalette::PlaceholderText) {
|
||||
// 5.15新添加此颜色 这里使用5.11的颜色保证效果与5.11对齐
|
||||
color = dcolor_list[DPalette::PlaceholderText];
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
// 处理半透明色
|
||||
|
|
@ -936,15 +998,7 @@ void DGuiApplicationHelper::generatePaletteColor(DPalette &base, QPalette::Color
|
|||
base.setBrush(QPalette::Disabled, role, window);
|
||||
base.setBrush(QPalette::Inactive, role, window);
|
||||
return;
|
||||
} else if (role == QPalette::Highlight && toColorType(base) == DarkType) {
|
||||
// 暗色模式下的高亮色亮度要降低10%,避免太突兀
|
||||
QColor highlight = base.highlight().color();
|
||||
|
||||
if (highlight.isValid()) {
|
||||
base.setColor(QPalette::Highlight, adjustColor(highlight, 0, 0, -20, 0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
generatePaletteColor_helper(base, role, type);
|
||||
}
|
||||
|
||||
|
|
@ -997,6 +1051,20 @@ void DGuiApplicationHelper::generatePalette(DPalette &base, ColorType type)
|
|||
}
|
||||
}
|
||||
|
||||
static inline QColor getActiveColor(const DPlatformTheme *theme, DGuiApplicationHelper::ColorType type)
|
||||
{
|
||||
QColor activeColor;
|
||||
if (type == DGuiApplicationHelper::DarkType) {
|
||||
activeColor = theme->darkActiveColor();
|
||||
if (!activeColor.isValid()) {
|
||||
activeColor = theme->activeColor();
|
||||
}
|
||||
} else {
|
||||
activeColor = theme->activeColor();
|
||||
}
|
||||
|
||||
return activeColor;
|
||||
}
|
||||
/*!
|
||||
\brief 获取调色板数据.
|
||||
|
||||
|
|
@ -1022,7 +1090,7 @@ DPalette DGuiApplicationHelper::fetchPalette(const DPlatformTheme *theme)
|
|||
|
||||
bool ok = false;
|
||||
base_palette = theme->fetchPalette(standardPalette(type), &ok);
|
||||
const QColor &active_color = theme->activeColor();
|
||||
const QColor &active_color = getActiveColor(theme, type);
|
||||
|
||||
if (active_color.isValid()) {
|
||||
base_palette.setColor(QPalette::Normal, QPalette::Highlight, active_color);
|
||||
|
|
@ -1162,7 +1230,7 @@ DPlatformTheme *DGuiApplicationHelper::windowTheme(QWindow *window) const
|
|||
\warning 不应该在DTK程序中使用QGuiApplication/QApplication::setPalette
|
||||
\return 应用程序调色板
|
||||
*/
|
||||
DPalette DGuiApplicationHelper::applicationPalette() const
|
||||
DPalette DGuiApplicationHelper::applicationPalette(ColorType paletteType) const
|
||||
{
|
||||
D_DC(DGuiApplicationHelper);
|
||||
|
||||
|
|
@ -1170,7 +1238,7 @@ DPalette DGuiApplicationHelper::applicationPalette() const
|
|||
return *d->appPalette;
|
||||
}
|
||||
|
||||
ColorType type = d->paletteType;
|
||||
ColorType type = paletteType;
|
||||
bool aa_setPalette = qGuiApp && qGuiApp->testAttribute(Qt::AA_SetPalette);
|
||||
// 此时appTheme可能还未初始化, 因此先使用systemTheme, 待appTheme初始化之后会
|
||||
// 通知程序调色板发生改变
|
||||
|
|
@ -1193,7 +1261,7 @@ DPalette DGuiApplicationHelper::applicationPalette() const
|
|||
// 覆盖DPalette中的的QPalette数据
|
||||
pa.QPalette::operator =(qGuiApp->palette());
|
||||
} else {
|
||||
const QColor &active_color = theme->activeColor();
|
||||
const QColor &active_color = getActiveColor(theme, type);
|
||||
|
||||
if (active_color.isValid()) {
|
||||
// 应用Active Color
|
||||
|
|
@ -1205,6 +1273,13 @@ DPalette DGuiApplicationHelper::applicationPalette() const
|
|||
return pa;
|
||||
}
|
||||
|
||||
DPalette DGuiApplicationHelper::applicationPalette() const
|
||||
{
|
||||
D_DC(DGuiApplicationHelper);
|
||||
|
||||
return applicationPalette(d->paletteType);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief DGuiApplicationHelper::setApplicationPalette.
|
||||
|
||||
|
|
@ -1268,6 +1343,11 @@ void DGuiApplicationHelper::setApplicationPalette(const DPalette &palette)
|
|||
*/
|
||||
DPalette DGuiApplicationHelper::windowPalette(QWindow *window) const
|
||||
{
|
||||
#if DTK_VERSION >= DTK_VERSION_CHECK(5, 0, 0, 0)
|
||||
Q_UNUSED(window);
|
||||
qCWarning(dgAppHelper) << "DGuiApplicationHelper::windowPalette is deprecated, please use applicationPalette instead.";
|
||||
return applicationPalette();
|
||||
#else
|
||||
D_DC(DGuiApplicationHelper);
|
||||
|
||||
// 如果程序自定义了调色版, 则不再关心窗口对应的平台主题上的设置
|
||||
|
|
@ -1282,6 +1362,7 @@ DPalette DGuiApplicationHelper::windowPalette(QWindow *window) const
|
|||
}
|
||||
|
||||
return fetchPalette(theme);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1296,6 +1377,8 @@ const DFontManager *DGuiApplicationHelper::fontManager() const
|
|||
{
|
||||
// 为对象初始化信号链接
|
||||
if (!_globalFM.exists()) {
|
||||
// fontManager's base font is update from qGuiApp.
|
||||
_globalFM->setBaseFont(qGuiApp->font());
|
||||
connect(this, &DGuiApplicationHelper::fontChanged, _globalFM, &DFontManager::setBaseFont);
|
||||
}
|
||||
|
||||
|
|
@ -1419,11 +1502,37 @@ bool DGuiApplicationHelper::setSingleInstance(const QString &key, DGuiApplicatio
|
|||
}
|
||||
|
||||
socket_key += key;
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
auto info = QFileInfo{"/proc/self/ns/pid"};
|
||||
// maybe kernel doesn't support namespace
|
||||
while (info.exists()) {
|
||||
auto pidns = QFileInfo{info.symLinkTarget()}.fileName();
|
||||
if (pidns.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
// maybe format has been changed
|
||||
auto start = pidns.indexOf('[');
|
||||
auto end = pidns.indexOf(']');
|
||||
if (start == -1 || end == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
auto num = pidns.mid(start + 1, end - start - 1);
|
||||
|
||||
// append pid namespace
|
||||
socket_key += QStringLiteral("_%1").arg(num);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
QString lockfile = socket_key;
|
||||
if (!lockfile.startsWith(QLatin1Char('/'))) {
|
||||
lockfile = QDir::cleanPath(QDir::tempPath());
|
||||
lockfile += QLatin1Char('/') + socket_key;
|
||||
}
|
||||
|
||||
lockfile += QStringLiteral(".lock");
|
||||
static QScopedPointer <QLockFile> lock(new QLockFile(lockfile));
|
||||
// 同一个进程多次调用本接口使用最后一次设置的 key
|
||||
|
|
@ -1565,6 +1674,28 @@ bool DGuiApplicationHelper::hasUserManual() const
|
|||
return userManualPaths(qApp->applicationName()).size() > 0;
|
||||
}
|
||||
|
||||
static inline QStringList translateDirs(const QString &appName)
|
||||
{
|
||||
Q_ASSERT(!appName.isEmpty());
|
||||
|
||||
QStringList dirs;
|
||||
|
||||
DCORE_USE_NAMESPACE
|
||||
//("/home/user/.local/share", "/usr/local/share", "/usr/share")
|
||||
auto dataDirs = DStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
|
||||
for (const auto &path : dataDirs) {
|
||||
DPathBuf pathBuf(path);
|
||||
dirs << (pathBuf / appName / "translations").toString();
|
||||
}
|
||||
|
||||
return dirs;
|
||||
}
|
||||
|
||||
bool DGuiApplicationHelper::loadTranslator(const QString &fileName, const QString &appName, const QList<QLocale> &localeFallback)
|
||||
{
|
||||
return loadTranslator(fileName, translateDirs(appName), localeFallback);
|
||||
}
|
||||
|
||||
bool DGuiApplicationHelper::loadTranslator(const QString &fileName, const QList<QString> &translateDirs, const QList<QLocale> &localeFallback)
|
||||
{
|
||||
DCORE_USE_NAMESPACE;
|
||||
|
|
@ -1577,40 +1708,30 @@ bool DGuiApplicationHelper::loadTranslator(const QString &fileName, const QList<
|
|||
for (auto item : defaultDirPrefix)
|
||||
dirs << item.join("translations").toString();
|
||||
|
||||
QStringList missingQmfiles;
|
||||
for (const auto &locale : localeFallback) {
|
||||
QStringList translateFilenames {QString("%1_%2").arg(fileName).arg(locale.name())};
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
auto behavior = Qt::SkipEmptyParts;
|
||||
#else
|
||||
auto behavior = QString::SkipEmptyParts;
|
||||
#endif
|
||||
const QStringList parseLocalNameList = locale.name().split("_", behavior);
|
||||
if (parseLocalNameList.length() > 0)
|
||||
translateFilenames << QString("%1_%2").arg(fileName).arg(parseLocalNameList.at(0));
|
||||
|
||||
for (const auto &translateFilename : translateFilenames) {
|
||||
for (const auto &dir : dirs) {
|
||||
DPathBuf path(dir);
|
||||
QString translatePath = (path / translateFilename).toString();
|
||||
if (QFile::exists(translatePath + ".qm")) {
|
||||
qDebug() << "load translate" << translatePath;
|
||||
auto translator = new QTranslator(qApp);
|
||||
translator->load(translatePath);
|
||||
qApp->installTranslator(translator);
|
||||
qApp->setProperty("dapp_locale", locale.name());
|
||||
return true;
|
||||
}
|
||||
for (const auto &dir : dirs) {
|
||||
auto translator = new QTranslator(qApp);
|
||||
// QTranslator::load(locale, filename, prefix, directory, suffix) automatically handles
|
||||
// locale fallback (e.g., zh_CN -> zh -> C) and file existence checking
|
||||
if (translator->load(locale, fileName, QString('_'), dir)) {
|
||||
qCDebug(dgAppHelper) << "load translate" << fileName << "for locale" << locale.name() << "from" << dir;
|
||||
qApp->installTranslator(translator);
|
||||
qApp->setProperty("dapp_locale", locale.name());
|
||||
return true;
|
||||
}
|
||||
|
||||
// fix english does not need to translation.
|
||||
if (locale.language() != QLocale::English)
|
||||
missingQmfiles << translateFilename + ".qm";
|
||||
delete translator; // Clean up if loading failed
|
||||
}
|
||||
}
|
||||
|
||||
if (missingQmfiles.size() > 0) {
|
||||
qWarning() << fileName << "can not find qm files" << missingQmfiles;
|
||||
// Collect locale names for warning message
|
||||
QStringList localeNames;
|
||||
for (const auto &locale : localeFallback) {
|
||||
if (locale.language() != QLocale::English) // English does not need translation
|
||||
localeNames << locale.name();
|
||||
}
|
||||
|
||||
if (!localeNames.isEmpty()) {
|
||||
qWarning() << fileName << "can not find qm files for locales" << localeNames;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1622,21 +1743,18 @@ bool DGuiApplicationHelper::loadTranslator(const QList<QLocale> &localeFallback)
|
|||
#else
|
||||
auto qTranslationsPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
|
||||
#endif
|
||||
loadTranslator("qt", {qTranslationsPath}, localeFallback);
|
||||
loadTranslator("qtbase", {qTranslationsPath}, localeFallback);
|
||||
|
||||
DCORE_USE_NAMESPACE
|
||||
QList<QString> translateDirs;
|
||||
auto appName = qApp->applicationName();
|
||||
//("/home/user/.local/share", "/usr/local/share", "/usr/share")
|
||||
auto dataDirs = DStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
|
||||
for (const auto &path : dataDirs) {
|
||||
DPathBuf DPathBuf(path);
|
||||
translateDirs << (DPathBuf / appName / "translations").toString();
|
||||
}
|
||||
auto qtranslateDirs = translateDirs("qt" QT_STRINGIFY(QT_VERSION_MAJOR));
|
||||
qtranslateDirs.prepend(qTranslationsPath);
|
||||
|
||||
// ${translateDir}/${appName}_${localeName}.qm
|
||||
return loadTranslator(appName, translateDirs, localeFallback);
|
||||
loadTranslator("qt", qtranslateDirs, localeFallback);
|
||||
loadTranslator("qtbase", qtranslateDirs, localeFallback);
|
||||
|
||||
auto appName = qApp->applicationName();
|
||||
|
||||
return loadTranslator(appName, appName, localeFallback);
|
||||
}
|
||||
|
||||
DGuiApplicationHelper::SizeMode DGuiApplicationHelper::sizeMode() const
|
||||
|
|
@ -1697,6 +1815,17 @@ bool DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::Attribute attri
|
|||
case IsSpecialEffectsEnvironment: {
|
||||
return qgetenv("DTK_DISABLED_SPECIAL_EFFECTS").toInt() != 1;
|
||||
}
|
||||
case IsWaylandPlatform: {
|
||||
static bool isTreeland = qApp->platformName() == QByteArrayLiteral("wayland");
|
||||
return isTreeland;
|
||||
}
|
||||
case HasAnimations: {
|
||||
static bool isDisable = qEnvironmentVariableIsSet(DTK_ANIMATIONS_ENV);
|
||||
if (isDisable)
|
||||
return false;
|
||||
|
||||
return _d_dconfig->enableDtkAnimations();
|
||||
}
|
||||
default:
|
||||
return DGuiApplicationHelperPrivate::attributes.testFlag(attribute);
|
||||
}
|
||||
|
|
@ -1736,6 +1865,8 @@ void DGuiApplicationHelper::setPaletteType(DGuiApplicationHelper::ColorType pale
|
|||
|
||||
d->initPaletteType();
|
||||
d->setPaletteType(paletteType, true);
|
||||
if (!DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::DontSaveApplicationTheme))
|
||||
_d_dconfig->setThemeType(static_cast<int>(paletteType));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -3,17 +3,33 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "dplatformtheme.h"
|
||||
#include "dguiapplicationhelper.h"
|
||||
#include "private/dplatformtheme_p.h"
|
||||
|
||||
#ifndef DTK_DISABLE_XCB
|
||||
#include "plugins/platform/xcb/dxcbplatforminterface.h"
|
||||
#endif
|
||||
#ifndef DTK_DISABLE_TREELAND
|
||||
#include "plugins/platform/treeland/dtreelandplatforminterface.h"
|
||||
#endif
|
||||
#include "private/dplatforminterface_p.h"
|
||||
#include "orgdeepindtkpreference.hpp"
|
||||
|
||||
#include <QVariant>
|
||||
#include <QTimer>
|
||||
#include <QMetaProperty>
|
||||
#include <QDebug>
|
||||
|
||||
#include <functional>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
static DPlatformInterfaceFactory::HelperCreator OutsideInterfaceCreator = nullptr;
|
||||
|
||||
void DPlatformInterfaceFactory::registerInterface(HelperCreator creator)
|
||||
{
|
||||
OutsideInterfaceCreator = creator;
|
||||
}
|
||||
|
||||
// "/deepin/palette" 为调色板属性的存储位置
|
||||
// 在x11平台下,将使用_DEEPIN_PALETTE作为存储调色板数据的窗口属性
|
||||
DPlatformThemePrivate::DPlatformThemePrivate(Dtk::Gui::DPlatformTheme *qq)
|
||||
|
|
@ -22,76 +38,6 @@ DPlatformThemePrivate::DPlatformThemePrivate(Dtk::Gui::DPlatformTheme *qq)
|
|||
|
||||
}
|
||||
|
||||
void DPlatformThemePrivate::_q_onThemePropertyChanged(const QByteArray &name, const QVariant &value)
|
||||
{
|
||||
D_Q(DPlatformTheme);
|
||||
|
||||
// 转发属性变化的信号,此信号来源可能为parent theme或“非调色板”的属性变化。
|
||||
// 使用队列的形式转发,避免多次发出同样的信号
|
||||
q->staticMetaObject.invokeMethod(q, "propertyChanged", Qt::QueuedConnection,
|
||||
Q_ARG(const QByteArray&, name), Q_ARG(const QVariant&, value));
|
||||
|
||||
if (QByteArrayLiteral("Gtk/FontName") == name) {
|
||||
Q_EMIT q->gtkFontNameChanged(value.toByteArray());
|
||||
return;
|
||||
}
|
||||
|
||||
if (name.startsWith("Qt/DPI/")) {
|
||||
const QString &screen_name = QString::fromLocal8Bit(name.mid(7));
|
||||
|
||||
if (!screen_name.isEmpty()) {
|
||||
bool ok = false;
|
||||
int dpi = value.toInt(&ok);
|
||||
|
||||
Q_EMIT q->dotsPerInchChanged(screen_name, ok ? dpi : -1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (QByteArrayLiteral("Xft/DPI") == name) {
|
||||
bool ok = false;
|
||||
int dpi = value.toInt(&ok);
|
||||
Q_EMIT q->dotsPerInchChanged(QString(), ok ? dpi : -1);
|
||||
}
|
||||
|
||||
const QByteArrayList &list = name.split('/');
|
||||
|
||||
if (list.count() != 2)
|
||||
return;
|
||||
|
||||
QByteArray pn = list.last();
|
||||
|
||||
if (pn.isEmpty())
|
||||
return;
|
||||
|
||||
// 转换首字母为小写
|
||||
pn[0] = QChar(pn.at(0)).toLower().toLatin1();
|
||||
|
||||
// 直接使用静态的meta object,防止通过metaObject函数调用到dynamic metaobject
|
||||
const QMetaObject *mo = &DPlatformTheme::staticMetaObject;
|
||||
int index = mo->indexOfProperty(pn.constData());
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
const QMetaProperty &p = mo->property(index);
|
||||
bool is_parent_signal = q->sender() != theme;
|
||||
|
||||
// 当自己的属性有效时应该忽略父主题的属性变化信号,优先以自身的属性值为准。
|
||||
if (is_parent_signal && p.read(q).isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p.hasNotifySignal()) {
|
||||
// invoke会做Q_ASSERT(mobj->cast(object))判断, DPlatformTheme的dynamic metaObject为
|
||||
// qt5platform-plugin插件的DNativeSettings. 导致崩溃.
|
||||
// invokeOnGadget与invoke代码逻辑一致, 只是少了异步支持.
|
||||
if (!p.notifySignal().invokeOnGadget(q, QGenericArgument(value.typeName(), value.constData())))
|
||||
qWarning() << "_q_onThemePropertyChanged() error when notify signal" << p.notifySignal().name();
|
||||
}
|
||||
}
|
||||
|
||||
void DPlatformThemePrivate::onQtColorChanged(QPalette::ColorRole role, const QColor &color)
|
||||
{
|
||||
if (!palette) {
|
||||
|
|
@ -142,7 +88,42 @@ DPlatformTheme::DPlatformTheme(quint32 window, QObject *parent)
|
|||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
if (OutsideInterfaceCreator) {
|
||||
d->platformInterface = OutsideInterfaceCreator(this);
|
||||
} else {
|
||||
#ifndef DTK_DISABLE_XCB
|
||||
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsXWindowPlatform)) {
|
||||
d->platformInterface = new DXCBPlatformInterface(0, this);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DTK_DISABLE_TREELAND
|
||||
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) {
|
||||
d->platformInterface = new DTreelandPlatformInterface(this);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!d->platformInterface) {
|
||||
d->platformInterface = new DPlatformInterface(this);
|
||||
}
|
||||
|
||||
d->theme = new DNativeSettings(window, QByteArray(), this);
|
||||
|
||||
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->scrollBarPolicy = static_cast<Qt::ScrollBarPolicy>(d->dtkPreferenceConfig->scrollBarPolicy());
|
||||
Q_EMIT scrollBarPolicyChanged(d->scrollBarPolicy);
|
||||
});
|
||||
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
connect(this, &DPlatformTheme::windowChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::Window, std::placeholders::_1));
|
||||
connect(this, &DPlatformTheme::windowTextChanged, std::bind(&DPlatformThemePrivate::onQtColorChanged, d, QPalette::WindowText, std::placeholders::_1));
|
||||
|
|
@ -172,8 +153,6 @@ DPlatformTheme::DPlatformTheme(quint32 window, QObject *parent)
|
|||
connect(this, &DPlatformTheme::darkLivelyChanged, std::bind(&DPlatformThemePrivate::onDtkColorChanged, d, DPalette::DarkLively, std::placeholders::_1));
|
||||
connect(this, &DPlatformTheme::frameBorderChanged, std::bind(&DPlatformThemePrivate::onDtkColorChanged, d, DPalette::FrameBorder, std::placeholders::_1));
|
||||
#endif
|
||||
connect(d->theme, SIGNAL(propertyChanged(const QByteArray &, const QVariant &)),
|
||||
this, SLOT(_q_onThemePropertyChanged(const QByteArray &, const QVariant &)));
|
||||
}
|
||||
|
||||
DPlatformTheme::DPlatformTheme(quint32 window, DPlatformTheme *parent)
|
||||
|
|
@ -194,6 +173,9 @@ DPlatformTheme::~DPlatformTheme()
|
|||
if (d->palette) {
|
||||
delete d->palette;
|
||||
}
|
||||
if (d->platformInterface) {
|
||||
delete d->platformInterface;
|
||||
}
|
||||
}
|
||||
|
||||
bool DPlatformTheme::isValid() const
|
||||
|
|
@ -298,6 +280,7 @@ DPalette DPlatformTheme::fetchPalette(const DPalette &base, bool *ok) const
|
|||
|
||||
void DPlatformTheme::setPalette(const DPalette &palette)
|
||||
{
|
||||
Q_UNUSED(palette);
|
||||
#define SET_PALETTE(Role) \
|
||||
set##Role(palette.color(QPalette::Normal, DPalette::Role))
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
|
|
@ -331,134 +314,106 @@ void DPlatformTheme::setPalette(const DPalette &palette)
|
|||
#endif
|
||||
}
|
||||
|
||||
#define FETCH_PROPERTY(Name, Function) \
|
||||
D_DC(DPlatformTheme); \
|
||||
QVariant value = d->theme->getSetting(QByteArrayLiteral(Name)); \
|
||||
if (d->fallbackProperty && !value.isValid() && d->parent) \
|
||||
return d->parent->Function(); \
|
||||
|
||||
#define FETCH_PROPERTY_WITH_ARGS(Name, Function, Args) \
|
||||
D_DC(DPlatformTheme); \
|
||||
QVariant value = d->theme->getSetting(Name); \
|
||||
if (d->fallbackProperty && !value.isValid() && d->parent) \
|
||||
return d->parent->Function(Args); \
|
||||
|
||||
int DPlatformTheme::cursorBlinkTime() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/CursorBlinkTime", cursorBlinkTime)
|
||||
|
||||
return value.toInt();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->cursorBlinkTime();
|
||||
}
|
||||
|
||||
int DPlatformTheme::cursorBlinkTimeout() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/CursorBlinkTimeout", cursorBlinkTimeout)
|
||||
|
||||
return value.toInt();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->cursorBlinkTimeout();
|
||||
}
|
||||
|
||||
bool DPlatformTheme::cursorBlink() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/CursorBlink", cursorBlink)
|
||||
|
||||
return value.toInt();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->cursorBlink();
|
||||
}
|
||||
|
||||
int DPlatformTheme::doubleClickDistance() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/DoubleClickDistance", doubleClickDistance)
|
||||
|
||||
return value.toInt();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->doubleClickDistance();
|
||||
}
|
||||
|
||||
int DPlatformTheme::doubleClickTime() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/DoubleClickTime", doubleClickTime)
|
||||
|
||||
return value.toInt();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->doubleClickTime();
|
||||
}
|
||||
|
||||
int DPlatformTheme::dndDragThreshold() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/DndDragThreshold", dndDragThreshold)
|
||||
|
||||
return value.toInt();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->dndDragThreshold();
|
||||
}
|
||||
|
||||
int DPlatformTheme::windowRadius() const
|
||||
{
|
||||
return windowRadius(-1);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->windowRadius();
|
||||
}
|
||||
|
||||
int DPlatformTheme::windowRadius(int defaultValue) const
|
||||
{
|
||||
Q_D(const DPlatformTheme);
|
||||
|
||||
QVariant value = d->theme->getSetting(QByteArrayLiteral("DTK/WindowRadius"));
|
||||
bool ok = false;
|
||||
|
||||
if (d->fallbackProperty && !value.isValid() && d->parent)
|
||||
return d->parent->windowRadius(defaultValue);
|
||||
|
||||
int radius = value.toInt(&ok);
|
||||
|
||||
return ok ? radius : defaultValue;
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->windowRadius(defaultValue);
|
||||
}
|
||||
|
||||
QByteArray DPlatformTheme::themeName() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/ThemeName", themeName)
|
||||
|
||||
return value.toByteArray();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->themeName();
|
||||
}
|
||||
|
||||
QByteArray DPlatformTheme::iconThemeName() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/IconThemeName", iconThemeName)
|
||||
|
||||
return value.toByteArray();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->iconThemeName();
|
||||
}
|
||||
|
||||
QByteArray DPlatformTheme::soundThemeName() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/SoundThemeName", soundThemeName)
|
||||
|
||||
return value.toByteArray();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->soundThemeName();
|
||||
}
|
||||
|
||||
QByteArray DPlatformTheme::fontName() const
|
||||
{
|
||||
FETCH_PROPERTY("Qt/FontName", fontName)
|
||||
|
||||
return value.toByteArray();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->fontName();
|
||||
}
|
||||
|
||||
QByteArray DPlatformTheme::monoFontName() const
|
||||
{
|
||||
FETCH_PROPERTY("Qt/MonoFontName", monoFontName)
|
||||
|
||||
return value.toByteArray();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->monoFontName();
|
||||
}
|
||||
|
||||
qreal DPlatformTheme::fontPointSize() const
|
||||
{
|
||||
FETCH_PROPERTY("Qt/FontPointSize", fontPointSize)
|
||||
|
||||
return value.toDouble();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->fontPointSize();
|
||||
}
|
||||
|
||||
QByteArray DPlatformTheme::gtkFontName() const
|
||||
{
|
||||
FETCH_PROPERTY("Gtk/FontName", gtkFontName)
|
||||
|
||||
return value.toByteArray();
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->gtkFontName();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::activeColor() const
|
||||
{
|
||||
FETCH_PROPERTY("Qt/ActiveColor", activeColor)
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->activeColor();
|
||||
}
|
||||
|
||||
return qvariant_cast<QColor>(value);
|
||||
QColor DPlatformTheme::darkActiveColor() const
|
||||
{
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->darkActiveColor();
|
||||
}
|
||||
|
||||
bool DPlatformTheme::isValidPalette() const
|
||||
|
|
@ -470,155 +425,171 @@ bool DPlatformTheme::isValidPalette() const
|
|||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
QColor DPlatformTheme::window() const
|
||||
{
|
||||
return GET_COLOR(window);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->window();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::windowText() const
|
||||
{
|
||||
return GET_COLOR(windowText);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->windowText();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::base() const
|
||||
{
|
||||
return GET_COLOR(base);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->base();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::alternateBase() const
|
||||
{
|
||||
return GET_COLOR(alternateBase);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->alternateBase();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::toolTipBase() const
|
||||
{
|
||||
return GET_COLOR(toolTipBase);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->toolTipBase();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::toolTipText() const
|
||||
{
|
||||
return GET_COLOR(toolTipText);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->toolTipText();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::text() const
|
||||
{
|
||||
return GET_COLOR(text);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->text();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::button() const
|
||||
{
|
||||
return GET_COLOR(button);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->button();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::buttonText() const
|
||||
{
|
||||
return GET_COLOR(buttonText);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->buttonText();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::brightText() const
|
||||
{
|
||||
return GET_COLOR(brightText);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->brightText();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::light() const
|
||||
{
|
||||
return GET_COLOR(light);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->light();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::midlight() const
|
||||
{
|
||||
return GET_COLOR(midlight);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->midlight();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::dark() const
|
||||
{
|
||||
return GET_COLOR(dark);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->dark();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::mid() const
|
||||
{
|
||||
return GET_COLOR(mid);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->mid();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::shadow() const
|
||||
{
|
||||
return GET_COLOR(shadow);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->shadow();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::highlight() const
|
||||
{
|
||||
return GET_COLOR(highlight);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->highlight();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::highlightedText() const
|
||||
{
|
||||
return GET_COLOR(highlightedText);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->highlightedText();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::link() const
|
||||
{
|
||||
return GET_COLOR(link);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->link();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::linkVisited() const
|
||||
{
|
||||
return GET_COLOR(linkVisited);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->linkVisited();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::itemBackground() const
|
||||
{
|
||||
return GET_COLOR(itemBackground);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->itemBackground();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::textTitle() const
|
||||
{
|
||||
return GET_COLOR(textTitle);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->textTitle();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::textTips() const
|
||||
{
|
||||
return GET_COLOR(textTips);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->textTips();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::textWarning() const
|
||||
{
|
||||
return GET_COLOR(textWarning);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->textWarning();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::textLively() const
|
||||
{
|
||||
return GET_COLOR(textLively);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->textLively();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::lightLively() const
|
||||
{
|
||||
return GET_COLOR(lightLively);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->lightLively();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::darkLively() const
|
||||
{
|
||||
return GET_COLOR(darkLively);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->darkLively();
|
||||
}
|
||||
|
||||
QColor DPlatformTheme::frameBorder() const
|
||||
{
|
||||
return GET_COLOR(frameBorder);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->frameBorder();
|
||||
}
|
||||
#endif
|
||||
|
||||
int DPlatformTheme::dotsPerInch(const QString &screenName) const
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
if (!screenName.isEmpty()) {
|
||||
FETCH_PROPERTY_WITH_ARGS("Qt/DPI/" + screenName.toLocal8Bit(), dotsPerInch, screenName);
|
||||
int dpi = value.toInt(&ok);
|
||||
|
||||
if (ok)
|
||||
return dpi;
|
||||
}
|
||||
|
||||
FETCH_PROPERTY_WITH_ARGS("Xft/DPI", dotsPerInch, screenName);
|
||||
int dpi = value.toInt(&ok);
|
||||
return ok ? dpi : -1;
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->dotsPerInch(screenName);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -628,8 +599,7 @@ int DPlatformTheme::dotsPerInch(const QString &screenName) const
|
|||
int DPlatformTheme::sizeMode() const
|
||||
{
|
||||
D_DC(DPlatformTheme);
|
||||
QVariant value = d->theme->getSetting(QByteArrayLiteral("DTK/SizeMode"));
|
||||
return value.toInt();
|
||||
return d->sizeMode;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -641,263 +611,275 @@ int DPlatformTheme::sizeMode() const
|
|||
*/
|
||||
int DPlatformTheme::scrollBarPolicy() const
|
||||
{
|
||||
FETCH_PROPERTY("Qt/ScrollBarPolicy", scrollBarPolicy)
|
||||
|
||||
return qvariant_cast<int>(value);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->scrollBarPolicy;
|
||||
}
|
||||
|
||||
void DPlatformTheme::setCursorBlinkTime(int cursorBlinkTime)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Net/CursorBlinkTime", cursorBlinkTime);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setCursorBlinkTime(cursorBlinkTime);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setCursorBlinkTimeout(int cursorBlinkTimeout)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Net/CursorBlinkTimeout", cursorBlinkTimeout);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setCursorBlinkTimeout(cursorBlinkTimeout);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setCursorBlink(bool cursorBlink)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Net/CursorBlink", cursorBlink);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setCursorBlink(cursorBlink);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setDoubleClickDistance(int doubleClickDistance)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Net/DoubleClickDistance", doubleClickDistance);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setDoubleClickDistance(doubleClickDistance);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setDoubleClickTime(int doubleClickTime)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Net/DoubleClickTime", doubleClickTime);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setDoubleClickTime(doubleClickTime);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setDndDragThreshold(int dndDragThreshold)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Net/DndDragThreshold", dndDragThreshold);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setDndDragThreshold(dndDragThreshold);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setThemeName(const QByteArray &themeName)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Net/ThemeName", themeName);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setThemeName(themeName);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setIconThemeName(const QByteArray &iconThemeName)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Net/IconThemeName", iconThemeName);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setIconThemeName(iconThemeName);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setSoundThemeName(const QByteArray &soundThemeName)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Net/SoundThemeName", soundThemeName);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setSoundThemeName(soundThemeName);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setFontName(const QByteArray &fontName)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Qt/FontName", fontName);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setFontName(fontName);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setMonoFontName(const QByteArray &monoFontName)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Qt/MonoFontName", monoFontName);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setMonoFontName(monoFontName);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setFontPointSize(qreal fontPointSize)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Qt/FontPointSize", fontPointSize);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setFontPointSize(fontPointSize);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setGtkFontName(const QByteArray &fontName)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("Gtk/FontName", fontName);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setGtkFontName(fontName);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setActiveColor(const QColor activeColor)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setActiveColor(activeColor);
|
||||
}
|
||||
|
||||
d->theme->setSetting("Qt/ActiveColor", activeColor);
|
||||
void DPlatformTheme::setDarkActiveColor(const QColor &activeColor)
|
||||
{
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setDarkActiveColor(activeColor);
|
||||
}
|
||||
|
||||
#define SET_COLOR(Role) setSetting(QByteArrayLiteral(#Role), Role)
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
void DPlatformTheme::setWindow(const QColor &window)
|
||||
{
|
||||
SET_COLOR(window);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setWindow(window);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setWindowText(const QColor &windowText)
|
||||
{
|
||||
SET_COLOR(windowText);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setWindowText(windowText);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setBase(const QColor &base)
|
||||
{
|
||||
SET_COLOR(base);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setBase(base);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setAlternateBase(const QColor &alternateBase)
|
||||
{
|
||||
SET_COLOR(alternateBase);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setAlternateBase(alternateBase);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setToolTipBase(const QColor &toolTipBase)
|
||||
{
|
||||
SET_COLOR(toolTipBase);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setToolTipBase(toolTipBase);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setToolTipText(const QColor &toolTipText)
|
||||
{
|
||||
SET_COLOR(toolTipText);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setToolTipText(toolTipText);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setText(const QColor &text)
|
||||
{
|
||||
SET_COLOR(text);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setText(text);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setButton(const QColor &button)
|
||||
{
|
||||
SET_COLOR(button);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setButton(button);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setButtonText(const QColor &buttonText)
|
||||
{
|
||||
SET_COLOR(buttonText);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setButtonText(buttonText);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setBrightText(const QColor &brightText)
|
||||
{
|
||||
SET_COLOR(brightText);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setBrightText(brightText);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setLight(const QColor &light)
|
||||
{
|
||||
SET_COLOR(light);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setLight(light);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setMidlight(const QColor &midlight)
|
||||
{
|
||||
SET_COLOR(midlight);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setMidlight(midlight);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setDark(const QColor &dark)
|
||||
{
|
||||
SET_COLOR(dark);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setDark(dark);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setMid(const QColor &mid)
|
||||
{
|
||||
SET_COLOR(mid);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setMid(mid);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setShadow(const QColor &shadow)
|
||||
{
|
||||
SET_COLOR(shadow);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setShadow(shadow);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setHighlight(const QColor &highlight)
|
||||
{
|
||||
SET_COLOR(highlight);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setHighlight(highlight);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setHighlightedText(const QColor &highlightText)
|
||||
{
|
||||
SET_COLOR(highlightText);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setHighlightedText(highlightText);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setLink(const QColor &link)
|
||||
{
|
||||
SET_COLOR(link);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setLink(link);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setLinkVisited(const QColor &linkVisited)
|
||||
{
|
||||
SET_COLOR(linkVisited);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setLinkVisited(linkVisited);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setItemBackground(const QColor &itemBackground)
|
||||
{
|
||||
SET_COLOR(itemBackground);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setItemBackground(itemBackground);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setTextTitle(const QColor &textTitle)
|
||||
{
|
||||
SET_COLOR(textTitle);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setTextTitle(textTitle);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setTextTips(const QColor &textTips)
|
||||
{
|
||||
SET_COLOR(textTips);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setTextTips(textTips);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setTextWarning(const QColor &textWarning)
|
||||
{
|
||||
SET_COLOR(textWarning);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setTextWarning(textWarning);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setTextLively(const QColor &textLively)
|
||||
{
|
||||
SET_COLOR(textLively);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setTextLively(textLively);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setLightLively(const QColor &lightLively)
|
||||
{
|
||||
SET_COLOR(lightLively);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setLightLively(lightLively);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setDarkLively(const QColor &darkLively)
|
||||
{
|
||||
SET_COLOR(darkLively);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setDarkLively(darkLively);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setFrameBorder(const QColor &frameBorder)
|
||||
{
|
||||
SET_COLOR(frameBorder);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setFrameBorder(frameBorder);
|
||||
}
|
||||
#endif
|
||||
|
||||
void DPlatformTheme::setDotsPerInch(const QString &screenName, int dpi)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
if (screenName.isEmpty()) {
|
||||
d->theme->setSetting("Xft/DPI", dpi);
|
||||
} else {
|
||||
d->theme->setSetting("Qt/DPI/" + screenName.toLocal8Bit(), dpi);
|
||||
}
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setDotsPerInch(screenName, dpi);
|
||||
}
|
||||
|
||||
void DPlatformTheme::setWindowRadius(int windowRadius)
|
||||
{
|
||||
D_D(DPlatformTheme);
|
||||
|
||||
d->theme->setSetting("DTK/WindowRadius", windowRadius);
|
||||
D_DC(DPlatformTheme);
|
||||
return d->platformInterface->setWindowRadius(windowRadius);
|
||||
}
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@
|
|||
|
||||
#include <functional>
|
||||
|
||||
#ifndef DTK_DISABLE_TREELAND
|
||||
#include "plugins/platform/treeland/dtreelandwindowmanagerhelper.h"
|
||||
#endif
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
#define DEFINE_CONST_CHAR(Name) const char _##Name[] = "_d_" #Name
|
||||
|
|
@ -111,6 +115,11 @@ public:
|
|||
mutable QList<DForeignWindow *> windowList;
|
||||
};
|
||||
|
||||
// TODO abstract an interface to adapt to various WM.
|
||||
#ifndef DTK_DISABLE_TREELAND
|
||||
Q_GLOBAL_STATIC(TreelandWindowManagerHelper, treelandWMHGlobal)
|
||||
#endif
|
||||
|
||||
class DWindowManagerHelper_ : public DWindowManagerHelper {};
|
||||
Q_GLOBAL_STATIC(DWindowManagerHelper_, wmhGlobal)
|
||||
|
||||
|
|
@ -323,6 +332,11 @@ DWindowManagerHelper::~DWindowManagerHelper()
|
|||
*/
|
||||
DWindowManagerHelper *DWindowManagerHelper::instance()
|
||||
{
|
||||
#ifndef DTK_DISABLE_TREELAND
|
||||
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) {
|
||||
return treelandWMHGlobal;
|
||||
}
|
||||
#endif
|
||||
return wmhGlobal;
|
||||
}
|
||||
|
||||
|
|
@ -519,6 +533,11 @@ void DWindowManagerHelper::popupSystemWindowMenu(const QWindow *window)
|
|||
*/
|
||||
bool DWindowManagerHelper::hasBlurWindow() const
|
||||
{
|
||||
#ifndef DTK_DISABLE_TREELAND
|
||||
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) {
|
||||
return treelandWMHGlobal->hasBlurWindow();
|
||||
}
|
||||
#endif
|
||||
return callPlatformFunction<bool, bool(*)()>(_hasBlurWindow);
|
||||
}
|
||||
|
||||
|
|
@ -528,6 +547,12 @@ bool DWindowManagerHelper::hasBlurWindow() const
|
|||
*/
|
||||
bool DWindowManagerHelper::hasComposite() const
|
||||
{
|
||||
#ifndef DTK_DISABLE_TREELAND
|
||||
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) {
|
||||
return treelandWMHGlobal->hasComposite();
|
||||
}
|
||||
#endif
|
||||
|
||||
QFunctionPointer hasComposite = Q_NULLPTR;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
|
|
@ -557,6 +582,11 @@ bool DWindowManagerHelper::hasComposite() const
|
|||
*/
|
||||
bool DWindowManagerHelper::hasNoTitlebar() const
|
||||
{
|
||||
#ifndef DTK_DISABLE_TREELAND
|
||||
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) {
|
||||
return treelandWMHGlobal->hasNoTitlebar();
|
||||
}
|
||||
#endif
|
||||
return callPlatformFunction<bool, bool(*)()>(_hasNoTitlebar);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,4 +7,5 @@ file(GLOB KERNEL_SOURCE
|
|||
set(kernel_SRC
|
||||
${KERNEL_HEADER}
|
||||
${KERNEL_SOURCE}
|
||||
${CMAKE_CURRENT_LIST_DIR}/orgdeepindtkpreference.hpp
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,751 @@
|
|||
/**
|
||||
* This file is generated by dconfig2cpp.
|
||||
* Command line arguments: ./build5/tools/dconfig2cpp/dconfig2cpp -c OrgDeepinDTKPreference /usr/share/dsg/configs/org.deepin.dtk.preference.json
|
||||
* Generation time: 2025-05-08T17:31:56
|
||||
* JSON file version: 1.0
|
||||
*
|
||||
* WARNING: DO NOT MODIFY THIS FILE MANUALLY.
|
||||
* If you need to change the content, please modify the dconfig2cpp tool.
|
||||
*/
|
||||
|
||||
#ifndef ORGDEEPINDTKPREFERENCE_H
|
||||
#define ORGDEEPINDTKPREFERENCE_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QVariant>
|
||||
#include <QPointer>
|
||||
#include <QDebug>
|
||||
#include <QAtomicPointer>
|
||||
#include <QAtomicInteger>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QProperty>
|
||||
#endif
|
||||
#include <DSGApplication>
|
||||
#include <DConfig>
|
||||
|
||||
class OrgDeepinDTKPreference : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(bool autoDisplayFeature READ autoDisplayFeature WRITE setAutoDisplayFeature NOTIFY autoDisplayFeatureChanged RESET resetAutoDisplayFeature)
|
||||
Q_PROPERTY(bool enableDtkAnimations READ enableDtkAnimations WRITE setEnableDtkAnimations NOTIFY enableDtkAnimationsChanged RESET resetEnableDtkAnimations)
|
||||
Q_PROPERTY(bool featureUpdated READ featureUpdated WRITE setFeatureUpdated NOTIFY featureUpdatedChanged RESET resetFeatureUpdated)
|
||||
Q_PROPERTY(bool keyboardsearchDisabled READ keyboardsearchDisabled WRITE setKeyboardsearchDisabled NOTIFY keyboardsearchDisabledChanged RESET resetKeyboardsearchDisabled)
|
||||
Q_PROPERTY(QString rules READ rules WRITE setRules NOTIFY rulesChanged RESET resetRules)
|
||||
Q_PROPERTY(qlonglong scrollBarPolicy READ scrollBarPolicy WRITE setScrollBarPolicy NOTIFY scrollBarPolicyChanged RESET resetScrollBarPolicy)
|
||||
Q_PROPERTY(qlonglong sizeMode READ sizeMode WRITE setSizeMode NOTIFY sizeModeChanged RESET resetSizeMode)
|
||||
Q_PROPERTY(qlonglong themeType READ themeType WRITE setThemeType NOTIFY themeTypeChanged RESET resetThemeType)
|
||||
Q_PROPERTY(qlonglong titlebarHeight READ titlebarHeight WRITE setTitlebarHeight NOTIFY titlebarHeightChanged RESET resetTitlebarHeight)
|
||||
Q_PROPERTY(bool underlineShortcut READ underlineShortcut WRITE setUnderlineShortcut NOTIFY underlineShortcutChanged RESET resetUnderlineShortcut)
|
||||
Q_CLASSINFO("DConfigKeyList", "autoDisplayFeature;enableDtkAnimations;featureUpdated;keyboardsearchDisabled;rules;scrollBarPolicy;sizeMode;themeType;titlebarHeight;underlineShortcut")
|
||||
Q_CLASSINFO("DConfigFileName", "org.deepin.dtk.preference")
|
||||
Q_CLASSINFO("DConfigFileVersion", "1.0")
|
||||
|
||||
public:
|
||||
explicit OrgDeepinDTKPreference(QThread *thread, DTK_CORE_NAMESPACE::DConfigBackend *backend,
|
||||
const QString &name, const QString &appId, const QString &subpath,
|
||||
bool isGeneric, QObject *parent)
|
||||
: QObject(nullptr) {
|
||||
if (!thread->isRunning()) {
|
||||
qWarning() << QLatin1String("Warning: The provided thread is not running.");
|
||||
}
|
||||
Q_ASSERT(QThread::currentThread() != thread);
|
||||
auto worker = new QObject();
|
||||
worker->moveToThread(thread);
|
||||
QPointer<QObject> watcher(parent);
|
||||
QMetaObject::invokeMethod(worker, [=, this]() {
|
||||
DTK_CORE_NAMESPACE::DConfig *config = nullptr;
|
||||
if (isGeneric) {
|
||||
if (backend) {
|
||||
config = DTK_CORE_NAMESPACE::DConfig::createGeneric(backend, name, subpath, nullptr);
|
||||
} else {
|
||||
config = DTK_CORE_NAMESPACE::DConfig::createGeneric(name, subpath, nullptr);
|
||||
}
|
||||
} else {
|
||||
if (backend) {
|
||||
if (appId.isNull()) {
|
||||
config = DTK_CORE_NAMESPACE::DConfig::create(backend, DTK_CORE_NAMESPACE::DSGApplication::id(),
|
||||
name, subpath, nullptr);
|
||||
} else {
|
||||
config = DTK_CORE_NAMESPACE::DConfig::create(backend, appId, name, subpath, nullptr);
|
||||
}
|
||||
} else {
|
||||
if (appId.isNull()) {
|
||||
config = DTK_CORE_NAMESPACE::DConfig::create(DTK_CORE_NAMESPACE::DSGApplication::id(),
|
||||
name, subpath, nullptr);
|
||||
} else {
|
||||
config = DTK_CORE_NAMESPACE::DConfig::create(appId, name, subpath, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!config) {
|
||||
qWarning() << QLatin1String("Failed to create DConfig instance.");
|
||||
worker->deleteLater();
|
||||
return;
|
||||
}
|
||||
config->moveToThread(QThread::currentThread());
|
||||
initializeInConfigThread(config);
|
||||
if (watcher != parent) {
|
||||
// delete this if watcher is changed to nullptr.
|
||||
deleteLater();
|
||||
} else if (!this->parent() && parent) {
|
||||
// !parent() means that parent is not changed.
|
||||
this->setParent(watcher);
|
||||
}
|
||||
worker->deleteLater();
|
||||
});
|
||||
}
|
||||
static OrgDeepinDTKPreference* create(const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
|
||||
{ return new OrgDeepinDTKPreference(thread, nullptr, QStringLiteral(u"\u006f\u0072\u0067\u002e\u0064\u0065\u0065\u0070\u0069\u006e\u002e\u0064\u0074\u006b\u002e\u0070\u0072\u0065\u0066\u0065\u0072\u0065\u006e\u0063\u0065"), appId, subpath, false, parent); }
|
||||
static OrgDeepinDTKPreference* create(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
|
||||
{ return new OrgDeepinDTKPreference(thread, backend, QStringLiteral(u"\u006f\u0072\u0067\u002e\u0064\u0065\u0065\u0070\u0069\u006e\u002e\u0064\u0074\u006b\u002e\u0070\u0072\u0065\u0066\u0065\u0072\u0065\u006e\u0063\u0065"), appId, subpath, false, parent); }
|
||||
static OrgDeepinDTKPreference* createByName(const QString &name, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
|
||||
{ return new OrgDeepinDTKPreference(thread, nullptr, name, appId, subpath, false, parent); }
|
||||
static OrgDeepinDTKPreference* createByName(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &name, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
|
||||
{ return new OrgDeepinDTKPreference(thread, backend, name, appId, subpath, false, parent); }
|
||||
static OrgDeepinDTKPreference* createGeneric(const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
|
||||
{ return new OrgDeepinDTKPreference(thread, nullptr, QStringLiteral(u"\u006f\u0072\u0067\u002e\u0064\u0065\u0065\u0070\u0069\u006e\u002e\u0064\u0074\u006b\u002e\u0070\u0072\u0065\u0066\u0065\u0072\u0065\u006e\u0063\u0065"), {}, subpath, true, parent); }
|
||||
static OrgDeepinDTKPreference* create(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
|
||||
{ return new OrgDeepinDTKPreference(thread, backend, QStringLiteral(u"\u006f\u0072\u0067\u002e\u0064\u0065\u0065\u0070\u0069\u006e\u002e\u0064\u0074\u006b\u002e\u0070\u0072\u0065\u0066\u0065\u0072\u0065\u006e\u0063\u0065"), {}, subpath, true, parent); }
|
||||
static OrgDeepinDTKPreference* createGenericByName(const QString &name, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
|
||||
{ return new OrgDeepinDTKPreference(thread, nullptr, name, {}, subpath, true, parent); }
|
||||
static OrgDeepinDTKPreference* createGenericByName(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &name, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
|
||||
{ return new OrgDeepinDTKPreference(thread, backend, name, {}, subpath, true, parent); }
|
||||
~OrgDeepinDTKPreference() {
|
||||
if (m_config.loadRelaxed()) {
|
||||
m_config.loadRelaxed()->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
Q_INVOKABLE DTK_CORE_NAMESPACE::DConfig *config() const {
|
||||
return m_config.loadRelaxed();
|
||||
}
|
||||
|
||||
Q_INVOKABLE bool isInitializeSucceed() const {
|
||||
return m_status.loadRelaxed() == static_cast<int>(Status::Succeed);
|
||||
}
|
||||
|
||||
Q_INVOKABLE bool isInitializeFailed() const {
|
||||
return m_status.loadRelaxed() == static_cast<int>(Status::Failed);
|
||||
}
|
||||
|
||||
Q_INVOKABLE bool isInitializing() const {
|
||||
return m_status.loadRelaxed() == static_cast<int>(Status::Invalid);
|
||||
}
|
||||
|
||||
Q_INVOKABLE QStringList keyList() const {
|
||||
return { QStringLiteral("autoDisplayFeature"),
|
||||
QStringLiteral("enableDtkAnimations"),
|
||||
QStringLiteral("featureUpdated"),
|
||||
QStringLiteral("keyboardsearchDisabled"),
|
||||
QStringLiteral("rules"),
|
||||
QStringLiteral("scrollBarPolicy"),
|
||||
QStringLiteral("sizeMode"),
|
||||
QStringLiteral("themeType"),
|
||||
QStringLiteral("titlebarHeight"),
|
||||
QStringLiteral("underlineShortcut")};
|
||||
}
|
||||
|
||||
Q_INVOKABLE bool isDefaultValue(const QString &key) const {
|
||||
if (key == QStringLiteral("autoDisplayFeature"))
|
||||
return autoDisplayFeatureIsDefaultValue();
|
||||
if (key == QStringLiteral("enableDtkAnimations"))
|
||||
return enableDtkAnimationsIsDefaultValue();
|
||||
if (key == QStringLiteral("featureUpdated"))
|
||||
return featureUpdatedIsDefaultValue();
|
||||
if (key == QStringLiteral("keyboardsearchDisabled"))
|
||||
return keyboardsearchDisabledIsDefaultValue();
|
||||
if (key == QStringLiteral("rules"))
|
||||
return rulesIsDefaultValue();
|
||||
if (key == QStringLiteral("scrollBarPolicy"))
|
||||
return scrollBarPolicyIsDefaultValue();
|
||||
if (key == QStringLiteral("sizeMode"))
|
||||
return sizeModeIsDefaultValue();
|
||||
if (key == QStringLiteral("themeType"))
|
||||
return themeTypeIsDefaultValue();
|
||||
if (key == QStringLiteral("titlebarHeight"))
|
||||
return titlebarHeightIsDefaultValue();
|
||||
if (key == QStringLiteral("underlineShortcut"))
|
||||
return underlineShortcutIsDefaultValue();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool autoDisplayFeature() const {
|
||||
return p_autoDisplayFeature;
|
||||
}
|
||||
void setAutoDisplayFeature(const bool &value) {
|
||||
auto oldValue = p_autoDisplayFeature;
|
||||
p_autoDisplayFeature = value;
|
||||
markPropertySet(0);
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this, value]() {
|
||||
m_config.loadRelaxed()->setValue(QStringLiteral("autoDisplayFeature"), value);
|
||||
});
|
||||
}
|
||||
if (p_autoDisplayFeature != oldValue) {
|
||||
Q_EMIT autoDisplayFeatureChanged();
|
||||
Q_EMIT valueChanged(QStringLiteral("autoDisplayFeature"), value);
|
||||
}
|
||||
}
|
||||
void resetAutoDisplayFeature() {
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this]() {
|
||||
m_config.loadRelaxed()->reset(QStringLiteral("autoDisplayFeature"));
|
||||
});
|
||||
}
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QBindable<bool> bindableAutoDisplayFeature() {
|
||||
return QBindable<bool>(this, "autoDisplayFeature");
|
||||
}
|
||||
#endif
|
||||
Q_INVOKABLE bool autoDisplayFeatureIsDefaultValue() const {
|
||||
return !testPropertySet(0);
|
||||
}
|
||||
bool enableDtkAnimations() const {
|
||||
return p_enableDtkAnimations;
|
||||
}
|
||||
void setEnableDtkAnimations(const bool &value) {
|
||||
auto oldValue = p_enableDtkAnimations;
|
||||
p_enableDtkAnimations = value;
|
||||
markPropertySet(1);
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this, value]() {
|
||||
m_config.loadRelaxed()->setValue(QStringLiteral("enableDtkAnimations"), value);
|
||||
});
|
||||
}
|
||||
if (p_enableDtkAnimations != oldValue) {
|
||||
Q_EMIT enableDtkAnimationsChanged();
|
||||
Q_EMIT valueChanged(QStringLiteral("enableDtkAnimations"), value);
|
||||
}
|
||||
}
|
||||
void resetEnableDtkAnimations() {
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this]() {
|
||||
m_config.loadRelaxed()->reset(QStringLiteral("enableDtkAnimations"));
|
||||
});
|
||||
}
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QBindable<bool> bindableEnableDtkAnimations() {
|
||||
return QBindable<bool>(this, "enableDtkAnimations");
|
||||
}
|
||||
#endif
|
||||
Q_INVOKABLE bool enableDtkAnimationsIsDefaultValue() const {
|
||||
return !testPropertySet(1);
|
||||
}
|
||||
bool featureUpdated() const {
|
||||
return p_featureUpdated;
|
||||
}
|
||||
void setFeatureUpdated(const bool &value) {
|
||||
auto oldValue = p_featureUpdated;
|
||||
p_featureUpdated = value;
|
||||
markPropertySet(2);
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this, value]() {
|
||||
m_config.loadRelaxed()->setValue(QStringLiteral("featureUpdated"), value);
|
||||
});
|
||||
}
|
||||
if (p_featureUpdated != oldValue) {
|
||||
Q_EMIT featureUpdatedChanged();
|
||||
Q_EMIT valueChanged(QStringLiteral("featureUpdated"), value);
|
||||
}
|
||||
}
|
||||
void resetFeatureUpdated() {
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this]() {
|
||||
m_config.loadRelaxed()->reset(QStringLiteral("featureUpdated"));
|
||||
});
|
||||
}
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QBindable<bool> bindableFeatureUpdated() {
|
||||
return QBindable<bool>(this, "featureUpdated");
|
||||
}
|
||||
#endif
|
||||
Q_INVOKABLE bool featureUpdatedIsDefaultValue() const {
|
||||
return !testPropertySet(2);
|
||||
}
|
||||
bool keyboardsearchDisabled() const {
|
||||
return p_keyboardsearchDisabled;
|
||||
}
|
||||
void setKeyboardsearchDisabled(const bool &value) {
|
||||
auto oldValue = p_keyboardsearchDisabled;
|
||||
p_keyboardsearchDisabled = value;
|
||||
markPropertySet(3);
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this, value]() {
|
||||
m_config.loadRelaxed()->setValue(QStringLiteral("keyboardsearchDisabled"), value);
|
||||
});
|
||||
}
|
||||
if (p_keyboardsearchDisabled != oldValue) {
|
||||
Q_EMIT keyboardsearchDisabledChanged();
|
||||
Q_EMIT valueChanged(QStringLiteral("keyboardsearchDisabled"), value);
|
||||
}
|
||||
}
|
||||
void resetKeyboardsearchDisabled() {
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this]() {
|
||||
m_config.loadRelaxed()->reset(QStringLiteral("keyboardsearchDisabled"));
|
||||
});
|
||||
}
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QBindable<bool> bindableKeyboardsearchDisabled() {
|
||||
return QBindable<bool>(this, "keyboardsearchDisabled");
|
||||
}
|
||||
#endif
|
||||
Q_INVOKABLE bool keyboardsearchDisabledIsDefaultValue() const {
|
||||
return !testPropertySet(3);
|
||||
}
|
||||
QString rules() const {
|
||||
return p_rules;
|
||||
}
|
||||
void setRules(const QString &value) {
|
||||
auto oldValue = p_rules;
|
||||
p_rules = value;
|
||||
markPropertySet(4);
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this, value]() {
|
||||
m_config.loadRelaxed()->setValue(QStringLiteral("rules"), value);
|
||||
});
|
||||
}
|
||||
if (p_rules != oldValue) {
|
||||
Q_EMIT rulesChanged();
|
||||
Q_EMIT valueChanged(QStringLiteral("rules"), value);
|
||||
}
|
||||
}
|
||||
void resetRules() {
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this]() {
|
||||
m_config.loadRelaxed()->reset(QStringLiteral("rules"));
|
||||
});
|
||||
}
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QBindable<QString> bindableRules() {
|
||||
return QBindable<QString>(this, "rules");
|
||||
}
|
||||
#endif
|
||||
Q_INVOKABLE bool rulesIsDefaultValue() const {
|
||||
return !testPropertySet(4);
|
||||
}
|
||||
qlonglong scrollBarPolicy() const {
|
||||
return p_scrollBarPolicy;
|
||||
}
|
||||
void setScrollBarPolicy(const qlonglong &value) {
|
||||
auto oldValue = p_scrollBarPolicy;
|
||||
p_scrollBarPolicy = value;
|
||||
markPropertySet(5);
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this, value]() {
|
||||
m_config.loadRelaxed()->setValue(QStringLiteral("scrollBarPolicy"), value);
|
||||
});
|
||||
}
|
||||
if (p_scrollBarPolicy != oldValue) {
|
||||
Q_EMIT scrollBarPolicyChanged();
|
||||
Q_EMIT valueChanged(QStringLiteral("scrollBarPolicy"), value);
|
||||
}
|
||||
}
|
||||
void resetScrollBarPolicy() {
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this]() {
|
||||
m_config.loadRelaxed()->reset(QStringLiteral("scrollBarPolicy"));
|
||||
});
|
||||
}
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QBindable<qlonglong> bindableScrollBarPolicy() {
|
||||
return QBindable<qlonglong>(this, "scrollBarPolicy");
|
||||
}
|
||||
#endif
|
||||
Q_INVOKABLE bool scrollBarPolicyIsDefaultValue() const {
|
||||
return !testPropertySet(5);
|
||||
}
|
||||
qlonglong sizeMode() const {
|
||||
return p_sizeMode;
|
||||
}
|
||||
void setSizeMode(const qlonglong &value) {
|
||||
auto oldValue = p_sizeMode;
|
||||
p_sizeMode = value;
|
||||
markPropertySet(6);
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this, value]() {
|
||||
m_config.loadRelaxed()->setValue(QStringLiteral("sizeMode"), value);
|
||||
});
|
||||
}
|
||||
if (p_sizeMode != oldValue) {
|
||||
Q_EMIT sizeModeChanged();
|
||||
Q_EMIT valueChanged(QStringLiteral("sizeMode"), value);
|
||||
}
|
||||
}
|
||||
void resetSizeMode() {
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this]() {
|
||||
m_config.loadRelaxed()->reset(QStringLiteral("sizeMode"));
|
||||
});
|
||||
}
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QBindable<qlonglong> bindableSizeMode() {
|
||||
return QBindable<qlonglong>(this, "sizeMode");
|
||||
}
|
||||
#endif
|
||||
Q_INVOKABLE bool sizeModeIsDefaultValue() const {
|
||||
return !testPropertySet(6);
|
||||
}
|
||||
qlonglong themeType() const {
|
||||
return p_themeType;
|
||||
}
|
||||
void setThemeType(const qlonglong &value) {
|
||||
auto oldValue = p_themeType;
|
||||
p_themeType = value;
|
||||
markPropertySet(7);
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this, value]() {
|
||||
m_config.loadRelaxed()->setValue(QStringLiteral("themeType"), value);
|
||||
});
|
||||
}
|
||||
if (p_themeType != oldValue) {
|
||||
Q_EMIT themeTypeChanged();
|
||||
Q_EMIT valueChanged(QStringLiteral("themeType"), value);
|
||||
}
|
||||
}
|
||||
void resetThemeType() {
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this]() {
|
||||
m_config.loadRelaxed()->reset(QStringLiteral("themeType"));
|
||||
});
|
||||
}
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QBindable<qlonglong> bindableThemeType() {
|
||||
return QBindable<qlonglong>(this, "themeType");
|
||||
}
|
||||
#endif
|
||||
Q_INVOKABLE bool themeTypeIsDefaultValue() const {
|
||||
return !testPropertySet(7);
|
||||
}
|
||||
qlonglong titlebarHeight() const {
|
||||
return p_titlebarHeight;
|
||||
}
|
||||
void setTitlebarHeight(const qlonglong &value) {
|
||||
auto oldValue = p_titlebarHeight;
|
||||
p_titlebarHeight = value;
|
||||
markPropertySet(8);
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this, value]() {
|
||||
m_config.loadRelaxed()->setValue(QStringLiteral("titlebarHeight"), value);
|
||||
});
|
||||
}
|
||||
if (p_titlebarHeight != oldValue) {
|
||||
Q_EMIT titlebarHeightChanged();
|
||||
Q_EMIT valueChanged(QStringLiteral("titlebarHeight"), value);
|
||||
}
|
||||
}
|
||||
void resetTitlebarHeight() {
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this]() {
|
||||
m_config.loadRelaxed()->reset(QStringLiteral("titlebarHeight"));
|
||||
});
|
||||
}
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QBindable<qlonglong> bindableTitlebarHeight() {
|
||||
return QBindable<qlonglong>(this, "titlebarHeight");
|
||||
}
|
||||
#endif
|
||||
Q_INVOKABLE bool titlebarHeightIsDefaultValue() const {
|
||||
return !testPropertySet(8);
|
||||
}
|
||||
bool underlineShortcut() const {
|
||||
return p_underlineShortcut;
|
||||
}
|
||||
void setUnderlineShortcut(const bool &value) {
|
||||
auto oldValue = p_underlineShortcut;
|
||||
p_underlineShortcut = value;
|
||||
markPropertySet(9);
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this, value]() {
|
||||
m_config.loadRelaxed()->setValue(QStringLiteral("underlineShortcut"), value);
|
||||
});
|
||||
}
|
||||
if (p_underlineShortcut != oldValue) {
|
||||
Q_EMIT underlineShortcutChanged();
|
||||
Q_EMIT valueChanged(QStringLiteral("underlineShortcut"), value);
|
||||
}
|
||||
}
|
||||
void resetUnderlineShortcut() {
|
||||
if (auto config = m_config.loadRelaxed()) {
|
||||
QMetaObject::invokeMethod(config, [this]() {
|
||||
m_config.loadRelaxed()->reset(QStringLiteral("underlineShortcut"));
|
||||
});
|
||||
}
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QBindable<bool> bindableUnderlineShortcut() {
|
||||
return QBindable<bool>(this, "underlineShortcut");
|
||||
}
|
||||
#endif
|
||||
Q_INVOKABLE bool underlineShortcutIsDefaultValue() const {
|
||||
return !testPropertySet(9);
|
||||
}
|
||||
Q_SIGNALS:
|
||||
void configInitializeFailed(DTK_CORE_NAMESPACE::DConfig *config);
|
||||
void configInitializeSucceed(DTK_CORE_NAMESPACE::DConfig *config);
|
||||
void valueChanged(const QString &key, const QVariant &value);
|
||||
|
||||
void autoDisplayFeatureChanged();
|
||||
void enableDtkAnimationsChanged();
|
||||
void featureUpdatedChanged();
|
||||
void keyboardsearchDisabledChanged();
|
||||
void rulesChanged();
|
||||
void scrollBarPolicyChanged();
|
||||
void sizeModeChanged();
|
||||
void themeTypeChanged();
|
||||
void titlebarHeightChanged();
|
||||
void underlineShortcutChanged();
|
||||
private:
|
||||
void initializeInConfigThread(DTK_CORE_NAMESPACE::DConfig *config) {
|
||||
Q_ASSERT(!m_config.loadRelaxed());
|
||||
m_config.storeRelaxed(config);
|
||||
if (!config->isValid()) {
|
||||
m_status.storeRelaxed(static_cast<int>(Status::Failed));
|
||||
Q_EMIT configInitializeFailed(config);
|
||||
return;
|
||||
}
|
||||
|
||||
if (testPropertySet(0)) {
|
||||
config->setValue(QStringLiteral("autoDisplayFeature"), QVariant::fromValue(p_autoDisplayFeature));
|
||||
} else {
|
||||
updateValue(QStringLiteral("autoDisplayFeature"), QVariant::fromValue(p_autoDisplayFeature));
|
||||
}
|
||||
if (testPropertySet(1)) {
|
||||
config->setValue(QStringLiteral("enableDtkAnimations"), QVariant::fromValue(p_enableDtkAnimations));
|
||||
} else {
|
||||
updateValue(QStringLiteral("enableDtkAnimations"), QVariant::fromValue(p_enableDtkAnimations));
|
||||
}
|
||||
if (testPropertySet(2)) {
|
||||
config->setValue(QStringLiteral("featureUpdated"), QVariant::fromValue(p_featureUpdated));
|
||||
} else {
|
||||
updateValue(QStringLiteral("featureUpdated"), QVariant::fromValue(p_featureUpdated));
|
||||
}
|
||||
if (testPropertySet(3)) {
|
||||
config->setValue(QStringLiteral("keyboardsearchDisabled"), QVariant::fromValue(p_keyboardsearchDisabled));
|
||||
} else {
|
||||
updateValue(QStringLiteral("keyboardsearchDisabled"), QVariant::fromValue(p_keyboardsearchDisabled));
|
||||
}
|
||||
if (testPropertySet(4)) {
|
||||
config->setValue(QStringLiteral("rules"), QVariant::fromValue(p_rules));
|
||||
} else {
|
||||
updateValue(QStringLiteral("rules"), QVariant::fromValue(p_rules));
|
||||
}
|
||||
if (testPropertySet(5)) {
|
||||
config->setValue(QStringLiteral("scrollBarPolicy"), QVariant::fromValue(p_scrollBarPolicy));
|
||||
} else {
|
||||
updateValue(QStringLiteral("scrollBarPolicy"), QVariant::fromValue(p_scrollBarPolicy));
|
||||
}
|
||||
if (testPropertySet(6)) {
|
||||
config->setValue(QStringLiteral("sizeMode"), QVariant::fromValue(p_sizeMode));
|
||||
} else {
|
||||
updateValue(QStringLiteral("sizeMode"), QVariant::fromValue(p_sizeMode));
|
||||
}
|
||||
if (testPropertySet(7)) {
|
||||
config->setValue(QStringLiteral("themeType"), QVariant::fromValue(p_themeType));
|
||||
} else {
|
||||
updateValue(QStringLiteral("themeType"), QVariant::fromValue(p_themeType));
|
||||
}
|
||||
if (testPropertySet(8)) {
|
||||
config->setValue(QStringLiteral("titlebarHeight"), QVariant::fromValue(p_titlebarHeight));
|
||||
} else {
|
||||
updateValue(QStringLiteral("titlebarHeight"), QVariant::fromValue(p_titlebarHeight));
|
||||
}
|
||||
if (testPropertySet(9)) {
|
||||
config->setValue(QStringLiteral("underlineShortcut"), QVariant::fromValue(p_underlineShortcut));
|
||||
} else {
|
||||
updateValue(QStringLiteral("underlineShortcut"), QVariant::fromValue(p_underlineShortcut));
|
||||
}
|
||||
|
||||
connect(config, &DTK_CORE_NAMESPACE::DConfig::valueChanged, this, [this](const QString &key) {
|
||||
updateValue(key);
|
||||
}, Qt::DirectConnection);
|
||||
|
||||
m_status.storeRelaxed(static_cast<int>(Status::Succeed));
|
||||
Q_EMIT configInitializeSucceed(config);
|
||||
}
|
||||
void updateValue(const QString &key, const QVariant &fallback = QVariant()) {
|
||||
Q_ASSERT(QThread::currentThread() == m_config.loadRelaxed()->thread());
|
||||
const QVariant &value = m_config.loadRelaxed()->value(key, fallback);
|
||||
if (key == QStringLiteral("autoDisplayFeature")) {
|
||||
markPropertySet(0, !m_config.loadRelaxed()->isDefaultValue(key));
|
||||
auto newValue = qvariant_cast<bool>(value);
|
||||
QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
|
||||
Q_ASSERT(QThread::currentThread() == this->thread());
|
||||
if (p_autoDisplayFeature != newValue) {
|
||||
p_autoDisplayFeature = newValue;
|
||||
Q_EMIT autoDisplayFeatureChanged();
|
||||
Q_EMIT valueChanged(key, value);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (key == QStringLiteral("enableDtkAnimations")) {
|
||||
markPropertySet(1, !m_config.loadRelaxed()->isDefaultValue(key));
|
||||
auto newValue = qvariant_cast<bool>(value);
|
||||
QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
|
||||
Q_ASSERT(QThread::currentThread() == this->thread());
|
||||
if (p_enableDtkAnimations != newValue) {
|
||||
p_enableDtkAnimations = newValue;
|
||||
Q_EMIT enableDtkAnimationsChanged();
|
||||
Q_EMIT valueChanged(key, value);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (key == QStringLiteral("featureUpdated")) {
|
||||
markPropertySet(2, !m_config.loadRelaxed()->isDefaultValue(key));
|
||||
auto newValue = qvariant_cast<bool>(value);
|
||||
QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
|
||||
Q_ASSERT(QThread::currentThread() == this->thread());
|
||||
if (p_featureUpdated != newValue) {
|
||||
p_featureUpdated = newValue;
|
||||
Q_EMIT featureUpdatedChanged();
|
||||
Q_EMIT valueChanged(key, value);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (key == QStringLiteral("keyboardsearchDisabled")) {
|
||||
markPropertySet(3, !m_config.loadRelaxed()->isDefaultValue(key));
|
||||
auto newValue = qvariant_cast<bool>(value);
|
||||
QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
|
||||
Q_ASSERT(QThread::currentThread() == this->thread());
|
||||
if (p_keyboardsearchDisabled != newValue) {
|
||||
p_keyboardsearchDisabled = newValue;
|
||||
Q_EMIT keyboardsearchDisabledChanged();
|
||||
Q_EMIT valueChanged(key, value);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (key == QStringLiteral("rules")) {
|
||||
markPropertySet(4, !m_config.loadRelaxed()->isDefaultValue(key));
|
||||
auto newValue = qvariant_cast<QString>(value);
|
||||
QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
|
||||
Q_ASSERT(QThread::currentThread() == this->thread());
|
||||
if (p_rules != newValue) {
|
||||
p_rules = newValue;
|
||||
Q_EMIT rulesChanged();
|
||||
Q_EMIT valueChanged(key, value);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (key == QStringLiteral("scrollBarPolicy")) {
|
||||
markPropertySet(5, !m_config.loadRelaxed()->isDefaultValue(key));
|
||||
auto newValue = qvariant_cast<qlonglong>(value);
|
||||
QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
|
||||
Q_ASSERT(QThread::currentThread() == this->thread());
|
||||
if (p_scrollBarPolicy != newValue) {
|
||||
p_scrollBarPolicy = newValue;
|
||||
Q_EMIT scrollBarPolicyChanged();
|
||||
Q_EMIT valueChanged(key, value);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (key == QStringLiteral("sizeMode")) {
|
||||
markPropertySet(6, !m_config.loadRelaxed()->isDefaultValue(key));
|
||||
auto newValue = qvariant_cast<qlonglong>(value);
|
||||
QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
|
||||
Q_ASSERT(QThread::currentThread() == this->thread());
|
||||
if (p_sizeMode != newValue) {
|
||||
p_sizeMode = newValue;
|
||||
Q_EMIT sizeModeChanged();
|
||||
Q_EMIT valueChanged(key, value);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (key == QStringLiteral("themeType")) {
|
||||
markPropertySet(7, !m_config.loadRelaxed()->isDefaultValue(key));
|
||||
auto newValue = qvariant_cast<qlonglong>(value);
|
||||
QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
|
||||
Q_ASSERT(QThread::currentThread() == this->thread());
|
||||
if (p_themeType != newValue) {
|
||||
p_themeType = newValue;
|
||||
Q_EMIT themeTypeChanged();
|
||||
Q_EMIT valueChanged(key, value);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (key == QStringLiteral("titlebarHeight")) {
|
||||
markPropertySet(8, !m_config.loadRelaxed()->isDefaultValue(key));
|
||||
auto newValue = qvariant_cast<qlonglong>(value);
|
||||
QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
|
||||
Q_ASSERT(QThread::currentThread() == this->thread());
|
||||
if (p_titlebarHeight != newValue) {
|
||||
p_titlebarHeight = newValue;
|
||||
Q_EMIT titlebarHeightChanged();
|
||||
Q_EMIT valueChanged(key, value);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (key == QStringLiteral("underlineShortcut")) {
|
||||
markPropertySet(9, !m_config.loadRelaxed()->isDefaultValue(key));
|
||||
auto newValue = qvariant_cast<bool>(value);
|
||||
QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
|
||||
Q_ASSERT(QThread::currentThread() == this->thread());
|
||||
if (p_underlineShortcut != newValue) {
|
||||
p_underlineShortcut = newValue;
|
||||
Q_EMIT underlineShortcutChanged();
|
||||
Q_EMIT valueChanged(key, value);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
inline void markPropertySet(const int index, bool on = true) {
|
||||
if (index < 32) {
|
||||
if (on)
|
||||
m_propertySetStatus0.fetchAndOrOrdered(1 << (index - 0));
|
||||
else
|
||||
m_propertySetStatus0.fetchAndAndOrdered(~(1 << (index - 0)));
|
||||
return;
|
||||
}
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
inline bool testPropertySet(const int index) const {
|
||||
if (index < 32) {
|
||||
return (m_propertySetStatus0.loadRelaxed() & (1 << (index - 0)));
|
||||
}
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
QAtomicPointer<DTK_CORE_NAMESPACE::DConfig> m_config = nullptr;
|
||||
|
||||
public:
|
||||
enum class Status {
|
||||
Invalid = 0,
|
||||
Succeed = 1,
|
||||
Failed = 2
|
||||
};
|
||||
private:
|
||||
QAtomicInteger<int> m_status = static_cast<int>(Status::Invalid);
|
||||
|
||||
bool p_autoDisplayFeature { false };
|
||||
bool p_enableDtkAnimations { false };
|
||||
bool p_featureUpdated { false };
|
||||
bool p_keyboardsearchDisabled { false };
|
||||
// Default value: ""
|
||||
QString p_rules { QLatin1String("") };
|
||||
qlonglong p_scrollBarPolicy { 0 };
|
||||
qlonglong p_sizeMode { 0 };
|
||||
qlonglong p_themeType { 0 };
|
||||
qlonglong p_titlebarHeight { -1 };
|
||||
bool p_underlineShortcut { false };
|
||||
QAtomicInteger<quint32> m_propertySetStatus0 = 0;
|
||||
};
|
||||
|
||||
#endif // ORGDEEPINDTKPREFERENCE_H
|
||||
|
|
@ -0,0 +1,480 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "dplatformtheme.h"
|
||||
#include "private/dplatforminterface_p.h"
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
DPlatformInterface::DPlatformInterface(DPlatformTheme *platformTheme)
|
||||
: m_platformTheme(platformTheme)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DPlatformInterface::~DPlatformInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int DPlatformInterface::cursorBlinkTime() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
int DPlatformInterface::cursorBlinkTimeout() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
bool DPlatformInterface::cursorBlink() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
int DPlatformInterface::doubleClickDistance() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
int DPlatformInterface::doubleClickTime() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
int DPlatformInterface::dndDragThreshold() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
int DPlatformInterface::windowRadius() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int DPlatformInterface::windowRadius(int defaultValue) const
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
QByteArray DPlatformInterface::themeName() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QByteArray DPlatformInterface::iconThemeName() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QByteArray DPlatformInterface::soundThemeName() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QByteArray DPlatformInterface::fontName() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QByteArray DPlatformInterface::monoFontName() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
qreal DPlatformInterface::fontPointSize() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QByteArray DPlatformInterface::gtkFontName() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::activeColor() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::darkActiveColor() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
QColor DPlatformInterface::window() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::windowText() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::base() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::alternateBase() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::toolTipBase() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::toolTipText() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::text() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::button() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::buttonText() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::brightText() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::light() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::midlight() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::dark() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::mid() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::shadow() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::highlight() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::highlightedText() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::link() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::linkVisited() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::itemBackground() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::textTitle() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::textTips() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::textWarning() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::textLively() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::lightLively() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::darkLively() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QColor DPlatformInterface::frameBorder() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
|
||||
int DPlatformInterface::dotsPerInch(const QString &) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
int DPlatformInterface::sizeMode() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
int DPlatformInterface::scrollBarPolicy() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformInterface::setCursorBlinkTime(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setCursorBlinkTimeout(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setCursorBlink(bool)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setDoubleClickDistance(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setDoubleClickTime(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setDndDragThreshold(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setThemeName(const QByteArray &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setIconThemeName(const QByteArray &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setSoundThemeName(const QByteArray &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setFontName(const QByteArray &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setMonoFontName(const QByteArray &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setFontPointSize(qreal)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setGtkFontName(const QByteArray &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setActiveColor(const QColor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setDarkActiveColor(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
void DPlatformInterface::setWindow(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setWindowText(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setBase(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setAlternateBase(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setToolTipBase(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setToolTipText(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setText(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setButton(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setButtonText(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setBrightText(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setLight(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setMidlight(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setDark(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setMid(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setShadow(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setHighlight(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setHighlightedText(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setLink(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setLinkVisited(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setItemBackground(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setTextTitle(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setTextTips(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setTextWarning(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setTextLively(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setLightLively(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setDarkLively(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setFrameBorder(const QColor &)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void DPlatformInterface::setDotsPerInch(const QString &, int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DPlatformInterface::setWindowRadius(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
|
@ -0,0 +1,196 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "private/dplatformwindowinterface_p.h"
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
DPlatformWindowInterface::DPlatformWindowInterface(QWindow *window, DPlatformHandle *platformHandle)
|
||||
: m_window(window)
|
||||
, m_platformHandle(platformHandle)
|
||||
{
|
||||
}
|
||||
|
||||
DPlatformWindowInterface::~DPlatformWindowInterface()
|
||||
{
|
||||
}
|
||||
|
||||
QWindow *DPlatformWindowInterface::window() const
|
||||
{
|
||||
return m_window;
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setEnabled(bool enabled)
|
||||
{
|
||||
Q_UNUSED(enabled)
|
||||
}
|
||||
|
||||
bool DPlatformWindowInterface::isEnabled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DPlatformWindowInterface::isEnabledNoTitlebar() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
bool DPlatformWindowInterface::setEnabledNoTitlebar(bool enable)
|
||||
{
|
||||
Q_UNUSED(enable)
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setDisableWindowOverrideCursor(bool disable)
|
||||
{
|
||||
Q_UNUSED(disable)
|
||||
}
|
||||
|
||||
int DPlatformWindowInterface::windowRadius() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setWindowRadius(int windowRadius)
|
||||
{
|
||||
Q_UNUSED(windowRadius)
|
||||
}
|
||||
|
||||
int DPlatformWindowInterface::borderWidth() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setBorderWidth(int borderWidth)
|
||||
{
|
||||
Q_UNUSED(borderWidth)
|
||||
}
|
||||
|
||||
QColor DPlatformWindowInterface::borderColor() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setBorderColor(const QColor &borderColor)
|
||||
{
|
||||
Q_UNUSED(borderColor)
|
||||
}
|
||||
|
||||
int DPlatformWindowInterface::shadowRadius() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setShadowRadius(int shadowRadius)
|
||||
{
|
||||
Q_UNUSED(shadowRadius)
|
||||
}
|
||||
|
||||
QPoint DPlatformWindowInterface::shadowOffset() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setShadowOffset(const QPoint &shadowOffset)
|
||||
{
|
||||
Q_UNUSED(shadowOffset)
|
||||
}
|
||||
|
||||
QColor DPlatformWindowInterface::shadowColor() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setShadowColor(const QColor &shadowColor)
|
||||
{
|
||||
Q_UNUSED(shadowColor)
|
||||
}
|
||||
|
||||
DPlatformHandle::EffectScene DPlatformWindowInterface::windowEffect()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setWindowEffect(DPlatformHandle::EffectScenes effectScene)
|
||||
{
|
||||
Q_UNUSED(effectScene)
|
||||
}
|
||||
|
||||
DPlatformHandle::EffectType DPlatformWindowInterface::windowStartUpEffect()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setWindowStartUpEffect(DPlatformHandle::EffectTypes effectType)
|
||||
{
|
||||
Q_UNUSED(effectType)
|
||||
}
|
||||
|
||||
QPainterPath DPlatformWindowInterface::clipPath() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setClipPath(const QPainterPath &clipPath)
|
||||
{
|
||||
Q_UNUSED(clipPath)
|
||||
}
|
||||
|
||||
QRegion DPlatformWindowInterface::frameMask() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setFrameMask(const QRegion &frameMask)
|
||||
{
|
||||
Q_UNUSED(frameMask)
|
||||
}
|
||||
|
||||
QMargins DPlatformWindowInterface::frameMargins() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
bool DPlatformWindowInterface::translucentBackground() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setTranslucentBackground(bool translucentBackground)
|
||||
{
|
||||
Q_UNUSED(translucentBackground)
|
||||
}
|
||||
|
||||
bool DPlatformWindowInterface::enableSystemResize() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setEnableSystemResize(bool enableSystemResize)
|
||||
{
|
||||
Q_UNUSED(enableSystemResize)
|
||||
}
|
||||
|
||||
bool DPlatformWindowInterface::enableSystemMove() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setEnableSystemMove(bool enableSystemMove)
|
||||
{
|
||||
Q_UNUSED(enableSystemMove)
|
||||
}
|
||||
|
||||
bool DPlatformWindowInterface::enableBlurWindow() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void DPlatformWindowInterface::setEnableBlurWindow(bool enableBlurWindow)
|
||||
{
|
||||
Q_UNUSED(enableBlurWindow)
|
||||
}
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(wayland_test)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(AUTOMOC_COMPILER_PREDEFINES ON)
|
||||
|
||||
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui WaylandClient)
|
||||
if(${QT_VERSION_MAJOR} STREQUAL "5")
|
||||
find_package(Qt5 REQUIRED COMPONENTS XkbCommonSupport)
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(WAYLAND_CLIENT REQUIRED wayland-client)
|
||||
|
||||
find_package(TreelandProtocols)
|
||||
set(TreelandProtocols_FOUND ${TreelandProtocols_FOUND})
|
||||
|
||||
add_executable(${PROJECT_NAME} main.cpp)
|
||||
|
||||
if("${QT_VERSION_MAJOR}" STREQUAL "6")
|
||||
qt6_generate_wayland_protocol_client_sources(${PROJECT_NAME} FILES
|
||||
${TREELAND_PROTOCOLS_DATA_DIR}/treeland-personalization-manager-v1.xml
|
||||
)
|
||||
|
||||
if (${Qt6Core_VERSION} VERSION_GREATER_EQUAL "6.10.0")
|
||||
set(QT_NO_PRIVATE_MODULE_WARNING ON)
|
||||
find_package(Qt6 REQUIRED COMPONENTS GuiPrivate CorePrivate WaylandClientPrivate)
|
||||
endif()
|
||||
else()
|
||||
# ECM setup
|
||||
include(FeatureSummary)
|
||||
find_package(ECM REQUIRED NO_MODULE)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${ECM_MODULE_PATH}")
|
||||
find_package(QtWaylandScanner)
|
||||
ecm_add_qtwayland_client_protocol(TABLET_SRCS
|
||||
PROTOCOL ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-personalization-manager-v1.xml
|
||||
BASENAME treeland-personalization-manager-v1
|
||||
)
|
||||
target_sources(${PROJECT_NAME} PRIVATE ${TABLET_SRCS})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::XkbCommonSupportPrivate
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::GuiPrivate
|
||||
Qt${QT_VERSION_MAJOR}::CorePrivate
|
||||
Qt${QT_VERSION_MAJOR}::WaylandClientPrivate
|
||||
${WAYLAND_CLIENT_LIBRARIES}
|
||||
)
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include <QtWaylandClient/QWaylandClientExtension>
|
||||
#include <QtWaylandClient/private/qwaylandsurface_p.h>
|
||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||
|
||||
#include <wayland-client-core.h>
|
||||
#include "qwayland-treeland-personalization-manager-v1.h"
|
||||
#include <qwaylandclientextension.h>
|
||||
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <private/qwaylandintegration_p.h>
|
||||
#include <private/qwaylandwindow_p.h>
|
||||
#include <private/qwaylanddisplay_p.h>
|
||||
|
||||
class PersonalizationWindowContext : public QWaylandClientExtensionTemplate<PersonalizationWindowContext>,
|
||||
public QtWayland::treeland_personalization_window_context_v1
|
||||
{
|
||||
public:
|
||||
PersonalizationWindowContext(struct ::treeland_personalization_window_context_v1 *context)
|
||||
: QWaylandClientExtensionTemplate<PersonalizationWindowContext>(1)
|
||||
, QtWayland::treeland_personalization_window_context_v1(context)
|
||||
{
|
||||
set_titlebar(enable_mode::enable_mode_disable);
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "dtreelandplatforminterface.h"
|
||||
|
||||
#include "dplatformtheme.h"
|
||||
#include "private/dplatforminterface_p.h"
|
||||
#include "personalizationwaylandclientextension.h"
|
||||
|
||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||
#include <QtWaylandClient/private/qwaylandsurface_p.h>
|
||||
#include <QWindow>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
DTreelandPlatformInterface::DTreelandPlatformInterface(DPlatformTheme *platformTheme)
|
||||
: DPlatformInterface(platformTheme)
|
||||
{
|
||||
m_manager = PersonalizationManager::instance();
|
||||
connect(m_manager, &PersonalizationManager::activeChanged, this, [this](){
|
||||
if (m_manager->isActive()) {
|
||||
initContext();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void DTreelandPlatformInterface::initContext()
|
||||
{
|
||||
if (m_appearanceContext.isNull()) {
|
||||
m_appearanceContext.reset(new PersonalizationAppearanceContext(m_manager->get_appearance_context(), this));
|
||||
}
|
||||
if (m_fontContext.isNull()) {
|
||||
m_fontContext.reset(new PersonalizationFontContext(m_manager->get_font_context(), this));
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray DTreelandPlatformInterface::iconThemeName() const
|
||||
{
|
||||
return m_iconThemeName;
|
||||
}
|
||||
|
||||
QByteArray DTreelandPlatformInterface::fontName() const
|
||||
{
|
||||
return m_fontName;
|
||||
}
|
||||
|
||||
QByteArray DTreelandPlatformInterface::monoFontName() const
|
||||
{
|
||||
return m_monoFontName;
|
||||
}
|
||||
|
||||
qreal DTreelandPlatformInterface::fontPointSize() const
|
||||
{
|
||||
return m_fontPointSize;
|
||||
}
|
||||
|
||||
QColor DTreelandPlatformInterface::activeColor() const
|
||||
{
|
||||
return m_activeColor;
|
||||
}
|
||||
|
||||
QByteArray DTreelandPlatformInterface::themeName() const
|
||||
{
|
||||
return m_themeName;
|
||||
}
|
||||
|
||||
void DTreelandPlatformInterface::setIconThemeName(const QByteArray &iconThemeName)
|
||||
{
|
||||
if (m_appearanceContext) {
|
||||
m_appearanceContext->set_icon_theme(iconThemeName);
|
||||
}
|
||||
}
|
||||
|
||||
void DTreelandPlatformInterface::setFontName(const QByteArray &fontName)
|
||||
{
|
||||
if (m_fontContext) {
|
||||
m_fontContext->set_font(fontName);
|
||||
}
|
||||
}
|
||||
|
||||
void DTreelandPlatformInterface::setMonoFontName(const QByteArray &monoFontName)
|
||||
{
|
||||
if (m_fontContext) {
|
||||
m_fontContext->set_monospace_font(monoFontName);
|
||||
}
|
||||
}
|
||||
|
||||
void DTreelandPlatformInterface::setFontPointSize(qreal fontPointSize)
|
||||
{
|
||||
if (m_fontContext) {
|
||||
m_fontContext->set_font_size(fontPointSize);
|
||||
}
|
||||
}
|
||||
|
||||
void DTreelandPlatformInterface::setActiveColor(const QColor activeColor)
|
||||
{
|
||||
if (m_appearanceContext) {
|
||||
m_appearanceContext->set_active_color(activeColor.name());
|
||||
}
|
||||
}
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#ifndef DTREELANDPLATFORMINTERFACE_H
|
||||
#define DTREELANDPLATFORMINTERFACE_H
|
||||
|
||||
#include "private/dplatforminterface_p.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QQueue>
|
||||
#include <DObject>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class DTreelandPlatformInterfacePrivate;
|
||||
class PersonalizationManager;
|
||||
class PersonalizationFontContext;
|
||||
class PersonalizationAppearanceContext;
|
||||
class PersonalizationWindowContext;
|
||||
|
||||
class DTreelandPlatformInterface : public QObject, public DPlatformInterface, public DCORE_NAMESPACE::DObject
|
||||
{
|
||||
Q_OBJECT
|
||||
friend PersonalizationFontContext;
|
||||
friend PersonalizationAppearanceContext;
|
||||
friend PersonalizationWindowContext;
|
||||
public:
|
||||
explicit DTreelandPlatformInterface(DPlatformTheme *platformTheme);
|
||||
|
||||
QByteArray iconThemeName() const override;
|
||||
QByteArray fontName() const override;
|
||||
QByteArray monoFontName() const override;
|
||||
qreal fontPointSize() const override;
|
||||
QColor activeColor() const override;
|
||||
QByteArray themeName() const override;
|
||||
|
||||
void setIconThemeName(const QByteArray &iconThemeName) override;
|
||||
void setFontName(const QByteArray &fontName) override;
|
||||
void setMonoFontName(const QByteArray &monoFontName) override;
|
||||
void setFontPointSize(qreal fontPointSize) override;
|
||||
void setActiveColor(const QColor activeColor) override;
|
||||
|
||||
private:
|
||||
void initContext();
|
||||
|
||||
private:
|
||||
PersonalizationManager *m_manager;
|
||||
QScopedPointer<PersonalizationAppearanceContext> m_appearanceContext;
|
||||
QScopedPointer<PersonalizationFontContext> m_fontContext;
|
||||
|
||||
QColor m_activeColor;
|
||||
int m_titleHeight;
|
||||
QByteArray m_fontName;
|
||||
QByteArray m_monoFontName;
|
||||
QByteArray m_iconThemeName;
|
||||
QByteArray m_cursorThemeName;
|
||||
qreal m_fontPointSize;
|
||||
int m_windowRadius;
|
||||
int m_scrollBarPolicy;
|
||||
QByteArray m_themeName;
|
||||
uint32_t m_blurOpacity;
|
||||
};
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -0,0 +1,398 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#define protected public
|
||||
#include <QWindow>
|
||||
#undef protected
|
||||
|
||||
#include "dtreelandplatformwindowinterface.h"
|
||||
|
||||
#include <QWaylandClientExtension>
|
||||
#include <QStyleHints>
|
||||
#include <private/qwaylandintegration_p.h>
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <private/qwaylandwindow_p.h>
|
||||
#include <private/qwaylandsurface_p.h>
|
||||
|
||||
#include "dvtablehook.h"
|
||||
|
||||
#include "personalizationwaylandclientextension.h"
|
||||
|
||||
DCORE_USE_NAMESPACE
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
class Q_DECL_HIDDEN MoveWindowHelper : public QObject
|
||||
{
|
||||
public:
|
||||
explicit MoveWindowHelper(QWindow *w);
|
||||
~MoveWindowHelper();
|
||||
|
||||
static QHash<const QWindow*, MoveWindowHelper*> mapped;
|
||||
|
||||
private:
|
||||
static bool windowEvent(QWindow *w, QEvent *event);
|
||||
void updateEnableSystemMoveFromProperty();
|
||||
|
||||
QWindow *m_window;
|
||||
bool m_windowMoving;
|
||||
bool m_enableSystemMove;
|
||||
};
|
||||
|
||||
QHash<const QWindow*, MoveWindowHelper*> MoveWindowHelper::mapped;
|
||||
|
||||
MoveWindowHelper::MoveWindowHelper(QWindow *window)
|
||||
: QObject(window)
|
||||
, m_window(window)
|
||||
{
|
||||
mapped[window] = this;
|
||||
updateEnableSystemMoveFromProperty();
|
||||
}
|
||||
|
||||
MoveWindowHelper::~MoveWindowHelper()
|
||||
{
|
||||
mapped.remove(static_cast<QWindow*>(parent()));
|
||||
}
|
||||
|
||||
void MoveWindowHelper::updateEnableSystemMoveFromProperty()
|
||||
{
|
||||
if (!m_window) {
|
||||
return;
|
||||
}
|
||||
const QVariant &v = m_window->property("_d_enableSystemMove");
|
||||
|
||||
m_enableSystemMove = !v.isValid() || v.toBool();
|
||||
|
||||
if (m_enableSystemMove) {
|
||||
DVtableHook::overrideVfptrFun(m_window, &QWindow::event, &MoveWindowHelper::windowEvent);
|
||||
} else if (DVtableHook::hasVtable(m_window)) {
|
||||
DVtableHook::resetVfptrFun(m_window, &QWindow::event);
|
||||
}
|
||||
}
|
||||
|
||||
bool MoveWindowHelper::windowEvent(QWindow *w, QEvent *event)
|
||||
{
|
||||
MoveWindowHelper *self = mapped.value(w);
|
||||
|
||||
if (!self)
|
||||
return DVtableHook::callOriginalFun(w, &QWindow::event, event);
|
||||
|
||||
// TODO Crashed when delete by Vtable.
|
||||
if (event->type() == QEvent::DeferredDelete) {
|
||||
DVtableHook::resetVtable(w);
|
||||
return w->event(event);
|
||||
}
|
||||
|
||||
// m_window 的 event 被 override 以后,在 windowEvent 里面获取到的 this 就成 m_window 了,
|
||||
// 而不是 DNoTitlebarWlWindowHelper,所以此处 windowEvent 改为 static 并传 self 进来
|
||||
{
|
||||
static bool isTouchDown = false;
|
||||
static QPointF touchBeginPosition;
|
||||
if (event->type() == QEvent::TouchBegin) {
|
||||
isTouchDown = true;
|
||||
}
|
||||
if (event->type() == QEvent::TouchEnd || event->type() == QEvent::MouseButtonRelease) {
|
||||
isTouchDown = false;
|
||||
}
|
||||
if (isTouchDown && event->type() == QEvent::MouseButtonPress) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
touchBeginPosition = static_cast<QMouseEvent*>(event)->globalPosition();
|
||||
#else
|
||||
touchBeginPosition = static_cast<QMouseEvent*>(event)->globalPos();
|
||||
#endif
|
||||
}
|
||||
// add some redundancy to distinguish trigger between system menu and system move
|
||||
if (event->type() == QEvent::MouseMove) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QPointF currentPos = static_cast<QMouseEvent*>(event)->globalPosition();
|
||||
#else
|
||||
QPointF currentPos = static_cast<QMouseEvent*>(event)->globalPos();
|
||||
#endif
|
||||
QPointF delta = touchBeginPosition - currentPos;
|
||||
if (delta.manhattanLength() < QGuiApplication::styleHints()->startDragDistance()) {
|
||||
return DVtableHook::callOriginalFun(w, &QWindow::event, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool is_mouse_move = event->type() == QEvent::MouseMove && static_cast<QMouseEvent*>(event)->buttons() == Qt::LeftButton;
|
||||
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
self->m_windowMoving = false;
|
||||
}
|
||||
|
||||
if (!DVtableHook::callOriginalFun(w, &QWindow::event, event))
|
||||
return false;
|
||||
|
||||
// workaround for kwin: Qt receives no release event when kwin finishes MOVE operation,
|
||||
// which makes app hang in windowMoving state. when a press happens, there's no sense of
|
||||
// keeping the moving state, we can just reset ti back to normal.
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
self->m_windowMoving = false;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (is_mouse_move && !event->isAccepted()
|
||||
&& w->geometry().contains(static_cast<QMouseEvent*>(event)->globalPosition().toPoint())) {
|
||||
#else
|
||||
if (is_mouse_move && !event->isAccepted()
|
||||
&& w->geometry().contains(static_cast<QMouseEvent*>(event)->globalPos())) {
|
||||
#endif
|
||||
if (!self->m_windowMoving && self->m_enableSystemMove) {
|
||||
self->m_windowMoving = true;
|
||||
|
||||
event->accept();
|
||||
if (w && w->handle()) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
static_cast<QPlatformWindow *>(w->handle())->startSystemMove(QCursor::pos());
|
||||
#else
|
||||
static_cast<QPlatformWindow *>(w->handle())->startSystemMove();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QMap<QWindow *, DTreeLandPlatformWindowHelper*> DTreeLandPlatformWindowHelper::windowMap;
|
||||
DTreeLandPlatformWindowHelper *DTreeLandPlatformWindowHelper::get(QWindow *window)
|
||||
{
|
||||
if (!PersonalizationManager::instance()->isSupported()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!window) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (auto helper = windowMap.value(window)) {
|
||||
return helper;
|
||||
}
|
||||
auto helper = new DTreeLandPlatformWindowHelper(window);
|
||||
windowMap[window] = helper;
|
||||
return helper;
|
||||
}
|
||||
|
||||
DTreeLandPlatformWindowHelper::DTreeLandPlatformWindowHelper(QWindow *window)
|
||||
: QObject(window)
|
||||
{
|
||||
window->installEventFilter(this);
|
||||
|
||||
if (!PersonalizationManager::instance()->isActive()) {
|
||||
qWarning() << "Personalization is not active" << window;
|
||||
connect(PersonalizationManager::instance(), &PersonalizationManager::activeChanged, this, &DTreeLandPlatformWindowHelper::onActiveChanged, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
if (window->handle()) {
|
||||
initWaylandWindow();
|
||||
}
|
||||
}
|
||||
|
||||
DTreeLandPlatformWindowHelper::~DTreeLandPlatformWindowHelper()
|
||||
{
|
||||
// see tst_qwindow.cpp tst_QWindow::qobject_castOnDestruction()
|
||||
windowMap.remove(static_cast<QWindow*>(parent()));
|
||||
}
|
||||
|
||||
bool DTreeLandPlatformWindowHelper::eventFilter(QObject *watched, QEvent *event) {
|
||||
if (event->type() == QEvent::PlatformSurface) {
|
||||
QPlatformSurfaceEvent *se = static_cast<QPlatformSurfaceEvent*>(event);
|
||||
if (se->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) {
|
||||
if (PersonalizationManager::instance()->isActive()) {
|
||||
initWaylandWindow();
|
||||
onSurfaceCreated();
|
||||
}
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void DTreeLandPlatformWindowHelper::initWaylandWindow()
|
||||
{
|
||||
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window()->handle());
|
||||
if (!waylandWindow) {
|
||||
qWarning() << "waylandWindow is nullptr!!!";
|
||||
return;
|
||||
}
|
||||
|
||||
connect(waylandWindow, &QtWaylandClient::QWaylandWindow::wlSurfaceCreated, this, &DTreeLandPlatformWindowHelper::onSurfaceCreated, Qt::UniqueConnection);
|
||||
connect(waylandWindow, &QtWaylandClient::QWaylandWindow::wlSurfaceDestroyed, this, &DTreeLandPlatformWindowHelper::onSurfaceDestroyed, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
void DTreeLandPlatformWindowHelper::onActiveChanged()
|
||||
{
|
||||
if (PersonalizationManager::instance()->isActive()) {
|
||||
qDebug() << "Personalization is actived, window" << window();
|
||||
if (window()->handle()) {
|
||||
onSurfaceCreated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DTreeLandPlatformWindowHelper::onSurfaceCreated()
|
||||
{
|
||||
if (m_isNoTitlebar) {
|
||||
doSetEnabledNoTitlebar();
|
||||
}
|
||||
if (m_radius > 0) {
|
||||
doSetWindowRadius();
|
||||
}
|
||||
if (m_isWindowBlur) {
|
||||
doSetEnabledBlurWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void DTreeLandPlatformWindowHelper::onSurfaceDestroyed()
|
||||
{
|
||||
if (m_windowContext) {
|
||||
m_windowContext->deleteLater();
|
||||
m_windowContext = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PersonalizationWindowContext *DTreeLandPlatformWindowHelper::windowContext() const
|
||||
{
|
||||
if (m_windowContext) {
|
||||
return m_windowContext;
|
||||
}
|
||||
|
||||
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window()->handle());
|
||||
if (!waylandWindow)
|
||||
return nullptr;
|
||||
|
||||
if (!waylandWindow->waylandSurface()) {
|
||||
qWarning() << "waylandSurface is nullptr!!!";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto surface = waylandWindow->waylandSurface()->object();
|
||||
if (!surface) {
|
||||
qWarning() << "wl_surface is nullptr!!!";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!m_windowContext) {
|
||||
const_cast<DTreeLandPlatformWindowHelper *>(this)->m_windowContext = new PersonalizationWindowContext(PersonalizationManager::instance()->get_window_context(surface));
|
||||
}
|
||||
|
||||
return m_windowContext;
|
||||
}
|
||||
|
||||
void DTreeLandPlatformWindowHelper::setEnabledNoTitlebar(bool enable)
|
||||
{
|
||||
m_isNoTitlebar = enable;
|
||||
doSetEnabledNoTitlebar();
|
||||
}
|
||||
void DTreeLandPlatformWindowHelper::setWindowRadius(int windowRadius)
|
||||
{
|
||||
m_radius = windowRadius;
|
||||
doSetWindowRadius();
|
||||
}
|
||||
void DTreeLandPlatformWindowHelper::setEnableBlurWindow(bool enableBlurWindow)
|
||||
{
|
||||
m_isWindowBlur = enableBlurWindow;
|
||||
doSetEnabledBlurWindow();
|
||||
}
|
||||
|
||||
void DTreeLandPlatformWindowHelper::doSetEnabledNoTitlebar()
|
||||
{
|
||||
if (auto context = windowContext()) {
|
||||
context->set_titlebar(m_isNoTitlebar ? PersonalizationWindowContext::enable_mode_disable : PersonalizationWindowContext::enable_mode_enable);
|
||||
}
|
||||
}
|
||||
|
||||
void DTreeLandPlatformWindowHelper::doSetWindowRadius()
|
||||
{
|
||||
if (auto context = windowContext()) {
|
||||
context->set_round_corner_radius(m_radius);
|
||||
}
|
||||
}
|
||||
|
||||
void DTreeLandPlatformWindowHelper::doSetEnabledBlurWindow()
|
||||
{
|
||||
if (auto context = windowContext()) {
|
||||
context->set_blend_mode(m_isWindowBlur ? PersonalizationWindowContext::blend_mode_blur : PersonalizationWindowContext::blend_mode_transparent);
|
||||
}
|
||||
}
|
||||
|
||||
DTreeLandPlatformWindowInterface::DTreeLandPlatformWindowInterface(QWindow *window, DPlatformHandle *platformHandle, QObject *parent)
|
||||
: QObject(parent)
|
||||
, DPlatformWindowInterface(window, platformHandle)
|
||||
{
|
||||
if (!MoveWindowHelper::mapped.value(window)) {
|
||||
Q_UNUSED(new MoveWindowHelper(window))
|
||||
}
|
||||
}
|
||||
|
||||
DTreeLandPlatformWindowInterface::~DTreeLandPlatformWindowInterface()
|
||||
{
|
||||
}
|
||||
|
||||
void DTreeLandPlatformWindowInterface::setEnabled(bool enabled)
|
||||
{
|
||||
if (setEnabledNoTitlebar(enabled)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool DTreeLandPlatformWindowInterface::isEnabled() const
|
||||
{
|
||||
return isEnabledNoTitlebar();
|
||||
}
|
||||
|
||||
bool DTreeLandPlatformWindowInterface::isEnabledNoTitlebar() const
|
||||
{
|
||||
return m_isNoTitlebar;
|
||||
}
|
||||
|
||||
bool DTreeLandPlatformWindowInterface::setEnabledNoTitlebar(bool enable)
|
||||
{
|
||||
if (m_isNoTitlebar == enable) {
|
||||
return true;
|
||||
}
|
||||
m_isNoTitlebar = enable;
|
||||
if (auto helper = DTreeLandPlatformWindowHelper::get(m_window)) {
|
||||
helper->setEnabledNoTitlebar(enable);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int DTreeLandPlatformWindowInterface::windowRadius() const
|
||||
{
|
||||
return m_radius;
|
||||
}
|
||||
|
||||
void DTreeLandPlatformWindowInterface::setWindowRadius(int windowRadius)
|
||||
{
|
||||
if (m_radius == windowRadius) {
|
||||
return;
|
||||
}
|
||||
m_radius = windowRadius;
|
||||
if (auto helper = DTreeLandPlatformWindowHelper::get(m_window)) {
|
||||
helper->setWindowRadius(m_radius);
|
||||
}
|
||||
if (m_platformHandle) {
|
||||
Q_EMIT m_platformHandle->windowRadiusChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool DTreeLandPlatformWindowInterface::enableBlurWindow() const
|
||||
{
|
||||
return m_isWindowBlur;
|
||||
}
|
||||
|
||||
void DTreeLandPlatformWindowInterface::setEnableBlurWindow(bool enable)
|
||||
{
|
||||
if (m_isWindowBlur == enable) {
|
||||
return;
|
||||
}
|
||||
m_isWindowBlur = enable;
|
||||
if (auto helper = DTreeLandPlatformWindowHelper::get(m_window)) {
|
||||
helper->setEnableBlurWindow(enable);
|
||||
}
|
||||
if (m_platformHandle) {
|
||||
Q_EMIT m_platformHandle->enableBlurWindowChanged();
|
||||
}
|
||||
}
|
||||
DGUI_END_NAMESPACE
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#ifndef DTREELANDPLATFORMWINDOWINTERFACE_H
|
||||
#define DTREELANDPLATFORMWINDOWINTERFACE_H
|
||||
|
||||
#include "dtkgui_global.h"
|
||||
#include "dtreelandplatforminterface.h"
|
||||
#include <QObject>
|
||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||
#include "private/dplatformwindowinterface_p.h"
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
class PersonalizationWindowContext;
|
||||
class DTreeLandPlatformWindowHelper : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static DTreeLandPlatformWindowHelper *get(QWindow *window);
|
||||
~DTreeLandPlatformWindowHelper() override;
|
||||
|
||||
QWindow *window() const { return qobject_cast<QWindow *>(parent()); }
|
||||
PersonalizationWindowContext *windowContext() const;
|
||||
|
||||
void setEnabledNoTitlebar(bool enable);
|
||||
void setWindowRadius(int windowRadius);
|
||||
void setEnableBlurWindow(bool enableBlurWindow);
|
||||
|
||||
private slots:
|
||||
void onActiveChanged();
|
||||
void onSurfaceCreated();
|
||||
void onSurfaceDestroyed();
|
||||
private:
|
||||
explicit DTreeLandPlatformWindowHelper(QWindow *window);
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
void initWaylandWindow();
|
||||
|
||||
void doSetEnabledNoTitlebar();
|
||||
void doSetWindowRadius();
|
||||
void doSetEnabledBlurWindow();
|
||||
private:
|
||||
PersonalizationWindowContext *m_windowContext = nullptr;
|
||||
static QMap<QWindow *, DTreeLandPlatformWindowHelper*> windowMap;
|
||||
|
||||
bool m_isNoTitlebar = false;
|
||||
bool m_isWindowBlur = false;
|
||||
int m_radius = 0;
|
||||
};
|
||||
|
||||
class DTreeLandPlatformWindowInterface : public QObject, public DPlatformWindowInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DTreeLandPlatformWindowInterface(QWindow *window, DPlatformHandle *platformHandle, QObject *parent = nullptr);
|
||||
~DTreeLandPlatformWindowInterface() override;
|
||||
|
||||
void setEnabled(bool enabled) override;
|
||||
bool isEnabled() const override;
|
||||
|
||||
bool isEnabledNoTitlebar() const override;
|
||||
bool setEnabledNoTitlebar(bool enable) override;
|
||||
|
||||
int windowRadius() const override;
|
||||
void setWindowRadius(int windowRadius) override;
|
||||
|
||||
bool enableBlurWindow() const override;
|
||||
void setEnableBlurWindow(bool enableBlurWindow) override;
|
||||
|
||||
private:
|
||||
bool m_isNoTitlebar = false;
|
||||
bool m_isWindowBlur = false;
|
||||
int m_radius = 0;
|
||||
};
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
#endif // DTREELANDPLATFORMWINDOWINTERFACE_H
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "dtreelandwindowmanagerhelper.h"
|
||||
#include "personalizationwaylandclientextension.h"
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
TreelandWindowManagerHelper::TreelandWindowManagerHelper(QObject *parent)
|
||||
: DWindowManagerHelper(parent)
|
||||
{
|
||||
connect(PersonalizationManager::instance(), &PersonalizationManager::activeChanged, this, [this](){
|
||||
Q_EMIT hasBlurWindowChanged();
|
||||
Q_EMIT hasNoTitlebarChanged();
|
||||
});
|
||||
}
|
||||
|
||||
bool TreelandWindowManagerHelper::hasBlurWindow() const
|
||||
{
|
||||
return PersonalizationManager::instance()->isSupported();
|
||||
}
|
||||
|
||||
bool TreelandWindowManagerHelper::hasComposite() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TreelandWindowManagerHelper::hasNoTitlebar() const
|
||||
{
|
||||
return PersonalizationManager::instance()->isSupported();
|
||||
}
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#ifndef DTREELANDWINDOWMANAGERHELPER_H
|
||||
#define DTREELANDWINDOWMANAGERHELPER_H
|
||||
|
||||
#include "dtkgui_global.h"
|
||||
#include "dwindowmanagerhelper.h"
|
||||
#include <QObject>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class TreelandWindowManagerHelper : public DWindowManagerHelper
|
||||
{
|
||||
public:
|
||||
explicit TreelandWindowManagerHelper(QObject *parent = 0);
|
||||
bool hasBlurWindow() const;
|
||||
bool hasComposite() const;
|
||||
bool hasNoTitlebar() const;
|
||||
};
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
||||
#endif // DTREELANDWINDOWMANAGERHELPER_H
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "personalizationwaylandclientextension.h"
|
||||
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <private/qwaylandintegration_p.h>
|
||||
#include <private/qwaylandwindow_p.h>
|
||||
#include <qwaylandclientextension.h>
|
||||
#include "dplatformtheme.h"
|
||||
|
||||
#include <QtWaylandClient/private/qwaylandsurface_p.h>
|
||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||
#include <QGuiApplication>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
PersonalizationManager::PersonalizationManager()
|
||||
: QWaylandClientExtensionTemplate<PersonalizationManager>(treeland_personalization_manager_v1_interface.version)
|
||||
, m_isSupported(false)
|
||||
{
|
||||
QtWaylandClient::QWaylandIntegration *waylandIntegration = static_cast<QtWaylandClient::QWaylandIntegration *>(QGuiApplicationPrivate::platformIntegration());
|
||||
if (!waylandIntegration) {
|
||||
qWarning() << "waylandIntegration is nullptr!!!";
|
||||
return;
|
||||
}
|
||||
m_waylandDisplay = waylandIntegration->display();
|
||||
if (m_waylandDisplay == nullptr) {
|
||||
qWarning() << "waylandDisplay is nullptr!!!";
|
||||
return;
|
||||
}
|
||||
addListener();
|
||||
m_isSupported = m_waylandDisplay->hasRegistryGlobal(QString::fromUtf8(treeland_personalization_manager_v1_interface.name));
|
||||
if (!m_isSupported) {
|
||||
qWarning() << "PersonalizationManager is not support";
|
||||
}
|
||||
}
|
||||
|
||||
void PersonalizationManager::addListener()
|
||||
{
|
||||
m_waylandDisplay->addRegistryListener(&handleListenerGlobal, this);
|
||||
}
|
||||
|
||||
void PersonalizationManager::removeListener()
|
||||
{
|
||||
m_waylandDisplay->removeListener(&handleListenerGlobal, this);
|
||||
}
|
||||
|
||||
void PersonalizationManager::handleListenerGlobal(void *data, wl_registry *registry, uint32_t id, const QString &interface, uint32_t version)
|
||||
{
|
||||
if (interface == treeland_personalization_manager_v1_interface.name) {
|
||||
PersonalizationManager *integration = static_cast<PersonalizationManager *>(data);
|
||||
if (!integration) {
|
||||
qWarning() << "integration is nullptr!!!";
|
||||
return;
|
||||
}
|
||||
|
||||
integration->init(registry, id, version);
|
||||
}
|
||||
}
|
||||
|
||||
PersonalizationManager *PersonalizationManager::instance()
|
||||
{
|
||||
static PersonalizationManager instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
PersonalizationWindowContext::PersonalizationWindowContext(struct ::treeland_personalization_window_context_v1 *context)
|
||||
: QWaylandClientExtensionTemplate<PersonalizationWindowContext>(treeland_personalization_window_context_v1_interface.version)
|
||||
, QtWayland::treeland_personalization_window_context_v1(context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PersonalizationAppearanceContext::PersonalizationAppearanceContext(struct ::treeland_personalization_appearance_context_v1 *context, DTreelandPlatformInterface *interface)
|
||||
: QWaylandClientExtensionTemplate<PersonalizationAppearanceContext>(treeland_personalization_appearance_context_v1_interface.version)
|
||||
, QtWayland::treeland_personalization_appearance_context_v1(context)
|
||||
, m_interface(interface)
|
||||
{
|
||||
get_round_corner_radius();
|
||||
get_icon_theme();
|
||||
get_active_color();
|
||||
get_window_theme_type();
|
||||
get_window_opacity();
|
||||
}
|
||||
|
||||
void PersonalizationAppearanceContext::treeland_personalization_appearance_context_v1_round_corner_radius(int32_t radius)
|
||||
{
|
||||
m_interface->m_windowRadius = radius;
|
||||
emit m_interface->m_platformTheme->windowRadiusChanged(radius);
|
||||
}
|
||||
|
||||
void PersonalizationAppearanceContext::treeland_personalization_appearance_context_v1_icon_theme(const QString &theme_name)
|
||||
{
|
||||
m_interface->m_iconThemeName = theme_name.toUtf8();
|
||||
emit m_interface->m_platformTheme->iconThemeNameChanged(theme_name.toUtf8());
|
||||
}
|
||||
|
||||
void PersonalizationAppearanceContext::treeland_personalization_appearance_context_v1_active_color(const QString &active_color)
|
||||
{
|
||||
m_interface->m_activeColor = active_color;
|
||||
emit m_interface->m_platformTheme->activeColorChanged(active_color);
|
||||
}
|
||||
|
||||
void PersonalizationAppearanceContext::treeland_personalization_appearance_context_v1_window_theme_type(uint32_t type)
|
||||
{
|
||||
QString theme = QStringLiteral("deepin");
|
||||
if (type == PersonalizationAppearanceContext::theme_type::theme_type_dark) {
|
||||
theme = theme + QStringLiteral("-dark");
|
||||
}
|
||||
m_interface->m_themeName = theme.toUtf8();
|
||||
emit m_interface->m_platformTheme->themeNameChanged(theme.toUtf8());
|
||||
}
|
||||
|
||||
void PersonalizationAppearanceContext::treeland_personalization_appearance_context_v1_window_opacity(uint32_t opacity)
|
||||
{
|
||||
m_interface->m_blurOpacity = opacity;
|
||||
}
|
||||
|
||||
PersonalizationFontContext::PersonalizationFontContext(struct ::treeland_personalization_font_context_v1 *context, DTreelandPlatformInterface *interface)
|
||||
: QWaylandClientExtensionTemplate<PersonalizationFontContext>(treeland_personalization_font_context_v1_interface.version)
|
||||
, QtWayland::treeland_personalization_font_context_v1(context)
|
||||
, m_interface(interface)
|
||||
{
|
||||
get_font();
|
||||
get_monospace_font();
|
||||
get_font_size();
|
||||
}
|
||||
|
||||
void PersonalizationFontContext::treeland_personalization_font_context_v1_font(const QString &font_name)
|
||||
{
|
||||
m_interface->m_fontName = font_name.toUtf8();
|
||||
emit m_interface->m_platformTheme->fontNameChanged(font_name.toUtf8());
|
||||
}
|
||||
|
||||
void PersonalizationFontContext::treeland_personalization_font_context_v1_monospace_font(const QString &font_name)
|
||||
{
|
||||
m_interface->m_monoFontName = font_name.toUtf8();
|
||||
emit m_interface->m_platformTheme->monoFontNameChanged(font_name.toUtf8());
|
||||
}
|
||||
|
||||
void PersonalizationFontContext::treeland_personalization_font_context_v1_font_size(uint32_t font_size)
|
||||
{
|
||||
// treeland侧无法存储浮点数,约定 font_size 为 10 倍的 pointSize
|
||||
qreal pointSize = font_size / 10.0;
|
||||
pointSize = qBound(8.25, pointSize, 15.00);
|
||||
m_interface->m_fontPointSize = pointSize;
|
||||
emit m_interface->m_platformTheme->fontPointSizeChanged(pointSize);
|
||||
}
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#ifndef PERSONALIZATIONWAYLANDCLIENTEXTENSION_H
|
||||
#define PERSONALIZATIONWAYLANDCLIENTEXTENSION_H
|
||||
|
||||
#include "dtreelandplatforminterface.h"
|
||||
#include "qwayland-treeland-personalization-manager-v1.h"
|
||||
|
||||
#include <dtkgui_global.h>
|
||||
#include <private/qwaylanddisplay_p.h>
|
||||
|
||||
#include <QtWaylandClient/QWaylandClientExtension>
|
||||
#include <QWaylandClientExtensionTemplate>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class PersonalizationAppearanceContext;
|
||||
class PersonalizationCursorContext;
|
||||
class PersonalizationFontContext;
|
||||
class DTreelandPlatformInterfacePrivate;
|
||||
|
||||
class PersonalizationManager: public QWaylandClientExtensionTemplate<PersonalizationManager>,
|
||||
public QtWayland::treeland_personalization_manager_v1
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static PersonalizationManager *instance();
|
||||
|
||||
[[nodiscard]]inline bool isSupported() const { return m_isSupported; }
|
||||
|
||||
private:
|
||||
void addListener();
|
||||
void removeListener();
|
||||
|
||||
explicit PersonalizationManager();
|
||||
static void handleListenerGlobal(void *data, wl_registry *registry, uint32_t id, const QString &interface, uint32_t version);
|
||||
|
||||
private:
|
||||
QtWaylandClient::QWaylandDisplay *m_waylandDisplay;
|
||||
bool m_isSupported;
|
||||
};
|
||||
|
||||
class PersonalizationWindowContext : public QWaylandClientExtensionTemplate<PersonalizationWindowContext>,
|
||||
public QtWayland::treeland_personalization_window_context_v1
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PersonalizationWindowContext(struct ::treeland_personalization_window_context_v1 *context);
|
||||
};
|
||||
|
||||
class PersonalizationAppearanceContext : public QWaylandClientExtensionTemplate<PersonalizationAppearanceContext>,
|
||||
public QtWayland::treeland_personalization_appearance_context_v1
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PersonalizationAppearanceContext(struct ::treeland_personalization_appearance_context_v1 *context, DTreelandPlatformInterface *interface);
|
||||
|
||||
protected:
|
||||
void treeland_personalization_appearance_context_v1_round_corner_radius(int32_t radius) override;
|
||||
void treeland_personalization_appearance_context_v1_icon_theme(const QString &theme_name) override;
|
||||
void treeland_personalization_appearance_context_v1_active_color(const QString &active_color) override;
|
||||
void treeland_personalization_appearance_context_v1_window_theme_type(uint32_t type) override;
|
||||
void treeland_personalization_appearance_context_v1_window_opacity(uint32_t opacity) override;
|
||||
private:
|
||||
DTreelandPlatformInterface *m_interface;
|
||||
};
|
||||
|
||||
class PersonalizationFontContext : public QWaylandClientExtensionTemplate<PersonalizationFontContext>,
|
||||
public QtWayland::treeland_personalization_font_context_v1
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PersonalizationFontContext(struct ::treeland_personalization_font_context_v1 *context, DTreelandPlatformInterface *interface);
|
||||
|
||||
protected:
|
||||
void treeland_personalization_font_context_v1_font(const QString &font_name) override;
|
||||
void treeland_personalization_font_context_v1_monospace_font(const QString &font_name) override;
|
||||
void treeland_personalization_font_context_v1_font_size(uint32_t font_size) override;
|
||||
private:
|
||||
DTreelandPlatformInterface *m_interface;
|
||||
};
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
||||
#endif // PERSONALIZATIONWAYLANDCLIENTEXTENSION_H
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
file(GLOB TREELAND_HEADER
|
||||
${CMAKE_CURRENT_LIST_DIR}/*.h
|
||||
)
|
||||
file(GLOB TREELAND_SOURCE
|
||||
${CMAKE_CURRENT_LIST_DIR}/*.cpp
|
||||
)
|
||||
set(treeland_SRC
|
||||
${TREELAND_HEADER}
|
||||
${TREELAND_SOURCE}
|
||||
)
|
||||
|
|
@ -0,0 +1,708 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "dxcbplatforminterface.h"
|
||||
#include "dxcbplatforminterface_p.h"
|
||||
|
||||
#include <DNativeSettings>
|
||||
#include <QPlatformSurfaceEvent>
|
||||
#include <QGuiApplication>
|
||||
#include <QMetaObject>
|
||||
#include <QMetaProperty>
|
||||
|
||||
#include "dplatformtheme.h"
|
||||
#include "dguiapplicationhelper.h"
|
||||
#include <qpa/qplatformwindow.h>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
#define DEFINE_CONST_CHAR(Name) const char _##Name[] = "_d_" #Name
|
||||
|
||||
#define FETCH_PROPERTY(Name, Function) \
|
||||
D_DC(DXCBPlatformInterface); \
|
||||
QVariant value = d->theme->getSetting(QByteArrayLiteral(Name)); \
|
||||
if (d->fallbackProperty && !value.isValid() && d->parent) \
|
||||
return d->parent->Function(); \
|
||||
|
||||
#define FETCH_PROPERTY_WITH_ARGS(Name, Function, Args) \
|
||||
D_DC(DXCBPlatformInterface); \
|
||||
QVariant value = d->theme->getSetting(Name); \
|
||||
if (d->fallbackProperty && !value.isValid() && d->parent) \
|
||||
return d->parent->Function(Args); \
|
||||
|
||||
|
||||
DXCBPlatformInterfacePrivate::DXCBPlatformInterfacePrivate(DXCBPlatformInterface *qq)
|
||||
:DCORE_NAMESPACE::DObjectPrivate(qq)
|
||||
{
|
||||
}
|
||||
|
||||
void DXCBPlatformInterfacePrivate::_q_onThemePropertyChanged(const QByteArray &name, const QVariant &value)
|
||||
{
|
||||
D_Q(DXCBPlatformInterface);
|
||||
|
||||
// 转发属性变化的信号,此信号来源可能为parent theme或“非调色板”的属性变化。
|
||||
// 使用队列的形式转发,避免多次发出同样的信号
|
||||
// q->staticMetaObject.invokeMethod(q, "propertyChanged", Qt::QueuedConnection,
|
||||
// Q_ARG(const QByteArray&, name), Q_ARG(const QVariant&, value));
|
||||
|
||||
if (QByteArrayLiteral("Gtk/FontName") == name) {
|
||||
Q_EMIT q->m_platformTheme->gtkFontNameChanged(value.toByteArray());
|
||||
return;
|
||||
}
|
||||
|
||||
if (name.startsWith("Qt/DPI/")) {
|
||||
const QString &screen_name = QString::fromLocal8Bit(name.mid(7));
|
||||
|
||||
if (!screen_name.isEmpty()) {
|
||||
bool ok = false;
|
||||
int dpi = value.toInt(&ok);
|
||||
|
||||
Q_EMIT q->m_platformTheme->dotsPerInchChanged(screen_name, ok ? dpi : -1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (QByteArrayLiteral("Xft/DPI") == name) {
|
||||
bool ok = false;
|
||||
int dpi = value.toInt(&ok);
|
||||
Q_EMIT q->m_platformTheme->dotsPerInchChanged(QString(), ok ? dpi : -1);
|
||||
}
|
||||
|
||||
const QByteArrayList &list = name.split('/');
|
||||
|
||||
if (list.count() != 2)
|
||||
return;
|
||||
|
||||
QByteArray pn = list.last();
|
||||
|
||||
if (pn.isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
// 转换首字母为小写
|
||||
pn[0] = QChar(pn.at(0)).toLower().toLatin1();
|
||||
|
||||
// 直接使用静态的meta object,防止通过metaObject函数调用到dynamic metaobject
|
||||
const QMetaObject *mo = &DPlatformTheme::staticMetaObject;
|
||||
|
||||
int index = mo->indexOfProperty(pn.constData());
|
||||
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
const QMetaProperty &p = mo->property(index);
|
||||
bool is_parent_signal = q->sender() != theme;
|
||||
|
||||
// 当自己的属性有效时应该忽略父主题的属性变化信号,优先以自身的属性值为准。
|
||||
if (is_parent_signal && p.read(q).isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p.hasNotifySignal()) {
|
||||
// invoke会做Q_ASSERT(mobj->cast(object))判断, DPlatformTheme的dynamic metaObject为
|
||||
// qt5platform-plugin插件的DNativeSettings. 导致崩溃.
|
||||
// invokeOnGadget与invoke代码逻辑一致, 只是少了异步支持.
|
||||
// return;
|
||||
|
||||
if (!p.notifySignal().invokeOnGadget(q->m_platformTheme, QGenericArgument(value.typeName(), value.constData())))
|
||||
qWarning() << "_q_onThemePropertyChanged() error when notify signal" << p.notifySignal().name();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DXCBPlatformInterface::DXCBPlatformInterface(quint32 window, DPlatformTheme *platformTheme)
|
||||
: DPlatformInterface(platformTheme)
|
||||
, Core::DObject(*new DXCBPlatformInterfacePrivate(this))
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme = new DNativeSettings(window, QByteArray(), platformTheme);
|
||||
|
||||
connect(d->theme, SIGNAL(propertyChanged(const QByteArray &, const QVariant &)),
|
||||
this, SLOT(_q_onThemePropertyChanged(const QByteArray &, const QVariant &)));
|
||||
}
|
||||
|
||||
int DXCBPlatformInterface::cursorBlinkTime() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/CursorBlinkTime", cursorBlinkTime)
|
||||
|
||||
return value.toInt();
|
||||
}
|
||||
|
||||
int DXCBPlatformInterface::cursorBlinkTimeout() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/CursorBlinkTimeout", cursorBlinkTimeout)
|
||||
|
||||
return value.toInt();
|
||||
}
|
||||
|
||||
bool DXCBPlatformInterface::cursorBlink() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/CursorBlink", cursorBlink)
|
||||
|
||||
return value.toInt();
|
||||
}
|
||||
|
||||
int DXCBPlatformInterface::doubleClickDistance() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/DoubleClickDistance", doubleClickDistance)
|
||||
|
||||
return value.toInt();
|
||||
}
|
||||
|
||||
int DXCBPlatformInterface::doubleClickTime() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/DoubleClickTime", doubleClickTime)
|
||||
|
||||
return value.toInt();
|
||||
}
|
||||
|
||||
int DXCBPlatformInterface::dndDragThreshold() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/DndDragThreshold", dndDragThreshold)
|
||||
|
||||
return value.toInt();
|
||||
}
|
||||
|
||||
int DXCBPlatformInterface::windowRadius() const
|
||||
{
|
||||
return windowRadius(-1);
|
||||
}
|
||||
|
||||
int DXCBPlatformInterface::windowRadius(int defaultValue) const
|
||||
{
|
||||
Q_D(const DXCBPlatformInterface);
|
||||
|
||||
QVariant value = d->theme->getSetting(QByteArrayLiteral("DTK/WindowRadius"));
|
||||
bool ok = false;
|
||||
|
||||
if (d->fallbackProperty && !value.isValid() && d->parent)
|
||||
return d->parent->windowRadius(defaultValue);
|
||||
|
||||
int radius = value.toInt(&ok);
|
||||
|
||||
return ok ? radius : defaultValue;
|
||||
}
|
||||
|
||||
QByteArray DXCBPlatformInterface::themeName() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/ThemeName", themeName)
|
||||
|
||||
return value.toByteArray();
|
||||
}
|
||||
|
||||
QByteArray DXCBPlatformInterface::iconThemeName() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/IconThemeName", iconThemeName)
|
||||
|
||||
return value.toByteArray();
|
||||
}
|
||||
|
||||
QByteArray DXCBPlatformInterface::soundThemeName() const
|
||||
{
|
||||
FETCH_PROPERTY("Net/SoundThemeName", soundThemeName)
|
||||
|
||||
return value.toByteArray();
|
||||
}
|
||||
|
||||
QByteArray DXCBPlatformInterface::fontName() const
|
||||
{
|
||||
FETCH_PROPERTY("Qt/FontName", fontName)
|
||||
|
||||
return value.toByteArray();
|
||||
}
|
||||
|
||||
QByteArray DXCBPlatformInterface::monoFontName() const
|
||||
{
|
||||
FETCH_PROPERTY("Qt/MonoFontName", monoFontName)
|
||||
|
||||
return value.toByteArray();
|
||||
}
|
||||
|
||||
qreal DXCBPlatformInterface::fontPointSize() const
|
||||
{
|
||||
FETCH_PROPERTY("Qt/FontPointSize", fontPointSize)
|
||||
|
||||
return value.toDouble();
|
||||
}
|
||||
|
||||
QByteArray DXCBPlatformInterface::gtkFontName() const
|
||||
{
|
||||
FETCH_PROPERTY("Gtk/FontName", gtkFontName)
|
||||
|
||||
return value.toByteArray();
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::activeColor() const
|
||||
{
|
||||
FETCH_PROPERTY("Qt/ActiveColor", activeColor)
|
||||
|
||||
return qvariant_cast<QColor>(value);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::darkActiveColor() const
|
||||
{
|
||||
FETCH_PROPERTY("Qt/DarkActiveColor", darkActiveColor)
|
||||
|
||||
return qvariant_cast<QColor>(value);
|
||||
}
|
||||
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
#define GET_COLOR(Role) qvariant_cast<QColor>(getSetting(QByteArrayLiteral(#Role)))
|
||||
static QColor getSetting(const QByteArray &key)
|
||||
{
|
||||
Q_UNUSED(key);
|
||||
qWarning() << "Not implemented, key:" << key;
|
||||
return {};
|
||||
}
|
||||
QColor DXCBPlatformInterface::window() const
|
||||
{
|
||||
return GET_COLOR(window);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::windowText() const
|
||||
{
|
||||
return GET_COLOR(windowText);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::base() const
|
||||
{
|
||||
return GET_COLOR(base);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::alternateBase() const
|
||||
{
|
||||
return GET_COLOR(alternateBase);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::toolTipBase() const
|
||||
{
|
||||
return GET_COLOR(toolTipBase);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::toolTipText() const
|
||||
{
|
||||
return GET_COLOR(toolTipText);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::text() const
|
||||
{
|
||||
return GET_COLOR(text);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::button() const
|
||||
{
|
||||
return GET_COLOR(button);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::buttonText() const
|
||||
{
|
||||
return GET_COLOR(buttonText);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::brightText() const
|
||||
{
|
||||
return GET_COLOR(brightText);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::light() const
|
||||
{
|
||||
return GET_COLOR(light);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::midlight() const
|
||||
{
|
||||
return GET_COLOR(midlight);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::dark() const
|
||||
{
|
||||
return GET_COLOR(dark);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::mid() const
|
||||
{
|
||||
return GET_COLOR(mid);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::shadow() const
|
||||
{
|
||||
return GET_COLOR(shadow);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::highlight() const
|
||||
{
|
||||
return GET_COLOR(highlight);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::highlightedText() const
|
||||
{
|
||||
return GET_COLOR(highlightedText);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::link() const
|
||||
{
|
||||
return GET_COLOR(link);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::linkVisited() const
|
||||
{
|
||||
return GET_COLOR(linkVisited);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::itemBackground() const
|
||||
{
|
||||
return GET_COLOR(itemBackground);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::textTitle() const
|
||||
{
|
||||
return GET_COLOR(textTitle);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::textTips() const
|
||||
{
|
||||
return GET_COLOR(textTips);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::textWarning() const
|
||||
{
|
||||
return GET_COLOR(textWarning);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::textLively() const
|
||||
{
|
||||
return GET_COLOR(textLively);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::lightLively() const
|
||||
{
|
||||
return GET_COLOR(lightLively);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::darkLively() const
|
||||
{
|
||||
return GET_COLOR(darkLively);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformInterface::frameBorder() const
|
||||
{
|
||||
return GET_COLOR(frameBorder);
|
||||
}
|
||||
#endif
|
||||
|
||||
int DXCBPlatformInterface::dotsPerInch(const QString &screenName) const
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
if (!screenName.isEmpty()) {
|
||||
FETCH_PROPERTY_WITH_ARGS("Qt/DPI/" + screenName.toLocal8Bit(), dotsPerInch, screenName);
|
||||
int dpi = value.toInt(&ok);
|
||||
|
||||
if (ok)
|
||||
return dpi;
|
||||
}
|
||||
|
||||
FETCH_PROPERTY_WITH_ARGS("Xft/DPI", dotsPerInch, screenName);
|
||||
int dpi = value.toInt(&ok);
|
||||
return ok ? dpi : -1;
|
||||
}
|
||||
|
||||
/*!
|
||||
\property DXCBPlatformInterface::sizeMode
|
||||
\brief This property holds the sizeMode of the system's SizeMode.
|
||||
*/
|
||||
int DXCBPlatformInterface::sizeMode() const
|
||||
{
|
||||
D_DC(DXCBPlatformInterface);
|
||||
QVariant value = d->theme->getSetting(QByteArrayLiteral("DTK/SizeMode"));
|
||||
return value.toInt();
|
||||
}
|
||||
|
||||
/*!
|
||||
\property DXCBPlatformInterface::scrollBarPolicy
|
||||
\brief This property holds the scrollBarPolicy of the system. same as Qt::ScrollBarPolicy
|
||||
\retval 0 show as needed auto hide, default
|
||||
\retval 1 always off
|
||||
\retval 2 always on
|
||||
*/
|
||||
int DXCBPlatformInterface::scrollBarPolicy() const
|
||||
{
|
||||
FETCH_PROPERTY("Qt/ScrollBarPolicy", scrollBarPolicy)
|
||||
|
||||
return qvariant_cast<int>(value);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setCursorBlinkTime(int cursorBlinkTime)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Net/CursorBlinkTime", cursorBlinkTime);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setCursorBlinkTimeout(int cursorBlinkTimeout)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Net/CursorBlinkTimeout", cursorBlinkTimeout);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setCursorBlink(bool cursorBlink)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Net/CursorBlink", cursorBlink);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setDoubleClickDistance(int doubleClickDistance)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Net/DoubleClickDistance", doubleClickDistance);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setDoubleClickTime(int doubleClickTime)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Net/DoubleClickTime", doubleClickTime);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setDndDragThreshold(int dndDragThreshold)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Net/DndDragThreshold", dndDragThreshold);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setThemeName(const QByteArray &themeName)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Net/ThemeName", themeName);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setIconThemeName(const QByteArray &iconThemeName)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Net/IconThemeName", iconThemeName);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setSoundThemeName(const QByteArray &soundThemeName)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Net/SoundThemeName", soundThemeName);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setFontName(const QByteArray &fontName)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Qt/FontName", fontName);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setMonoFontName(const QByteArray &monoFontName)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Qt/MonoFontName", monoFontName);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setFontPointSize(qreal fontPointSize)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Qt/FontPointSize", fontPointSize);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setGtkFontName(const QByteArray &fontName)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Gtk/FontName", fontName);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setActiveColor(const QColor activeColor)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Qt/ActiveColor", activeColor);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setDarkActiveColor(const QColor &activeColor)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("Qt/DarkActiveColor", activeColor);
|
||||
}
|
||||
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
#define SET_COLOR(Role) setSetting(QByteArrayLiteral(#Role), Role)
|
||||
static void setSetting(const QByteArray &key, const QColor &color)
|
||||
{
|
||||
Q_UNUSED(key);
|
||||
Q_UNUSED(color);
|
||||
qWarning() << "Not implemented, key: " << key << "value: " << color;
|
||||
}
|
||||
void DXCBPlatformInterface::setWindow(const QColor &window)
|
||||
{
|
||||
SET_COLOR(window);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setWindowText(const QColor &windowText)
|
||||
{
|
||||
SET_COLOR(windowText);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setBase(const QColor &base)
|
||||
{
|
||||
SET_COLOR(base);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setAlternateBase(const QColor &alternateBase)
|
||||
{
|
||||
SET_COLOR(alternateBase);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setToolTipBase(const QColor &toolTipBase)
|
||||
{
|
||||
SET_COLOR(toolTipBase);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setToolTipText(const QColor &toolTipText)
|
||||
{
|
||||
SET_COLOR(toolTipText);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setText(const QColor &text)
|
||||
{
|
||||
SET_COLOR(text);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setButton(const QColor &button)
|
||||
{
|
||||
SET_COLOR(button);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setButtonText(const QColor &buttonText)
|
||||
{
|
||||
SET_COLOR(buttonText);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setBrightText(const QColor &brightText)
|
||||
{
|
||||
SET_COLOR(brightText);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setLight(const QColor &light)
|
||||
{
|
||||
SET_COLOR(light);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setMidlight(const QColor &midlight)
|
||||
{
|
||||
SET_COLOR(midlight);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setDark(const QColor &dark)
|
||||
{
|
||||
SET_COLOR(dark);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setMid(const QColor &mid)
|
||||
{
|
||||
SET_COLOR(mid);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setShadow(const QColor &shadow)
|
||||
{
|
||||
SET_COLOR(shadow);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setHighlight(const QColor &highlight)
|
||||
{
|
||||
SET_COLOR(highlight);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setHighlightedText(const QColor &highlightText)
|
||||
{
|
||||
SET_COLOR(highlightText);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setLink(const QColor &link)
|
||||
{
|
||||
SET_COLOR(link);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setLinkVisited(const QColor &linkVisited)
|
||||
{
|
||||
SET_COLOR(linkVisited);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setItemBackground(const QColor &itemBackground)
|
||||
{
|
||||
SET_COLOR(itemBackground);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setTextTitle(const QColor &textTitle)
|
||||
{
|
||||
SET_COLOR(textTitle);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setTextTips(const QColor &textTips)
|
||||
{
|
||||
SET_COLOR(textTips);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setTextWarning(const QColor &textWarning)
|
||||
{
|
||||
SET_COLOR(textWarning);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setTextLively(const QColor &textLively)
|
||||
{
|
||||
SET_COLOR(textLively);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setLightLively(const QColor &lightLively)
|
||||
{
|
||||
SET_COLOR(lightLively);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setDarkLively(const QColor &darkLively)
|
||||
{
|
||||
SET_COLOR(darkLively);
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setFrameBorder(const QColor &frameBorder)
|
||||
{
|
||||
SET_COLOR(frameBorder);
|
||||
}
|
||||
#endif
|
||||
|
||||
void DXCBPlatformInterface::setDotsPerInch(const QString &screenName, int dpi)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
if (screenName.isEmpty()) {
|
||||
d->theme->setSetting("Xft/DPI", dpi);
|
||||
} else {
|
||||
d->theme->setSetting("Qt/DPI/" + screenName.toLocal8Bit(), dpi);
|
||||
}
|
||||
}
|
||||
|
||||
void DXCBPlatformInterface::setWindowRadius(int windowRadius)
|
||||
{
|
||||
D_D(DXCBPlatformInterface);
|
||||
|
||||
d->theme->setSetting("DTK/WindowRadius", windowRadius);
|
||||
}
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
||||
#include "moc_dxcbplatforminterface.cpp"
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#ifndef DXCBPLATFORMINTERFACE_H
|
||||
#define DXCBPLATFORMINTERFACE_H
|
||||
|
||||
#include "private/dplatforminterface_p.h"
|
||||
|
||||
#include <DObject>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class DXCBPlatformInterfacePrivate;
|
||||
class DXCBPlatformInterface : public QObject, public DPlatformInterface, public DCORE_NAMESPACE::DObject
|
||||
{
|
||||
Q_OBJECT
|
||||
D_DECLARE_PRIVATE(DXCBPlatformInterface)
|
||||
public:
|
||||
explicit DXCBPlatformInterface(quint32 window, DPlatformTheme *platformTheme);
|
||||
|
||||
int cursorBlinkTime() const override;
|
||||
int cursorBlinkTimeout() const override;
|
||||
bool cursorBlink() const override;
|
||||
int doubleClickDistance() const override;
|
||||
int doubleClickTime() const override;
|
||||
int dndDragThreshold() const override;
|
||||
int windowRadius() const override;
|
||||
int windowRadius(int defaultValue) const override;
|
||||
QByteArray themeName() const override;
|
||||
QByteArray iconThemeName() const override;
|
||||
QByteArray soundThemeName() const override;
|
||||
|
||||
QByteArray fontName() const override;
|
||||
QByteArray monoFontName() const override;
|
||||
qreal fontPointSize() const override;
|
||||
QByteArray gtkFontName() const override;
|
||||
|
||||
QColor activeColor() const override;
|
||||
QColor darkActiveColor() const override;
|
||||
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
QColor window() const override;
|
||||
QColor windowText() const override;
|
||||
QColor base() const override;
|
||||
QColor alternateBase() const override;
|
||||
QColor toolTipText() const override;
|
||||
QColor toolTipBase() const override;
|
||||
QColor text() const override;
|
||||
QColor button() const override;
|
||||
QColor buttonText() const override;
|
||||
QColor brightText() const override;
|
||||
QColor light() const override;
|
||||
QColor midlight() const override;
|
||||
QColor dark() const override;
|
||||
QColor mid() const override;
|
||||
QColor shadow() const override;
|
||||
QColor highlight() const override;
|
||||
QColor highlightedText() const override;
|
||||
QColor link() const override;
|
||||
QColor linkVisited() const override;
|
||||
QColor itemBackground() const override;
|
||||
QColor textTitle() const override;
|
||||
QColor textTips() const override;
|
||||
QColor textWarning() const override;
|
||||
QColor textLively() const override;
|
||||
QColor lightLively() const override;
|
||||
QColor darkLively() const override;
|
||||
QColor frameBorder() const override;
|
||||
#endif
|
||||
|
||||
int sizeMode() const override;
|
||||
int scrollBarPolicy() const override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setCursorBlinkTime(int cursorBlinkTime) override;
|
||||
void setCursorBlinkTimeout(int cursorBlinkTimeout) override;
|
||||
void setCursorBlink(bool cursorBlink) override;
|
||||
void setDoubleClickDistance(int doubleClickDistance) override;
|
||||
void setDoubleClickTime(int doubleClickTime) override;
|
||||
void setDndDragThreshold(int dndDragThreshold) override;
|
||||
void setThemeName(const QByteArray &themeName) override;
|
||||
void setIconThemeName(const QByteArray &iconThemeName) override;
|
||||
void setSoundThemeName(const QByteArray &soundThemeName) override;
|
||||
void setFontName(const QByteArray &fontName) override;
|
||||
void setMonoFontName(const QByteArray &monoFontName) override;
|
||||
void setFontPointSize(qreal fontPointSize) override;
|
||||
void setGtkFontName(const QByteArray &fontName) override;
|
||||
void setActiveColor(const QColor activeColor) override;
|
||||
void setDarkActiveColor(const QColor &activeColor) override;
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
void setWindow(const QColor &window) override;
|
||||
void setWindowText(const QColor &windowText) override;
|
||||
void setBase(const QColor &base) override;
|
||||
void setAlternateBase(const QColor &alternateBase) override;
|
||||
void setToolTipBase(const QColor &toolTipBase) override;
|
||||
void setToolTipText(const QColor &toolTipText) override;
|
||||
void setText(const QColor &text) override;
|
||||
void setButton(const QColor &button) override;
|
||||
void setButtonText(const QColor &buttonText) override;
|
||||
void setBrightText(const QColor &brightText) override;
|
||||
void setLight(const QColor &light) override;
|
||||
void setMidlight(const QColor &midlight) override;
|
||||
void setDark(const QColor &dark) override;
|
||||
void setMid(const QColor &mid) override;
|
||||
void setShadow(const QColor &shadow) override;
|
||||
void setHighlight(const QColor &highlight) override;
|
||||
void setHighlightedText(const QColor &highlightedText) override;
|
||||
void setLink(const QColor &link) override;
|
||||
void setLinkVisited(const QColor &linkVisited) override;
|
||||
void setItemBackground(const QColor &itemBackground) override;
|
||||
void setTextTitle(const QColor &textTitle) override;
|
||||
void setTextTips(const QColor &textTips) override;
|
||||
void setTextWarning(const QColor &textWarning) override;
|
||||
void setTextLively(const QColor &textLively) override;
|
||||
void setLightLively(const QColor &lightLively) override;
|
||||
void setDarkLively(const QColor &darkLively) override;
|
||||
void setFrameBorder(const QColor &frameBorder) override;
|
||||
#endif
|
||||
|
||||
int dotsPerInch(const QString &screenName = QString()) const override;
|
||||
void setDotsPerInch(const QString &screenName, int dpi) override;
|
||||
void setWindowRadius(int windowRadius) override;
|
||||
|
||||
private:
|
||||
friend class DPlatformThemePrivate;
|
||||
D_PRIVATE_SLOT(void _q_onThemePropertyChanged(const QByteArray &name, const QVariant &value))
|
||||
};
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
#endif // DXCBPLATFORMINTERFACE_H
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#ifndef DXCBPLATFORMINTERFACE_P_H
|
||||
#define DXCBPLATFORMINTERFACE_P_H
|
||||
|
||||
#include "dxcbplatforminterface.h"
|
||||
#include "private/dplatforminterface_p.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <DObjectPrivate>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class DNativeSettings;
|
||||
class DPlatformTheme;
|
||||
|
||||
class DXCBPlatformInterfacePrivate : public DCORE_NAMESPACE::DObjectPrivate
|
||||
{
|
||||
public:
|
||||
D_DECLARE_PUBLIC(DXCBPlatformInterface)
|
||||
DXCBPlatformInterfacePrivate(DXCBPlatformInterface *qq);
|
||||
|
||||
void _q_onThemePropertyChanged(const QByteArray &name, const QVariant &value);
|
||||
|
||||
public:
|
||||
DPlatformTheme *parent = nullptr;
|
||||
bool fallbackProperty = true;
|
||||
DNativeSettings *theme;
|
||||
QHash<QString, QString> m_properties;
|
||||
};
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
||||
#endif // DNATIVESETTINGS_P_H
|
||||
|
|
@ -0,0 +1,724 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "dxcbplatformwindowinterface.h"
|
||||
#include "dguiapplicationhelper.h"
|
||||
#include "dplatformtheme.h"
|
||||
#include "dwindowmanagerhelper.h"
|
||||
|
||||
#include <private/qwaylandwindow_p.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QPlatformSurfaceEvent>
|
||||
#include <QStyleHints>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
#define DXCB_PLUGIN_KEY "dxcb"
|
||||
#define DXCB_PLUGIN_SYMBOLIC_PROPERTY "_d_isDxcb"
|
||||
|
||||
#define DEFINE_CONST_CHAR(Name) [[maybe_unused]] const char _##Name[] = "_d_" #Name
|
||||
|
||||
DEFINE_CONST_CHAR(useDxcb);
|
||||
DEFINE_CONST_CHAR(redirectContent);
|
||||
DEFINE_CONST_CHAR(netWmStates);
|
||||
DEFINE_CONST_CHAR(windowRadius);
|
||||
DEFINE_CONST_CHAR(borderWidth);
|
||||
DEFINE_CONST_CHAR(borderColor);
|
||||
DEFINE_CONST_CHAR(windowEffect);
|
||||
DEFINE_CONST_CHAR(windowStartUpEffect);
|
||||
DEFINE_CONST_CHAR(shadowRadius);
|
||||
DEFINE_CONST_CHAR(shadowOffset);
|
||||
DEFINE_CONST_CHAR(shadowColor);
|
||||
DEFINE_CONST_CHAR(clipPath);
|
||||
DEFINE_CONST_CHAR(frameMask);
|
||||
DEFINE_CONST_CHAR(frameMargins);
|
||||
DEFINE_CONST_CHAR(translucentBackground);
|
||||
DEFINE_CONST_CHAR(enableSystemResize);
|
||||
DEFINE_CONST_CHAR(enableSystemMove);
|
||||
DEFINE_CONST_CHAR(enableBlurWindow);
|
||||
DEFINE_CONST_CHAR(windowBlurAreas);
|
||||
DEFINE_CONST_CHAR(windowBlurPaths);
|
||||
DEFINE_CONST_CHAR(windowWallpaperParas);
|
||||
DEFINE_CONST_CHAR(autoInputMaskByClipPath);
|
||||
|
||||
DEFINE_CONST_CHAR(resolve_mask);
|
||||
enum PropRole {
|
||||
WindowRadius,
|
||||
|
||||
// TO BE CONTINUE
|
||||
};
|
||||
|
||||
// functions
|
||||
DEFINE_CONST_CHAR(setWmBlurWindowBackgroundArea);
|
||||
DEFINE_CONST_CHAR(setWmBlurWindowBackgroundPathList);
|
||||
DEFINE_CONST_CHAR(setWmBlurWindowBackgroundMaskImage);
|
||||
DEFINE_CONST_CHAR(setWmWallpaperParameter);
|
||||
DEFINE_CONST_CHAR(setWindowProperty);
|
||||
DEFINE_CONST_CHAR(pluginVersion);
|
||||
DEFINE_CONST_CHAR(disableOverrideCursor);
|
||||
DEFINE_CONST_CHAR(enableDxcb);
|
||||
DEFINE_CONST_CHAR(isEnableDxcb);
|
||||
DEFINE_CONST_CHAR(setEnableNoTitlebar);
|
||||
DEFINE_CONST_CHAR(isEnableNoTitlebar);
|
||||
DEFINE_CONST_CHAR(clientLeader);
|
||||
|
||||
static void resolve(QObject *obj, PropRole role)
|
||||
{
|
||||
int mask = obj->property(_resolve_mask).toInt();
|
||||
obj->setProperty(_resolve_mask, (mask |= 1 << role));
|
||||
}
|
||||
|
||||
static bool resolved(QObject *obj, PropRole role)
|
||||
{
|
||||
int mask = obj->property(_resolve_mask).toInt();
|
||||
return mask & (1 << role);
|
||||
}
|
||||
|
||||
static void setWindowProperty(QWindow *window, const char *name, const QVariant &value)
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
static QFunctionPointer setWindowProperty = qApp->platformFunction(_setWindowProperty);
|
||||
#else
|
||||
constexpr QFunctionPointer setWindowProperty = nullptr;
|
||||
#endif
|
||||
|
||||
if (!setWindowProperty) {
|
||||
window->setProperty(name, value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
reinterpret_cast<void(*)(QWindow *, const char *, const QVariant &)>(setWindowProperty)(window, name, value);
|
||||
}
|
||||
|
||||
DXCBPlatformWindowInterface::DXCBPlatformWindowInterface(QWindow *window, DPlatformHandle *platformHandle, QObject *parent)
|
||||
: QObject(parent)
|
||||
, DPlatformWindowInterface(window, platformHandle)
|
||||
{
|
||||
if (window) {
|
||||
window->installEventFilter(this);
|
||||
}
|
||||
}
|
||||
|
||||
DXCBPlatformWindowInterface::~DXCBPlatformWindowInterface()
|
||||
{
|
||||
}
|
||||
|
||||
QString DXCBPlatformWindowInterface::pluginVersion()
|
||||
{
|
||||
QFunctionPointer pv = 0;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
pv = qApp->platformFunction(_pluginVersion);
|
||||
#endif
|
||||
|
||||
if (Q_UNLIKELY(!pv))
|
||||
return QString();
|
||||
|
||||
return reinterpret_cast<QString(*)()>(pv)();
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::isDXcbPlatform()
|
||||
{
|
||||
if (!qApp)
|
||||
return false;
|
||||
|
||||
static bool _is_dxcb = qApp->platformName() == DXCB_PLUGIN_KEY || qApp->property(DXCB_PLUGIN_SYMBOLIC_PROPERTY).toBool();
|
||||
|
||||
return _is_dxcb;
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::connectWindowManagerChangedSignal(QObject *object, std::function<void ()> slot)
|
||||
{
|
||||
if (object) {
|
||||
return QObject::connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::windowManagerChanged, object, slot);
|
||||
}
|
||||
|
||||
return QObject::connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::windowManagerChanged, slot);
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::connectHasBlurWindowChanged(QObject *object, std::function<void ()> slot)
|
||||
{
|
||||
if (object) {
|
||||
return QObject::connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasBlurWindowChanged, object, slot);
|
||||
}
|
||||
|
||||
return QObject::connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasBlurWindowChanged, slot);
|
||||
}
|
||||
|
||||
WId DXCBPlatformWindowInterface::windowLeader()
|
||||
{
|
||||
QFunctionPointer clientLeader = Q_NULLPTR;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
clientLeader = qApp->platformFunction(_clientLeader);
|
||||
#endif
|
||||
|
||||
if (!clientLeader) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return reinterpret_cast<quint32(*)()>(clientLeader)();
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setEnabled(bool enabled)
|
||||
{
|
||||
// 优先使用窗口管理器中实现的no titlebar接口实现自定义窗口修饰器的效果
|
||||
if (setEnabledNoTitlebar(enabled)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isDXcbPlatform())
|
||||
return;
|
||||
|
||||
QFunctionPointer enable_dxcb = nullptr;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
enable_dxcb = qApp->platformFunction(_enableDxcb);
|
||||
#endif
|
||||
|
||||
if (enable_dxcb) {
|
||||
(*reinterpret_cast<bool(*)(QWindow*)>(enable_dxcb))(m_window);
|
||||
} else if (m_window->handle()) {
|
||||
Q_ASSERT_X(m_window->property(_useDxcb).toBool(), "DXCBPlatformWindowInterfacer:",
|
||||
"Must be called before window handle has been created. See also QWindow::handle()");
|
||||
} else {
|
||||
m_window->setProperty(_useDxcb, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::enableDXcb(bool redirectContent)
|
||||
{
|
||||
m_window->setProperty(_redirectContent, redirectContent);
|
||||
|
||||
setEnabled(true);
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::isEnabled() const
|
||||
{
|
||||
if (isEnabledNoTitlebar())
|
||||
return true;
|
||||
|
||||
QFunctionPointer is_enable_dxcb = nullptr;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
is_enable_dxcb = qApp->platformFunction(_isEnableDxcb);
|
||||
#endif
|
||||
|
||||
if (is_enable_dxcb) {
|
||||
return (*reinterpret_cast<bool(*)(const QWindow*)>(is_enable_dxcb))(m_window);
|
||||
}
|
||||
|
||||
return m_window->property(_useDxcb).toBool();
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (obj == m_window && m_platformHandle) {
|
||||
if (event->type() == QEvent::DynamicPropertyChange) {
|
||||
QDynamicPropertyChangeEvent *e = static_cast<QDynamicPropertyChangeEvent *>(event);
|
||||
|
||||
if (e->propertyName() == _windowRadius) {
|
||||
Q_EMIT m_platformHandle->windowRadiusChanged();
|
||||
} else if (e->propertyName() == _borderWidth) {
|
||||
Q_EMIT m_platformHandle->borderWidthChanged();
|
||||
} else if (e->propertyName() == _borderColor) {
|
||||
Q_EMIT m_platformHandle->borderColorChanged();
|
||||
} else if (e->propertyName() == _shadowRadius) {
|
||||
Q_EMIT m_platformHandle->shadowRadiusChanged();
|
||||
} else if (e->propertyName() == _shadowOffset) {
|
||||
Q_EMIT m_platformHandle->shadowOffsetChanged();
|
||||
} else if (e->propertyName() == _shadowColor) {
|
||||
Q_EMIT m_platformHandle->shadowColorChanged();
|
||||
} else if (e->propertyName() == _clipPath) {
|
||||
Q_EMIT m_platformHandle->clipPathChanged();
|
||||
} else if (e->propertyName() == _frameMask) {
|
||||
Q_EMIT m_platformHandle->frameMaskChanged();
|
||||
} else if (e->propertyName() == _frameMargins) {
|
||||
Q_EMIT m_platformHandle->frameMarginsChanged();
|
||||
} else if (e->propertyName() == _translucentBackground) {
|
||||
Q_EMIT m_platformHandle->translucentBackgroundChanged();
|
||||
} else if (e->propertyName() == _enableSystemResize) {
|
||||
Q_EMIT m_platformHandle->enableSystemResizeChanged();
|
||||
} else if (e->propertyName() == _enableSystemMove) {
|
||||
Q_EMIT m_platformHandle->enableSystemMoveChanged();
|
||||
} else if (e->propertyName() == _enableBlurWindow) {
|
||||
Q_EMIT m_platformHandle->enableBlurWindowChanged();
|
||||
} else if (e->propertyName() == _autoInputMaskByClipPath) {
|
||||
Q_EMIT m_platformHandle->autoInputMaskByClipPathChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
static void initWindowRadius(QWindow *window)
|
||||
{
|
||||
if (window->property(_windowRadius).isValid())
|
||||
return;
|
||||
|
||||
auto theme = DGuiApplicationHelper::instance()->systemTheme();
|
||||
int radius = theme->windowRadius(12); //###(zccrs): 暂时在此处给窗口默认设置为12px的圆角
|
||||
|
||||
setWindowProperty(window, _windowRadius, radius);
|
||||
// Qt::UniqueConnection will report a warning
|
||||
// to `unique connections require a pointer to member function of a QObject subclass`.
|
||||
const char *uniqueueConnectionFlag("_d_uniqueueConnectionFlag");
|
||||
bool connected = window->property(uniqueueConnectionFlag).toBool();
|
||||
if (!connected) {
|
||||
window->setProperty(uniqueueConnectionFlag, true);
|
||||
window->connect(theme, &DPlatformTheme::windowRadiusChanged, window, [window] (int radius) {
|
||||
if (!resolved(window, PropRole::WindowRadius))
|
||||
setWindowProperty(window, _windowRadius, radius);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class Q_DECL_HIDDEN CreatorWindowEventFilter : public QObject {
|
||||
public:
|
||||
CreatorWindowEventFilter(QObject *par= nullptr): QObject(par){}
|
||||
|
||||
public:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override {
|
||||
if (event->type() == QEvent::PlatformSurface) {
|
||||
QPlatformSurfaceEvent *se = static_cast<QPlatformSurfaceEvent*>(event);
|
||||
if (se->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) { // 若收到此信号, 则 WinID 已被创建
|
||||
auto window = qobject_cast<QWindow *>(watched);
|
||||
initWindowRadius(window);
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
};
|
||||
|
||||
bool DXCBPlatformWindowInterface::isEnabledNoTitlebar() const
|
||||
{
|
||||
QFunctionPointer is_enable_no_titlebar = nullptr;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
is_enable_no_titlebar = qApp->platformFunction(_isEnableNoTitlebar);
|
||||
#endif
|
||||
|
||||
if (is_enable_no_titlebar) {
|
||||
return (*reinterpret_cast<bool(*)(const QWindow*)>(is_enable_no_titlebar))(m_window);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::setEnabledNoTitlebar(bool enable)
|
||||
{
|
||||
if (isEnabledNoTitlebar() == enable)
|
||||
return true;
|
||||
|
||||
QFunctionPointer enable_no_titlear = nullptr;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
enable_no_titlear = qApp->platformFunction(_setEnableNoTitlebar);
|
||||
#endif
|
||||
|
||||
if (enable_no_titlear) {
|
||||
bool ok = (*reinterpret_cast<bool(*)(QWindow*, bool)>(enable_no_titlear))(m_window, enable);
|
||||
if (ok && enable) {
|
||||
if (m_window->handle()) {
|
||||
initWindowRadius(m_window);
|
||||
} else {
|
||||
m_window->installEventFilter(new CreatorWindowEventFilter(m_window));
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline DPlatformHandle::WMBlurArea operator *(const DPlatformHandle::WMBlurArea &area, qreal scale)
|
||||
{
|
||||
if (qFuzzyCompare(scale, 1.0))
|
||||
return area;
|
||||
|
||||
DPlatformHandle::WMBlurArea new_area;
|
||||
|
||||
new_area.x = qRound64(area.x * scale);
|
||||
new_area.y = qRound64(area.y * scale);
|
||||
new_area.width = qRound64(area.width * scale);
|
||||
new_area.height = qRound64(area.height * scale);
|
||||
new_area.xRadius = qRound64(area.xRadius * scale);
|
||||
new_area.yRaduis = qRound64(area.yRaduis * scale);
|
||||
|
||||
return new_area;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief DXCBPlatformWindowInterface::setWindowBlurAreaByWM
|
||||
设置窗口背景的模糊区域,示例:
|
||||
\code
|
||||
QWindow w;
|
||||
QVector<DXCBPlatformWindowInterface::WMBlurArea> area_list;
|
||||
DXCBPlatformWindowInterface::WMBlurArea area;
|
||||
|
||||
area.x = 50;
|
||||
area.y = 50;
|
||||
area.width = 200;
|
||||
area.height = 200;
|
||||
area.xRadius = 10;
|
||||
area.yRaduis = 10;
|
||||
area_list.append(area);
|
||||
|
||||
DXCBPlatformWindowInterface::setWindowBlurAreaByWM(&w, area_list);
|
||||
|
||||
QSurfaceFormat format = w.format();
|
||||
format.setAlphaBufferSize(8);
|
||||
|
||||
w.setFormat(format);
|
||||
w.resize(300, 300);
|
||||
w.show();
|
||||
|
||||
\endcode
|
||||
\image blur_window_demo1.png
|
||||
\a window 目标窗口对象
|
||||
\a area 模糊区域,此区域范围内的窗口背景将填充为窗口后面内容模糊之后的图像
|
||||
\return 如果设置成功则返回 true,否则返回 false
|
||||
\note 对于需要显示模糊背景的窗口,需要将其 QSurfaceFormat 的 alpha 通道设置为8
|
||||
\note 调用此接口设置窗口背景模糊区域后将覆盖之前所设置的区域,包括调用
|
||||
setWindowBlurAreaByWM(QWindow *, const QList<QPainterPath> &)
|
||||
所设置的区域
|
||||
\note 建议使用 DBlurEffectWidget 实现窗口背景模糊效果
|
||||
\note 此功能依赖于窗口管理器的实现,目前仅支持 deepin-wm 和 kwin 这两个窗口管理器
|
||||
\sa Dtk::Widget::DBlurEffectWidget
|
||||
\sa QSurfaceFormat::setAlphaBufferSize
|
||||
\sa QWindow::setFormat
|
||||
\sa DWindowManagerHelper::hasBlurWindow
|
||||
\sa DXCBPlatformWindowInterface::setWindowBlurAreaByWM(QWindow *, const QList<QPainterPath> &)
|
||||
*/
|
||||
bool DXCBPlatformWindowInterface::setWindowBlurArea(const QVector<DPlatformHandle::WMBlurArea> &area)
|
||||
{
|
||||
if (!m_window) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isEnabled()) {
|
||||
QVector<quint32> areas;
|
||||
for (auto item : area)
|
||||
areas << item.x << item.y << item.width << item.height << item.xRadius << item.yRaduis;
|
||||
setWindowProperty(m_window, _windowBlurAreas, QVariant::fromValue(areas));
|
||||
return true;
|
||||
}
|
||||
|
||||
QFunctionPointer setWmBlurWindowBackgroundArea = Q_NULLPTR;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
setWmBlurWindowBackgroundArea = qApp->platformFunction(_setWmBlurWindowBackgroundArea);
|
||||
#endif
|
||||
|
||||
if (!setWmBlurWindowBackgroundArea) {
|
||||
qWarning("setWindowBlurAreaByWM is not support");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QSurfaceFormat format = m_window->format();
|
||||
|
||||
format.setAlphaBufferSize(8);
|
||||
m_window->setFormat(format);
|
||||
|
||||
const qreal device_ratio = m_window->devicePixelRatio();
|
||||
|
||||
if (qFuzzyCompare(device_ratio, 1.0)) {
|
||||
return reinterpret_cast<bool(*)(const quint32, const QVector<DPlatformHandle::WMBlurArea>&)>(setWmBlurWindowBackgroundArea)(m_window->winId(), area);
|
||||
}
|
||||
|
||||
QVector<DPlatformHandle::WMBlurArea> new_areas;
|
||||
|
||||
new_areas.reserve(area.size());
|
||||
|
||||
for (const DPlatformHandle::WMBlurArea &a : area) {
|
||||
new_areas.append(a * device_ratio);
|
||||
}
|
||||
|
||||
return reinterpret_cast<bool(*)(const quint32, const QVector<DPlatformHandle::WMBlurArea>&)>(setWmBlurWindowBackgroundArea)(m_window->winId(), new_areas);
|
||||
}
|
||||
|
||||
inline QPainterPath operator *(const QPainterPath &path, qreal scale)
|
||||
{
|
||||
if (qFuzzyCompare(1.0, scale))
|
||||
return path;
|
||||
|
||||
QPainterPath new_path = path;
|
||||
|
||||
for (int i = 0; i < path.elementCount(); ++i) {
|
||||
const QPainterPath::Element &e = path.elementAt(i);
|
||||
|
||||
new_path.setElementPositionAt(i, qRound(e.x * scale), qRound(e.y * scale));
|
||||
}
|
||||
|
||||
return new_path;
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::setWindowBlurArea(const QList<QPainterPath> &paths)
|
||||
{
|
||||
if (!m_window) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isEnabled()) {
|
||||
setWindowProperty(m_window, _windowBlurPaths, QVariant::fromValue(paths));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QFunctionPointer setWmBlurWindowBackgroundPathList = Q_NULLPTR;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
setWmBlurWindowBackgroundPathList = qApp->platformFunction(_setWmBlurWindowBackgroundPathList);
|
||||
#endif
|
||||
|
||||
if (!setWmBlurWindowBackgroundPathList) {
|
||||
qWarning("setWindowBlurAreaByWM is not support");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QSurfaceFormat format = m_window->format();
|
||||
|
||||
format.setAlphaBufferSize(8);
|
||||
m_window->setFormat(format);
|
||||
|
||||
const qreal device_ratio = m_window->devicePixelRatio();
|
||||
|
||||
if (qFuzzyCompare(device_ratio, 1.0)) {
|
||||
return reinterpret_cast<bool(*)(const quint32, const QList<QPainterPath>&)>(setWmBlurWindowBackgroundPathList)(m_window->winId(), paths);
|
||||
}
|
||||
|
||||
QList<QPainterPath> new_paths;
|
||||
|
||||
new_paths.reserve(paths.size());
|
||||
|
||||
for (const QPainterPath &p : paths) {
|
||||
new_paths.append(p * device_ratio);
|
||||
}
|
||||
|
||||
return reinterpret_cast<bool(*)(const quint32, const QList<QPainterPath>&)>(setWmBlurWindowBackgroundPathList)(m_window->winId(), new_paths);
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::setWindowWallpaperPara(const QRect &area, DPlatformHandle::WallpaperScaleMode sMode, DPlatformHandle::WallpaperFillMode fMode)
|
||||
{
|
||||
if (!m_window) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QFunctionPointer setWmWallpaperParameter = Q_NULLPTR;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
setWmWallpaperParameter = qApp->platformFunction(_setWmWallpaperParameter);
|
||||
#endif
|
||||
|
||||
if (!setWmWallpaperParameter) {
|
||||
qWarning("setWindowWallpaperParaByWM is not support");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QSurfaceFormat format = m_window->format();
|
||||
|
||||
format.setAlphaBufferSize(8);
|
||||
m_window->setFormat(format);
|
||||
|
||||
quint32 bMode = sMode | fMode;
|
||||
|
||||
// 激活 backing store
|
||||
m_window->setProperty("_d_dxcb_wallpaper", QVariant::fromValue(QPair<QRect, int>(area, bMode)));
|
||||
|
||||
if (!m_window->handle()) {
|
||||
return true;
|
||||
} else {
|
||||
qWarning() << "because the window handle has been created, so 2D mode will have no effect";
|
||||
}
|
||||
|
||||
const qreal device_ratio = m_window->devicePixelRatio();
|
||||
if (qFuzzyCompare(device_ratio, 1.0) || !area.isValid()) {
|
||||
return reinterpret_cast<bool(*)(const quint32, const QRect&, const quint32)>(setWmWallpaperParameter)(m_window->winId(), area, bMode);
|
||||
}
|
||||
|
||||
QRect new_area(area.x() * device_ratio,
|
||||
area.y() * device_ratio,
|
||||
area.width() * device_ratio,
|
||||
area.height() * device_ratio);
|
||||
|
||||
return reinterpret_cast<bool(*)(const quint32, const QRect&, const quint32)>(setWmWallpaperParameter)(m_window->winId(), new_area, bMode);
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setDisableWindowOverrideCursor(bool disable)
|
||||
{
|
||||
m_window->setProperty(_disableOverrideCursor, disable);
|
||||
}
|
||||
|
||||
int DXCBPlatformWindowInterface::windowRadius() const
|
||||
{
|
||||
return m_window->property(_windowRadius).toInt();
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setWindowRadius(int windowRadius)
|
||||
{
|
||||
setWindowProperty(m_window, _windowRadius, windowRadius);
|
||||
resolve(m_window, PropRole::WindowRadius);
|
||||
}
|
||||
|
||||
int DXCBPlatformWindowInterface::borderWidth() const
|
||||
{
|
||||
return m_window->property(_borderWidth).toInt();
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setBorderWidth(int borderWidth)
|
||||
{
|
||||
setWindowProperty(m_window, _borderWidth, borderWidth);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformWindowInterface::borderColor() const
|
||||
{
|
||||
return qvariant_cast<QColor>(m_window->property(_borderColor));
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setBorderColor(const QColor &borderColor)
|
||||
{
|
||||
setWindowProperty(m_window, _borderColor, QVariant::fromValue(borderColor));
|
||||
}
|
||||
|
||||
int DXCBPlatformWindowInterface::shadowRadius() const
|
||||
{
|
||||
return m_window->property(_shadowRadius).toInt();
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setShadowRadius(int shadowRadius)
|
||||
{
|
||||
setWindowProperty(m_window, _shadowRadius, shadowRadius);
|
||||
}
|
||||
|
||||
QPoint DXCBPlatformWindowInterface::shadowOffset() const
|
||||
{
|
||||
return m_window->property(_shadowOffset).toPoint();
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setShadowOffset(const QPoint &shadowOffset)
|
||||
{
|
||||
setWindowProperty(m_window, _shadowOffset, shadowOffset);
|
||||
}
|
||||
|
||||
QColor DXCBPlatformWindowInterface::shadowColor() const
|
||||
{
|
||||
return qvariant_cast<QColor>(m_window->property(_shadowColor));
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setShadowColor(const QColor &shadowColor)
|
||||
{
|
||||
setWindowProperty(m_window, _shadowColor, QVariant::fromValue(shadowColor));
|
||||
}
|
||||
|
||||
DPlatformHandle::EffectScene DXCBPlatformWindowInterface::windowEffect()
|
||||
{
|
||||
return qvariant_cast<DPlatformHandle::EffectScene>(m_window->property(_windowEffect));
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setWindowEffect(DPlatformHandle::EffectScenes effectScene)
|
||||
{
|
||||
setWindowProperty(m_window, _windowEffect, static_cast<quint32>(effectScene));
|
||||
}
|
||||
|
||||
DPlatformHandle::EffectType DXCBPlatformWindowInterface::windowStartUpEffect()
|
||||
{
|
||||
return qvariant_cast<DPlatformHandle::EffectType>(m_window->property(_windowStartUpEffect));
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setWindowStartUpEffect(DPlatformHandle::EffectTypes effectType)
|
||||
{
|
||||
setWindowProperty(m_window, _windowStartUpEffect, static_cast<quint32>(effectType));
|
||||
}
|
||||
|
||||
QPainterPath DXCBPlatformWindowInterface::clipPath() const
|
||||
{
|
||||
return qvariant_cast<QPainterPath>(m_window->property(_clipPath));
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setClipPath(const QPainterPath &clipPath)
|
||||
{
|
||||
setWindowProperty(m_window, _clipPath, QVariant::fromValue(clipPath));
|
||||
}
|
||||
|
||||
QRegion DXCBPlatformWindowInterface::frameMask() const
|
||||
{
|
||||
return qvariant_cast<QRegion>(m_window->property(_frameMask));
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setFrameMask(const QRegion &frameMask)
|
||||
{
|
||||
setWindowProperty(m_window, _frameMask, QVariant::fromValue(frameMask));
|
||||
}
|
||||
|
||||
QMargins DXCBPlatformWindowInterface::frameMargins() const
|
||||
{
|
||||
return qvariant_cast<QMargins>(m_window->property(_frameMargins));
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::translucentBackground() const
|
||||
{
|
||||
return m_window->property(_translucentBackground).toBool();
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setTranslucentBackground(bool translucentBackground)
|
||||
{
|
||||
setWindowProperty(m_window, _translucentBackground, translucentBackground);
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::enableSystemResize() const
|
||||
{
|
||||
return m_window->property(_enableSystemResize).toBool();
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setEnableSystemResize(bool enableSystemResize)
|
||||
{
|
||||
setWindowProperty(m_window, _enableSystemResize, enableSystemResize);
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::enableSystemMove() const
|
||||
{
|
||||
return m_window->property(_enableSystemMove).toBool();
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setEnableSystemMove(bool enableSystemMove)
|
||||
{
|
||||
setWindowProperty(m_window, _enableSystemMove, enableSystemMove);
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::enableBlurWindow() const
|
||||
{
|
||||
return m_window->property(_enableBlurWindow).toBool();
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setEnableBlurWindow(bool enableBlurWindow)
|
||||
{
|
||||
setWindowProperty(m_window, _enableBlurWindow, enableBlurWindow);
|
||||
}
|
||||
|
||||
bool DXCBPlatformWindowInterface::autoInputMaskByClipPath() const
|
||||
{
|
||||
return m_window->property(_autoInputMaskByClipPath).toBool();
|
||||
}
|
||||
|
||||
void DXCBPlatformWindowInterface::setAutoInputMaskByClipPath(bool autoInputMaskByClipPath)
|
||||
{
|
||||
setWindowProperty(m_window, _autoInputMaskByClipPath, autoInputMaskByClipPath);
|
||||
}
|
||||
|
||||
WId DXCBPlatformWindowInterface::realWindowId() const
|
||||
{
|
||||
return qvariant_cast<WId>(m_window->property("_d_real_content_window"));
|
||||
}
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#ifndef DXCBPLATFORMWINDOWINTERFACE_H
|
||||
#define DXCBPLATFORMWINDOWINTERFACE_H
|
||||
|
||||
#include "private/dplatformwindowinterface_p.h"
|
||||
|
||||
#include <QWindow>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class DXCBPlatformWindowInterface : public QObject, public DPlatformWindowInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DXCBPlatformWindowInterface(QWindow *window, DPlatformHandle *platformHandle, QObject *parent = nullptr);
|
||||
~DXCBPlatformWindowInterface() override;
|
||||
|
||||
static QString pluginVersion();
|
||||
static bool isDXcbPlatform();
|
||||
static bool connectWindowManagerChangedSignal(QObject *object, std::function<void ()> slot);
|
||||
static bool connectHasBlurWindowChanged(QObject *object, std::function<void ()> slot);
|
||||
static WId windowLeader();
|
||||
|
||||
void enableDXcb(bool redirectContent);
|
||||
|
||||
bool setWindowBlurArea(const QVector<DPlatformHandle::WMBlurArea> &area);
|
||||
bool setWindowBlurArea(const QList<QPainterPath> &paths);
|
||||
bool setWindowWallpaperPara(const QRect &area, DPlatformHandle::WallpaperScaleMode sMode, DPlatformHandle::WallpaperFillMode fMode);
|
||||
|
||||
bool autoInputMaskByClipPath() const;
|
||||
void setAutoInputMaskByClipPath(bool autoInputMaskByClipPath);
|
||||
|
||||
WId realWindowId() const;
|
||||
|
||||
void setEnabled(bool enabled) override;
|
||||
bool isEnabled() const override;
|
||||
|
||||
void setDisableWindowOverrideCursor(bool disable) override;
|
||||
|
||||
bool isEnabledNoTitlebar() const override;
|
||||
bool setEnabledNoTitlebar(bool enable) override;
|
||||
|
||||
int windowRadius() const override;
|
||||
void setWindowRadius(int windowRadius) override;
|
||||
|
||||
int borderWidth() const override;
|
||||
void setBorderWidth(int borderWidth) override;
|
||||
|
||||
QColor borderColor() const override;
|
||||
void setBorderColor(const QColor &borderColor) override;
|
||||
|
||||
int shadowRadius() const override;
|
||||
void setShadowRadius(int shadowRadius) override;
|
||||
|
||||
QPoint shadowOffset() const override;
|
||||
void setShadowOffset(const QPoint &shadowOffset) override;
|
||||
|
||||
QColor shadowColor() const override;
|
||||
void setShadowColor(const QColor &shadowColor) override;
|
||||
|
||||
DPlatformHandle::EffectScene windowEffect() override;
|
||||
void setWindowEffect(DPlatformHandle::EffectScenes effectScene) override;
|
||||
|
||||
DPlatformHandle::EffectType windowStartUpEffect() override;
|
||||
void setWindowStartUpEffect(DPlatformHandle::EffectTypes effectType) override;
|
||||
|
||||
QPainterPath clipPath() const override;
|
||||
void setClipPath(const QPainterPath &clipPath) override;
|
||||
|
||||
QRegion frameMask() const override;
|
||||
void setFrameMask(const QRegion &frameMask) override;
|
||||
|
||||
QMargins frameMargins() const override;
|
||||
|
||||
bool translucentBackground() const override;
|
||||
void setTranslucentBackground(bool translucentBackground) override;
|
||||
|
||||
bool enableSystemResize() const override;
|
||||
void setEnableSystemResize(bool enableSystemResize) override;
|
||||
|
||||
bool enableSystemMove() const override;
|
||||
void setEnableSystemMove(bool enableSystemMove) override;
|
||||
|
||||
bool enableBlurWindow() const override;
|
||||
void setEnableBlurWindow(bool enableBlurWindow) override;
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
};
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
#endif // DXCBPLATFORMWINDOWINTERFACE_H
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
file(GLOB XCB_HEADER
|
||||
${CMAKE_CURRENT_LIST_DIR}/*.h
|
||||
)
|
||||
file(GLOB XCB_SOURCE
|
||||
${CMAKE_CURRENT_LIST_DIR}/*.cpp
|
||||
)
|
||||
set(xcb_SRC
|
||||
${XCB_HEADER}
|
||||
${XCB_SOURCE}
|
||||
)
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
option(DTK_DISABLE_XCB "Disable XCB Protocols" OFF)
|
||||
|
||||
option(DTK_DISABLE_TREELAND "Disable Treeland Protocols" OFF)
|
||||
|
||||
file(GLOB PLATFORM_INTERFACE_HEADER
|
||||
${CMAKE_CURRENT_LIST_DIR}/*.h
|
||||
)
|
||||
file(GLOB PLATFORM_INTERFACE_SOURCE
|
||||
${CMAKE_CURRENT_LIST_DIR}/*.cpp
|
||||
)
|
||||
|
||||
set(platform_interface_SRC
|
||||
${PLATFORM_INTERFACE_HEADER}
|
||||
${PLATFORM_INTERFACE_SOURCE}
|
||||
)
|
||||
target_sources(${LIB_NAME} PRIVATE
|
||||
${platform_interface_SRC}
|
||||
)
|
||||
|
||||
set(PRIVATE_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/private/dplatforminterface_p.h)
|
||||
set(PRIVATE_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/dtk${PROJECT_VERSION_MAJOR}/DGui/Private")
|
||||
|
||||
# XCB
|
||||
if(NOT DTK_DISABLE_XCB)
|
||||
message("Support XCB!")
|
||||
include(plugins/platform/xcb/xcb.cmake)
|
||||
target_sources(${LIB_NAME} PRIVATE
|
||||
${xcb_SRC}
|
||||
)
|
||||
else()
|
||||
target_compile_definitions(${LIB_NAME} PRIVATE DTK_DISABLE_XCB)
|
||||
endif()
|
||||
|
||||
# Treeland
|
||||
|
||||
try_compile(DEEPIN_WAYLAND_TEST_COMPILE_RESULT ${CMAKE_CURRENT_BINARY_DIR}/treeland_test
|
||||
${CMAKE_CURRENT_LIST_DIR}/platform/config.tests/treeland_test treeland_test CMAKE_FLAGS -DQT_VERSION_MAJOR=${QT_VERSION_MAJOR})
|
||||
|
||||
if(NOT DEEPIN_WAYLAND_TEST_COMPILE_RESULT)
|
||||
message("wayland_test failed, disable treeland support")
|
||||
set(DTK_DISABLE_TREELAND ON)
|
||||
endif()
|
||||
|
||||
if(NOT DTK_DISABLE_TREELAND)
|
||||
find_package(TreelandProtocols)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS WaylandClient)
|
||||
set(TreelandProtocols_FOUND ${TreelandProtocols_FOUND})
|
||||
endif()
|
||||
|
||||
if(NOT DTK_DISABLE_TREELAND AND TreelandProtocols_FOUND)
|
||||
message("Support Treeland!")
|
||||
if("${QT_VERSION_MAJOR}" STREQUAL "6")
|
||||
qt6_generate_wayland_protocol_client_sources(${LIB_NAME} FILES
|
||||
${TREELAND_PROTOCOLS_DATA_DIR}/treeland-personalization-manager-v1.xml
|
||||
)
|
||||
else()
|
||||
# ECM setup
|
||||
include(FeatureSummary)
|
||||
find_package(ECM REQUIRED NO_MODULE)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${ECM_MODULE_PATH}")
|
||||
find_package(QtWaylandScanner)
|
||||
ecm_add_qtwayland_client_protocol(CLIENT_LIB_SRCS
|
||||
PROTOCOL ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-personalization-manager-v1.xml
|
||||
BASENAME treeland-personalization-manager-v1
|
||||
)
|
||||
target_sources(${LIB_NAME} PRIVATE
|
||||
${CLIENT_LIB_SRCS}
|
||||
)
|
||||
endif()
|
||||
|
||||
include(plugins/platform/treeland/treeland.cmake)
|
||||
target_sources(${LIB_NAME} PRIVATE
|
||||
${treeland_SRC}
|
||||
)
|
||||
else()
|
||||
target_compile_definitions(${LIB_NAME} PRIVATE DTK_DISABLE_TREELAND)
|
||||
endif()
|
||||
|
||||
install(FILES ${PRIVATE_HEADER_FILES} DESTINATION "${PRIVATE_INCLUDE_INSTALL_DIR}")
|
||||
|
|
@ -17,7 +17,7 @@ class DFontManagerPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate
|
|||
public:
|
||||
DFontManagerPrivate(DFontManager *qq);
|
||||
|
||||
int fontPixelSize[DFontManager::NSizeTypes] = {40, 30, 24, 20, 17, 14, 13, 12, 11, 10};
|
||||
int fontPixelSize[DFontManager::NSizeTypes] = {40, 30, 24, 20, 16, 14, 13, 12, 11, 10, 8};
|
||||
int baseFontSizeType = DFontManager::T6;
|
||||
// 字号的差值
|
||||
int fontPixelSizeDiff = 0;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ public:
|
|||
DGuiApplicationHelper::SizeMode fetchSizeMode(bool *isSystemSizeMode = nullptr) const;
|
||||
void notifyAppThemeChanged();
|
||||
void notifyAppThemeChangedByEvent();
|
||||
void onApplicationPaletteChanged();
|
||||
// 返回程序是否自定义了调色板
|
||||
inline bool isCustomPalette() const;
|
||||
void setPaletteType(DGuiApplicationHelper::ColorType ct, bool emitSignal);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,136 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#ifndef DPLATFORMINTERFACE_H
|
||||
#define DPLATFORMINTERFACE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWindow>
|
||||
|
||||
#include "dtkgui_global.h"
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class DPlatformTheme;
|
||||
|
||||
class LIBDTKCORESHARED_EXPORT DPlatformInterface
|
||||
{
|
||||
public:
|
||||
explicit DPlatformInterface(DPlatformTheme *platformTheme);
|
||||
virtual ~DPlatformInterface();
|
||||
virtual int cursorBlinkTime() const;
|
||||
virtual int cursorBlinkTimeout() const;
|
||||
virtual bool cursorBlink() const;
|
||||
virtual int doubleClickDistance() const;
|
||||
virtual int doubleClickTime() const;
|
||||
virtual int dndDragThreshold() const;
|
||||
virtual int windowRadius() const;
|
||||
virtual int windowRadius(int defaultValue) const;
|
||||
virtual QByteArray themeName() const;
|
||||
virtual QByteArray iconThemeName() const;
|
||||
virtual QByteArray soundThemeName() const;
|
||||
|
||||
virtual QByteArray fontName() const;
|
||||
virtual QByteArray monoFontName() const;
|
||||
virtual qreal fontPointSize() const;
|
||||
virtual QByteArray gtkFontName() const;
|
||||
|
||||
virtual QColor activeColor() const;
|
||||
virtual QColor darkActiveColor() const;
|
||||
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
virtual QColor window() const;
|
||||
virtual QColor windowText() const;
|
||||
virtual QColor base() const;
|
||||
virtual QColor alternateBase() const;
|
||||
virtual QColor toolTipBase() const;
|
||||
virtual QColor toolTipText() const;
|
||||
virtual QColor text() const;
|
||||
virtual QColor button() const;
|
||||
virtual QColor buttonText() const;
|
||||
virtual QColor brightText() const;
|
||||
virtual QColor light() const;
|
||||
virtual QColor midlight() const;
|
||||
virtual QColor dark() const;
|
||||
virtual QColor mid() const;
|
||||
virtual QColor shadow() const;
|
||||
virtual QColor highlight() const;
|
||||
virtual QColor highlightedText() const;
|
||||
virtual QColor link() const;
|
||||
virtual QColor linkVisited() const;
|
||||
virtual QColor itemBackground() const;
|
||||
virtual QColor textTitle() const;
|
||||
virtual QColor textTips() const;
|
||||
virtual QColor textWarning() const;
|
||||
virtual QColor textLively() const;
|
||||
virtual QColor lightLively() const;
|
||||
virtual QColor darkLively() const;
|
||||
virtual QColor frameBorder() const;
|
||||
#endif
|
||||
|
||||
virtual int sizeMode() const;
|
||||
virtual int scrollBarPolicy() const;
|
||||
|
||||
public:
|
||||
virtual void setCursorBlinkTime(int cursorBlinkTime);
|
||||
virtual void setCursorBlinkTimeout(int cursorBlinkTimeout);
|
||||
virtual void setCursorBlink(bool cursorBlink);
|
||||
virtual void setDoubleClickDistance(int doubleClickDistance);
|
||||
virtual void setDoubleClickTime(int doubleClickTime);
|
||||
virtual void setDndDragThreshold(int dndDragThreshold);
|
||||
virtual void setThemeName(const QByteArray &themeName);
|
||||
virtual void setIconThemeName(const QByteArray &iconThemeName);
|
||||
virtual void setSoundThemeName(const QByteArray &soundThemeName);
|
||||
virtual void setFontName(const QByteArray &fontName);
|
||||
virtual void setMonoFontName(const QByteArray &monoFontName);
|
||||
virtual void setFontPointSize(qreal fontPointSize);
|
||||
virtual void setGtkFontName(const QByteArray &fontName);
|
||||
virtual void setActiveColor(const QColor activeColor);
|
||||
virtual void setDarkActiveColor(const QColor &activeColor);
|
||||
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
|
||||
virtual void setWindow(const QColor &window);
|
||||
virtual void setWindowText(const QColor &windowText);
|
||||
virtual void setBase(const QColor &base);
|
||||
virtual void setAlternateBase(const QColor &alternateBase);
|
||||
virtual void setToolTipBase(const QColor &toolTipBase);
|
||||
virtual void setToolTipText(const QColor &toolTipText);
|
||||
virtual void setText(const QColor &text);
|
||||
virtual void setButton(const QColor &button);
|
||||
virtual void setButtonText(const QColor &buttonText);
|
||||
virtual void setBrightText(const QColor &brightText);
|
||||
virtual void setLight(const QColor &light);
|
||||
virtual void setMidlight(const QColor &midlight);
|
||||
virtual void setDark(const QColor &dark);
|
||||
virtual void setMid(const QColor &mid);
|
||||
virtual void setShadow(const QColor &shadow);
|
||||
virtual void setHighlight(const QColor &highlight);
|
||||
virtual void setHighlightedText(const QColor &highlightedText);
|
||||
virtual void setLink(const QColor &link);
|
||||
virtual void setLinkVisited(const QColor &linkVisited);
|
||||
virtual void setItemBackground(const QColor &itemBackground);
|
||||
virtual void setTextTitle(const QColor &textTitle);
|
||||
virtual void setTextTips(const QColor &textTips);
|
||||
virtual void setTextWarning(const QColor &textWarning);
|
||||
virtual void setTextLively(const QColor &textLively);
|
||||
virtual void setLightLively(const QColor &lightLively);
|
||||
virtual void setDarkLively(const QColor &darkLively);
|
||||
virtual void setFrameBorder(const QColor &frameBorder);
|
||||
#endif
|
||||
|
||||
virtual int dotsPerInch(const QString &screenName = QString()) const;
|
||||
virtual void setDotsPerInch(const QString &screenName, int dpi);
|
||||
virtual void setWindowRadius(int windowRadius);
|
||||
|
||||
protected:
|
||||
DPlatformTheme *m_platformTheme;
|
||||
};
|
||||
|
||||
class LIBDTKCORESHARED_EXPORT DPlatformInterfaceFactory {
|
||||
public:
|
||||
using HelperCreator = DPlatformInterface * (*)(DPlatformTheme*);
|
||||
static void registerInterface(HelperCreator creator);
|
||||
};
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
#endif // DNATIVESETTINGS_P_H
|
||||
|
|
@ -5,9 +5,15 @@
|
|||
#ifndef DPLATFORMTHEME_P_H
|
||||
#define DPLATFORMTHEME_P_H
|
||||
|
||||
#include "private/dplatforminterface_p.h"
|
||||
#include "dplatformtheme.h"
|
||||
#include "dnativesettings_p.h"
|
||||
|
||||
#include <dguiapplicationhelper.h>
|
||||
|
||||
class OrgDeepinDTKPreference;
|
||||
|
||||
DCORE_USE_NAMESPACE
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class DPlatformThemePrivate : public DNativeSettingsPrivate
|
||||
|
|
@ -18,7 +24,6 @@ public:
|
|||
|
||||
// 接收parent主题或非调色板DNativeSettings对象(theme对象)的属性变化通知
|
||||
// 调色板相关的属性变化与此无关
|
||||
void _q_onThemePropertyChanged(const QByteArray &name, const QVariant &value);
|
||||
void onQtColorChanged(QPalette::ColorRole role, const QColor &color);
|
||||
void onDtkColorChanged(DPalette::ColorType type, const QColor &color);
|
||||
void notifyPaletteChanged();
|
||||
|
|
@ -34,6 +39,12 @@ public:
|
|||
DPalette *palette = nullptr;
|
||||
// 减少调色板changed信号的通知频率
|
||||
QTimer *notifyPaletteChangeTimer = nullptr;
|
||||
OrgDeepinDTKPreference *dtkPreferenceConfig = nullptr;
|
||||
|
||||
DPlatformInterface *platformInterface = nullptr;
|
||||
|
||||
DGuiApplicationHelper::SizeMode sizeMode = DGuiApplicationHelper::NormalMode;
|
||||
Qt::ScrollBarPolicy scrollBarPolicy = Qt::ScrollBarAsNeeded;
|
||||
};
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -0,0 +1,86 @@
|
|||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#ifndef DPLATFORMWINDOWINTERFACE_P_H
|
||||
#define DPLATFORMWINDOWINTERFACE_P_H
|
||||
|
||||
#include <QPointer>
|
||||
#include <QWindow>
|
||||
|
||||
#include "dplatformhandle.h"
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class LIBDTKCORESHARED_EXPORT DPlatformWindowInterface
|
||||
{
|
||||
public:
|
||||
explicit DPlatformWindowInterface(QWindow *window, DPlatformHandle *platformHandle);
|
||||
virtual ~DPlatformWindowInterface();
|
||||
|
||||
QWindow* window() const;
|
||||
|
||||
virtual void setEnabled(bool enabled);
|
||||
virtual bool isEnabled() const;
|
||||
|
||||
virtual bool isEnabledNoTitlebar() const;
|
||||
virtual bool setEnabledNoTitlebar(bool enable);
|
||||
|
||||
virtual void setDisableWindowOverrideCursor(bool disable);
|
||||
|
||||
virtual int windowRadius() const;
|
||||
virtual void setWindowRadius(int windowRadius);
|
||||
|
||||
virtual int borderWidth() const;
|
||||
virtual void setBorderWidth(int borderWidth);
|
||||
|
||||
virtual QColor borderColor() const;
|
||||
virtual void setBorderColor(const QColor &borderColor);
|
||||
|
||||
virtual int shadowRadius() const;
|
||||
virtual void setShadowRadius(int shadowRadius);
|
||||
|
||||
virtual QPoint shadowOffset() const;
|
||||
virtual void setShadowOffset(const QPoint &shadowOffset);
|
||||
|
||||
virtual QColor shadowColor() const;
|
||||
virtual void setShadowColor(const QColor &shadowColor);
|
||||
|
||||
virtual DPlatformHandle::EffectScene windowEffect();
|
||||
virtual void setWindowEffect(DPlatformHandle::EffectScenes effectScene);
|
||||
|
||||
virtual DPlatformHandle::EffectType windowStartUpEffect();
|
||||
virtual void setWindowStartUpEffect(DPlatformHandle::EffectTypes effectType);
|
||||
|
||||
virtual QPainterPath clipPath() const;
|
||||
virtual void setClipPath(const QPainterPath &clipPath);
|
||||
|
||||
virtual QRegion frameMask() const;
|
||||
virtual void setFrameMask(const QRegion &frameMask);
|
||||
|
||||
virtual QMargins frameMargins() const;
|
||||
|
||||
virtual bool translucentBackground() const;
|
||||
virtual void setTranslucentBackground(bool translucentBackground);
|
||||
|
||||
virtual bool enableSystemResize() const;
|
||||
virtual void setEnableSystemResize(bool enableSystemResize);
|
||||
|
||||
virtual bool enableSystemMove() const;
|
||||
virtual void setEnableSystemMove(bool enableSystemMove);
|
||||
|
||||
virtual bool enableBlurWindow() const;
|
||||
virtual void setEnableBlurWindow(bool enableBlurWindow);
|
||||
protected:
|
||||
QPointer<QWindow> m_window;
|
||||
QPointer<DPlatformHandle> m_platformHandle;
|
||||
};
|
||||
|
||||
class LIBDTKCORESHARED_EXPORT DPlatformWindowInterfaceFactory {
|
||||
public:
|
||||
using Creator = DPlatformWindowInterface * (*)(QWindow *, DPlatformHandle*);
|
||||
static void registerInterface(Creator creator);
|
||||
};
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
#endif // DPLATFORMWINDOWINTERFACE_P_H
|
||||
|
|
@ -7,4 +7,6 @@ set(private_SRC
|
|||
${CMAKE_CURRENT_LIST_DIR}/dregionmonitor_p.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/dtaskbarcontrol_p.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/dfontmanager_p.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/dplatforminterface_p.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/dplatformwindowinterface_p.h
|
||||
)
|
||||
|
|
|
|||
|
|
@ -598,6 +598,8 @@ void DDciIconPrivate::loadIconList()
|
|||
node.entries << icon;
|
||||
node.maxPaddings = qMax(node.maxPaddings, icon->maxPaddings);
|
||||
}
|
||||
if (node.entries.isEmpty())
|
||||
continue;
|
||||
icons << std::move(node);
|
||||
}
|
||||
}
|
||||
|
|
@ -646,7 +648,7 @@ DDciIconEntry *DDciIconPrivate::tryMatchIcon(int iconSize, DDciIcon::Theme theme
|
|||
}
|
||||
|
||||
const auto targetIcon = std::max_element(iconWeight.constBegin(), iconWeight.constEnd());
|
||||
if (*targetIcon > 0)
|
||||
if (targetIcon != iconWeight.constEnd() && *targetIcon > 0)
|
||||
return listOfSize.entries.at(targetIcon - iconWeight.constBegin());
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -656,7 +658,11 @@ static const DDciIconEntry::ScalableLayer &findScalableLayer(const DDciIconEntry
|
|||
const DDciIconEntry::ScalableLayer *maxLayer = nullptr;
|
||||
const int imagePixelRatio = qCeil(devicePixelRatio);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
for (const auto &i : std::as_const(entry->scalableLayers)) {
|
||||
#else
|
||||
for (const auto &i : qAsConst(entry->scalableLayers)) {
|
||||
#endif
|
||||
if (!maxLayer || i.imagePixelRatio > maxLayer->imagePixelRatio)
|
||||
maxLayer = &i;
|
||||
if (i.imagePixelRatio > imagePixelRatio)
|
||||
|
|
@ -850,7 +856,7 @@ QList<int> DDciIcon::availableSizes(DDciIcon::Theme theme, DDciIcon::Mode mode)
|
|||
return sizes;
|
||||
}
|
||||
|
||||
bool DDciIcon::isSupportedAttribute(DDciIconMatchResult result, IconAttibute attr) const
|
||||
bool DDciIcon::isSupportedAttribute(DDciIconMatchResult result, IconAttribute attr) const
|
||||
{
|
||||
switch (attr) {
|
||||
case HasPalette:
|
||||
|
|
@ -862,7 +868,7 @@ bool DDciIcon::isSupportedAttribute(DDciIconMatchResult result, IconAttibute att
|
|||
return false;
|
||||
}
|
||||
|
||||
bool DDciIcon::isSupportedAttribute(const DDciIconImage &image, IconAttibute attr)
|
||||
bool DDciIcon::isSupportedAttribute(const DDciIconImage &image, IconAttribute attr)
|
||||
{
|
||||
if (image.isNull())
|
||||
return false;
|
||||
|
|
@ -1135,7 +1141,11 @@ int DDciIconImage::currentImageNumber() const
|
|||
void DDciIconImagePrivate::init()
|
||||
{
|
||||
readers.reserve(layers.size());
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
for (const auto &layer : std::as_const(layers)) {
|
||||
#else
|
||||
for (const auto &layer : qAsConst(layers)) {
|
||||
#endif
|
||||
ReaderData *data = new ReaderData;
|
||||
Q_ASSERT(data);
|
||||
auto buffer = new QBuffer();
|
||||
|
|
|
|||
|
|
@ -207,7 +207,11 @@ bool DDciIconImagePlayer::setPalette(const DDciIconPalette &palette)
|
|||
d->palette = palette;
|
||||
|
||||
bool hasPalette = false;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
for (const auto &i : std::as_const(d->images))
|
||||
#else
|
||||
for (const auto &i : qAsConst(d->images))
|
||||
#endif
|
||||
if (i.hasPalette())
|
||||
hasPalette = true;
|
||||
|
||||
|
|
@ -649,7 +653,7 @@ void DDciIconPlayerPrivate::initPlayer()
|
|||
// Remove the finished animation
|
||||
animationJobs.removeFirst();
|
||||
|
||||
qCDebug(diPlayer, "Number of animations remaining is %i", animationJobs.size());
|
||||
qCDebug(diPlayer) << "Number of animations remaining is" << animationJobs.size();
|
||||
if (!animationJobs.isEmpty()) {
|
||||
_q_playFromQueue();
|
||||
return;
|
||||
|
|
@ -692,7 +696,7 @@ bool DDciIconPlayerPrivate::ensureHoverModeLastImage()
|
|||
}
|
||||
if (!image.atEnd())
|
||||
return false;
|
||||
Q_ASSERT(!player);
|
||||
Q_ASSERT(player);
|
||||
hoverModeLastImage = image.toImage(player->palette());
|
||||
return !hoverModeLastImage.isNull();
|
||||
}
|
||||
|
|
@ -1075,10 +1079,15 @@ QImage DDciIconPlayer::currentImage() const
|
|||
return d->image;
|
||||
}
|
||||
|
||||
void DDciIconPlayer::play(DDciIcon::Mode mode)
|
||||
void DDciIconPlayer::play(DDciIcon::Mode mode, DDciIconImagePlayer::Flags flags)
|
||||
{
|
||||
D_D(DDciIconPlayer);
|
||||
d->play(mode, DDciIconImagePlayer::IgnoreLastImageLoop);
|
||||
d->play(mode, flags);
|
||||
}
|
||||
|
||||
void DDciIconPlayer::play(DDciIcon::Mode mode)
|
||||
{
|
||||
play(mode, DDciIconImagePlayer::IgnoreLastImageLoop);
|
||||
}
|
||||
|
||||
void DDciIconPlayer::stop()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,217 @@
|
|||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "ddesktopservices.h"
|
||||
#include <QtDBus/QtDBus>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
#define EASY_CALL_DBUS(name) \
|
||||
QDBusInterface *interface = fileManager1DBusInterface(); \
|
||||
return interface && \
|
||||
interface->call(#name, urls2uris(urls), startupId).type() != \
|
||||
QDBusMessage::ErrorMessage;
|
||||
|
||||
static const QStringList SOUND_EFFECT_LIST {
|
||||
"message",
|
||||
"camera-shutter",
|
||||
"trash-empty",
|
||||
"x-deepin-app-sent-to-desktop",
|
||||
"desktop-login",
|
||||
"system-shutdown",
|
||||
"desktop-logout",
|
||||
"suspend-resume",
|
||||
"audio-volume-change",
|
||||
"power-unplug-battery-low",
|
||||
"power-plug",
|
||||
"power-unplug",
|
||||
"device-added",
|
||||
"device-removed",
|
||||
"dialog-error",
|
||||
};
|
||||
|
||||
static QDBusInterface *fileManager1DBusInterface()
|
||||
{
|
||||
static QDBusInterface interface(QStringLiteral("org.freedesktop.FileManager1"),
|
||||
QStringLiteral("/org/freedesktop/FileManager1"),
|
||||
QStringLiteral("org.freedesktop.FileManager1"));
|
||||
return &interface;
|
||||
}
|
||||
|
||||
static QStringList urls2uris(const QList<QUrl> &urls)
|
||||
{
|
||||
QStringList list;
|
||||
|
||||
list.reserve(urls.size());
|
||||
|
||||
for (const QUrl &url : urls) {
|
||||
list << url.toString();
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static QList<QUrl> path2urls(const QList<QString> &paths)
|
||||
{
|
||||
QList<QUrl> list;
|
||||
|
||||
list.reserve(paths.size());
|
||||
|
||||
for (const QString &path : paths) {
|
||||
list << QUrl::fromLocalFile(path);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static QDBusInterface soundEffectInterface()
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
const auto& infc = QDBusConnection::sessionBus().interface();
|
||||
QStringList activatableServiceNames = infc->activatableServiceNames();
|
||||
bool isNewInterface = activatableServiceNames.contains(QLatin1String("org.deepin.dde.SoundEffect1"));
|
||||
#else
|
||||
bool isNewInterface = false; // Qt 5.14 以下就直接用旧的接口
|
||||
#endif
|
||||
const QLatin1String service(isNewInterface ? "org.deepin.dde.SoundEffect1" :"com.deepin.daemon.SoundEffect");
|
||||
const QLatin1String path(isNewInterface ? "/org/deepin/dde/SoundEffect1" : "/com/deepin/daemon/SoundEffect");
|
||||
const QLatin1String interface(isNewInterface ? "org.deepin.dde.SoundEffect1" :"com.deepin.daemon.SoundEffect");
|
||||
|
||||
// 使用后端 dbus 接口播放系统音频,音频存放目录: /usr/share/sounds/deepin/stereo/
|
||||
return QDBusInterface(service, path, interface);
|
||||
}
|
||||
|
||||
static bool systemSoundEffectEnabled(const QString &name)
|
||||
{
|
||||
auto soundEffect = soundEffectInterface();
|
||||
if (!soundEffect.property("Enabled").toBool())
|
||||
return false;
|
||||
|
||||
QDBusReply<bool> reply = soundEffect.call("IsSoundEnabled", name);
|
||||
|
||||
return reply.isValid() && reply.value();
|
||||
}
|
||||
|
||||
bool DDesktopServices::showFolder(const QString &localFilePath, const QString &startupId)
|
||||
{
|
||||
return showFolder(QUrl::fromLocalFile(localFilePath), startupId);
|
||||
}
|
||||
|
||||
bool DDesktopServices::showFolders(const QList<QString> &localFilePaths, const QString &startupId)
|
||||
{
|
||||
return showFolders(path2urls(localFilePaths), startupId);
|
||||
}
|
||||
|
||||
bool DDesktopServices::showFolder(const QUrl &url, const QString &startupId)
|
||||
{
|
||||
return showFolders(QList<QUrl>() << url, startupId);
|
||||
}
|
||||
|
||||
bool DDesktopServices::showFolders(const QList<QUrl> &urls, const QString &startupId)
|
||||
{
|
||||
EASY_CALL_DBUS(ShowFolders)
|
||||
}
|
||||
|
||||
bool DDesktopServices::showFileItemProperty(const QString &localFilePath, const QString &startupId)
|
||||
{
|
||||
return showFileItemProperty(QUrl::fromLocalFile(localFilePath), startupId);
|
||||
}
|
||||
|
||||
bool DDesktopServices::showFileItemProperties(const QList<QString> &localFilePaths, const QString &startupId)
|
||||
{
|
||||
return showFileItemProperties(path2urls(localFilePaths), startupId);
|
||||
}
|
||||
|
||||
bool DDesktopServices::showFileItemProperty(const QUrl &url, const QString &startupId)
|
||||
{
|
||||
return showFileItemProperties(QList<QUrl>() << url, startupId);
|
||||
}
|
||||
|
||||
bool DDesktopServices::showFileItemProperties(const QList<QUrl> &urls, const QString &startupId)
|
||||
{
|
||||
EASY_CALL_DBUS(ShowItemProperties)
|
||||
}
|
||||
|
||||
bool DDesktopServices::showFileItem(const QString &localFilePath, const QString &startupId)
|
||||
{
|
||||
return showFileItem(QUrl::fromLocalFile(localFilePath), startupId);
|
||||
}
|
||||
|
||||
bool DDesktopServices::showFileItems(const QList<QString> &localFilePaths, const QString &startupId)
|
||||
{
|
||||
return showFileItems(path2urls(localFilePaths), startupId);
|
||||
}
|
||||
|
||||
bool DDesktopServices::showFileItem(const QUrl &url, const QString &startupId)
|
||||
{
|
||||
return showFileItems(QList<QUrl>() << url, startupId);
|
||||
}
|
||||
|
||||
bool DDesktopServices::showFileItems(const QList<QUrl> &urls, const QString &startupId)
|
||||
{
|
||||
EASY_CALL_DBUS(ShowItems)
|
||||
}
|
||||
|
||||
bool DDesktopServices::trash(const QString &localFilePath)
|
||||
{
|
||||
return trash(QUrl::fromLocalFile(localFilePath));
|
||||
}
|
||||
|
||||
bool DDesktopServices::trash(const QList<QString> &localFilePaths)
|
||||
{
|
||||
return trash(path2urls(localFilePaths));
|
||||
}
|
||||
|
||||
bool DDesktopServices::trash(const QUrl &url)
|
||||
{
|
||||
return trash(QList<QUrl>() << url);
|
||||
}
|
||||
|
||||
bool DDesktopServices::trash(const QList<QUrl> &urls)
|
||||
{
|
||||
QDBusInterface *interface = fileManager1DBusInterface();
|
||||
return interface && interface->call("Trash", urls2uris(urls)).type() != QDBusMessage::ErrorMessage;
|
||||
}
|
||||
|
||||
bool DDesktopServices::playSystemSoundEffect(const DDesktopServices::SystemSoundEffect &effect)
|
||||
{
|
||||
return playSystemSoundEffect(SOUND_EFFECT_LIST.at(static_cast<int>(effect)));
|
||||
}
|
||||
|
||||
bool DDesktopServices::playSystemSoundEffect(const QString &name)
|
||||
{
|
||||
if (!systemSoundEffectEnabled(name))
|
||||
return false;
|
||||
|
||||
return previewSystemSoundEffect(name);
|
||||
}
|
||||
|
||||
bool DDesktopServices::previewSystemSoundEffect(const DDesktopServices::SystemSoundEffect &effect)
|
||||
{
|
||||
return previewSystemSoundEffect(SOUND_EFFECT_LIST.at(static_cast<int>(effect)));
|
||||
}
|
||||
|
||||
bool DDesktopServices::previewSystemSoundEffect(const QString &name)
|
||||
{
|
||||
if (name.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 使用后端 dbus 接口播放系统音频,音频存放目录: /usr/share/sounds/deepin/stereo/
|
||||
return soundEffectInterface().call("PlaySound", name).type() != QDBusMessage::ErrorMessage;
|
||||
}
|
||||
|
||||
QString DDesktopServices::getNameByEffectType(const DDesktopServices::SystemSoundEffect &effect)
|
||||
{
|
||||
return SOUND_EFFECT_LIST.at(static_cast<int>(effect));
|
||||
}
|
||||
|
||||
QString DDesktopServices::errorMessage()
|
||||
{
|
||||
return fileManager1DBusInterface()->lastError().message();
|
||||
}
|
||||
|
||||
DGUI_END_NAMESPACE
|
||||
|
|
@ -49,7 +49,7 @@ DFontManager::~DFontManager()
|
|||
\value T4
|
||||
系统级别为 T4 的字体大小, 默认是20 px
|
||||
\value T5
|
||||
系统级别为 T5 的字体大小, 默认是17 px
|
||||
系统级别为 T5 的字体大小, 默认是16 px
|
||||
\value T6
|
||||
系统级别为 T6 的字体大小, 默认是14 px
|
||||
\value T7
|
||||
|
|
@ -60,6 +60,8 @@ DFontManager::~DFontManager()
|
|||
系统级别为 T9 的字体大小, 默认是11 px
|
||||
\value T10
|
||||
系统级别为 T10 的字体大小, 默认是10 px
|
||||
\value T11
|
||||
系统级别为 T11 的字体大小, 默认是8 px
|
||||
|
||||
\omitvalue NSizeTypes
|
||||
*/
|
||||
|
|
@ -147,6 +149,8 @@ QFont DFontManager::get(int pixelSize, const QFont &base)
|
|||
{
|
||||
QFont font = base;
|
||||
font.setPixelSize(pixelSize);
|
||||
// Ensure that the FamilyResolved flag is set in order for Qt to correctly set fonts
|
||||
font.setFamilies(base.families());
|
||||
return font;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "private/dbuiltiniconengine_p.h"
|
||||
#include "private/dciiconengine_p.h"
|
||||
#include "private/diconproxyengine_p.h"
|
||||
#include <private/qicon_p.h>
|
||||
#ifndef DTK_DISABLE_LIBXDG
|
||||
#include "private/xdgiconproxyengine_p.h"
|
||||
#else
|
||||
|
|
@ -95,6 +96,9 @@ QIconEngine *DIconTheme::createIconEngine(const QString &iconName, Options optio
|
|||
|
||||
QIcon DIconTheme::findQIcon(const QString &iconName, Options options)
|
||||
{
|
||||
if (QDir::isAbsolutePath(iconName)) {
|
||||
return QIcon(iconName);
|
||||
}
|
||||
auto engine = createIconEngine(iconName, options);
|
||||
// fallback to QIcon::fromTheme
|
||||
if (!options.testFlag(DontFallbackToQIconFromTheme) && !engine)
|
||||
|
|
@ -122,12 +126,12 @@ bool DIconTheme::isBuiltinIcon(const QIcon &icon)
|
|||
|
||||
bool DIconTheme::isXdgIcon(const QIcon &icon)
|
||||
{
|
||||
#ifdef DTK_DISABLE_LIBXDG
|
||||
return false;
|
||||
#else
|
||||
if (icon.isNull())
|
||||
return false;
|
||||
|
||||
#ifdef DTK_DISABLE_LIBXDG
|
||||
return false;
|
||||
#else
|
||||
QIconEngine *engine = const_cast<QIcon &>(icon).data_ptr()->engine;
|
||||
if (auto proxyEngine = dynamic_cast<DIconProxyEngine *>(engine))
|
||||
return !proxyEngine->proxyKey().compare("XdgIconProxyEngine");
|
||||
|
|
@ -173,7 +177,8 @@ void DIconTheme::Cached::clear()
|
|||
|
||||
QIcon DIconTheme::Cached::findQIcon(const QString &iconName, Options options, const QIcon &fallback)
|
||||
{
|
||||
const QString cacheKey = iconName + QChar('/') + QString::number(static_cast<int>(options));
|
||||
const QString themeName = QIcon::themeName();
|
||||
const QString cacheKey = themeName + QChar('/') + iconName + QChar('/') + QString::number(static_cast<int>(options));
|
||||
if (data->cache.contains(cacheKey)) {
|
||||
auto cacheIcon = data->cache.object(cacheKey);
|
||||
if (cacheIcon->isNull())
|
||||
|
|
@ -182,10 +187,12 @@ QIcon DIconTheme::Cached::findQIcon(const QString &iconName, Options options, co
|
|||
}
|
||||
|
||||
auto newIcon = new QIcon(DIconTheme::findQIcon(iconName, options));
|
||||
data->cache.insert(cacheKey, newIcon);
|
||||
|
||||
if (newIcon->isNull())
|
||||
if (newIcon->isNull()) {
|
||||
return fallback;
|
||||
} else {
|
||||
data->cache.insert(cacheKey, newIcon);
|
||||
}
|
||||
|
||||
return *newIcon;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,7 +145,10 @@ QImage DSvgRendererPrivate::getImage(const QSize &size, const QString &elementId
|
|||
QImage image(size, QImage::Format_ARGB32_Premultiplied);
|
||||
image.fill(Qt::transparent);
|
||||
QPainter pa(&image);
|
||||
qRenderer->render(&pa, elementId);
|
||||
if (elementId.isEmpty())
|
||||
qRenderer->render(&pa);
|
||||
else
|
||||
qRenderer->render(&pa, elementId);
|
||||
return image;
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,18 +36,17 @@
|
|||
<file>texts/unlock_indicator_24px.svg</file>
|
||||
<file>texts/unselected_indicator_16px.svg</file>
|
||||
<file>texts/window-close_round_30px.svg</file>
|
||||
<file>texts/search_indicator_20px.svg</file>
|
||||
<file>texts/unchecked_20px.svg</file>
|
||||
<file>texts/checked_20px.svg</file>
|
||||
<file>texts/next_indicator_24px.svg</file>
|
||||
<file>texts/prev_indicator_24px.svg</file>
|
||||
<file>actions/edit-select-all_16px.svg</file>
|
||||
<file>actions/edit-copy_16px.svg</file>
|
||||
<file>actions/edit-cut_16px.svg</file>
|
||||
<file>actions/edit-delete_16px.svg</file>
|
||||
<file>actions/edit-paste_16px.svg</file>
|
||||
<file>actions/edit-redo_16px.svg</file>
|
||||
<file>actions/edit-undo_16px.svg</file>
|
||||
<file alias="texts/edit-select-all_16px.svg">actions/edit-select-all_16px.svg</file>
|
||||
<file alias="texts/edit-copy_16px.svg">actions/edit-copy_16px.svg</file>
|
||||
<file alias="texts/edit-cut_16px.svg">actions/edit-cut_16px.svg</file>
|
||||
<file alias="texts/edit-delete_16px.svg">actions/edit-delete_16px.svg</file>
|
||||
<file alias="texts/edit-paste_16px.svg">actions/edit-paste_16px.svg</file>
|
||||
<file alias="texts/edit-redo_16px.svg">actions/edit-redo_16px.svg</file>
|
||||
<file alias="texts/edit-undo_16px.svg">actions/edit-undo_16px.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/icons/deepin/builtin/light">
|
||||
<file alias="icons/button_edit-clear_30px.svg/normal.svg">icons/light/edit-clear_30px.svg</file>
|
||||
|
|
@ -59,6 +58,7 @@
|
|||
<file alias="icons/list_add_16px.svg">icons/light/list_add_16px.svg</file>
|
||||
<file alias="icons/window-close_round_30px.svg/normal.svg">icons/light/window-close_round_30px.svg</file>
|
||||
<file alias="icons/window-close_round_30px.svg/selected.svg">icons/light/window-close_round_press_30px.svg</file>
|
||||
<file alias="texts/search_indicator_20px.svg">icons/light/search_indicator_20px.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/icons/deepin/builtin/dark">
|
||||
<file alias="icons/button_edit-clear_30px.svg/normal.svg">icons/dark/edit-clear_30px.svg</file>
|
||||
|
|
@ -70,6 +70,7 @@
|
|||
<file alias="icons/list_add_16px.svg">icons/dark/list_add_16px.svg</file>
|
||||
<file alias="icons/window-close_round_30px.svg/normal.svg">icons/dark/window-close_round_30px.svg</file>
|
||||
<file alias="icons/window-close_round_30px.svg/selected.svg">icons/dark/window-close_round_press_30px.svg</file>
|
||||
<file alias="texts/search_indicator_20px.svg">icons/dark/search_indicator_20px.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/dsg/built-in-icons">
|
||||
<file alias="sp_ok.dci">dci/sp_ok.dci</file>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>画板</title>
|
||||
<g id="画板" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="search_indicator_36px" transform="translate(2.000000, 2.000000)" fill="#ffffff" fill-rule="nonzero">
|
||||
<path d="M6.6,-1.77635684e-15 C10.2450793,-1.77635684e-15 13.2,2.9549207 13.2,6.6 C13.2,8.2063613 12.6261237,9.6786865 11.6722057,10.8231412 L16.4242641,15.5757359 C16.6585786,15.8100505 16.6585786,16.1899495 16.4242641,16.4242641 C16.1899495,16.6585786 15.8100505,16.6585786 15.5757359,16.4242641 L15.5757359,16.4242641 L10.8231412,11.6722057 C9.6786865,12.6261237 8.2063613,13.2 6.6,13.2 C2.9549207,13.2 -1.77635684e-15,10.2450793 -1.77635684e-15,6.6 C-1.77635684e-15,2.9549207 2.9549207,-1.77635684e-15 6.6,-1.77635684e-15 Z M6.6,1.2 C3.6176624,1.2 1.2,3.6176624 1.2,6.6 C1.2,9.5823376 3.6176624,12 6.6,12 C9.5823376,12 12,9.5823376 12,6.6 C12,3.6176624 9.5823376,1.2 6.6,1.2 Z" id="形状"></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
|
@ -19,6 +19,17 @@
|
|||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
static qreal devicePixelRatio(QPainter *painter)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (qApp->testAttribute(Qt::AA_UseHighDpiPixmaps))
|
||||
return (painter && painter->device()) ? painter->device()->devicePixelRatioF() : qApp->devicePixelRatio();
|
||||
return 1.0;
|
||||
#else
|
||||
return (painter && painter->device()) ? painter->device()->devicePixelRatioF() : qApp->devicePixelRatio();
|
||||
#endif
|
||||
}
|
||||
|
||||
class Q_DECL_HIDDEN ImageEntry : public QIconLoaderEngineEntry
|
||||
{
|
||||
public:
|
||||
|
|
@ -50,11 +61,20 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override {
|
||||
#else
|
||||
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override {
|
||||
#endif
|
||||
Q_UNUSED(state)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
const QSize pixmapSize = size * scale;
|
||||
#else
|
||||
const QSize pixmapSize(size);
|
||||
#endif
|
||||
QPixmap pm;
|
||||
QString pmckey(pmcKey(size, mode, state));
|
||||
QString pmckey(pmcKey(pixmapSize, mode, state));
|
||||
if (QPixmapCache::find(pmckey, &pm)) {
|
||||
genIconTypeIcon(pm, mode);
|
||||
return pm;
|
||||
|
|
@ -67,7 +87,7 @@ public:
|
|||
}
|
||||
|
||||
if (dir.type == QIconDirInfo::Scalable)
|
||||
reader.setScaledSize(size);
|
||||
reader.setScaledSize(pixmapSize);
|
||||
|
||||
pm = QPixmap::fromImageReader(&reader);
|
||||
if (!pm.isNull())
|
||||
|
|
@ -111,7 +131,11 @@ public:
|
|||
return dir.filePath("normal." + suffix);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override {
|
||||
#else
|
||||
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override {
|
||||
#endif
|
||||
if (iconFileMap.isEmpty()) {
|
||||
const QString &suffix = QFileInfo(filename).suffix();
|
||||
QDir dir(filename);
|
||||
|
|
@ -128,7 +152,11 @@ public:
|
|||
|
||||
reader.setFileName(iconFileMap.value(mode << 8 | state));
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
return ImageEntry::pixmap(size, mode, state, scale);
|
||||
#else
|
||||
return ImageEntry::pixmap(size, mode, state);
|
||||
#endif
|
||||
}
|
||||
|
||||
QMap<qint16, QString> iconFileMap;
|
||||
|
|
@ -192,7 +220,11 @@ QPixmap DBuiltinIconEngine::pixmap(const QSize &size, QIcon::Mode mode,
|
|||
|
||||
QIconLoaderEngineEntry *entry = QIconLoaderEngine::entryForSize(m_info, size);
|
||||
if (entry)
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
return entry->pixmap(size, mode, state, devicePixelRatio(nullptr));
|
||||
#else
|
||||
return entry->pixmap(size, mode, state);
|
||||
#endif
|
||||
|
||||
return QPixmap();
|
||||
}
|
||||
|
|
@ -202,13 +234,7 @@ void DBuiltinIconEngine::paint(QPainter *painter, const QRect &rect,
|
|||
{
|
||||
ensureLoaded();
|
||||
|
||||
qreal scale = 1.0;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (qApp->testAttribute(Qt::AA_UseHighDpiPixmaps))
|
||||
scale = painter->device() ? painter->device()->devicePixelRatioF() : qApp->devicePixelRatio();
|
||||
#else
|
||||
scale = painter->device() ? painter->device()->devicePixelRatioF() : qApp->devicePixelRatio();
|
||||
#endif
|
||||
const qreal scale = devicePixelRatio(painter);
|
||||
QSize pixmapSize = rect.size() * scale;
|
||||
|
||||
QIconLoaderEngineEntry *entry = QIconLoaderEngine::entryForSize(m_info, pixmapSize);
|
||||
|
|
@ -222,7 +248,11 @@ void DBuiltinIconEngine::paint(QPainter *painter, const QRect &rect,
|
|||
QIcon(bgFileName).paint(painter, rect, Qt::AlignCenter, mode, state);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
QPixmap pm = entry->pixmap(pixmapSize, mode, state, 1.0);
|
||||
#else
|
||||
QPixmap pm = entry->pixmap(pixmapSize, mode, state);
|
||||
#endif
|
||||
ImageEntry::Type type = static_cast<ImageEntry *>(entry)->type;
|
||||
if (type == ImageEntry::TextType || (type == ImageEntry::ActionType && mode != QIcon::Normal)) {
|
||||
QPainter pa(&pm);
|
||||
|
|
@ -271,6 +301,28 @@ QString DBuiltinIconEngine::iconName()
|
|||
return m_iconName;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QList<QSize> DBuiltinIconEngine::availableSizes(QIcon::Mode mode, QIcon::State state)
|
||||
{
|
||||
Q_UNUSED(mode);
|
||||
Q_UNUSED(state);
|
||||
ensureLoaded();
|
||||
|
||||
QList<QSize> sizes;
|
||||
const int N = m_info.entries.size();
|
||||
sizes.reserve(N);
|
||||
|
||||
// Gets all sizes from the DirectoryInfo entries
|
||||
for (int i = 0; i < N; ++i) {
|
||||
const auto& entry = m_info.entries.at(i);
|
||||
int size = entry->dir.size;
|
||||
sizes.append(QSize(size, size));
|
||||
}
|
||||
|
||||
return sizes;
|
||||
}
|
||||
#endif
|
||||
|
||||
QThemeIconInfo DBuiltinIconEngine::loadIcon(const QString &iconName, uint key)
|
||||
{
|
||||
QThemeIconInfo info;
|
||||
|
|
@ -386,7 +438,11 @@ void DBuiltinIconEngine::virtual_hook(int id, void *data)
|
|||
// QIcon::pixmap() multiplies size by the device pixel ratio.
|
||||
const int integerScale = qCeil(arg.scale);
|
||||
QIconLoaderEngineEntry *entry = QIconLoaderEngine::entryForSize(m_info, arg.size / integerScale, integerScale);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
arg.pixmap = entry ? entry->pixmap(arg.size, arg.mode, arg.state, arg.scale) : QPixmap();
|
||||
#else
|
||||
arg.pixmap = entry ? entry->pixmap(arg.size, arg.mode, arg.state) : QPixmap();
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ public:
|
|||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString iconName() override;
|
||||
QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off) override;
|
||||
#else
|
||||
QString iconName() const override;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
|
||||
#include <private/qhexstring_p.h>
|
||||
#include <private/qiconloader_p.h>
|
||||
|
|
@ -158,6 +159,23 @@ const
|
|||
return m_iconName;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QList<QSize> DDciIconEngine::availableSizes(QIcon::Mode mode, QIcon::State state)
|
||||
{
|
||||
Q_UNUSED(state);
|
||||
ensureIconTheme();
|
||||
|
||||
const auto availableSizes = m_dciIcon.availableSizes(dciTheme(), dciMode(mode));
|
||||
QList<QSize> sizes;
|
||||
sizes.reserve(availableSizes.size());
|
||||
|
||||
for (int size : availableSizes)
|
||||
sizes.append(QSize(size, size));
|
||||
|
||||
return sizes;
|
||||
}
|
||||
#endif
|
||||
|
||||
void DDciIconEngine::virtual_hook(int id, void *data)
|
||||
{
|
||||
ensureIconTheme();
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public:
|
|||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString iconName() override;
|
||||
QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off) override;
|
||||
#else
|
||||
QString iconName() const override;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include <QDir>
|
||||
|
||||
#include <private/qiconloader_p.h>
|
||||
#if XDG_ICON_VERSION_MAR >= 3
|
||||
#if (XDG_ICON_VERSION_MAR >= 3)
|
||||
#define private public
|
||||
#include <private/xdgiconloader/xdgiconloader_p.h>
|
||||
#undef private
|
||||
|
|
@ -156,8 +156,9 @@ QIconEngine *DIconProxyEngine::clone() const
|
|||
|
||||
bool DIconProxyEngine::read(QDataStream &in)
|
||||
{
|
||||
// ensureEngine, will changed themeName if not the same
|
||||
in >> m_iconName >> m_iconThemeName;
|
||||
|
||||
ensureEngine();
|
||||
return m_iconEngine ? m_iconEngine->read(in) : false;
|
||||
}
|
||||
|
||||
|
|
@ -172,9 +173,24 @@ QString DIconProxyEngine::iconName()
|
|||
const
|
||||
#endif
|
||||
{
|
||||
return m_iconName;
|
||||
return m_iconEngine ? m_iconEngine->iconName() : QString();
|
||||
}
|
||||
|
||||
QList<QSize> DIconProxyEngine::availableSizes(QIcon::Mode mode, QIcon::State state)
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
const
|
||||
#endif
|
||||
{
|
||||
return m_iconEngine ? m_iconEngine->availableSizes(mode, state) : QIconEngine::availableSizes(mode, state);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
bool DIconProxyEngine::isNull()
|
||||
{
|
||||
return m_iconEngine ? m_iconEngine->isNull() : QIconEngine::isNull();
|
||||
}
|
||||
#endif
|
||||
|
||||
QString DIconProxyEngine::proxyKey()
|
||||
{
|
||||
ensureEngine();
|
||||
|
|
@ -210,9 +226,12 @@ void DIconProxyEngine::ensureEngine()
|
|||
return;
|
||||
|
||||
static QMap<QString, QSet<QString>> nonCache;
|
||||
const auto it = nonCache.find(theme);
|
||||
if (it != nonCache.end() && it->contains(m_iconName))
|
||||
return;
|
||||
if (Q_UNLIKELY(!m_option.testFlag(DIconTheme::IgnoreIconCache)))
|
||||
{
|
||||
const auto it = nonCache.find(theme);
|
||||
if (it != nonCache.end() && it->contains(m_iconName))
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_iconEngine) {
|
||||
// dci => dci
|
||||
|
|
@ -242,19 +261,22 @@ void DIconProxyEngine::ensureEngine()
|
|||
m_iconEngine = createDBuiltinIconEngine(m_iconName);
|
||||
}
|
||||
#ifdef DTK_DISABLE_LIBXDG
|
||||
if (!m_iconEngine && Q_UNLIKELY(!m_option.testFlag(DIconTheme::DontFallbackToQIconFromTheme)) && QGuiApplicationPrivate::platformTheme() ) {
|
||||
// Warning : do not call from qplatformTheme createIconEngine (stackoverflow)
|
||||
m_iconEngine = QGuiApplicationPrivate::platformTheme()->createIconEngine(m_iconName);
|
||||
if (!m_iconEngine) {
|
||||
QPlatformTheme * const platformTheme = QGuiApplicationPrivate::platformTheme();
|
||||
if (platformTheme) {
|
||||
m_iconEngine = platformTheme->QPlatformTheme::createIconEngine(m_iconName);
|
||||
} else {
|
||||
qWarning() << "PlatformTheme not found!";
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!m_iconEngine ) {
|
||||
m_iconEngine = createXdgProxyIconEngine(m_iconName);
|
||||
}
|
||||
#endif
|
||||
if (!m_iconEngine ) {
|
||||
qErrnoWarning("create icon [%s] engine failed.[theme:%s] nonCache[theme].size[%d]",
|
||||
m_iconName.toUtf8().data(),
|
||||
theme.toUtf8().data(), nonCache[theme].size());
|
||||
if (!m_iconEngine && !nonCache[theme].contains(m_iconName)) {
|
||||
qWarning() << "create icon [" << m_iconName << "] engine failed."
|
||||
<< "theme:" << theme << "and nonCache's size:" << nonCache.size();
|
||||
nonCache[theme].insert(m_iconName);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,16 @@ public:
|
|||
#else
|
||||
QString iconName() const override;
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off) override;
|
||||
#else
|
||||
QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off) const override;
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
bool isNull() override;
|
||||
#endif
|
||||
inline QString themeName() const { return m_iconThemeName; }
|
||||
|
||||
QString proxyKey();
|
||||
|
|
|
|||
|
|
@ -49,6 +49,11 @@ static inline QPixmap entryPixmap(ScalableEntry *color_entry, const QSize &size,
|
|||
if (!color_entry)
|
||||
return QPixmap();
|
||||
|
||||
// init svgIcon with svg absolute path
|
||||
// force to use svg iconengine
|
||||
if (color_entry->svgIcon.isNull())
|
||||
color_entry->svgIcon = QIcon(color_entry->filename);
|
||||
|
||||
if (auto d = color_entry->svgIcon.data_ptr())
|
||||
if (d->engine)
|
||||
return d->engine->pixmap(size, mode, state);
|
||||
|
|
@ -99,7 +104,7 @@ QPixmap XdgIconProxyEngine::followColorPixmap(ScalableEntry *color_entry, const
|
|||
|
||||
// 当size为1时表示此svg文件不需要处理ColorScheme标签
|
||||
if (!cache_color_scheme.isEmpty() && cache_color_scheme[DEEPIN_XDG_THEME::Text].size() == 1)
|
||||
return color_entry->pixmap(size, mode, state);
|
||||
return entryPixmap(color_entry, size, mode, state);
|
||||
|
||||
const DEEPIN_XDG_THEME::PALETTE_MAP &color_scheme = DEEPIN_XDG_THEME::colorScheme.localData();
|
||||
QPixmap pm = color_scheme == cache_color_scheme ? entryPixmap(color_entry, size, mode, state) : QPixmap();
|
||||
|
|
@ -144,7 +149,7 @@ QPixmap XdgIconProxyEngine::followColorPixmap(ScalableEntry *color_entry, const
|
|||
if (invalidBuffers) {
|
||||
// 此svg图标无ColorScheme标签时不应该再下面的操作,且应该记录下来,避免后续再处理svg文件内容
|
||||
entryToColorScheme[cache_key] = DEEPIN_XDG_THEME::PALETTE_MAP({ {DEEPIN_XDG_THEME::Text, "#"} });
|
||||
return color_entry->pixmap(size, mode, state);
|
||||
return entryPixmap(color_entry, size, mode, state);
|
||||
}
|
||||
|
||||
// use the QSvgIconEngine
|
||||
|
|
@ -184,7 +189,11 @@ QPixmap XdgIconProxyEngine::pixmapByEntry(QIconLoaderEngineEntry *entry, const Q
|
|||
if (!XdgIconFollowColorScheme()) {
|
||||
DEEPIN_XDG_THEME::colorScheme.setLocalData(DEEPIN_XDG_THEME::PALETTE_MAP());
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 1)
|
||||
return entry->pixmap(size, mode, state, 1.0);
|
||||
#else
|
||||
return entry->pixmap(size, mode, state);
|
||||
#endif
|
||||
}
|
||||
|
||||
QPixmap pixmap;
|
||||
|
|
@ -201,7 +210,11 @@ QPixmap XdgIconProxyEngine::pixmapByEntry(QIconLoaderEngineEntry *entry, const Q
|
|||
|
||||
pixmap = followColorPixmap(static_cast<ScalableEntry *>(entry), size, mode, state);
|
||||
} else {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 1)
|
||||
pixmap = entry->pixmap(size, mode, state, 1.0);
|
||||
#else
|
||||
pixmap = entry->pixmap(size, mode, state);
|
||||
#endif
|
||||
}
|
||||
|
||||
free(type_name);
|
||||
|
|
@ -238,8 +251,11 @@ void XdgIconProxyEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode
|
|||
QPixmap XdgIconProxyEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
|
||||
{
|
||||
engine->ensureLoaded();
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QIconLoaderEngineEntry *entry = engine->entryForSize(size);
|
||||
#else
|
||||
QIconLoaderEngineEntry *entry = engine->entryForSize(engine->m_info ,size);
|
||||
#endif
|
||||
|
||||
if (!entry) {
|
||||
DEEPIN_XDG_THEME::colorScheme.setLocalData(DEEPIN_XDG_THEME::PALETTE_MAP());
|
||||
|
|
@ -294,7 +310,12 @@ void XdgIconProxyEngine::virtual_hook(int id, void *data)
|
|||
QIconEngine::ScaledPixmapArgument &arg = *reinterpret_cast<QIconEngine::ScaledPixmapArgument *>(data);
|
||||
// QIcon::pixmap() multiplies size by the device pixel ratio.
|
||||
const int integerScale = qCeil(arg.scale);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QIconLoaderEngineEntry *entry = engine->entryForSize(arg.size / integerScale, integerScale);
|
||||
#else
|
||||
QIconLoaderEngineEntry *entry = engine->entryForSize(engine->m_info, arg.size / integerScale, integerScale);
|
||||
#endif
|
||||
// 先禁用缩放,因为此size是已经缩放过的
|
||||
bool useHighDpiPixmap = qGuiApp->testAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
qGuiApp->setAttribute(Qt::AA_UseHighDpiPixmaps, false);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#define XDGICONPROXYENGINE_H
|
||||
|
||||
#include <dtkgui_global.h>
|
||||
#include <QHash>
|
||||
|
||||
#if XDG_ICON_VERSION_MAR >= 3
|
||||
#include <QIconEngine>
|
||||
|
|
@ -25,7 +26,8 @@ struct ScalableEntry;
|
|||
class QIconLoaderEngineEntry;
|
||||
class XdgIconLoaderEngine;
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
#if XDG_ICON_VERSION_MAR >= 3
|
||||
|
||||
#if (XDG_ICON_VERSION_MAR >= 3)
|
||||
class Q_DECL_HIDDEN XdgIconProxyEngine : public QIconEngine
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
if(NOT DTK_DISABLE_LIBXDG)
|
||||
message("Enable libxdg!")
|
||||
# find_package(qt${QT_VERSION_MAJOR}xdgiconloader)
|
||||
if (Qt5_FOUND)
|
||||
find_package(qt5xdgiconloader)
|
||||
add_definitions(-DXDG_ICON_VERSION_MAR=${qt5xdgiconloader_VERSION_MAJOR})
|
||||
endif()
|
||||
find_package(qt${QT_VERSION_MAJOR}xdgiconloader)
|
||||
|
||||
add_definitions(-DXDG_ICON_VERSION_MAR=${qt${QT_VERSION_MAJOR}xdgiconloader_VERSION_MAJOR})
|
||||
|
||||
set(UTIL_PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/private/xdgiconproxyengine_p.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/private/xdgiconproxyengine.cpp
|
||||
|
|
|
|||
|
|
@ -1,6 +1,13 @@
|
|||
set(BIN_NAME ut-DtkGui)
|
||||
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Test)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets DBus Network Test)
|
||||
if ("${QT_VERSION_MAJOR}" STREQUAL "6")
|
||||
if (${Qt6Core_VERSION} VERSION_GREATER_EQUAL "6.10.0")
|
||||
set(QT_NO_PRIVATE_MODULE_WARNING ON)
|
||||
find_package(Qt6 REQUIRED COMPONENTS CorePrivate GuiPrivate WaylandClientPrivate)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(GTest REQUIRED)
|
||||
|
||||
file(GLOB test_SRC
|
||||
|
|
@ -44,7 +51,7 @@ target_link_libraries(${BIN_NAME} PRIVATE
|
|||
m
|
||||
)
|
||||
|
||||
if(NOT DTK_DISABLE_EX_IMAGE_FORMAT AND EX_IMAGE_FORMAT_LIBS_FOUND)
|
||||
if(NOT DTK_DISABLE_EX_IMAGE_FORMAT AND EX_IMAGE_FORMAT_LIBS_FOUND)
|
||||
target_link_libraries(${BIN_NAME} PRIVATE
|
||||
PkgConfig::libraw
|
||||
FreeImage::FreeImage
|
||||
|
|
@ -52,7 +59,7 @@ target_link_libraries(${BIN_NAME} PRIVATE
|
|||
endif()
|
||||
|
||||
if(NOT DTK_DISABLE_LIBXDG)
|
||||
target_link_libraries(${BIN_NAME} PRIVATE
|
||||
target_link_libraries(${BIN_NAME} PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}XdgIconLoader
|
||||
)
|
||||
endif()
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -127,6 +127,15 @@ void DDynamicMetaObject::init(const QMetaObject *metaObject)
|
|||
|
||||
QMetaPropertyBuilder op;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
switch (mp.metaType().id()) {
|
||||
case QMetaType::QByteArray:
|
||||
case QMetaType::QString:
|
||||
case QMetaType::QColor:
|
||||
case QMetaType::Int:
|
||||
case QMetaType::Double:
|
||||
case QMetaType::Bool:
|
||||
#else
|
||||
switch (mp.type()) {
|
||||
case QVariant::Type::ByteArray:
|
||||
case QVariant::Type::String:
|
||||
|
|
@ -134,6 +143,7 @@ void DDynamicMetaObject::init(const QMetaObject *metaObject)
|
|||
case QVariant::Type::Int:
|
||||
case QVariant::Type::Double:
|
||||
case QVariant::Type::Bool:
|
||||
#endif
|
||||
op = ob.addProperty(mp);
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class DPlatformSettings;
|
||||
class DDynamicMetaObject : public QAbstractDynamicMetaObject
|
||||
class Q_DECL_HIDDEN DDynamicMetaObject : public QAbstractDynamicMetaObject
|
||||
{
|
||||
public:
|
||||
explicit DDynamicMetaObject(QObject *base, DPlatformSettings *settings, bool global_settings);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ QT_END_NAMESPACE
|
|||
|
||||
DGUI_BEGIN_NAMESPACE
|
||||
|
||||
class DPlatformSettings
|
||||
class Q_DECL_HIDDEN DPlatformSettings
|
||||
{
|
||||
public:
|
||||
virtual ~DPlatformSettings() {}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "dummysettings.h"
|
||||
#include <QDebug>
|
||||
|
||||
class DummySettingsPrivate : public QObject
|
||||
class Q_DECL_HIDDEN DummySettingsPrivate : public QObject
|
||||
{
|
||||
public:
|
||||
DummySettingsPrivate(DummySettings *q, const QString &domain, QObject *parent = nullptr);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
DGUI_USE_NAMESPACE
|
||||
|
||||
class DummySettingsPrivate;
|
||||
class DummySettings : public DPlatformSettings
|
||||
class Q_DECL_HIDDEN DummySettings : public DPlatformSettings
|
||||
{
|
||||
public:
|
||||
explicit DummySettings(const QString &domain = QString());
|
||||
|
|
|
|||
|
|
@ -13,11 +13,18 @@
|
|||
#include <qpa/qplatformwindow.h>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <private/qgenericunixeventdispatcher_p.h>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
|
||||
#include <private/qdesktopunixservices_p.h>
|
||||
#else
|
||||
#include <private/qgenericunixservices_p.h>
|
||||
#endif
|
||||
|
||||
MinimalIntegration::MinimalIntegration(const QStringList ¶meters)
|
||||
{
|
||||
Q_UNUSED(parameters);
|
||||
m_primaryScreen = new MinimalScreen();
|
||||
|
||||
m_primaryScreen->mGeometry = QRect(0, 0, 240, 320);
|
||||
|
|
@ -53,7 +60,11 @@ QAbstractEventDispatcher *MinimalIntegration::createEventDispatcher() const
|
|||
QPlatformServices *MinimalIntegration::services() const
|
||||
{
|
||||
if (!m_services)
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
|
||||
m_services.reset(new QDesktopUnixServices);
|
||||
#else
|
||||
m_services.reset(new QGenericUnixServices);
|
||||
#endif
|
||||
return m_services.get();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ DGUI_USE_NAMESPACE
|
|||
#define ICONNAME "icon_Layout"
|
||||
#define ICONSIZE 16
|
||||
|
||||
class ut_DBuiltinIconEngine : public testing::Test
|
||||
class GTEST_API_ ut_DBuiltinIconEngine : public testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override;
|
||||
|
|
@ -60,7 +60,11 @@ TEST_F(ut_DBuiltinIconEngine, loadIcon)
|
|||
ASSERT_EQ(entry->dir.path, builtinActionPath);
|
||||
ASSERT_EQ(entry->dir.size, ICONSIZE);
|
||||
ASSERT_EQ(entry->dir.type, QIconDirInfo::Scalable);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
ASSERT_FALSE(entry->pixmap(QSize(ICONSIZE, ICONSIZE), QIcon::Normal, QIcon::On, 1.0).isNull());
|
||||
#else
|
||||
ASSERT_FALSE(entry->pixmap(QSize(ICONSIZE, ICONSIZE), QIcon::Normal, QIcon::On).isNull());
|
||||
#endif
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
||||
for (auto item : themeInfo.entries) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
class ut_DDciIconEngine : public testing::Test
|
||||
class GTEST_API_ ut_DDciIconEngine : public testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
class ut_DDciIcon : public DTest
|
||||
class GTEST_API_ ut_DDciIcon : public DTest
|
||||
{
|
||||
public:
|
||||
ut_DDciIcon()
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ TEST(ut_DDciIconImage, render)
|
|||
}
|
||||
}
|
||||
|
||||
class ut_DDciIconPlayer : public DTest
|
||||
class GTEST_API_ ut_DDciIconPlayer : public DTest
|
||||
{
|
||||
protected:
|
||||
ut_DDciIconPlayer()
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ TEST(ut_DFontManager, StaticFunction)
|
|||
ASSERT_TRUE(DFontManager::fontPixelSize(tF) > 0);
|
||||
}
|
||||
|
||||
class TDFontManager : public DTestWithParam<int>
|
||||
class GTEST_API_ TDFontManager : public DTestWithParam<int>
|
||||
{
|
||||
protected:
|
||||
void SetUp();
|
||||
|
|
@ -76,4 +76,5 @@ TEST_F(TDFontManager, testFontSize)
|
|||
ASSERT_EQ(manager->t8().pixelSize(), manager->fontPixelSize(DFontManager::T8));
|
||||
ASSERT_EQ(manager->t9().pixelSize(), manager->fontPixelSize(DFontManager::T9));
|
||||
ASSERT_EQ(manager->t10().pixelSize(), manager->fontPixelSize(DFontManager::T10));
|
||||
ASSERT_EQ(manager->t11().pixelSize(), manager->fontPixelSize(DFontManager::T11));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ DGUI_BEGIN_NAMESPACE
|
|||
#define WmClass "_d_WmClass"
|
||||
#define ProcessId "_d_ProcessId"
|
||||
|
||||
class TDForeignWindow : public DTest
|
||||
class GTEST_API_ TDForeignWindow : public DTest
|
||||
{
|
||||
protected:
|
||||
virtual void SetUp()
|
||||
{
|
||||
const QVector<quint32> ¤tIdList = DWindowManagerHelper::instance()->currentWorkspaceWindowIdList();
|
||||
foreignWindows.clear();
|
||||
for (quint32 currentId : qAsConst(currentIdList)) {
|
||||
for (const auto ¤tId : currentIdList) {
|
||||
foreignWindows.append(DForeignWindow::fromWinId(currentId));
|
||||
}
|
||||
}
|
||||
|
|
@ -36,13 +36,13 @@ protected:
|
|||
|
||||
TEST_F(TDForeignWindow, wmClass)
|
||||
{
|
||||
for (auto foreignWindow : qAsConst(foreignWindows))
|
||||
for (auto foreignWindow : foreignWindows)
|
||||
ASSERT_NE(foreignWindow->wmClass(), QString());
|
||||
}
|
||||
|
||||
TEST_F(TDForeignWindow, pid)
|
||||
{
|
||||
for (auto foreignWindow : qAsConst(foreignWindows))
|
||||
for (auto foreignWindow : foreignWindows)
|
||||
ASSERT_NE(foreignWindow->pid(), 0);
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ TEST_F(TDForeignWindow, event)
|
|||
QDynamicPropertyChangeEvent wmevent(WmClass);
|
||||
QDynamicPropertyChangeEvent pidevent(ProcessId);
|
||||
|
||||
for (auto foreignWindow : qAsConst(foreignWindows)) {
|
||||
for (auto foreignWindow : foreignWindows) {
|
||||
QSignalSpy wmspy(foreignWindow, SIGNAL(wmClassChanged()));
|
||||
ASSERT_TRUE(foreignWindow->event(&wmevent));
|
||||
ASSERT_EQ(wmspy.count(), 1);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <QPainter>
|
||||
#include <QIODevice>
|
||||
#include <private/qicon_p.h>
|
||||
|
||||
#include <DGuiApplicationHelper>
|
||||
#include <DPlatformTheme>
|
||||
|
|
@ -22,7 +23,7 @@ private:
|
|||
void virtual_hook(int id, void *data) override;
|
||||
*/
|
||||
|
||||
class ut_DIconProxyEngine : public testing::Test
|
||||
class GTEST_API_ ut_DIconProxyEngine : public testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override;
|
||||
|
|
@ -115,18 +116,21 @@ TEST_F(ut_DIconProxyEngine, read_write)
|
|||
ASSERT_EQ(iconName, mIconEngine->iconName());
|
||||
}
|
||||
|
||||
iconName = "test_icon_name";
|
||||
themeName = "test_theme_name";
|
||||
{
|
||||
auto engine = new DIconProxyEngine("selected_indicator" ,DIconTheme::DontFallbackToQIconFromTheme);
|
||||
QIcon icon_write(engine);
|
||||
QDataStream out(&data, QIODevice::WriteOnly);
|
||||
out << iconName << themeName;
|
||||
}
|
||||
{
|
||||
QDataStream in(&data, QIODevice::ReadOnly);
|
||||
mIconEngine->read(in);
|
||||
out << icon_write;
|
||||
|
||||
ASSERT_EQ(themeName, mIconEngine->themeName());
|
||||
ASSERT_EQ(iconName, mIconEngine->iconName());
|
||||
QIcon icon_read;
|
||||
QDataStream in(&data, QIODevice::ReadOnly);
|
||||
in >> icon_read;
|
||||
|
||||
ASSERT_TRUE(icon_read.data_ptr()->engine);
|
||||
EXPECT_EQ(icon_read.data_ptr()->engine->key(),
|
||||
engine->key());
|
||||
EXPECT_EQ(icon_read.data_ptr()->engine->iconName(),
|
||||
engine->iconName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ TEST(ut_DIconTheme, builtinIcon)
|
|||
// icon2 只可能是从外部找到的图标,不会与 icon1 相同
|
||||
ASSERT_TRUE(icon1.cacheKey() != icon2.cacheKey());
|
||||
#ifndef DTK_DISABLE_LIBXDG
|
||||
if (!icon2.isNull())
|
||||
if (!icon2.isNull()) {
|
||||
ASSERT_TRUE(DIconTheme::isXdgIcon(icon2));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -36,8 +37,9 @@ TEST(ut_DIconTheme, cachedTheme)
|
|||
// icon2 只可能是从外部找到的图标,不会与 icon1 相同
|
||||
ASSERT_TRUE(icon1.cacheKey() != icon2.cacheKey());
|
||||
#ifndef DTK_DISABLE_LIBXDG
|
||||
if (!icon2.isNull())
|
||||
if (!icon2.isNull()) {
|
||||
ASSERT_TRUE(DIconTheme::isXdgIcon(icon2));
|
||||
}
|
||||
#endif
|
||||
|
||||
const QIcon icon1_cached1 = DIconTheme::cached()->findQIcon("edit");
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
DGUI_USE_NAMESPACE
|
||||
DCORE_USE_NAMESPACE
|
||||
|
||||
class ut_DNativeSettings : public testing::Test
|
||||
class GTEST_API_ ut_DNativeSettings : public testing::Test
|
||||
{
|
||||
public:
|
||||
static void SetUpTestSuite();
|
||||
|
|
|
|||
|
|
@ -106,13 +106,21 @@ TEST_F(TDPlatformHandle, testFunction)
|
|||
DPlatformHandle::setDisableWindowOverrideCursor(window, true);
|
||||
QVariant windowRadius = window->property(WINDOWRADIUS);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (windowRadius.isValid() && windowRadius.canConvert<int>()) {
|
||||
#else
|
||||
if (windowRadius.isValid() && windowRadius.canConvert(QVariant::Int)) {
|
||||
#endif
|
||||
ASSERT_EQ(pHandle->windowRadius(), windowRadius.toInt());
|
||||
}
|
||||
|
||||
QVariant borderWidth = window->property(BORDERWIDTH);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (borderWidth.isValid() && borderWidth.canConvert<int>()) {
|
||||
#else
|
||||
if (borderWidth.isValid() && borderWidth.canConvert(QVariant::Int)) {
|
||||
#endif
|
||||
ASSERT_EQ(pHandle->borderWidth(), borderWidth.toInt());
|
||||
} else {
|
||||
ASSERT_EQ(pHandle->borderWidth(), 0);
|
||||
|
|
@ -120,7 +128,11 @@ TEST_F(TDPlatformHandle, testFunction)
|
|||
|
||||
QVariant borderColor = window->property(BORDRCOLOR);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (borderColor.isValid() && borderColor.canConvert<QColor>()) {
|
||||
#else
|
||||
if (borderColor.isValid() && borderColor.canConvert(QVariant::Color)) {
|
||||
#endif
|
||||
ASSERT_EQ(pHandle->borderColor(), borderColor.value<QColor>());
|
||||
} else {
|
||||
ASSERT_FALSE(pHandle->borderColor().isValid());
|
||||
|
|
@ -128,7 +140,11 @@ TEST_F(TDPlatformHandle, testFunction)
|
|||
|
||||
QVariant shadowRadius = window->property(SHADOWRADIUS);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (shadowRadius.isValid() && shadowRadius.canConvert<int>()) {
|
||||
#else
|
||||
if (shadowRadius.isValid() && shadowRadius.canConvert(QVariant::Int)) {
|
||||
#endif
|
||||
ASSERT_EQ(pHandle->shadowRadius(), shadowRadius.toInt());
|
||||
} else {
|
||||
ASSERT_FALSE(pHandle->borderColor().isValid());
|
||||
|
|
@ -136,7 +152,11 @@ TEST_F(TDPlatformHandle, testFunction)
|
|||
|
||||
QVariant shadowOffset = window->property(SHADOWOFFSET);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (shadowOffset.isValid() && shadowOffset.canConvert<QPoint>()) {
|
||||
#else
|
||||
if (shadowOffset.isValid() && shadowOffset.canConvert(QVariant::Point)) {
|
||||
#endif
|
||||
ASSERT_EQ(pHandle->shadowOffset(), shadowOffset.value<QPoint>());
|
||||
} else {
|
||||
ASSERT_TRUE(pHandle->shadowOffset().isNull());
|
||||
|
|
@ -144,7 +164,11 @@ TEST_F(TDPlatformHandle, testFunction)
|
|||
|
||||
QVariant shadowColor = window->property(SHADOWCOLOR);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (shadowColor.isValid() && shadowColor.canConvert<QColor>()) {
|
||||
#else
|
||||
if (shadowColor.isValid() && shadowColor.canConvert(QVariant::Color)) {
|
||||
#endif
|
||||
ASSERT_EQ(pHandle->shadowColor(), shadowColor.value<QColor>());
|
||||
} else {
|
||||
ASSERT_FALSE(pHandle->shadowColor().isValid());
|
||||
|
|
@ -160,7 +184,11 @@ TEST_F(TDPlatformHandle, testFunction)
|
|||
|
||||
QVariant frameMask = window->property(FRAMEMASK);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (frameMask.isValid() && frameMask.canConvert<QRegion>()) {
|
||||
#else
|
||||
if (frameMask.isValid() && frameMask.canConvert(QVariant::Region)) {
|
||||
#endif
|
||||
ASSERT_EQ(pHandle->frameMask(), frameMask.value<QRegion>());
|
||||
} else {
|
||||
ASSERT_TRUE(pHandle->frameMask().isEmpty());
|
||||
|
|
@ -175,35 +203,55 @@ TEST_F(TDPlatformHandle, testFunction)
|
|||
}
|
||||
|
||||
QVariant translucentBackground = window->property(TRANSLUCENTBACKGROUND);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (translucentBackground.isValid() && translucentBackground.canConvert<bool>()) {
|
||||
#else
|
||||
if (translucentBackground.isValid() && translucentBackground.canConvert(QVariant::Bool)) {
|
||||
#endif
|
||||
ASSERT_EQ(pHandle->translucentBackground(), translucentBackground.toBool());
|
||||
} else {
|
||||
ASSERT_FALSE(pHandle->translucentBackground());
|
||||
}
|
||||
|
||||
QVariant enableSystemResize = window->property(ENABLESYSTEMRESIZE);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (enableSystemResize.isValid() && enableSystemResize.canConvert<bool>()) {
|
||||
#else
|
||||
if (enableSystemResize.isValid() && enableSystemResize.canConvert(QVariant::Bool)) {
|
||||
#endif
|
||||
ASSERT_EQ(pHandle->enableSystemResize(), enableSystemResize.toBool());
|
||||
} else {
|
||||
ASSERT_FALSE(pHandle->enableSystemResize());
|
||||
}
|
||||
|
||||
QVariant enableSystemMove = window->property(ENABLESYSTEMMOVE);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (enableSystemMove.isValid() && enableSystemMove.canConvert<bool>()) {
|
||||
#else
|
||||
if (enableSystemMove.isValid() && enableSystemMove.canConvert(QVariant::Bool)) {
|
||||
#endif
|
||||
ASSERT_EQ(pHandle->enableSystemMove(), enableSystemMove.toBool());
|
||||
} else {
|
||||
ASSERT_FALSE(pHandle->enableSystemMove());
|
||||
}
|
||||
|
||||
QVariant enableBlurWindow = window->property(ENABLEBLURWINDOW);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (enableBlurWindow.isValid() && enableBlurWindow.canConvert<bool>()) {
|
||||
#else
|
||||
if (enableBlurWindow.isValid() && enableBlurWindow.canConvert(QVariant::Bool)) {
|
||||
#endif
|
||||
ASSERT_EQ(pHandle->enableBlurWindow(), enableBlurWindow.toBool());
|
||||
} else {
|
||||
ASSERT_FALSE(pHandle->enableBlurWindow());
|
||||
}
|
||||
|
||||
QVariant autoInputMaskByClipPath = window->property(AUTOINPUTMASKBYCLIPPATH);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (autoInputMaskByClipPath.isValid() && autoInputMaskByClipPath.canConvert<bool>()) {
|
||||
#else
|
||||
if (autoInputMaskByClipPath.isValid() && autoInputMaskByClipPath.canConvert(QVariant::Bool)) {
|
||||
#endif
|
||||
ASSERT_EQ(pHandle->autoInputMaskByClipPath(), autoInputMaskByClipPath.toBool());
|
||||
} else {
|
||||
ASSERT_FALSE(pHandle->autoInputMaskByClipPath());
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue