Skip to content
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
2 changes: 2 additions & 0 deletions examples/exhibition/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class Object : public QObject {

int main(int argc, char **argv)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif

QGuiApplication app(argc, argv);
app.setOrganizationName("deepin");
Expand Down
2 changes: 2 additions & 0 deletions examples/qml-inspect/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif

QGuiApplication app(argc, argv);
app.setOrganizationName("deepin");
Expand Down
3 changes: 3 additions & 0 deletions qt6/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ qt_add_qml_module(${LIB_NAME}

dtk_extend_target(${LIB_NAME} EnableCov ${ENABLE_COV})
dtk_extend_target(${PLUGIN_NAME} EnableCov ${ENABLE_COV})
target_compile_definitions(${LIB_NAME} PRIVATE
D_IGNORE_DEPRECATIONS
)

qt_add_translations(${LIB_NAME}
TS_FILES ${TS_FILES}
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ add_library(${LIB_NAME} SHARED
)

dtk_extend_target(${LIB_NAME} EnableCov ${ENABLE_COV})
target_compile_definitions(${LIB_NAME} PRIVATE
D_IGNORE_DEPRECATIONS
)

set_target_properties(${LIB_NAME} PROPERTIES
VERSION ${CMAKE_PROJECT_VERSION}
Expand Down
10 changes: 9 additions & 1 deletion src/dapploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Q_LOGGING_CATEGORY(appLoaderLog, "dtk.quick.apploader");
static const QQuickItemPrivate::ChangeTypes changedTypes = QQuickItemPrivate::Geometry;
DAppLoader *DAppLoader::self = nullptr;

static inline const bool heightValid(QQuickItemPrivate *item)
static inline bool heightValid(QQuickItemPrivate *item)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return item->heightValid;
Expand Down Expand Up @@ -246,7 +246,11 @@ bool DAppLoaderPrivate::createObjects(const char *propertyName)
void DAppLoaderPrivate::createChildComponents()
{
auto components = appRootItem->findChildren<QQmlComponent *>(QStringLiteral(""), Qt::FindDirectChildrenOnly);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
for (auto childCom : std::as_const(components)) {
#else
for (auto childCom : qAsConst(components)) {
#endif
QObject::connect(childCom, SIGNAL(progressChanged(qreal)), q_func(), SLOT(_q_onComponentProgressChanged()));
auto asyn = appRootItem->asynchronous() ? DQmlComponentIncubator::Asynchronous : DQmlComponentIncubator::AsynchronousIfNested;
DQmlComponentIncubator *incubator = new DQmlComponentIncubator(childCom, this, asyn);
Expand Down Expand Up @@ -436,7 +440,11 @@ void DAppLoaderPrivate::_q_onComponentProgressChanged()
{
qreal progress = 0;
auto components = appRootItem->findChildren<QQmlComponent *>();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
for (auto childCom : std::as_const(components) {
#else
for (auto childCom : qAsConst(components)) {
#endif
progress += childCom->progress();
}

Expand Down
10 changes: 9 additions & 1 deletion src/dquickwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ void DQuickWindowAttachedPrivate::_q_updateBlurAreaForWindow()
QList<QPainterPath> blurPathList;
QVector<DPlatformHandle::WMBlurArea> blurAreaList;

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
for (const DQuickBehindWindowBlur *blur : std::as_const(blurList)) {
#else
for (const DQuickBehindWindowBlur *blur : qAsConst(blurList)) {
#endif
if (!blur->d_func()->isValidBlur())
continue;

Expand All @@ -244,7 +248,11 @@ void DQuickWindowAttachedPrivate::_q_updateBlurAreaForWindow()
blurSuc = q->setWindowBlurAreaByWM(blurAreaList);
} else {
// convert to QPainterPath
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
for (const DPlatformHandle::WMBlurArea &area : std::as_const(blurAreaList)) {
#else
for (const DPlatformHandle::WMBlurArea &area : qAsConst(blurAreaList)) {
#endif
QPainterPath path;
path.addRoundedRect(area.x, area.y, area.width, area.height, area.xRadius, area.yRaduis);
blurPathList << path;
Expand Down Expand Up @@ -343,7 +351,7 @@ bool DQuickWindowAttached::isEnabled() const
{
D_DC(DQuickWindowAttached);
return d->handle && (DPlatformHandle::isEnabledDXcb(window())
|| DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsTreelandPlatform));
|| DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform));
}

/*!
Expand Down
2 changes: 0 additions & 2 deletions src/private/dbackdropnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ class Q_DECL_HIDDEN DataManager : public DataManagerBase
}

static DataManagerPointer<Derive> resolve(const DataManagerPointer<Derive> &other, QQuickWindow *owner) {
static_assert(&Derive::metaObject);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Removing static_assert may reduce compile-time type safety.

Consider if removing this compile-time check could allow incorrect template instantiations, leading to runtime errors. If so, evaluate whether an alternative validation is necessary.

Q_ASSERT(owner);
if (other && other->owner() == owner)
return other;
Expand Down Expand Up @@ -828,7 +827,6 @@ class Q_DECL_HIDDEN RhiNode : public DBackdropNode {
texture->data->pixelSize().height() / float(m_rect.height() * devicePixelRatio)});
rhi->render(renderData->rt.get());
} else {
auto rhi = this->rhi->rhi();
QPointF sourcePos = renderMatrix.map(m_rect.topLeft()) * devicePixelRatio;

if (ct) {
Expand Down
12 changes: 12 additions & 0 deletions src/private/dquickcontrolpalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,11 @@ void DQuickControlColorSelector::findAndSetControlParent()
{
QQuickItem *parentItem = qobject_cast<QQuickItem*>(parent());
Q_ASSERT(parentItem);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
for (const QMetaObject::Connection &conn : qAsConst(m_itemParentChangeConnections)) {
#else
for (const QMetaObject::Connection &conn : std::as_const(m_itemParentChangeConnections)) {
#endif
disconnect(conn);
}
m_itemParentChangeConnections.clear();
Expand Down Expand Up @@ -1028,7 +1032,11 @@ void DQuickControlColorSelector::recvPaletteColorChanged()
auto palette = qobject_cast<DQuickControlPalette*>(sender());
Q_ASSERT(palette);
// Maybe the multiple properties is use a same palette.
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
for (const auto &i : std::as_const(m_palettes)) {
#else
for (const auto &i : qAsConst(m_palettes)) {
#endif
if (i.second != palette)
continue;
updatePropertyFromName(i.first, palette);
Expand All @@ -1040,7 +1048,11 @@ void DQuickControlColorSelector::onPaletteDestroyed()
auto palette = sender();
Q_ASSERT(palette);
// Maybe the multiple properties is use a same palette.
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
for (const auto &i : std::as_const(m_palettes)) {
#else
for (const auto &i : qAsConst(m_palettes)) {
#endif
if (i.second != palette)
continue;
setPalette(i.first, nullptr);
Expand Down
1 change: 1 addition & 0 deletions src/private/dquickimageprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ static QPainterPath roundedRectPath(const QRectF &rect, const DQuickShadowProvid

QImage DQuickShadowProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
Q_UNUSED(requestedSize)
ShadowConfig config;
QColor color;
qreal xOffset;
Expand Down
4 changes: 2 additions & 2 deletions src/private/dquickwaterprogressattribute_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class WaterPopAttribute : public QObject

qreal sizeRatio() const;

inline qreal yOffset() const;
inline void setYOffset(qreal offset);
qreal yOffset() const;
void setYOffset(qreal offset);

Q_SIGNALS:
void xSpeedChanged();
Expand Down
4 changes: 2 additions & 2 deletions src/private/dquickwindow_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class DQuickWindowAttachedPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate
QPoint explicitShadowOffset;
QColor explicitBorderColor;
QColor explicitShadowColor;
DPlatformHandle::EffectScenes explicitEffectScene = DPlatformHandle::EffectScenes(0);
DPlatformHandle::EffectTypes explicitEffectType = DPlatformHandle::EffectTypes(0);
DPlatformHandle::EffectScenes explicitEffectScene {};
DPlatformHandle::EffectTypes explicitEffectType {};

DWindowManagerHelper::WmWindowTypes wmWindowTypes;
DWindowManagerHelper::MotifFunctions motifFunctions;
Expand Down
64 changes: 56 additions & 8 deletions src/private/dsettingscontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ static constexpr char const *settingsGroupObjectName = "_d_settings_group";
// key: 'group1.group2'
static SettingsGroup *groupByKey(const QList<SettingsGroup *> groups, const QString &key)
{
for (auto group : qAsConst(groups)) {
for (auto group :
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
std::as_const(groups)
#else
qAsConst(groups)
#endif
) {
if (key == group->key()) {
return group;
}
Expand Down Expand Up @@ -125,15 +131,27 @@ QVector<SettingsGroup *> SettingsContainer::groupList() const
{
QVector<SettingsGroup *> list;
QStack<SettingsGroup*> stack;
for (auto group : qAsConst(m_groups)) {
for (auto group :
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
std::as_const(m_groups)
#else
qAsConst(m_groups)
#endif
) {
stack.push_back(group);
while (!stack.isEmpty()) {
auto group = stack.pop();

auto children = *static_cast<QList<SettingsGroup*>*>(group->children().data);
// keep order when it's declaration.
std::reverse(children.begin(), children.end());
for (auto childGroup : qAsConst(children)) {
for (auto childGroup :
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
std::as_const(children)
#else
qAsConst(children)
#endif
) {
stack.push(childGroup);
}
list.push_back(group);
Expand Down Expand Up @@ -176,7 +194,13 @@ bool SettingsContainer::groupVisible(const QString &key) const

void SettingsContainer::resetSettings()
{
for (auto group : qAsConst(m_groups)) {
for (auto group :
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
std::as_const(m_groups)
#else
qAsConst(m_groups)
#endif
) {
QList<SettingsGroup *> gs;
gs.append(group);

Expand Down Expand Up @@ -440,10 +464,22 @@ void SettingsGroup::setBackground(QQmlComponent *background)

void SettingsGroup::setConfig(QObject *config)
{
for (auto childGroup : qAsConst(m_children)) {
for (auto childGroup :
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
std::as_const(m_children)
#else
qAsConst(m_children)
#endif
) {
childGroup->setConfig(config);
}
for (auto option : qAsConst(m_options)) {
for (auto option :
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
std::as_const(m_options)
#else
qAsConst(m_options)
#endif
) {
option->setConfig(config);
}
}
Expand Down Expand Up @@ -584,7 +620,13 @@ class SettingsCompositor
for (int i = 0; i < groupItems.count(); i++)
groupItems[i] = nullptr;

for (auto group : qAsConst(groups)) {
for (auto group :
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
std::as_const(groups)
#else
qAsConst(groups)
#endif
) {
if (group->visible()) {
currentGroups.push_back(group);
}
Expand Down Expand Up @@ -852,7 +894,13 @@ QObject *SettingsContentModel::object(int index, QQmlIncubator::IncubationMode i

QQuickItem *columnItem = qobject_cast<QQuickItem*>(columnCom.beginCreate(groupContext));
columnItem->setParentItem(groupItem);
for (auto option: qAsConst(*options)) {
for (auto option:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
std::as_const(*options)
#else
qAsConst(*options)
#endif
) {

if (!option->delegate())
continue;
Expand Down
3 changes: 1 addition & 2 deletions tests/ut_dapploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ class AppLoaderSimulator : public DAppLoader
}
~AppLoaderSimulator()
{
// don't release app.
d->app.take();
// app will be automatically cleaned up by QScopedPointer
}
int load()
{
Expand Down
Loading