Compare commits

...

13 Commits

Author SHA1 Message Date
github-actions[bot] b03849d6de chore: New release 5.7.25
Log:
2025-10-30 13:59:43 +00:00
zhangkun 187be9a947 feat: improve icon theme generation with scalable support
1. Add SCALABLE_SIZE constant for scalable icon directories
2. Change foundSize return type from uint to int to support scalable
detection
3. Modify writeScaledImage to accept baseSize parameter instead of
parsing from directory
4. Move directory parsing logic to writeImage function for better
organization
5. Add scalable directory detection in size parsing logic
6. Use QImageReader's scaledSize for better image scaling quality
7. Fix error handling to continue processing instead of exiting on first
error

Log: Improved icon theme generation with better scalable icon support

Influence:
1. Test with icon directories containing scalable icons
2. Verify different scale factors work correctly
3. Test error handling when encountering invalid image files
4. Verify image quality at various scales
5. Test with both fixed-size and scalable icon directories

feat: 改进图标主题生成,支持可缩放图标

1. 添加 SCALABLE_SIZE 常量用于可缩放图标目录
2. 将 foundSize 返回类型从 uint 改为 int 以支持可缩放检测
3. 修改 writeScaledImage 函数,接受 baseSize 参数而非从目录解析
4. 将目录解析逻辑移至 writeImage 函数以获得更好的代码组织
5. 在尺寸解析逻辑中添加可缩放目录检测
6. 使用 QImageReader 的 scaledSize 获得更好的图像缩放质量
7. 修复错误处理,在遇到错误时继续处理而非立即退出

Log: 改进图标主题生成,提供更好的可缩放图标支持

Influence:
1. 测试包含可缩放图标的目录
2. 验证不同缩放因子是否正确工作
3. 测试遇到无效图像文件时的错误处理
4. 验证各种缩放比例下的图像质量
5. 测试固定尺寸和可缩放图标目录
2025-10-23 08:41:20 +00:00
github-actions[bot] 16145642e1 chore: New release 5.7.24
Log:
2025-10-16 20:13:34 +08:00
zhangkun 39a50cca37 feat: improve icon size detection and duplicate handling
1. Added foundSize function to parse icon size from directory names
using multiple strategies
2. Implemented duplicate entry detection to skip existing icons in DCI
files
3. Added QFileInfo and QLogging includes for new functionality
4. Removed debug-specific code that was adding unnecessary prefixes
5. Improved size detection logic to handle both numeric and "NxN" format
directory names
6. Added fallback to parent directory when current directory name
doesn't contain size information

Log: Improved icon theme generation with better size detection and
duplicate prevention

Influence:
1. Test icon theme generation with various directory naming conventions
2. Verify that duplicate icons are properly skipped during generation
3. Test with directories containing numeric names vs "widthxheight"
format
4. Verify fallback to parent directory size detection works correctly
5. Check that existing icons in DCI files are not overwritten
6. Test with different directory structures and naming patterns

feat: 改进图标尺寸检测和重复项处理

1. 添加 foundSize 函数,使用多种策略从目录名解析图标尺寸
2. 实现重复条目检测,跳过 DCI 文件中已存在的图标
3. 添加 QFileInfo 和 QLogging 包含以支持新功能
4. 移除添加不必要前缀的调试专用代码
5. 改进尺寸检测逻辑,支持数字和"NxN"格式的目录名
6. 在当前目录名不包含尺寸信息时,添加回退到父目录的检测

Log: 改进图标主题生成,提供更好的尺寸检测和重复项预防

Influence:
1. 测试使用不同目录命名约定的图标主题生成
2. 验证在生成过程中重复图标是否被正确跳过
3. 测试包含数字名称与"宽x高"格式的目录
4. 验证回退到父目录尺寸检测是否正常工作
5. 检查 DCI 文件中现有图标是否不会被覆盖
6. 测试不同的目录结构和命名模式
2025-10-16 11:05:03 +00:00
yeshanshan 2767618f84 fix: fix Qt6 compilation error with libxdg
1. Restructured the conditional logic for libxdg usage to avoid Qt6
compilation errors
2. Moved the DTK_DISABLE_LIBXDG check to outer scope to properly handle
both Qt5 and Qt6
3. Added explicit Qt6 handling by disabling libxdg when not using Qt5
4. This resolves build failures in Qt6 environments where
Qt5XdgIconLoader is not available

The previous implementation only checked for Qt5XdgIconLoader when
using Qt5, but didn't properly handle Qt6 scenarios, causing compilation
errors when building with Qt6.

fix: 修复 Qt6 下 libxdg 编译错误

1. 重构了 libxdg 使用的条件逻辑以避免 Qt6 编译错误
2. 将 DTK_DISABLE_LIBXDG 检查移到外层作用域以正确处理 Qt5 和 Qt6
3. 添加了明确的 Qt6 处理逻辑,在非 Qt5 环境下禁用 libxdg
4. 解决了在 Qt6 环境中因 Qt5XdgIconLoader 不可用而导致的构建失败问题

之前的实现只在 Qt5 环境下检查 Qt5XdgIconLoader,但没有正确处理 Qt6 场
景,导致在使用 Qt6 构建时出现编译错误。
2025-10-16 17:39:56 +08:00
ComixHe 36c06be095 fix: correct lockfile path construction
Move process ID namespace handling from lockfile to socket_key variable to ensure consistent lock file paths.
Reorganize code structure for proper execution order.

Signed-off-by: ComixHe <heyuming@deepin.org>
2025-10-16 13:14:00 +08:00
ComixHe 80db4dd238 feat: support Qt 6.10
Also adjusting the logic for finding QtXDGIconLoader.
This library only be used in Qt 5.

Signed-off-by: ComixHe <heyuming@deepin.org>
2025-10-13 13:03:30 +08:00
github-actions[bot] 3d0713f7a2 chore: New release 5.7.23
Log:
2025-09-25 17:44:27 +08:00
Mingcong Bai af1259edbb fix(tests): fix build for Qt 6.9
Qt 6.9 renamed <private/qdesktopunixservices_p.h> to
<private/qgenericunixservices_p.h>, as well as some of the classes along
the same format (QGenericUnixServices => QDesktopUnixServices).

Add a condition test with QT_VERSION to fix build with Qt >= 6.9.

Signed-off-by: Mingcong Bai <jeffbai@aosc.io>
2025-09-24 16:17:19 +08:00
Robertkill 3b5ba9bbda fix: 解决控制中心闪烁问题
初始化时立即读取并设置主题色,避免异步出现主题色闪烁问题

Log: 修复配置管理以使用标准 DConfig 接口

Influence:
1. 测试主题切换功能以确保正确的主题类型检测
2. 验证动画设置使用新的配置方法正常工作
3. 检查主题偏好是否正确保存和恢复
4. 测试配置值缺失或无效时的应用程序行为

PMS: BUG-334439
2025-09-18 13:26:13 +08:00
github-actions[bot] c8f2955bd0 chore: New release 5.7.22
Log:
2025-09-04 20:06:26 +08:00
zhangkun 96d0b45dd0 feat: add T11 font size and adjust T5 default
Added T11 font size with 8px default value to extend the font size
options
Modified T5 default size from 17px to 16px for better size progression
Updated font pixel size array to include the new T11 size
Added t11() accessor method and corresponding test case
cherry-pick from: 2c3b351b43

feat: 添加 T11 字体大小并调整 T5 默认值

添加了默认值为 8px 的 T11 字体大小以扩展字体大小选项
将 T5 默认大小从 17px 修改为 16px 以获得更好的大小递进
更新了字体像素大小数组以包含新的 T11 大小
添加了 t11() 访问器方法和相应的测试用例
cherry-pick from: 2c3b351b43

pms: BUG-310879
2025-09-01 11:27:52 +08:00
ComixHe 00109d07e3 fix: improve PID namespace detection in setSingleInstance
Replace stat-based PID namespace detection with QFileInfo approach
for better compatibility across different kernel versions and
containerized environments. Add robust parsing and fallback handling
for namespace format variations.

PMS: BUG-329663
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-08-19 10:14:09 +08:00
16 changed files with 224 additions and 59 deletions

View File

@ -5,6 +5,44 @@ 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

View File

@ -1 +1 @@
5.7.21
5.7.25

View File

@ -1,6 +1,6 @@
# Maintainer: justforlxz <justforlxz@gmail.com>
pkgname=dtkgui-git
pkgver=5.7.21
pkgver=5.7.25
pkgrel=1
sourcename=dtkgui
sourcetars=("$sourcename"_"$pkgver".tar.xz)

24
debian/changelog vendored
View File

@ -1,3 +1,27 @@
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

View File

@ -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)
@ -120,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)

View File

@ -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();

View File

@ -1,5 +1,5 @@
Name: dtkgui
Version: 5.7.21
Version: 5.7.25
Release: 1%{?dist}
Summary: Deepin dtkgui
License: LGPLv3+

View File

@ -1,5 +1,10 @@
if("${QT_VERSION_MAJOR}" STREQUAL "6")
find_package(Qt6 REQUIRED COMPONENTS Core Widgets WaylandClient)
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()

View File

@ -392,7 +392,12 @@ void DGuiApplicationHelperPrivate::notifyAppThemeChanged()
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);
@ -456,7 +461,10 @@ void DGuiApplicationHelperPrivate::initPaletteType() const
const_cast<DGuiApplicationHelperPrivate *>(this)->setPaletteType(DGuiApplicationHelper::ColorType(ct), emitSignal);
};
applyThemeType(false);
// 读取配置文件中的主题类型并立即应用
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);
@ -506,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
*/
@ -520,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
*/
@ -1494,23 +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;
}
#ifdef Q_OS_LINUX
struct stat st{};
auto ret = ::lstat("/proc/self/ns/pid", &st);
if (ret < 0) {
qCWarning(dgAppHelper)
<< "failed to get pid namespace:" << ::strerror(errno);
return false;
}
lockfile += QStringLiteral("_%1").arg(st.st_ino);
#endif
lockfile += QStringLiteral(".lock");
static QScopedPointer <QLockFile> lock(new QLockFile(lockfile));
// 同一个进程多次调用本接口使用最后一次设置的 key
@ -1707,7 +1729,7 @@ bool DGuiApplicationHelper::loadTranslator(const QString &fileName, const QList<
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;
}

View File

@ -28,6 +28,11 @@ 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)

View File

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

View File

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

View File

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

View File

@ -13,8 +13,14 @@
#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 &parameters)
{
@ -54,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();
}

View File

@ -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));
}

View File

@ -30,6 +30,7 @@ private:
#define MAX_SCALE 10
#define INVALIDE_QUALITY -2
#define SCALABLE_SIZE 256
static int quality4Scaled[MAX_SCALE] = {};
static inline void initQuality() {
for (int i = 0; i < MAX_SCALE; ++i)
@ -43,6 +44,41 @@ static inline void dciChecker(bool result, std::function<const QString()> cb) {
}
}
// TODO 应该使用xdg图标查找规范解析index.theme来查找尺寸
static int foundSize(const QFileInfo &fileInfo) {
QDir dir = fileInfo.absoluteDir();
// 解析尺寸
auto parseSize = [](const QString &dirName) -> int {
bool ok;
if (int size = dirName.toUInt(&ok); ok) {
return size;
}
if (dirName.contains('x') && dirName.split('x').size() == 2) {
if (int size = dirName.split('x').first().toUInt(&ok); ok) {
return size;
}
}
if (dirName == "scalable") {
return SCALABLE_SIZE;
}
return 0;
};
if (int size = parseSize(dir.dirName()); size > 0) {
return size;
}
// 尝试找上一级目录
if (!dir.cdUp())
return 0;
return parseSize(dir.dirName());
}
static inline QByteArray webpImageData(const QImage &image, int quality) {
QByteArray data;
QBuffer buffer(&data);
@ -52,14 +88,8 @@ static inline QByteArray webpImageData(const QImage &image, int quality) {
return data;
}
static bool writeScaledImage(DDciFile &dci, const QImage &image, const QString &targetDir, int scale/* = 2*/)
static bool writeScaledImage(DDciFile &dci, const QImage &image, const QString &targetDir, const int baseSize, int scale/* = 2*/)
{
QString sizeDir = targetDir.mid(1, targetDir.indexOf("/", 1) - 1);
bool ok = false;
int baseSize = sizeDir.toInt(&ok);
if (!ok)
baseSize = 256;
int size = scale * baseSize;
QImage img;
if (image.width() == size) {
@ -78,20 +108,28 @@ static bool writeScaledImage(DDciFile &dci, const QImage &image, const QString &
static bool writeImage(DDciFile &dci, const QString &imageFile, const QString &targetDir)
{
QString sizeDir = targetDir.mid(1, targetDir.indexOf("/", 1) - 1);
bool ok = false;
int baseSize = sizeDir.toInt(&ok);
if (!ok)
baseSize = 256;
QImageReader reader(imageFile);
if (!reader.canRead()) {
qWarning() << "Ignore the null image file:" << imageFile;
return false;
}
auto image = reader.read();
for (int i = 0; i < MAX_SCALE; ++i) {
if (quality4Scaled[i] == INVALIDE_QUALITY)
continue;
int scale = i + 1;
if (!writeScaledImage(dci, image, targetDir, i + 1))
reader.setScaledSize(QSize(baseSize * scale, baseSize * scale));
auto image = reader.read();
if (!writeScaledImage(dci, image, targetDir, baseSize, scale))
return false;
}
}
return true;
}
@ -293,10 +331,6 @@ int main(int argc, char *argv[])
#endif
QStringList qualityList = cp.value(scaleQuality).split(":", behavior);
#ifdef QT_DEBUG
surfix = cp.value(scaleQuality).prepend("-");
#endif
for (const QString &kv : qualityList) {
auto sq = kv.split("=");
if (sq.size() != 2) {
@ -418,10 +452,9 @@ int main(int argc, char *argv[])
for (const QFileInfo &file : files) {
QString dirName = file.absoluteDir().dirName();
bool isNum = false;
dirName.toInt(&isNum);
dirName.prepend("/");
uint iconSize = foundSize(file);
dirName = iconSize > 0 ? QString("/%1").arg(iconSize) : dirName.prepend("/");
// Initialize DCI file once per icon group
if (dciFile.isNull()) {
if (QFileInfo::exists(dciFilePath)) {
@ -438,10 +471,15 @@ int main(int argc, char *argv[])
qInfo() << "Writing to dci file:" << file.absoluteFilePath() << "==>" << dciFilePath;
QString sizeDir = isNum ? dirName : "/256"; // "/256"
QString sizeDir = iconSize > 0 ? dirName : "/256"; // "/256" as default
QString normalLight = sizeDir + "/normal.light"; // "/256/normal.light"
QString normalDark = sizeDir + "/normal.dark"; // "/256/normal.dark"
if (dciFile->exists(sizeDir)) {
qWarning() << "Skip exists dci file:" << dciFilePath << sizeDir << dciFile->list(sizeDir);
continue;
}
dciChecker(dciFile->mkdir(sizeDir), [&]{return dciFile->lastErrorString();});
dciChecker(dciFile->mkdir(normalLight), [&]{return dciFile->lastErrorString();});
if (!writeImage(*dciFile, file.filePath(), normalLight))
@ -473,8 +511,8 @@ int main(int argc, char *argv[])
});
if (hasError.load()) {
qWarning() << "Encountered errors during DCI file writing. Exiting with error code:" << errorCode;
return errorCode;
qWarning() << "Encountered errors during DCI file writing" << errorCode;
continue;
}
}