Compare commits
13 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
b03849d6de | |
|
|
187be9a947 | |
|
|
16145642e1 | |
|
|
39a50cca37 | |
|
|
2767618f84 | |
|
|
36c06be095 | |
|
|
80db4dd238 | |
|
|
3d0713f7a2 | |
|
|
af1259edbb | |
|
|
3b5ba9bbda | |
|
|
c8f2955bd0 | |
|
|
96d0b45dd0 | |
|
|
00109d07e3 |
38
CHANGELOG.md
38
CHANGELOG.md
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
18
dtkgui.cmake
18
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)
|
||||
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Name: dtkgui
|
||||
Version: 5.7.21
|
||||
Version: 5.7.25
|
||||
Release: 1%{?dist}
|
||||
Summary: Deepin dtkgui
|
||||
License: LGPLv3+
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 ¶meters)
|
||||
{
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue