Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkdeclarative
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#380
  • Loading branch information
deepin-ci-robot committed Oct 16, 2024
1 parent ae29ee9 commit a3c6ddd
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
21 changes: 10 additions & 11 deletions qt6/src/qml/TextField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,21 @@ T.TextField {
verticalAlignment: TextInput.AlignVCenter
onEffectiveHorizontalAlignmentChanged: placeholder.effectiveHorizontalAlignmentChanged()

Loader {
// use Loader will cause placeholdertext horizontalAlignment not work
// QQuickPlaceholderText will assume it's parent item is QQuickTextInput or QQuickTextInput
// see QQuickPlaceholderText::updateAlignment()
PlaceholderText {
id: placeholder
active: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
x: control.leftPadding
y: control.topPadding
width: control.width - (control.leftPadding + control.rightPadding)
height: control.height - (control.topPadding + control.bottomPadding)
signal effectiveHorizontalAlignmentChanged

sourceComponent: PlaceholderText {
text: control.placeholderText
font: control.font
color: control.placeholderTextColor
verticalAlignment: control.verticalAlignment
renderType: control.renderType
}
text: control.placeholderText
visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
font: control.font
color: control.placeholderTextColor
verticalAlignment: control.verticalAlignment
renderType: control.renderType
}

background: EditPanel {
Expand Down
27 changes: 27 additions & 0 deletions src/dquickwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@

#include <QPlatformSurfaceEvent>

// Fix top level window flags in case only the type flags are passed.
static inline void fixTopLevelWindowFlags(Qt::WindowFlags &flags)
{
// Not supported on Windows, also do correction when it is set.
flags &= ~Qt::WindowFullscreenButtonHint;
switch (flags) {
case Qt::Window:
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint;
break;
case Qt::Dialog:
Q_FALLTHROUGH
case Qt::Tool:
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
break;
default:
break;
}
if ((flags & Qt::WindowType_Mask) == Qt::SplashScreen)
flags |= Qt::FramelessWindowHint;
}

DQUICK_BEGIN_NAMESPACE

DQuickWindowPrivate::DQuickWindowPrivate(DQuickWindow *qq)
Expand Down Expand Up @@ -319,6 +340,12 @@ DQuickWindowAttached::DQuickWindowAttached(QWindow *window)
: QObject(window)
, DObject(*new DQuickWindowAttachedPrivate(window, this))
{
auto windowFlags = window->flags();
if (window->isTopLevel()) {
fixTopLevelWindowFlags(windowFlags);
window->setFlags(windowFlags);
}

window->installEventFilter(this);
QObject::connect(DWindowManagerHelper::instance(), SIGNAL(windowMotifWMHintsChanged(quint32)),
this, SLOT(_q_onWindowMotifHintsChanged(quint32)));
Expand Down
1 change: 1 addition & 0 deletions src/dtkdeclarative_assets.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<file alias="built-in-icons/slider_point_left.dci">icons/bloom/slider_point_left.dci</file>
<file alias="built-in-icons/slider_round_hor.dci">icons/bloom/slider_round_hor.dci</file>
<file alias="built-in-icons/slider_round_ver.dci">icons/bloom/slider_round_ver.dci</file>
<file alias="built-in-icons/switch_button.dci">icons/bloom/switch_button.dci</file>
<file alias="built-in-icons/switch_on.dci">icons/bloom/switch_on.dci</file>
<file alias="built-in-icons/switch_off.dci">icons/bloom/switch_off.dci</file>
<file alias="built-in-icons/slider_point_up.dci">icons/bloom/slider_point_up.dci</file>
Expand Down
7 changes: 5 additions & 2 deletions src/private/dquickimageprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ static QImage requestImageFromQIcon(const QString &id, QSize *size, const QSize
} else {
icon = DIconTheme::findQIcon(name);
}
if (icon.isNull())
return invalidIcon(size, requestedSize);

QIcon::Mode qMode = QIcon::Normal;
QIcon::State qState = QIcon::Off;
Expand All @@ -66,6 +64,11 @@ static QImage requestImageFromQIcon(const QString &id, QSize *size, const QSize
devicePixelRatio = 1.0;
}

if (icon.isNull()) {
QSize icon_size = requestedSize;
return invalidIcon(size, icon_size /= devicePixelRatio);
}

QSize icon_size = requestedSize;
// 初始时可能没有为图标设置期望的大小
if (icon_size.isEmpty()) {
Expand Down

0 comments on commit a3c6ddd

Please sign in to comment.