Skip to content

Commit 46cc05e

Browse files
deepin-ci-robot18202781743
authored andcommitted
sync: from linuxdeepin/dtkgui
Synchronize source files from linuxdeepin/dtkgui. Source-pull-request: linuxdeepin/dtkgui#337
1 parent ffff3c4 commit 46cc05e

29 files changed

Lines changed: 134 additions & 35 deletions

include/util/ddciicon.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ class DDciIcon
7777
Light = 0,
7878
Dark = 1
7979
};
80-
D_DECL_DEPRECATED enum IconAttibute {
80+
// IconAttibute is deprecated, please use IconAttribute instead.
81+
enum IconAttibute {
8182
HasPalette = 0x001
8283
};
8384
using IconAttribute = DDciIcon::IconAttibute;

src/kernel/dguiapplicationhelper.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ DPlatformTheme *DGuiApplicationHelperPrivate::initWindow(QWindow *window) const
322322
window->setProperty(WINDOW_THEME_KEY, QVariant::fromValue(theme));
323323
theme->setParent(window); // 跟随窗口销毁
324324

325-
auto onWindowThemeChanged = [window, theme, this] {
325+
auto onWindowThemeChanged = [window, this] {
326326
// 如果程序自定义了调色板, 则没有必要再关心窗口自身平台主题的变化
327327
// 需要注意的是, 这里的信号和事件可能会与 notifyAppThemeChanged 中的重复
328328
// 但是不能因此而移除这里的通知, 当窗口自身所对应的平台主题发生变化时, 这里
@@ -1335,6 +1335,11 @@ void DGuiApplicationHelper::setApplicationPalette(const DPalette &palette)
13351335
*/
13361336
DPalette DGuiApplicationHelper::windowPalette(QWindow *window) const
13371337
{
1338+
#if DTK_VERSION >= DTK_VERSION_CHECK(5, 0, 0, 0)
1339+
Q_UNUSED(window);
1340+
qCWarning(dgAppHelper) << "DGuiApplicationHelper::windowPalette is deprecated, please use applicationPalette instead.";
1341+
return applicationPalette();
1342+
#else
13381343
D_DC(DGuiApplicationHelper);
13391344

13401345
// 如果程序自定义了调色版, 则不再关心窗口对应的平台主题上的设置
@@ -1349,6 +1354,7 @@ DPalette DGuiApplicationHelper::windowPalette(QWindow *window) const
13491354
}
13501355

13511356
return fetchPalette(theme);
1357+
#endif
13521358
}
13531359
#endif
13541360

src/kernel/dplatformtheme.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ DPalette DPlatformTheme::fetchPalette(const DPalette &base, bool *ok) const
280280

281281
void DPlatformTheme::setPalette(const DPalette &palette)
282282
{
283+
Q_UNUSED(palette);
283284
#define SET_PALETTE(Role) \
284285
set##Role(palette.color(QPalette::Normal, DPalette::Role))
285286
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)

src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,19 @@ bool MoveWindowHelper::windowEvent(QWindow *w, QEvent *event)
9595
isTouchDown = false;
9696
}
9797
if (isTouchDown && event->type() == QEvent::MouseButtonPress) {
98+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
99+
touchBeginPosition = static_cast<QMouseEvent*>(event)->globalPosition();
100+
#else
98101
touchBeginPosition = static_cast<QMouseEvent*>(event)->globalPos();
102+
#endif
99103
}
100104
// add some redundancy to distinguish trigger between system menu and system move
101105
if (event->type() == QEvent::MouseMove) {
106+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
107+
QPointF currentPos = static_cast<QMouseEvent*>(event)->globalPosition();
108+
#else
102109
QPointF currentPos = static_cast<QMouseEvent*>(event)->globalPos();
110+
#endif
103111
QPointF delta = touchBeginPosition - currentPos;
104112
if (delta.manhattanLength() < QGuiApplication::styleHints()->startDragDistance()) {
105113
return DVtableHook::callOriginalFun(w, &QWindow::event, event);
@@ -123,8 +131,13 @@ bool MoveWindowHelper::windowEvent(QWindow *w, QEvent *event)
123131
self->m_windowMoving = false;
124132
}
125133

134+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
135+
if (is_mouse_move && !event->isAccepted()
136+
&& w->geometry().contains(static_cast<QMouseEvent*>(event)->globalPosition().toPoint())) {
137+
#else
126138
if (is_mouse_move && !event->isAccepted()
127139
&& w->geometry().contains(static_cast<QMouseEvent*>(event)->globalPos())) {
140+
#endif
128141
if (!self->m_windowMoving && self->m_enableSystemMove) {
129142
self->m_windowMoving = true;
130143

src/plugins/platform/xcb/dxcbplatforminterface.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,14 @@ QColor DXCBPlatformInterface::darkActiveColor() const
250250
return qvariant_cast<QColor>(value);
251251
}
252252

253+
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
254+
#define GET_COLOR(Role) qvariant_cast<QColor>(getSetting(QByteArrayLiteral(#Role)))
253255
static QColor getSetting(const QByteArray &key)
254256
{
257+
Q_UNUSED(key);
255258
qWarning() << "Not implemented, key:" << key;
256259
return {};
257260
}
258-
259-
#define GET_COLOR(Role) qvariant_cast<QColor>(getSetting(QByteArrayLiteral(#Role)))
260-
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
261261
QColor DXCBPlatformInterface::window() const
262262
{
263263
return GET_COLOR(window);
@@ -541,13 +541,14 @@ void DXCBPlatformInterface::setDarkActiveColor(const QColor &activeColor)
541541
d->theme->setSetting("Qt/DarkActiveColor", activeColor);
542542
}
543543

544+
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
545+
#define SET_COLOR(Role) setSetting(QByteArrayLiteral(#Role), Role)
544546
static void setSetting(const QByteArray &key, const QColor &color)
545547
{
548+
Q_UNUSED(key);
549+
Q_UNUSED(color);
546550
qWarning() << "Not implemented, key: " << key << "value: " << color;
547551
}
548-
549-
#define SET_COLOR(Role) setSetting(QByteArrayLiteral(#Role), Role)
550-
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
551552
void DXCBPlatformInterface::setWindow(const QColor &window)
552553
{
553554
SET_COLOR(window);

src/plugins/platform/xcb/dxcbplatformwindowinterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ DGUI_BEGIN_NAMESPACE
1818
#define DXCB_PLUGIN_KEY "dxcb"
1919
#define DXCB_PLUGIN_SYMBOLIC_PROPERTY "_d_isDxcb"
2020

21-
#define DEFINE_CONST_CHAR(Name) const char _##Name[] = "_d_" #Name
21+
#define DEFINE_CONST_CHAR(Name) [[maybe_unused]] const char _##Name[] = "_d_" #Name
2222

2323
DEFINE_CONST_CHAR(useDxcb);
2424
DEFINE_CONST_CHAR(redirectContent);

src/util/ddciicon.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,11 @@ static const DDciIconEntry::ScalableLayer &findScalableLayer(const DDciIconEntry
658658
const DDciIconEntry::ScalableLayer *maxLayer = nullptr;
659659
const int imagePixelRatio = qCeil(devicePixelRatio);
660660

661+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
662+
for (const auto &i : std::as_const(entry->scalableLayers)) {
663+
#else
661664
for (const auto &i : qAsConst(entry->scalableLayers)) {
665+
#endif
662666
if (!maxLayer || i.imagePixelRatio > maxLayer->imagePixelRatio)
663667
maxLayer = &i;
664668
if (i.imagePixelRatio > imagePixelRatio)
@@ -1137,7 +1141,11 @@ int DDciIconImage::currentImageNumber() const
11371141
void DDciIconImagePrivate::init()
11381142
{
11391143
readers.reserve(layers.size());
1144+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
1145+
for (const auto &layer : std::as_const(layers)) {
1146+
#else
11401147
for (const auto &layer : qAsConst(layers)) {
1148+
#endif
11411149
ReaderData *data = new ReaderData;
11421150
Q_ASSERT(data);
11431151
auto buffer = new QBuffer();

src/util/ddciiconplayer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ bool DDciIconImagePlayer::setPalette(const DDciIconPalette &palette)
207207
d->palette = palette;
208208

209209
bool hasPalette = false;
210+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
211+
for (const auto &i : std::as_const(d->images))
212+
#else
210213
for (const auto &i : qAsConst(d->images))
214+
#endif
211215
if (i.hasPalette())
212216
hasPalette = true;
213217

@@ -649,7 +653,7 @@ void DDciIconPlayerPrivate::initPlayer()
649653
// Remove the finished animation
650654
animationJobs.removeFirst();
651655

652-
qCDebug(diPlayer, "Number of animations remaining is %i", animationJobs.size());
656+
qCDebug(diPlayer) << "Number of animations remaining is" << animationJobs.size();
653657
if (!animationJobs.isEmpty()) {
654658
_q_playFromQueue();
655659
return;

src/util/private/dbuiltiniconengine.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ QString DBuiltinIconEngine::iconName()
304304
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
305305
QList<QSize> DBuiltinIconEngine::availableSizes(QIcon::Mode mode, QIcon::State state)
306306
{
307+
Q_UNUSED(mode);
308+
Q_UNUSED(state);
307309
ensureLoaded();
308310

309311
QList<QSize> sizes;

src/util/private/dciiconengine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,10 @@ const
162162
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
163163
QList<QSize> DDciIconEngine::availableSizes(QIcon::Mode mode, QIcon::State state)
164164
{
165+
Q_UNUSED(state);
165166
ensureIconTheme();
166167

167-
const auto availableSizes = m_dciIcon.availableSizes(dciTheme(), DDciIcon::Normal);
168+
const auto availableSizes = m_dciIcon.availableSizes(dciTheme(), dciMode(mode));
168169
QList<QSize> sizes;
169170
sizes.reserve(availableSizes.size());
170171

0 commit comments

Comments
 (0)