Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: from linuxdeepin/dtkdeclarative #13

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ set(MKSPECS_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/qt${QT_VERSION_MAJOR}/mkspecs/m
set(QML_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/qt${QT_VERSION_MAJOR}/qml" CACHE STRING "Qml plugin install directory")

set(USE_QQuickStylePluginPrivate OFF)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR}QuickControls2)
if(EnableQt5)
if(TARGET Qt::QuickControls2 AND TARGET Qt::QuickControls2Private)
Expand Down
6 changes: 6 additions & 0 deletions cmake/DtkBuildConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function(dtk_extend_target TARGET)
set(args_option)
set(args_single
EnableCov
SkipRPATH
)
cmake_parse_arguments(PARSE_ARGV 1 arg "${args_option}" "${args_single}" "${args_multi}")

Expand All @@ -99,4 +100,9 @@ function(dtk_extend_target TARGET)
endif()
target_link_libraries(${TARGET} PRIVATE gcov)
endif()

# skip RUNPATH avoid to `Insecure RUNPATH`
if (arg_SkipRPATH)
set_target_properties(${TARGET} PROPERTIES SKIP_BUILD_RPATH ${arg_SkipRPATH})
endif()
endfunction()
4 changes: 2 additions & 2 deletions docs/DevSpecification.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ Settings.SettingsDialog {
key: "key" // Option中的键可以直接绑定到config中同名的属性值
name: "ComboBox"
Settings.ComboBox { // Settings封装的基础控件类型
model: ["first", "sceond", "three"]
model: ["first", "second", "three"]
}
}
Settings.SettingsOption {
Expand Down Expand Up @@ -1028,7 +1028,7 @@ Settings.SettingsDialog {
key: "key" // Option中的键可以直接绑定到config中同名的属性值
name: "ComboBox"
Settings.ComboBox { // Settings封装的基础控件类型
model: ["first", "sceond", "three"]
model: ["first", "second", "three"]
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions docs/qml/noqml/dquicksettingcontainer.zh_CN.dox
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
key: "key2"
name: "ComboBox"
ComboBox {
model: ["first", "sceond", "third"]
model: ["first", "second", "third"]
}
}
}
Expand Down Expand Up @@ -447,7 +447,7 @@
key: "key2"
name: "ComboBox"
Settings.ComboBox {
model: ["first", "sceond", "third"]
model: ["first", "second", "third"]
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/qml/settings/SettingDialog.zh_CN.dox
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
Settings.SettingOption {
key: "setting1" // 对应 Config 中的属性名
Settings.ComboBox { // Settings封装的基础控件类型
model: ["first", "sceond", "three"]
model: ["first", "second", "three"]
}
}
}
Expand Down Expand Up @@ -121,7 +121,7 @@
Settings.SettingOption {
key: "setting1" // 对应 Config 中的属性名
Settings.ComboBox { // Settings封装的基础控件类型
model: ["first", "sceond", "three"]
model: ["first", "second", "three"]
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions examples/exhibition/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,5 @@ set(EXAMPLE_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
if (EnableQt6)
set(EXAMPLE_INSTALL_DIR "${LIB_INSTALL_DIR}/dtk${PROJECT_VERSION_MAJOR}/DDeclarative")
endif()
configure_package_config_file(
"${CMAKE_CURRENT_LIST_DIR}/dtk-exhibition.desktop.in"
"${CMAKE_CURRENT_BINARY_DIR}/dtk${DTK_VERSION_MAJOR}-exhibition.desktop"
INSTALL_DESTINATION "${EXAMPLE_INSTALL_DIR}"
)

install(TARGETS ${BIN_NAME} DESTINATION ${EXAMPLE_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dtk${DTK_VERSION_MAJOR}-exhibition.desktop DESTINATION "${CMAKE_INSTALL_DATADIR}/applications")
7 changes: 0 additions & 7 deletions examples/exhibition/dtk-exhibition.desktop.in

This file was deleted.

4 changes: 2 additions & 2 deletions examples/qml-inspect/Example_settingsdialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Rectangle {
key: "key2"
name: "ComboBox"
Settings.ComboBox {
model: ["first", "sceond", "three"]
model: ["first", "second", "three"]
}
}
Settings.SettingsOption {
Expand Down Expand Up @@ -146,7 +146,7 @@ Rectangle {
key: "option1"
name: "option1"
ComboBox {
model: ["first", "sceond", "three"]
model: ["first", "second", "three"]
}
}
}
Expand Down
1 change: 1 addition & 0 deletions misc/DtkDeclarativeConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ find_package(Qt@QT_VERSION_MAJOR@ COMPONENTS
REQUIRED
)
include(${CMAKE_CURRENT_LIST_DIR}/Dtk@[email protected])
include(${CMAKE_CURRENT_LIST_DIR}/Dtk@[email protected])
set(DTK_QML_APP_PLUGIN_PATH @DTK_QML_APP_PLUGIN_PATH@)
get_target_property(DtkDeclarative_INCLUDE_DIRS Dtk@DTK_VERSION_MAJOR@::Declarative INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(DtkDeclarative_LIBRARY_DIRS Dtk@DTK_VERSION_MAJOR@::Declarative INTERFACE_LINK_DIRECTORIES)
Expand Down
4 changes: 3 additions & 1 deletion qt6/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ qt_add_qml_module(${LIB_NAME}
)

dtk_extend_target(${LIB_NAME} EnableCov ${ENABLE_COV})
dtk_extend_target(${PLUGIN_NAME} EnableCov ${ENABLE_COV})
dtk_extend_target(${PLUGIN_NAME} EnableCov ${ENABLE_COV}
SkipRPATH ON
)

qt_add_translations(${LIB_NAME}
TS_FILES ${TS_FILES}
Expand Down
23 changes: 13 additions & 10 deletions qt6/src/qml/CheckDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import org.deepin.dtk.style 1.0 as DS

T.CheckDelegate {
id: control
property Component content: Label {
text: control.text
}
property Component content
property D.Palette backgroundColor: DS.Style.itemDelegate.checkBackgroundColor

implicitWidth: DS.Style.control.implicitWidth(control)
Expand Down Expand Up @@ -41,15 +39,20 @@ T.CheckDelegate {
}

contentItem: RowLayout {
spacing: control.spacing
D.DciIcon {
palette: D.DTK.makeIconPalette(control.palette)
mode: control.D.ColorSelector.controlState
theme: control.D.ColorSelector.controlTheme
name: control.icon.name
sourceSize: Qt.size(control.icon.width, control.icon.height)
D.IconLabel {
spacing: control.spacing
mirrored: control.mirrored
display: control.display
alignment: control.display === D.IconLabel.IconOnly || control.display === D.IconLabel.TextUnderIcon
? Qt.AlignCenter : Qt.AlignLeft | Qt.AlignVCenter
text: control.text
font: control.font
color: control.palette.windowText
icon: D.DTK.makeIcon(control.icon, control.D.DciIcon)
Layout.fillWidth: !control.content
}
Loader {
active: control.content
sourceComponent: control.content
Layout.fillWidth: true
}
Expand Down
4 changes: 3 additions & 1 deletion qt6/src/qml/settings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ qt_add_qml_module(dtkdeclarativesettingsplugin
"${PLUGIN_OUTPUT_DIR}/${URI_PATH}/settings"
)

dtk_extend_target(dtkdeclarativesettingsplugin EnableCov ${ENABLE_COV})
dtk_extend_target(dtkdeclarativesettingsplugin EnableCov ${ENABLE_COV}
SkipRPATH ON
)

target_link_libraries(dtkdeclarativesettingsplugin
PRIVATE
Expand Down
3 changes: 1 addition & 2 deletions src/private/dquickdciiconimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ void DQuickDciIconImageItemPrivate::maybeUpdateUrl()
{
Q_Q(DQuickIconImage);
if (parentPriv->name.isEmpty()) {
q->setSource(QUrl());
return;
return DQuickIconImagePrivate::maybeUpdateUrl();
}

QUrl url;
Expand Down
6 changes: 6 additions & 0 deletions src/private/dquickiconimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ DQUICK_BEGIN_NAMESPACE

bool DQuickIconImagePrivate::updateDevicePixelRatio(qreal targetDevicePixelRatio)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (!qApp->testAttribute(Qt::AA_UseHighDpiPixmaps)) {
devicePixelRatio = 1.0;
return true;
}
#endif
devicePixelRatio = targetDevicePixelRatio > 1.0 ? targetDevicePixelRatio : calculateDevicePixelRatio();
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions src/private/dquickimageprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,13 @@ QImage DQuickDciIconProvider::requestImage(const QString &id, QSize *size, const
// the boundingSize should typically divide by devicePixelRatio,
// see Qt::AA_UseHighDpiPixmaps.
int boundingSize = qMax(requestedSize.width(), requestedSize.height());
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (qApp->testAttribute(Qt::AA_UseHighDpiPixmaps)) {
boundingSize = qRound(boundingSize / devicePixelRatio);
}
#else
boundingSize = qRound(boundingSize / devicePixelRatio);
#endif

const auto currentTheme = toDciTheme(theme);
auto currentMode = mode;
Expand Down
23 changes: 13 additions & 10 deletions src/qml/CheckDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import org.deepin.dtk.style 1.0 as DS

T.CheckDelegate {
id: control
property Component content: Label {
text: control.text
}
property Component content
property D.Palette backgroundColor: DS.Style.itemDelegate.checkBackgroundColor

implicitWidth: DS.Style.control.implicitWidth(control)
Expand Down Expand Up @@ -41,15 +39,20 @@ T.CheckDelegate {
}

contentItem: RowLayout {
spacing: control.spacing
D.DciIcon {
palette: D.DTK.makeIconPalette(control.palette)
mode: control.D.ColorSelector.controlState
theme: control.D.ColorSelector.controlTheme
name: control.icon.name
sourceSize: Qt.size(control.icon.width, control.icon.height)
D.IconLabel {
spacing: control.spacing
mirrored: control.mirrored
display: control.display
alignment: control.display === D.IconLabel.IconOnly || control.display === D.IconLabel.TextUnderIcon
? Qt.AlignCenter : Qt.AlignLeft | Qt.AlignVCenter
text: control.text
font: control.font
color: control.palette.windowText
icon: D.DTK.makeIcon(control.icon, control.D.DciIcon)
Layout.fillWidth: !control.content
}
Loader {
active: control.content
sourceComponent: control.content
Layout.fillWidth: true
}
Expand Down
7 changes: 7 additions & 0 deletions src/qml/FlowStyle.qml
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,11 @@ QtObject {

property D.Palette text : D.Palette {
normal: D.DTK.makeColor(D.Color.HighlightedText)
normalDark: D.DTK.makeColor(D.Color.HighlightedText)
hovered: D.DTK.makeColor(D.Color.HighlightedText).lightness(+10)
hoveredDark: D.DTK.makeColor(D.Color.HighlightedText).lightness(+10)
pressed: D.DTK.makeColor(D.Color.HighlightedText).opacity(-20)
pressedDark: D.DTK.makeColor(D.Color.HighlightedText).opacity(-20)
}

property D.Palette dropShadow : D.Palette {
Expand Down Expand Up @@ -655,13 +658,17 @@ QtObject {

property D.Palette background: D.Palette {
normal: D.DTK.makeColor(D.Color.Highlight)
normalDark: D.DTK.makeColor(D.Color.Highlight)
hovered: D.DTK.makeColor(D.Color.Highlight).lightness(+10)
hoveredDark: D.DTK.makeColor(D.Color.Highlight).lightness(+10)
}
property D.Palette dropShadow: D.Palette {
normal: D.DTK.makeColor(D.Color.Highlight).lightness(+20)
normalDark: D.DTK.makeColor(D.Color.Highlight).lightness(+20)
}
property D.Palette innerShadow: D.Palette {
normal: D.DTK.makeColor(D.Color.Highlight).lightness(-20)
normalDark: D.DTK.makeColor(D.Color.Highlight).lightness(-20)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ install(FILES ${PUBLIC_HEADERS} ${D_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}

# Install ${LIB_NAME}_properties
install(TARGETS ${LIB_NAME}_properties EXPORT Dtk${DTK_VERSION_MAJOR}DeclarativeProperties DESTINATION "${LIB_INSTALL_DIR}")
install(EXPORT Dtk${DTK_VERSION_MAJOR}DeclarativeProperties NAMESPACE Dtk${DTK_VERSION_MAJOR}:: FILE Dtk${DTK_VERSION_MAJOR}DeclarativeTargets-Properties.cmake DESTINATION "${CONFIG_INSTALL_DIR}")
install(EXPORT Dtk${DTK_VERSION_MAJOR}DeclarativeProperties NAMESPACE Dtk${DTK_VERSION_MAJOR}:: FILE Dtk${DTK_VERSION_MAJOR}DeclarativePropertiesTargets.cmake DESTINATION "${CONFIG_INSTALL_DIR}")